Files
thetool/Layout/default/Producttech/Form.php
2022-04-19 21:41:08 +02:00

228 lines
11 KiB
PHP

<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Product")?>">Produkte</a></li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Producttech")?>">Technologien</a></li>
<li class="breadcrumb-item active"><?=($producttech->id) ? "bearbeiten" : "Neu" ?></li>
</ol>
</div>
<h4 class="page-title">Technologien</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h4 class="header-title mb-2"><?=($producttech->id) ? "Technologie bearbeiten" : "Neue Technologie"?></h4>
<form class="form-horizontal" method="post" action="<?=self::getUrl("Producttech", "save")?>">
<div class="card">
<div class="card-body">
<input type="hidden" name="id" value="<?=$producttech->id?>" />
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="name">Name</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="name" id="name" value="<?=$producttech->name?>" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="customer_type">Kundentyp</label>
<div class="col-lg-10">
<select class="select2 form-control " name="customer_type" id="customer_type">
<option value="residential" <?=($producttech->customer_type != "business") ? "selected='selected'" : ""?>>Residential</option>
<option value="business" <?=($producttech->customer_type == "business") ? "selected='selected'" : ""?>>Business</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="description">Beschreibung</label>
<div class="col-lg-10">
<textarea name="description" id="description" class="form-control" rows="2"><?=$producttech->description?></textarea>
</div>
</div>
</div>
</div>
<h4 class="header-title mb-2">Produktattribute</h4>
<div class="card">
<div class="card-body">
<?php if(is_array($producttech->attributes) && count($producttech->attributes)): ?>
<?php $i=0; foreach($producttech->attributes as $attribute): ?>
<div class="p-2 <?=($i % 2 == 0) ? "bg-light" : ""?>">
<div class="row">
<div class="col-md-11 float-left">
<h4 class="header-title">Attribut <span class="text-monospace text-pink"><?=$attribute->name?></span></h4>
</div>
<div class="col-md-1 float-right">
<small><a class="text-danger" href="<?=self::getUrl("ProducttechAttribute", "delete", ['id' => $attribute->id])?>" onclick="if(!confirm('Attribut wirklich löschen?')) return false;"><i class="fas fa-trash-alt"></i> löschen</a></small>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="attributes_<?=$attribute->id?>_name">Name <small class="text-monospace">[a-z0-9._-]</small></label>
<input type="text" class="form-control" id="attributes_<?=$attribute->id?>_name" name="attributes[<?=$attribute->id?>][name]" value="<?=$attribute->name?>" />
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="attributes_<?=$attribute->id?>_displayname">Anzeigename</label>
<input type="text" class="form-control" id="attributes_<?=$attribute->id?>_displayname" name="attributes[<?=$attribute->id?>][displayname]" value="<?=$attribute->displayname?>" />
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="attributes_<?=$attribute->id?>_value">Standardwert</label>
<input type="text" class="form-control" id="attributes_<?=$attribute->id?>_value" name="attributes[<?=$attribute->id?>][value]" value="<?=$attribute->value?>">
</div>
</div>
</div>
<div class="form-group row">
<div class="col-md-6">
<div class="form-group">
<label for="attributes_<?=$attribute->id?>_description">Beschreibung</label>
<input type="text" class="form-control" id="attributes_<?=$attribute->id?>_description" name="attributes[<?=$attribute->id?>][description]" value="<?=$attribute->description?>" />
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="attributes_<?=$attribute->id?>_note">Interne Notiz</label>
<input type="text" class="form-control" id="attributes_<?=$attribute->id?>_note" name="attributes[<?=$attribute->id?>][note]" value="<?=$attribute->note?>" />
</div>
</div>
</div>
</div>
<?php $i++; endforeach; ?>
<?php endif; ?>
<hr />
<h4 class="header-title">Neues Attribut:</h4>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="attributes_new_name">Name <small class="text-monospace">[a-z0-9._-]</small></label>
<input type="text" class="form-control" id="attributes_new_name" name="attributes[new][name]" value="" />
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="attributes_new_displayname">Anzeigename</label>
<input type="text" class="form-control" id="attributes_new_displayname" name="attributes[new][displayname]" value="" />
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="attributes_new_value">Standardwert</label>
<input type="text" class="form-control" id="attributes_new_value" name="attributes[new][value]" value="">
</div>
</div>
</div>
<div class="form-group row">
<div class="col-md-6">
<div class="form-group">
<label for="attributes_new_description">Beschreibung</label>
<input type="text" class="form-control" id="attributes_new_description" name="attributes[new][description]" value="" />
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="attributes_new_note">Interne Notiz</label>
<input type="text" class="form-control" id="attributes_new_note" name="attributes[new][note]" value="" />
</div>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
<div class="col-lg-10">
<textarea id="note" class="form-control" name="note" rows="5"><?=$product->note?></textarea>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2"></label>
<div class="col-lg-10">
<button type="submit" class="btn btn-primary">Speichern</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$("#productgroup_id").select2({
allowClear: true,
placeholder: ""
});
$("#producttech_id").select2({
allowClear: true,
placeholder: ""
});
$("#networks").select2({
allowClear: true,
placeholder: ""
});
$('#productgroup_id').change(function() {
var value = $('#productgroup_id option:selected').val();
console.log(value);
if(value == "new") {
$('#productgroup_form').show();
} else {
$('#productgroup_form').hide();
}
});
$('#producttech_id').change(function() {
var value = $('#producttech_id option:selected').val();
console.log(value);
if(value == "new") {
$('#producttech_form').show();
} else {
$('#producttech_form').hide();
}
});
// disable mousewheel on input number field when in focus
$('form').on('focus', 'input[type=number]', function (e) {
$(this).on('wheel.disableScroll', function (e) {
e.preventDefault()
})
});
$('form').on('blur', 'input[type=number]', function (e) {
$(this).off('wheel.disableScroll')
});
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>