Added termination select to Product/Form
This commit is contained in:
@@ -345,7 +345,7 @@
|
||||
<!-- product lines -->
|
||||
<div class="row">
|
||||
<!-- line 1 -->
|
||||
<div class="col-5">
|
||||
<div class="col-4">
|
||||
<label class="form-label" for="product_id-<?=$product->id?>">Produkt</label>
|
||||
<select name="products[<?=$product->id?>][product_id]" id="product_id-<?=$product->id?>" class="form-control" onchange="updateProduct(<?=$product->id?>)">
|
||||
<option></option>
|
||||
@@ -355,34 +355,55 @@
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="amount-<?=$product->id?>">Anzahl/Menge</label>
|
||||
<input type="text" class="form-control" name="products[<?=$product->id?>][amount]" id="amount-<?=$product->id?>" value="<?=$product->formatAmount()?>" placeholder="Anzahl/Menge" />
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="billing_period-<?=$product->id?>" >Verrechungsperiode</label>
|
||||
<label class="form-label" for="billing_period-<?=$product->id?>">Verrechungsperiode</label>
|
||||
<select class="form-control" name="products[<?=$product->id?>][billing_period]" id="billing_period-<?=$product->id?>" placeholder="Verrechnungsperiode">
|
||||
<option value="12" <?=($product->billing_period == 12) ? "selected='selected'" : ""?>>Monatlich</option>
|
||||
<option value="1"> <?=($product->billing_period == 1 ? "selected='selected'" : "")?>Jährlich</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="price-<?=$product->id?>" >Preis p. Periode</label>
|
||||
<label class="form-label" for="price-<?=$product->id?>">Preis p. Periode</label>
|
||||
<input type="text" class="form-control" name="products[<?=$product->id?>][price]" id="price-<?=$product->id?>" value="<?=$this::dotToComma($product->price)?>" placeholder="Preis p. Periode" />
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="price_setup-<?=$product->id?>">Preis Setup</label>
|
||||
<input type="text" class="form-control" name="products[<?=$product->id?>][price_setup]" id="price_setup-<?=$product->id?>" value="<?=$this::dotToComma($product->price_setup)?>" placeholder="Preis Setup" />
|
||||
</div>
|
||||
|
||||
</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">
|
||||
<!-- line to choose termination -->
|
||||
<div class="col-12">
|
||||
<label class="form-label" for="termination_id-<?=$product->id?>">Anschluss</label>
|
||||
<select name="products[<?=$product->id?>][termination_id]" id="termination_id-<?=$product->id?>" class="form-control select2">
|
||||
<option></option>
|
||||
<?php foreach($terminations as $t): ?>
|
||||
<option value="<?=$t->id?>" <?=($t->id == $product->termination_id) ? "selected='selected'" : ""?>><?=$t->code?> - <?=$t->getAddress()?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<div class="row mt-1 mb-2">
|
||||
<!-- line 2 -->
|
||||
<div class="col-10">
|
||||
<label class="form-label" for="description-<?=$product->id?>" >Zusatztext</label>
|
||||
<textarea class="form-control" name="products[<?=$product->id?>][description]" id="description-<?=$product->id?>" placeholder="Zusatztext"><?=$product->description?></textarea>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="price_setup-<?=$product->id?>" >Preis Setup</label>
|
||||
<input type="text" class="form-control" name="products[<?=$product->id?>][price_setup]" id="price_setup-<?=$product->id?>" value="<?=$this::dotToComma($product->price_setup)?>" placeholder="Preis Setup" />
|
||||
<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)" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -402,8 +423,8 @@
|
||||
<!-- product lines -->
|
||||
<div class="row">
|
||||
<!-- line 1 -->
|
||||
<div class="col-5">
|
||||
<label class="form-label" for="product_id-new" >Produkt</label>
|
||||
<div class="col-4">
|
||||
<label class="form-label" for="product_id-new">Produkt</label>
|
||||
<select name="products[new][product_id]" id="product_id-new" class="form-control" onchange="updateProduct('new')">
|
||||
<option></option>
|
||||
<?php foreach($products as $p): ?>
|
||||
@@ -411,7 +432,7 @@
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="amount-new">Anzahl/Menge</label>
|
||||
<input type="text" class="form-control" name="products[new][amount]" id="amount-new" value="" placeholder="Anzahl/Menge (Standard: 1)" />
|
||||
</div>
|
||||
@@ -427,6 +448,24 @@
|
||||
<input type="text" class="form-control" name="products[new][price]" id="price-new" value="" placeholder="Preis p. Periode" />
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="price_setup-new" >Preis Setup</label>
|
||||
<input type="text" class="form-control" name="products[new][price_setup]" id="price_setup-new" value="" placeholder="Preis Setup" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row mt-1 mb-2 hidden" id="termination_id-new-line">
|
||||
<!-- line to choose termination -->
|
||||
<div class="col-12">
|
||||
<label class="form-label" for="termination_id-new">Anschluss</label>
|
||||
<select name="products[new][termination_id]" id="termination_id-new" class="form-control">
|
||||
<option></option>
|
||||
<?php foreach($terminations as $t): ?>
|
||||
<option value="<?=$t->id?>"><?=$t->code?> - <?=$t->getAddress()?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-1 mb-2">
|
||||
@@ -437,8 +476,8 @@
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="price_setup-new" >Preis Setup</label>
|
||||
<input type="text" class="form-control" name="products[new][price_setup]" id="price_setup-new" value="" placeholder="Preis Setup" />
|
||||
<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)" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -456,7 +495,7 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php if(!$order->id): ?>
|
||||
<i>Verfügbar nach speichern.</i>
|
||||
<i class="text-pink">Verfügbar nach speichern.</i>
|
||||
<?php else: ?>
|
||||
|
||||
<?php if(is_array($order->files) && count($order->files)): ?>
|
||||
@@ -564,6 +603,13 @@
|
||||
placeholder: ""
|
||||
});
|
||||
|
||||
$('.select2').each(function(){
|
||||
$(this).select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
});
|
||||
|
||||
$('#owner_id').change(function() {
|
||||
var val = $('#owner_id').val();
|
||||
|
||||
@@ -620,6 +666,20 @@
|
||||
$('#billing_period-' + id).val(p.billing_period);
|
||||
$('#price-' + id).val(p.price);
|
||||
$('#price_setup-' + id).val(p.price_setup);
|
||||
|
||||
console.log(p.attributes);
|
||||
|
||||
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({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
} else {
|
||||
$('#termination_id-new-line').hide();
|
||||
}
|
||||
},
|
||||
'json');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user