Preorder: Status can now be changed manually

This commit is contained in:
Frank Schubert
2023-11-07 13:00:29 +01:00
parent bd3489f6e4
commit 79fe0aa00e
18 changed files with 367 additions and 69 deletions

View File

@@ -35,7 +35,20 @@
<td><?=$preorder->campaign->name?></td>
</tr><tr>
<th>Status:</th>
<td class="text-monospace"><?=$preorder->status->code?> - <?=$preorder->status->name?></td>
<td class="text-monospace">
<span id="preorder-detail-status-<?=$preorder->id?>-text"><span id="preorder-detail-status-<?=$preorder->id?>-statustext"><?=$preorder->status->code?> - <?=$preorder->status->name?></span> <a href="#" onclick="return toggleStatusControl(<?=$preorder->id?>, <?=$preorder->status_id?>)"><i class="fas fa-fw fa-edit"></i></a></span>
<div class="input-group" id="preorder-detail-status-<?=$preorder->id?>-input" style="display:none">
<select class="form-control">
<?php foreach(PreorderstatusModel::getAll() as $status): ?>
<option value="<?=$status->id?>" <?=($preorder->status_id == $status->id) ? "selected='selected'" : ""?>><?=$status->code?> - <?=$status->name?></option>
<?php endforeach; ?>
</select>
<div class="input-group-append">
<button type="button" class="btn btn-primary" title="Speichern" onclick="savePreorderStatusControl(<?=$preorder->id?>, 'email')"><i class="fas fa-check"></i></button>
<button type="button" class="btn btn-secondary" title="Abbrechen" onclick="toggleStatusControl(<?=$preorder->id?>, 'email')"><i class="fas fa-times"></i></button>
</div>
</div>
</td>
</tr><tr>
<th>OAID:</th>
<td class="text-monospace text-pink"><?=$preorder->oaid?></td>
@@ -329,4 +342,42 @@
</div>
</div>
</div>
</div>
<script type="text/javascript">
function toggleStatusControl(pid, sid) {
$("#preorder-detail-status-" + pid + "-input select").val(sid);
$("#preorder-detail-status-" + pid + "-text").toggle();
$("#preorder-detail-status-" + pid + "-input").toggle();
return false;
}
function savePreorderStatusControl(pid) {
if(!Number.isInteger(pid) || pid < 1) {
return false;
}
var value = $("#preorder-detail-status-" + pid + "-input select").val();
$.post("<?=self::getUrl("Preorder","Api")?>",
{
'do': "updateStatus",
id: pid,
status_id: value
},
function(success) {
if(success.status == "OK") {
$("#preorder-detail-status-" + pid + "-statustext").text(success.result.status_code + " - " + success.result.status_text);
$("#preorder-detail-status-" + pid + "-text").addClass("text-success");
setTimeout(() => { $("#preorder-detail-status-" + pid + "-text").removeClass("text-success") }, 1500);
$("#preorder-" + pid + " .status").text(success.result.status_code + " - " + success.result.status_text);
$("#preorder-" + pid + " .status").addClass("text-success");
setTimeout(() => { $("#preorder-" + pid + " .status").removeClass("text-success") }, 1500);
toggleStatusControl(pid);
}
},
'json');
}
</script>