Additional status changes

merge-requests/2/head
Mike Koch 10 years ago
parent 23bb7c027c
commit 5713ecbda8

@ -332,6 +332,7 @@ if ( defined('HESK_DEMO') )
if (d.s_custom19_use.checked && d.s_custom19_name.value == '') {alert('<?php echo addslashes($hesklang['err_custname']); ?>'); return false;}
if (d.s_custom20_use.checked && d.s_custom20_name.value == '') {alert('<?php echo addslashes($hesklang['err_custname']); ?>'); return false;}
// DISABLE SUBMIT BUTTON
d.submitbutton.disabled=true;
d.submitbutton.value='<?php echo addslashes($hesklang['saving']); ?>';
@ -1786,6 +1787,7 @@ if ( defined('HESK_DEMO') )
$statusesRS = hesk_dbQuery($statusesSql);
//Print header
?>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
@ -1794,6 +1796,7 @@ if ( defined('HESK_DEMO') )
<th><?php echo $hesklang['longNameKey']; ?> <i class="fa fa-question-circle settingsquestionmark" data-toggle="popover" title="<?php echo $hesklang['longNameKey']; ?>" data-content="<?php echo $hesklang['longNameKeyDescr']; ?>"></i></th>
<th><?php echo $hesklang['textColor']; ?> <i class="fa fa-question-circle settingsquestionmark" data-toggle="popover" title="<?php echo $hesklang['textColor']; ?>" data-content="<?php echo $hesklang['textColorDescr']; ?>"></i></th>
<th><?php echo $hesklang['closedQuestionMark']; ?> <i class="fa fa-question-circle settingsquestionmark" data-toggle="popover" data-placement="top" title="<?php echo $hesklang['closedQuestionMark']; ?>" data-content="<?php echo $hesklang['closedQuestionMarkDescr']; ?>"></i></th>
<th><?php echo $hesklang['delete']; ?></th>
</tr>
</thead>
<tbody>
@ -1804,15 +1807,27 @@ if ( defined('HESK_DEMO') )
$checkedEcho = ($row['IsClosed'] == 1) ? 'checked="checked"' : '';
echo '<tr>';
echo '<td>'.$hesklang[$row['ShortNameContentKey']].'</td>'; //Name
echo '<td><input type="text" class="form-control" name="s'.$row['ID'].'_shortName" value="'.$row['ShortNameContentKey'].'"></td>'; // Short Name Language File
echo '<td><input type="text" class="form-control" name="s'.$row['ID'].'_longName" value="'.$row['TicketViewContentKey'].'"></td>'; // Long Name Language File
echo '<td><input type="text" class="form-control" name="s'.$row['ID'].'_textColor" value="'.$row['TextColor'].'"></td>'; // Text Color
echo '<td><input type="checkbox" name="s'.$row['ID'].'_isClosed" value="1" '.$checkedEcho.'"></td>'; // Resolved Status?
echo '<td><input type="text" class="form-control" name="s'.$row['ID'].'_shortName" value="'.$row['ShortNameContentKey'].'" placeholder="'.$hesklang['shortNameKey'].'"></td>'; // Short Name Language File
echo '<td><input type="text" class="form-control" name="s'.$row['ID'].'_longName" value="'.$row['TicketViewContentKey'].'" placeholder="'.$hesklang['longNameKey'].'"></td>'; // Long Name Language File
echo '<td><input type="text" class="form-control" name="s'.$row['ID'].'_textColor" value="'.$row['TextColor'].'" placeholder="'.$hesklang['textColor'].'"></td>'; // Text Color
echo '<td><input type="checkbox" name="s'.$row['ID'].'_isClosed" value="1" '.$checkedEcho.'></td>'; // Resolved Status?
echo '<td><input type="checkbox" name="s'.$row['ID'].'_delete" value="1"></td>'; //Delete status?
echo '</tr>';
}
//Print out an additional blank space for adding a status
echo '<tr>';
echo '<td><b>'.$hesklang['addNew'].'</b></td>';
echo '<td><input type="text" class="form-control" name="sN_shortName" value="" placeholder="'.$hesklang['shortNameKey'].'"></td>'; // Short Name Language File
echo '<td><input type="text" class="form-control" name="sN_longName" value="" placeholder="'.$hesklang['longNameKey'].'"></td>'; // Long Name Language File
echo '<td><input type="text" class="form-control" name="sN_textColor" value="" placeholder="'.$hesklang['textColor'].'"></td>'; // Text Color
echo '<td><input type="checkbox" name="sN_isClosed" value="1"></td>'; // Resolved Status?
echo '<td></td>'; //Empty placeholder where the delete row is.
echo '</tr>';
?>
</tbody>
</table>
</div>
<h6 style="font-weight: bold"><?php echo $hesklang['defaultStatusForAction']; ?></h6>
<div class="footerWithBorder blankSpace"></div>
<div class="form-group">

