Added stuff to order form
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
<th>OAN ID</th>
|
||||
<th>Adresse</th>
|
||||
<th>Einheiten</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($buildings as $building): ?>
|
||||
@@ -53,6 +54,7 @@
|
||||
<?=$building->zip?> <?=$building->city?>
|
||||
</td>
|
||||
<td onclick="toggleBuilding(<?=$building->id?>)"><?=$building->units?></td>
|
||||
<td onclick="toggleBuilding(<?=$building->id?>)" class="text-monospace"><?=__($building->status->name)?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Building", "edit", ["id" => $building->id])?>"><i class="far fa-edit" title="Objekt Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Building", "delete", ["id" => $building->id])?>" class="text-danger" onclick="if(!confirm('Objekt wirklich löschen?')) return false;" title="Objekt Löschen"><i class="fas fa-trash"></i></a>
|
||||
@@ -79,6 +81,7 @@
|
||||
<th>Kontakt</th>
|
||||
<th>Telefon</th>
|
||||
<th>Email</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($building->terminations as $term): ?>
|
||||
@@ -145,6 +148,7 @@
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td class="text-monospace"><?=__($term->status->name)?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Termination", "delete", ["id" => $term->id])?>" class="text-danger" onclick="if(!confirm('Objekt wirklich löschen?')) return false;" title="Objekt Löschen"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
|
||||
@@ -260,6 +260,27 @@
|
||||
<input type="text" class="form-control" name="order_date" id="order_date" value="<?=($order->order_date) ? date("d.m.Y", $order->order_date) : date("d.m.Y")?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title">Verzögerte Herstellung</h4>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="finish_after">Herstellbar ab</label>
|
||||
<div class="col-lg-4">
|
||||
<input type="text" class="form-control" name="finish_after" id="finish_after" value="<?=($order->finish_after) ? date("d.m.Y", $order->finish_after) : ""?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="finish_after_comment">Verzögerungsgrund</label>
|
||||
<div class="col-lg-4">
|
||||
<textarea class="form-control" name="finish_after_comment" id="finish_after_comment" placeholder="Verzögerungsgrund"><?=$order->finish_after_comment?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -377,8 +398,16 @@
|
||||
|
||||
</div>
|
||||
|
||||
<?php if(array_key_exists(TT_ATTRIB_TERMINATION_REQUIRED_NAME, $product->product->attributes) && $product->product->attributes[TT_ATTRIB_TERMINATION_REQUIRED_NAME] == 1): ?>
|
||||
<div class="row mt-1 mb-2">
|
||||
<?php if(
|
||||
(is_array($product->product->attributes) && count($product->product->attributes))
|
||||
&& (array_key_exists(TT_ATTRIB_TERMINATION_REQUIRED_NAME, $product->product->attributes)
|
||||
&& $product->product->attributes[TT_ATTRIB_TERMINATION_REQUIRED_NAME] == 1)
|
||||
|| $product->termination_id
|
||||
): ?>
|
||||
<div class="row mt-1 mb-2" id="termination_id-<?=$product->id?>-line">
|
||||
<?php else: ?>
|
||||
<div class="row mt-1 mb-2 hidden" id="termination_id-<?=$product->id?>-line">
|
||||
<?php endif; ?>
|
||||
<!-- line to choose termination -->
|
||||
<div class="col-12">
|
||||
<label class="form-label" for="termination_id-<?=$product->id?>">Anschluss</label>
|
||||
@@ -390,7 +419,7 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
<div class="row mt-1 mb-2">
|
||||
@@ -401,7 +430,7 @@
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="billing_delay-<?=$product->id?>" >Verzögerter Verrechnungsstart</label>
|
||||
<input type="text" class="form-control" name="products[<?=$product->id?>][billing_delay]" id="billing_delay-<?=$product->id?>" value="" placeholder="(Monate)" />
|
||||
<input type="text" class="form-control" name="products[<?=$product->id?>][billing_delay]" id="billing_delay-<?=$product->id?>" value="<?=$product->billing_delay?>" placeholder="Freimonate" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -477,7 +506,7 @@
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="billing_delay-new" >Verzögerter Verrechnungsstart</label>
|
||||
<input type="text" class="form-control" name="products[new][billing_delay]" id="billing_delay-new" value="" placeholder="(in Monaten)" />
|
||||
<input type="text" class="form-control" name="products[new][billing_delay]" id="billing_delay-new" value="" placeholder="Freimonate" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -636,7 +665,15 @@
|
||||
showWeekDays: true,
|
||||
todayBtn: 'linked',
|
||||
autoclose: true
|
||||
});
|
||||
});
|
||||
|
||||
$('#finish_after').datepicker({
|
||||
language: 'de',
|
||||
format: "dd.mm.yyyy",
|
||||
showWeekDays: true,
|
||||
todayBtn: 'linked',
|
||||
autoclose: true
|
||||
});
|
||||
|
||||
|
||||
// disable mousewheel on input number field when in focus
|
||||
@@ -668,17 +705,18 @@
|
||||
$('#price_setup-' + id).val(p.price_setup);
|
||||
|
||||
console.log(p.attributes);
|
||||
|
||||
console.log("form_id: " + id);
|
||||
if(typeof p.attributes === 'object' && "termination_required" in p.attributes && p.attributes.termination_required == 1) {
|
||||
console.log("termination_required");
|
||||
$('#termination_id-new-line').show();
|
||||
console.log($('#termination_id-new').val());
|
||||
$('#termination_id-new').select2({
|
||||
$('#termination_id-' + id + '-line').show();
|
||||
console.log($('#termination_id-' + id).val());
|
||||
$('#termination_id-' + id).select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
} else {
|
||||
$('#termination_id-new-line').hide();
|
||||
$('#termination_id-' + id + '-line').hide();
|
||||
//$('#termination_id-' + id + '-line').hide();
|
||||
}
|
||||
},
|
||||
'json');
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</footer>
|
||||
<!-- end Footer -->
|
||||
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>assests/js/vendor.min.js"></script>
|
||||
<!--<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/vendor.min.js"></script>-->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -188,26 +188,16 @@ class OrderController extends mfBaseController {
|
||||
$order_data['allow_spin'] = ($r->allow_spin) ? 1 : 0;
|
||||
$order_data['note'] = $r->note;
|
||||
|
||||
$order_date = $r->order_date;
|
||||
$order_data['order_date'] = Layout::dateToInt($r->order_date);
|
||||
|
||||
if(!preg_match('/^(\d\d)\.(\d\d)\.(\d\d\d\d)$/',$order_date, $m)) {
|
||||
$errors[] = "Ungültiges Bestelldateum";
|
||||
} else {
|
||||
$day = intval($m[1]);
|
||||
$month = intval($m[2]);
|
||||
$year = intval($m[3]);
|
||||
|
||||
if($day > 31 || $day < 1
|
||||
|| $month > 12 || $month < 1
|
||||
|| $year > date('Y')+1 || $year < date('Y'))
|
||||
{
|
||||
$this->layout()->setFlash("Ungültiges Bestelldatum");
|
||||
$this->layout()->set("Order", $r);
|
||||
if($r->finish_after) {
|
||||
$order_data['finish_after'] = Layout::dateToInt($r->finish_after);
|
||||
if(!$r->finish_after_comment) {
|
||||
$this->layout()->setFlash("Bitte Verzögerungsgrund angeben.", "warn");
|
||||
$this->layout()->set("order", $r);
|
||||
return $this->add();
|
||||
}
|
||||
|
||||
$order_date_ts = mktime(0,0,0,$month,$day,$year);
|
||||
$order_data['order_date'] = $order_date_ts;
|
||||
$order_data['finish_after_comment'] = $r->finish_after_comment;
|
||||
}
|
||||
|
||||
$order_data['edit_by'] = $this->me->id;
|
||||
@@ -272,10 +262,6 @@ class OrderController extends mfBaseController {
|
||||
$this->log->warn(__CLASS__."::save() Invalid product: ".$p['product_id']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$product_data = [];
|
||||
$product_data["order_id"] = $new_id;
|
||||
$product_data["product_id"] = $p["product_id"];
|
||||
@@ -284,17 +270,20 @@ class OrderController extends mfBaseController {
|
||||
$product_data["description"] = $p["description"];
|
||||
$product_data["price"] = Layout::commaToDot($p["price"]);
|
||||
$product_data["price_setup"] = Layout::commaToDot($p["price_setup"]);
|
||||
$product_data["billing_delay"] = 0;
|
||||
$product_data["billing_delay"] = ($p["billing_delay"]) ? $p["billing_delay"] : 0;
|
||||
$product_data["billing_period"] = $p["billing_period"];
|
||||
|
||||
|
||||
$require_term = false;
|
||||
if(array_key_exists(TT_ATTRIB_TERMINATION_REQUIRED_NAME, $prod->attributes) && $prod->attributes[TT_ATTRIB_TERMINATION_REQUIRED_NAME] == 1) {
|
||||
$require_term = true;
|
||||
if(!$p['termination_id']) {
|
||||
$this->layout()->setFlash("Produkt nicht gespeichert. Produkt erfordert Anschluss.", "warn");
|
||||
$this->layout()->setFlash("Ein oder mehrere Produkte erfordern Anschluss.", "warn");
|
||||
continue;
|
||||
}
|
||||
$product_data['termination_id'] = $p['termination_id'];
|
||||
} else {
|
||||
$product_data['termination_id'] = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -75,6 +75,11 @@ class Termination extends mfBaseModel {
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "status") {
|
||||
$this->status = TerminationstatusModel::getOne($this->status_id);
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
@@ -16,11 +16,35 @@ class Layout extends mfLayout {
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function dotToComma($num) {
|
||||
public static function dotToComma($num) {
|
||||
return str_replace(".", ",", $num);
|
||||
}
|
||||
|
||||
public function commaToDot($num) {
|
||||
public static function commaToDot($num) {
|
||||
return str_replace(",", ".", $num);
|
||||
}
|
||||
|
||||
public static function dateToInt($date) {
|
||||
if(!preg_match('/^(\d\d)\.(\d\d)\.(\d\d\d\d)$/',$date, $m)) {
|
||||
return false;
|
||||
} else {
|
||||
$day = intval($m[1]);
|
||||
$month = intval($m[2]);
|
||||
$year = intval($m[3]);
|
||||
|
||||
if($day > 31 || $day < 1
|
||||
|| $month > 12 || $month < 1
|
||||
|| $year > date('Y')+1 || $year < date('Y'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$date_ts = mktime(0,0,0,$month,$day,$year);
|
||||
return $date_ts;
|
||||
}
|
||||
}
|
||||
|
||||
public static function intToDate($int) {
|
||||
return date("d.m.Y", $int);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user