Browse Source

#39 making more progress on parent/child relationships

Still need to update childs when merging/deleting tickets, and need to add the ability to assign its parent, and to delete a parent/child relationship
merge-requests/2/head
Mike Koch 7 years ago
parent
commit
3151ece7df
  1. 53
      admin/admin_ticket.php
  2. 10
      js/nuMods-javascript.js
  3. 5
      language/en/text.php

53
admin/admin_ticket.php

@ -309,6 +309,42 @@ if ( ($can_reply || $can_edit) && isset($_POST['h']) && isset($_POST['m']) && is
hesk_process_messages($hesklang['twu'],'admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999),'SUCCESS');
}
/* Add child action */
if (($can_reply || $can_edit) && isset($_POST['childTrackingId'])) {
//-- Make sure this isn't the same ticket or one of its merged tickets.
$mergedTickets = hesk_dbQuery('SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'tickets` WHERE `trackid` =
\''.hesk_dbEscape($trackingID).'\' AND `merged` LIKE \'#'.hesk_dbEscape($_POST['childTrackingId']).'\'');
if ($_POST['childTrackingId'] == $trackingID || $mergedTickets->num_rows > 0) {
hesk_process_messages($hesklang['child_is_itself'], 'admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999));
}
//-- Does the child exist?
$existRs = hesk_dbQuery('SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'tickets` WHERE `trackid` = \''.hesk_dbEscape($_POST['childTrackingId']).'\'');
if ($existRs->num_rows == 0) {
//-- Maybe it was merged?
$existRs = hesk_dbQuery('SELECT `trackid` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'tickets` WHERE `merged` LIKE \'#'.hesk_dbEscape($_POST['childTrackingId']).'#\'');
if ($existRs->num_rows > 0) {
//-- Yes, it was merged. Set the child to the "new" ticket; not the merged one.
$exist = $existRs->fetch_assoc();
$_POST['childTrackingId'] = $exist['trackid'];
} else {
hesk_process_messages(sprintf($hesklang['child_does_not_exist'], $_POST['childTrackingId']), 'admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999));
}
}
//-- Check if the ticket is already a child.
$childRs = hesk_dbQuery('SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'tickets` WHERE `parent` = '.$ticket['id'].' AND `trackid` = \''.$_POST['childTrackingId'].'\'');
if ($childRs->num_rows > 0) {
hesk_process_messages(sprintf($hesklang['is_child_already'], $_POST['childTrackingId']), 'admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999), 'NOTICE');
}
hesk_dbQuery('UPDATE `'.hesk_dbEscape($hesk_settings['db_pfix']).'tickets` SET `parent` = '.$ticket['id'].' WHERE `trackid` = \''.$_POST['childTrackingId'].'\'');
hesk_process_messages(sprintf($hesklang['child_added'], $_POST['childTrackingId']), 'admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999), 'SUCCESS');
}
/* Delete child action */
//TODO Populate this
/* Delete attachment action */
if (isset($_GET['delatt']) && hesk_token_check())
{
@ -528,6 +564,23 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
echo $hesklang['none'];
}
?></p>
<?php
if ($can_reply || $can_edit) {
?>
<div id="addChildText"><p><?php echo '<a class="btn btn-default btn-sm" href="javascript:void(0)" onclick="toggleChildrenForm(true)">'.$hesklang['add_child'].'</a>'; ?></p></div>
<div id="childrenForm" style="display: none">
<form action="admin_ticket.php" method="post">
<div class="form-group"><label for="childTrackingId" class="control-label">Tracking ID</label>
<input type="text" name="childTrackingId" class="form-control input-sm"></div>
<input type="submit" class="btn btn-primary btn-sm" value="<?php echo $hesklang['save']; ?>">
<a class="btn btn-default btn-sm" href="javascript:void(0)" onclick="toggleChildrenForm(false)">
<?php echo $hesklang['cancel']; ?>
</a>
<input type="hidden" name="track" value="<?php echo $trackingID; ?>" />
<input type="hidden" name="token" value="<?php hesk_token_echo(); ?>" />
</form>
</div>
<?php } ?>
</li>
</ul>
</div>

10
js/nuMods-javascript.js

@ -40,4 +40,14 @@ function toggleFilterCheckboxes(show) {
}
}
function toggleChildrenForm(show) {
if (show) {
$('#childrenForm').show();
$('#addChildText').hide();
} else {
$('#childrenForm').hide();
$('#addChildText').show();
}
}
jQuery(document).ready(loadJquery);

5
language/en/text.php

@ -62,6 +62,11 @@ $hesklang['email_banned'] = 'The email address you have entered has been banned
$hesklang['none'] = 'None';
$hesklang['parent'] = 'Parent';
$hesklang['children'] = 'Children';
$hesklang['add_child'] = 'Add Child';
$hesklang['child_added'] = 'Successfully added <strong>%s</strong> as a child to this ticket.'; //%s: the child tracking ID
$hesklang['is_child_already'] = '<strong>%s</strong> is already a child of this ticket.'; //%s: the child tracking ID
$hesklang['child_does_not_exist'] = '<strong>%s</strong> is not a valid Tracking ID!'; //%s: the child tracking ID
$hesklang['child_is_itself'] = 'You cannot set a ticket as a child of itself.';
// ADDED OR MODIFIED IN NuMods 1.3.1
$hesklang['autorefresh'] = 'Autorefresh:';

Loading…
Cancel
Save