@ -59,6 +59,22 @@ if ( defined('HESK_DEMO') )
hesk_process_messages($hesklang['sdemo'], 'admin_settings.php');
}
//-- Before we do anything, make sure the statuses are valid.
$rows = hesk_dbQuery('SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`');
while ($row = $rows->fetch_assoc())
{
if (!isset($_POST['s'.$row['ID'].'_delete']))
{
validateStatus($_POST['s'.$row['ID'].'_shortName'], $_POST['s'.$row['ID'].'_longName'], $_POST['s'.$row['ID'].'_textColor']);
}
}
//-- Validate the new one if at least one of the fields are used / checked
if ($_POST['sN_shortName'] != null || $_POST['sN_longName'] != null || $_POST['sN_textColor'] != null || isset($_POST['sN_isClosed']))
{
validateStatus($_POST['sN_shortName'], $_POST['sN_longName'], $_POST['sN_textColor']);
}
$set=array();
/*** GENERAL ***/
@ -386,11 +402,32 @@ for ($i=1;$i<=20;$i++)
//-- Update the statuses
hesk_dbConnect();
//-- Get all the status IDs
$statusesSql = 'SELECT * FROM `'.$hesk_settings['db_pfix'].'statuses`';
$results = hesk_dbQuery($statusesSql);
while ($row = $results->fetch_assoc());
while ($row = $results->fetch_assoc())
{
//-- If the status is marked for deletion, delete it and skip everything below.
if (isset($_POST['s'.$row['ID'].'_delete']))
{
$delete = "DELETE FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` WHERE `ID` = ?";
$stmt = hesk_dbConnect()->prepare($delete);
$stmt->bind_param('i', $row['ID']);
$stmt->execute();
//-- In case we deleted a status in the middle, we now need to re-index the other IDs.
$reIndexQuery = 'SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `ID` > '.$row['ID'];
$reIndexRS = hesk_dbQuery($reIndexQuery);
//-- Update each ID by subtracting 1
$reIndexQuery = 'UPDATE `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` SET `ID` = ? WHERE `ID` = ?';
while ($row = $reIndexRS->fetch_assoc())
{
$stmt = hesk_dbConnect()->prepare($reIndexQuery);
$newID = $row['ID'] - 1;
$stmt->bind_param('ii', $newID, $row['ID']);
$stmt->execute();
}
} else
{
//-- Update the information in the database with what is on the page
$query = "UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET `ShortNameContentKey` = ?, `TicketViewContentKey` = ?, `TextColor` = ?, `IsClosed` = ? WHERE `ID` = ?";
@ -399,6 +436,19 @@ while ($row = $results->fetch_assoc());
$stmt->bind_param('sssii', $_POST['s'.$row['ID'].'_shortName'], $_POST['s'.$row['ID'].'_longName'], $_POST['s'.$row['ID'].'_textColor'], $isStatusClosed, $row['ID']);
$stmt->execute();
}
}
//-- Insert the addition if there is anything to add
if ($_POST['sN_shortName'] != null && $_POST['sN_longName'] != null && $_POST['sN_textColor'] != null)
{
//-- The next ID is equal to the number of rows, since the IDs are zero-indexed.
$nextValue = hesk_dbQuery('SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`')->num_rows;
$insert = "INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` (`ID`, `ShortNameContentKey`, `TicketViewContentKey`, `TextColor`, `IsClosed`) VALUES (?, ?, ?, ?, ?)";
$stmt = hesk_dbConnect()->prepare($insert);
$isClosed = isset($_POST['sN_isClosed']) ? 1 : 0;
$stmt->bind_param('isssi', $nextValue, $_POST['sN_shortName'], $_POST['sN_longName'], $_POST['sN_textColor'], $isClosed);
$stmt->execute();
}
//-- Update default status for actions
$defaultQuery = "UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET ";
@ -781,4 +831,21 @@ function hesk_formatUnits($size)
return false;
} // End hesk_formatBytes()
function validateStatus($shortName, $longName, $textColor)
{
global $hesklang;
//-- Validation logic
if ($shortName == '')
{
hesk_process_messages($hesklang['shortNameRequired'], 'admin_settings.php');
} elseif ($longName == '')
{
hesk_process_messages($hesklang['longNameRequired'], 'admin_settings.php');
} elseif ($textColor == '')
{
hesk_process_messages($hesklang['textColorRequired'], 'admin_settings.php');
}
}
?>

@ -40,6 +40,10 @@ $hesklang['isStaffReopenedStatusMsg'] = 'When a staff member clicks the "Open ti
$hesklang['isDefaultStaffReplyStatusMsg'] = 'When a staff member replies to a ticket, change the status to:';
$hesklang['lockedTicketStatusMsg'] = 'When a ticket is locked, change the status to:';
$hesklang['nuHeskVersion'] = 'NuHesk Version';
$hesklang['shortNameRequired'] = 'Short Name Key is required.';
$hesklang['longNameRequired'] = 'Long Name Key is required.';
$hesklang['textColorRequired'] = 'Text Color is required.';
$hesklang['addNew'] = 'Add New';
// ADDED OR MODIFIED IN HESK UI

Loading…
Cancel
Save