284 lines
14 KiB
PHP
284 lines
14 KiB
PHP
<?
|
|
$formname = "form_process_cardform";
|
|
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
|
$inputname = "input_id";
|
|
|
|
?>
|
|
|
|
|
|
<div id="overlaycrumb">
|
|
<?php if ($input_process["id"] == "") {
|
|
echo $translation->get("new_process");
|
|
} else {
|
|
echo $translation->get("edit_process");
|
|
}
|
|
?>
|
|
</div>
|
|
|
|
<ul class="toolbar_menu">
|
|
<?php
|
|
// Zurueck zur uebersicht
|
|
button("left", $translation->get("back"), $formname, "loadCard('load_process', true)");
|
|
|
|
// Speichern buttons
|
|
button("save", $translation->get("save"), $formname, "loadCard('save_process', true)");
|
|
button("save", $translation->get("save_and_close"), $formname, "jQuery('#save_and_close', jQuery('#" . $formname . "')).val(1);loadCard('save_process', true)");
|
|
|
|
if ($input_process["id"] != "") {
|
|
echo button("delete", $translation->get("delete"), $formname, "loadCard('delete_process', true, '{$translation->get('delete_process_confirm')}')");
|
|
}
|
|
?>
|
|
</ul>
|
|
|
|
<?php
|
|
if (!empty($messages) && is_array($messages)) {
|
|
echo '<div id="overlayMessages">' . implode("\r\n", $messages) . '</div>';
|
|
}
|
|
?>
|
|
|
|
|
|
<form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
|
|
<input name="input_process_id" type="hidden" value="<?= $input_process["id"] ?>" />
|
|
<input name="input_id" type="hidden" value="<?= $_REQUEST['input_id'] ?>">
|
|
<input name="save_and_close" id="save_and_close" type="hidden" value="0" />
|
|
|
|
<table class="cardform" border="0" cellspacing="0" cellpadding="0">
|
|
<tr>
|
|
<td>
|
|
<? input($translation->get("description"), "input_description", "text", $input_process["description"]) ?>
|
|
</td>
|
|
</tr>
|
|
|
|
<?php if ($input_process["id"] != ""): ?>
|
|
<?php
|
|
// Function to get and display statuses for the process
|
|
function getProcessStatuses($processId, $translation, $formname) {
|
|
// Get all available statuses (excluding mandatory ones)
|
|
$statuses_query = "SELECT id, description FROM main_tickets_status WHERE id NOT IN (0, 1, 2, 3) ORDER BY description";
|
|
$statuses_result = mysqli_query($GLOBALS['mysql_con'], $statuses_query);
|
|
$all_statuses = [];
|
|
while ($status = mysqli_fetch_assoc($statuses_result)) {
|
|
$all_statuses[$status['id']] = $status;
|
|
}
|
|
|
|
// Get selected statuses for this process
|
|
$selected_query = "SELECT mps.id, mps.main_tickets_status_id, mps.sorting, mts.description
|
|
FROM main_tickets_process_status mps
|
|
JOIN main_tickets_status mts ON mps.main_tickets_status_id = mts.id
|
|
WHERE mps.main_tickets_process_id = '$processId'
|
|
ORDER BY mps.sorting";
|
|
$selected_result = mysqli_query($GLOBALS['mysql_con'], $selected_query);
|
|
$selected_statuses = [];
|
|
while ($selected = mysqli_fetch_assoc($selected_result)) {
|
|
$selected_statuses[$selected['main_tickets_status_id']] = $selected;
|
|
}
|
|
|
|
// Calculate available statuses (all minus selected)
|
|
$available_statuses = array_diff_key($all_statuses, $selected_statuses);
|
|
|
|
// HTML output
|
|
?>
|
|
<tr>
|
|
<td>
|
|
<label><?= $translation->get("process_statuses") ?: "Process Statuses" ?></label>
|
|
<div class="status-selector">
|
|
<div class="status-columns">
|
|
<div class="status-column">
|
|
<h4><?= $translation->get("available_statuses") ?: "Available Statuses" ?></h4>
|
|
<select multiple id="available-statuses" class="status-list">
|
|
<?php foreach ($available_statuses as $status): ?>
|
|
<option value="<?= $status['id'] ?>"><?= htmlspecialchars($status['description']) ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<button type="button" id="add-status"><?= $translation->get("add_status") ?: "Add →" ?></button>
|
|
</div>
|
|
<div class="status-column">
|
|
<h4><?= $translation->get("selected_statuses") ?: "Selected Statuses" ?></h4>
|
|
<select multiple id="selected-statuses" class="status-list sortable">
|
|
<?php
|
|
// Sort selected statuses by sorting field
|
|
usort($selected_statuses, function($a, $b) {
|
|
return $a['sorting'] - $b['sorting'];
|
|
});
|
|
|
|
foreach ($selected_statuses as $status): ?>
|
|
<option value="<?= $status['main_tickets_status_id'] ?>"><?= htmlspecialchars($status['description']) ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<button type="button" id="remove-status"><?= $translation->get("remove_status") ?: "← Remove" ?></button>
|
|
<div style="width: 100%" class="sorting-buttons">
|
|
<button type="button" id="move-up"><?= $translation->get("move_up") ?: "Move Up" ?></button>
|
|
<button type="button" id="move-down"><?= $translation->get("move_down") ?: "Move Down" ?></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Hidden input to store selected statuses -->
|
|
<input type="hidden" name="selected_statuses" id="selected-statuses-input" value="">
|
|
</div>
|
|
|
|
<script>
|
|
jQuery(document).ready(function($) {
|
|
// Add status
|
|
$("#add-status").click(function() {
|
|
$("#available-statuses option:selected").each(function() {
|
|
$(this).appendTo("#selected-statuses");
|
|
});
|
|
updateSelectedStatusesInput();
|
|
});
|
|
|
|
// Remove status
|
|
$("#remove-status").click(function() {
|
|
$("#selected-statuses option:selected").each(function() {
|
|
$(this).appendTo("#available-statuses");
|
|
});
|
|
updateSelectedStatusesInput();
|
|
});
|
|
|
|
// Move up
|
|
$("#move-up").click(function() {
|
|
var $selected = $("#selected-statuses option:selected");
|
|
if ($selected.length && !$selected.is(":first-child")) {
|
|
$selected.each(function() {
|
|
$(this).insertBefore($(this).prev());
|
|
});
|
|
updateSelectedStatusesInput();
|
|
}
|
|
});
|
|
|
|
// Move down
|
|
$("#move-down").click(function() {
|
|
var $selected = $("#selected-statuses option:selected");
|
|
if ($selected.length && !$selected.is(":last-child")) {
|
|
$($selected.get().reverse()).each(function() {
|
|
$(this).insertAfter($(this).next());
|
|
});
|
|
updateSelectedStatusesInput();
|
|
}
|
|
});
|
|
|
|
// Update hidden input before form submission
|
|
$("#<?= $formname ?>").on("submit", updateSelectedStatusesInput);
|
|
|
|
function updateSelectedStatusesInput() {
|
|
var selectedStatuses = [];
|
|
$("#selected-statuses option").each(function(index) {
|
|
selectedStatuses.push({
|
|
id: $(this).val(),
|
|
sorting: index
|
|
});
|
|
});
|
|
$("#selected-statuses-input").val(JSON.stringify(selectedStatuses));
|
|
}
|
|
|
|
// Initialize
|
|
updateSelectedStatusesInput();
|
|
});
|
|
</script>
|
|
|
|
<style>
|
|
.status-selector {
|
|
margin: 15px 0;
|
|
padding: 15px;
|
|
background-color: #f9f9f9;
|
|
border: 1px solid #e0e0e0;
|
|
border-radius: 5px;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
}
|
|
.status-columns {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
gap: 20px;
|
|
margin-bottom: 20px;
|
|
}
|
|
.status-column {
|
|
width: 48%;
|
|
background: #fff;
|
|
padding: 10px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
}
|
|
.status-column h4 {
|
|
margin-top: 0;
|
|
padding-bottom: 8px;
|
|
border-bottom: 1px solid #eee;
|
|
color: #444;
|
|
font-size: 14px;
|
|
}
|
|
.status-list {
|
|
width: 100%;
|
|
height: 220px;
|
|
margin: 10px 0;
|
|
border: 1px solid #ccc;
|
|
border-radius: 3px;
|
|
padding: 0;
|
|
font-family: inherit;
|
|
}
|
|
.status-list option {
|
|
padding: 6px 8px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
}
|
|
.status-list option:hover {
|
|
background-color: #f5f5f5;
|
|
}
|
|
button {
|
|
padding: 6px 12px;
|
|
background: #f0f0f0;
|
|
border: 1px solid #ccc;
|
|
border-radius: 3px;
|
|
color: #333;
|
|
cursor: pointer;
|
|
font-size: 13px;
|
|
transition: all 0.2s ease;
|
|
margin-right: 5px;
|
|
}
|
|
button:hover {
|
|
background: #e0e0e0;
|
|
}
|
|
#add-status, #remove-status {
|
|
width: 100%;
|
|
margin: 5px 0 10px 0;
|
|
font-weight: bold;
|
|
}
|
|
#add-status {
|
|
background-color: #e8f5e9;
|
|
border-color: #c8e6c9;
|
|
}
|
|
#add-status:hover {
|
|
background-color: #c8e6c9;
|
|
}
|
|
#remove-status {
|
|
background-color: #ffebee;
|
|
border-color: #ffcdd2;
|
|
}
|
|
#remove-status:hover {
|
|
background-color: #ffcdd2;
|
|
}
|
|
.sorting-buttons {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin-top: 10px;
|
|
}
|
|
.sorting-buttons button {
|
|
width: 48%;
|
|
background-color: #e3f2fd;
|
|
border-color: #bbdefb;
|
|
}
|
|
.sorting-buttons button:hover {
|
|
background-color: #bbdefb;
|
|
}
|
|
</style>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
// Call the function to display statuses
|
|
getProcessStatuses($input_process["id"], $translation, $formname);
|
|
?>
|
|
<?php endif; ?>
|
|
</table>
|
|
</form>
|
|
|
|
|