Finished Cpeshipping

This commit is contained in:
Frank Schubert
2021-10-28 20:53:27 +02:00
parent 877d511030
commit 5a9ffd2679
11 changed files with 425 additions and 17 deletions
+38 -9
View File
@@ -58,30 +58,31 @@
<?php endif; ?>
</div>
<form method="post" action="<?=self::getUrl("Cpeshipping", "ship")?>">
<form method="post" id="submit-form" action="<?=self::getUrl("Cpeshipping", "ship")?>">
<table class="table table-striped table-hover">
<tr>
<th class="text-center">Versand<br /><input type="checkbox" id="checkAll" class="form-control" /></th>
<th class="text-center">Externes Produkt<br />bestellt</th>
<th>Kundennummer</th>
<th>Kunde</th>
<th>Lieferort</th>
<th>Gerät</th>
<th>Lieferort</th>
<th>Kunde</th>
<th>Kundennummer</th>
</tr>
<?php foreach($cpeprovisionings as $c): ?>
<tr>
<td class="versand-checkbox text-center"><input type="checkbox" class="form-control" name="ships[]" value="<?=$c->id?>" /></td>
<td class="versand-checkbox text-center"><input type="checkbox" class="form-control" id="ship-<?=$c->id?>" name="ships[]" value="<?=$c->id?>" /></td>
<td class="text-center">
<?php if(array_key_exists("hostnetwork_order", $c->orderproduct->product->attributes) && $c->orderproduct->product->attributes['hostnetwork_order']->value): ?>
<input type="checkbox" class="form-control" name="external_finish-<?=$c->id?>" value="1" />
<input type="checkbox" class="form-control" id="external_finish-<?=$c->id?>" name="external_finish-<?=$c->id?>" value="1" />
<span id="ship-error-<?=$c->id?>" class="text-danger hidden">Externes Produkt muss bestellt sein vor Versand!</span>
<?php else: ?>
n/a
<?php endif; ?>
</td>
<td><?=$c->order->owner->customer_number?></td>
<td><?=$c->order->owner->getCompanyOrName()?></td>
<td><?=($c->termination_id) ? $c->termination->building->zip." ".$c->termination->building->city : $c->order->owner->zip." ".$c->order->owner->city?></td>
<td><?=$c->routertype?></td>
<td><?=($c->termination_id) ? $c->termination->building->zip." ".$c->termination->building->city : $c->order->owner->zip." ".$c->order->owner->city?></td>
<td><?=$c->order->owner->getCompanyOrName()?></td>
<td><?=$c->order->owner->customer_number?></td>
</tr>
<?php endforeach; ?>
</table>
@@ -134,5 +135,33 @@
$('.versand-checkbox input:checkbox').not(this).prop('checked', this.checked);
});
});
$("#submit-form" ).submit(function( event ) {
$('[id^=ship-error-').each(function() {
$(this).hide();
});
var error = false;
$('input[name^=external_finish-]').each(function() {
var id_match = $(this).attr("name").match(/external_finish-(\d+)$/);
var id = id_match[1];
if(!$("input[name^=external_finish-").is(":checked")) {
if($("#ship-" + id).is(":checked")) {
error = true;
$("#ship-error-" + id).show();
}
}
});
if(error) {
console.log("not submitting");
event.preventDefault();
}
return;
});
</script>
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>