Merge branch 'master' of code.fronk.at:fronk/thetool

This commit is contained in:
Frank Schubert
2021-07-13 19:33:27 +02:00
37 changed files with 2304 additions and 17 deletions

View File

@@ -75,7 +75,7 @@
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("User", "Index", ["filter" => ["address_id" => $address->id]])?>" title="Benutzer anzeigen"><i class="fas fa-users"></i></a>
<a href="<?=self::getUrl("Address", "edit", ["id" => $address->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a href="<?=self::getUrl("Address", "delete", ["id" => $address->id])?>" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
<a href="<?=self::getUrl("Address", "delete", ["id" => $address->id])?>" onclick="if(!confirm('Person/Firma wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>

View File

@@ -10,8 +10,7 @@
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">the-tool</a></li>
<li class="breadcrumb-item"><a href="javascript: void(0);">Dashboard</a></li>
<li class="breadcrumb-item active">Starter</li>
<li class="breadcrumb-item active">Dashboard</li>
</ol>
</div>
<h4 class="page-title">Dashboard</h4>

View File

@@ -133,6 +133,7 @@
<table class="table table-bordered">
<tr>
<th>Name</th>
<th>Netzeigentümer</th>
<?php foreach(TT_NETWORK_ROLES as $role): ?>
<th class="text-center"><?=__($role)?></th>
<?php endforeach ?>
@@ -141,10 +142,11 @@
<?php foreach($network->addresstypes as $address_id => $addresstypes): ?>
<tr>
<td><?=AddressModel::getOne($address_id)->getCompanyOrName()?></td>
<td><input type="checkbox" <?=($network->owner_id == $address_id) ? "checked='checked'" : ""?> disabled="disabled" /></td>
<?php foreach(TT_NETWORK_ROLES as $role): ?>
<td class="text-center">
<?php if(AddresstypeModel::getFirst(['address_id' => $address_id, 'addresstype' => [$role]]) !== null): ?>
<input
<input type="checkbox"
type="checkbox"
name="roles[<?=$address_id?>][]"
value="<?=$role?>"
@@ -158,7 +160,7 @@
</td>
<?php endforeach; ?>
<td class="controls" style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("NetworkAddress", "delete", ["id" => $address_id])?>" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
<a href="<?=self::getUrl("NetworkAddress", "delete", ["network_id" => $network->id, "address_id" => $address_id])?>" onclick="if(!confirm('Berechtigungen wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
@@ -184,7 +186,7 @@
<tr>
<td>
<select class="select2 form-control " name="address_id" id="address_id">
<select class="select2 form-control" name="address_id" id="address_id">
<option></option>
<?php foreach(AddressModel::search(["parents_only" => 1]) as $address): ?>
<?php if(is_array($network->addresstypes) && array_key_exists($address->id, $network->addresstypes)) continue; ?>

View File

@@ -148,10 +148,10 @@
$(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__)."/../")."/footer.php"); ?>

View File

@@ -0,0 +1,291 @@
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
<div class="wrapper">
<div class="container-fluid">
<!-- 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")?>">the-tool</a></li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Product")?>">Produkte</a></li>
<li class="breadcrumb-item active"><?=($product->id) ? "bearbeiten" : "Neu" ?></li>
</ol>
</div>
<h4 class="page-title">Produkte</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"><?=($product->id) ? "Produkt bearbeiten" : "Neues Produkt"?></h4>
<form class="form-horizontal" method="post" action="<?=self::getUrl("Product", "save")?>">
<div class="card">
<div class="card-body">
<input type="hidden" name="id" value="<?=$product->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="<?=$product->name?>" />
</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"><?=$product->description?></textarea>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="external">Fremdprodukt</label>
<div class="col-lg-10">
<select class="select2 form-control " name="external" id="external">
<option value="0" <?=($product->external != 1) ? "selected='selected'" : ""?>>Nein</option>
<option value="1" <?=($product->external == 1) ? "selected='selected'" : ""?>>Ja</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="productgroup_id">Produktgruppe</label>
<div class="col-lg-10">
<select class="select2 form-control" name="productgroup_id" id="productgroup_id">
<option></option>
<option value="new">Neue Produktgruppe...</option>
<option value="1">1</option>
<?php foreach($productgroups as $group): ?>
<option value="<?=$group->id?>" <?=($product->productgroup_id == $group->id) ? "selected='selected'" : ""?>><?=$group->name?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row" id="productgroup_form" style="display:none;">
<label class="col-lg-2 col-form-label" for="productgroup_new"></label>
<div class="col-lg-10">
<div class="row">
<div class="col-lg-2">Neue Produktgruppe:</div>
<div class="col-lg-10">
Name: <input type="text" class="form-control" name="productgroup_new_name" id="productgroup_new_name" value="<?=$productgroup_new_name?>">
Beschreibung: <textarea class="form-control" name="productgroup_new_description" id="productgroup_new_description"><?=$productgroup_new_description?></textarea>
Interne Notiz: <textarea class="form-control" name="productgroup_new_note" id="productgroup_new_note"><?=$productgroup_new_note?></textarea>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="producttech_id">Technologie</label>
<div class="col-lg-10">
<select class="select2 form-control " name="producttech_id" id="producttech_id">
<option></option>
<option value="new">Neue Technologie...</option>
<?php foreach($producttechs as $tech): ?>
<option value="<?=$tech->id?>" <?=($product->producttech_id == $tech->id) ? "selected='selected'" : ""?>><?=$tech->name?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row" id="producttech_form" style="display: none;">
<label class="col-lg-2 col-form-label" for="producttech_new"></label>
<div class="col-lg-10">
<div class="row">
<div class="col-lg-2">Neue Technologie:</div>
<div class="col-lg-10">
Name: <input type="text" class="form-control" name="producttech_new_name" id="producttech_new_name" value="<?=$producttech_new_name?>">
Kundentyp: <select name="producttech_new_customer_type" class="form-control"><option value="residential">Residential</option><option value="business">Business</option></select>
RTR Code: <input type="text" class="form-control" name="producttech_new_rtrcode" id="producttech_new_rtrcode" value="<?=$producttech_new_rtrcode?>">
Beschreibung: <textarea class="form-control" name="producttech_new_description" id="productgroup_new_description"><?=$producttech_new_description?></textarea>
Interne Notiz: <textarea class="form-control" name="producttech_new_note" id="productgroup_new_note"><?=$producttech_new_note?></textarea>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="sla_id">SLA</label>
<div class="col-lg-10">
<select class="select2 form-control " name="sla_id" id="sla_id">
<option></option>
<?php foreach($slas as $sla): ?>
<option value="<?=$sla->id?>" <?=($product->sla_id == $sla->id) ? "selected='selected'" : ""?>><?=$sla->name?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="networks">Netzgebiete</label>
<div class="col-lg-10">
<select class="select2 form-control select2-multiple" name="networks[]" id="networks" multiple="multiple" data-placeholder="Choose ...">
<option></option>
<?php foreach($networks as $network): ?>
<option value="<?=$network->id?>" <?=(array_key_exists($network->id, $product->networks)) ? "selected='selected'" : ""?>><?=$network->name?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="ivt_id">IVT Produkt ID</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="ivt_id" id="ivt_id" value="<?=$product->ivt_id?>" />
</div>
</div>
</div>
</div>
<h4 class="header-title mb-2">Verrechnungsdaten</h4>
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="price">Setup Preis Netto (Einmalig)</label>
<div class="col-lg-10">
<input type="text" name="price_setup" id="price_setup" class="form-control" value="<?=$this::dotToComma($product->price_setup)?>" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="price">Verkaufspreis Netto (Periodisch)</label>
<div class="col-lg-10">
<input type="text" name="price" id="price" class="form-control" value="<?=$this::dotToComma($product->price)?>" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="nne">Netznutzungsentgelt (NNE)</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="price_nne" id="price_nne" value="<?=$this::dotToComma($product->price_nne)?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="nbe">Netzbetriebsentgelt (NBE)</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="price_nbe" id="price_nbe" value="<?=$this::dotToComma($product->price_nbe)?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="billing_period">Verrechnungsperiode</label>
<div class="col-lg-10">
<select class="select2 form-control " name="billing_period" id="billing_period">
<option value="1" <?=($product->billing_period == 1) ? "selected='selected'" : ""?>>Jährlich</option>
<option value="12" <?=($product->billing_period == 12) ? "selected='selected'" : ""?>>Monatlich</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="billing_delay">Verzögerter Verrechnungsstart (Monate)</label>
<div class="col-lg-10">
<input type="text" name="billing_delay" id="billing_delay" class="form-control" value="<?=$this::dotToComma($product->billing_delay)?>" />
</div>
</div>
</div>
</div>
<?php if(is_array($product->attributes) && count($product->attributes)): ?>
<h4 class="header-title mb-2">Produktattribute</h4>
<div class="card">
<div class="card-body">
<?php foreach($product->attributes as $attrib): ?>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="attributes_<?=$attrib->producttechattribute_id?>"><?=$attrib->displayname?></label>
<div class="col-lg-10">
<input type="text" class="form-control" name="attributes[<?=$attrib->producttechattribute_id?>]" id="attributes_<?=$attrib->producttechattribute_id?>" value="<?=$attrib->value?>" />
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<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>
</div> <!-- end container-fluid -->
</div>
<!-- end wrapper -->
<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__)."/../")."/footer.php"); ?>

View File

@@ -0,0 +1,75 @@
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
<div class="wrapper">
<div class="container-fluid">
<!-- 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")?>">the-tool</a></li>
<li class="breadcrumb-item active">Produkte</li>
</ol>
</div>
<h4 class="page-title">Produkte</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body mb-3">
<div class="float-left">
<h4 class="header-title">Liste aller Produkte</h4>
</div>
<div class="float-right">
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Product", "add")?>"><i class="fas fa-plus"></i> Neues Produkt anlegen</a>
</div>
<table class="table table-striped table-hover">
<tr>
<th>Netzgebiete</th>
<th>Gruppe</th>
<th>Name</th>
<th>Technologie</th>
<th>Kundentyp</th>
<th>Verkaufspreis</th>
<th>Verr. Periode</th>
<th>SLA</th>
<th>IVT ID</th>
<th></th>
</tr>
<?php foreach($products as $product): ?>
<tr>
<td><?=(count($product->networks)) ? array_shift($product->networks)->name . ((count($product->networks) > 1) ? ", ..." : "") : ""?></td>
<td><?=$product->productgroup->name?></td>
<td><?=$product->name?></td>
<td><?=$product->producttech->name?> (<?=$product->attributes[TT_ATTRIB_RTRTECHCODE_NAME]->value?>)</td>
<td><?=__($product->producttech->customer_type)?></td>
<td><?=$product->price?></td>
<td><?=$product->billing_period?>x Jährlich</td>
<td><?=$product->sla->name?></td>
<td><?=$product->ivt_id?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("Product", "edit", ["id" => $product->id])?>"><i class="far fa-edit" title="Produkt Bearbeiten"></i></a>
<a href="<?=self::getUrl("Product", "delete", ["id" => $product->id])?>" class="text-danger" onclick="if(!confirm('Berechtigungen wirklich löschen?')) return false;" title="Produkt Löschen"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
</div> <!-- end container-fluid -->
</div>
<!-- end wrapper -->
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>

View File

@@ -0,0 +1,235 @@
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
<div class="wrapper">
<div class="container-fluid">
<!-- 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")?>">the-tool</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">Produkte</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>
</div> <!-- end container-fluid -->
</div>
<!-- end wrapper -->
<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__)."/../")."/footer.php"); ?>

View File

@@ -0,0 +1,62 @@
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
<div class="wrapper">
<div class="container-fluid">
<!-- 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")?>">the-tool</a></li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Product")?>">Produkte</a></li>
<li class="breadcrumb-item active">Technologien</li>
</ol>
</div>
<h4 class="page-title">Produkttechnologien</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body mb-3">
<div class="float-left">
<h4 class="header-title">Liste aller Technologien</h4>
</div>
<div class="float-right">
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Producttech", "add")?>"><i class="fas fa-plus"></i> Neue Technologie anlegen</a>
</div>
<table class="table table-striped table-hover">
<tr>
<th>Name</th>
<th>Kundentyp</th>
<th></th>
</tr>
<?php foreach($producttechs as $tech): ?>
<tr>
<td><?=$tech->name?></td>
<td><?=__($tech->customer_type)?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("Producttech", "edit", ["id" => $tech->id])?>"><i class="far fa-edit" title="Technologie Bearbeiten"></i></a>
<a href="<?=self::getUrl("Producttech", "delete", ["id" => $tech->id])?>" class="text-danger" onclick="if(!confirm('Technologie wirklich löschen?')) return false;" title="Technologie Löschen"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
</div> <!-- end container-fluid -->
</div>
<!-- end wrapper -->
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>

View File

@@ -13,7 +13,7 @@
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>">the-tool</a></li>
<li class="breadcrumb-item">Benutzer</li>
<li class="breadcrumb-item active">Benutzer</li>
</ol>
</div>
<h4 class="page-title">Benutzer</h4>

View File

@@ -3,7 +3,7 @@
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
the tool &copy; 2021 <a href="https://www.xinon.at">Xinon GmbH</a> - Made by fronk - Simulor Theme by Coderthemes
the tool &copy; 2021 <a href="https://www.xinon.at">Xinon GmbH</a> - Made by fronk
</div>
<div class="col-md-6">
<div class="text-md-right footer-links d-none d-sm-block">

View File

@@ -7,11 +7,10 @@
<li class="has-submenu">
<a href="<?=self::getUrl("Dashboard")?>"><i class="fe-airplay"></i>Dashboard</a>
</li>
<li class="has-submenu">
<a href="#">
<i class="fas fa-database"></i>Stammdaten <div class="arrow-down"></div>
</a>
</a>
<ul class="submenu">
<li class="has-sub-submenu">
<a href="<?=self::getUrl("Address")?>">Personen & Firmen</a>
@@ -21,12 +20,16 @@
<li><a href="<?=self::getUrl("Address", "Index" , ["filter" => ["addresstype" => ["supplier"]]])?>">Lieferanten</a></li>
</ul>
</li>
<li class="has-sub-submenu">
<a href="<?=self::getUrl("Product")?>">Produkte</a>
<ul class="sub-submenu">
<li><a href="<?=self::getUrl("Producttech")?>">Technologien</a></li>
</ul>
</li>
<li><a href="<?=self::getUrl("User")?>">Benutzer</a></li>
<li><a href="<?=self::getUrl("Network")?>">Neztgebiete</a></li>
<li><a href="<?=self::getUrl("Network")?>">Netzgebiete</a></li>
</ul>
</li>
</ul>
<!-- End navigation menu -->

View File

@@ -56,7 +56,7 @@ class NetworkController extends mfBaseController {
$mode = "edit";
$network = new Network($id);
if(!$network->id) {
$this->layout()->setFlash("Netzgebie tnicht gefunden", "error");
$this->layout()->setFlash("Netzgebiet nicht gefunden", "error");
$this->redirect("Network");
}
} else {

View File

@@ -20,6 +20,16 @@ class NetworkModel {
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}

View File

@@ -100,4 +100,42 @@ class NetworkAddressController extends mfBaseController {
$this->redirect("Network", "Index", [],"view=roles&net=$network_id");
}
protected function deleteAction() {
$r = $this->request;
//var_dump($r->roles);exit;
if(!is_numeric($r->network_id) && $r->network_id <= 0) {
$this->layout()->setFlash("Netzgebiet nicht gefunden.", "error");
$this->redirect("Network");
}
if(!is_numeric($r->address_id) && $r->address_id <= 0) {
$this->layout()->setFlash("Person/Firma nicht gefunden.", "error");
$this->redirect("Network");
}
$network_id = $r->network_id;
$address_id = $r->address_id;
$network = new Network($network_id);
if(!$network->id) {
$this->layout()->setFlash("Netzgebiet nicht gefunden.", "error");
$this->redirect("Network");
}
$address = new Address($address_id);
if(!$address->id) {
$this->layout()->setFlash("Person/Firma nicht gefunden.", "error");
$this->redirect("Network", "Index", [], "view=roles&net=$network_id");
}
$roles = NetworkAddressModel::search(["network_id" => $network_id, "address_id" => $address_id]);
//var_dump($roles);exit;
foreach($roles as $role) {
$role->delete();
}
$this->layout()->setFlash("Berechtigungen erfolgreich gelöscht.", "success");
$this->redirect("Network", "Index", [], "view=roles&net=$network_id");
}
}

View File

@@ -0,0 +1,69 @@
<?php
class Product extends mfBaseModel {
private $productgroup;
private $producttech;
private $sla;
private $networks;
private $attributes;
public function loadAttributes() {
if(!$this->producttech_id) {
return false;
}
$this->attributes = [];
// get tech attribs
$ptattribs = ProducttechAttributeModel::search(['producttech_id' => $this->producttech_id]);
// fill atrribs with existing values of product attribs
foreach($ptattribs as $pta) {
$attrib = ProductAttributeModel::getFirst(['product_id' => $this->id, 'producttechattribute_id' => $pta->id]);
if(!$attrib) {
$attrib = new ProductAttribute();
$attrib->product_id = $this->id;
$attrib->producttechattribute_id = $pta->id;
$attrib->value = $pta->value;
$attrib->note = $pta->note;
}
$attrib->name = $pta->name;
$attrib->displayname = $pta->displayname;
$attrib->description = $pta->description;
$this->attributes[$attrib->name] = $attrib;
}
return true;
}
public function getProperty($name) {
if($this->$name == null) {
if($name == "networks") {
$this->networks = [];
$productNetworks = ProductNetworkModel::search(['product_id' => $this->id]);
foreach($productNetworks as $pnet) {
$this->networks[$pnet->network_id] = new Network($pnet->network_id);
}
return $this->networks;
}
if($name == "attributes") {
$this->loadAttributes();
return $this->attributes;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}

View File

@@ -0,0 +1,181 @@
<?php
class ProductController extends mfBaseController {
protected function init() {
$this->needlogin=true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me",$me);
/*
if(!$me->isAdmin()) {
$this->redirect("Dashboard");
}*/
}
protected function indexAction() {
$this->layout()->set("products", ProductModel::getAll());
}
protected function addAction() {
$this->layout()->setTemplate("Product/Form");
$this->layout()->set("productgroups", ProductgroupModel::getAll());
$this->layout()->set("producttechs", ProducttechModel::getAll());
$this->layout()->set("slas", SlaModel::getAll());
$this->layout()->set("networks", NetworkModel::getAll());
}
protected function editAction() {
$product_id = $this->request->id;
$product = new Product($product_id);
if(!$product->id) {
$this->layout()->setFlash("Produkt nicht gefunden.", "error");
$this->redirect("Product");
}
//var_dump($product->attributes);exit;
$this->layout()->set("product", $product);
return $this->addAction();
}
protected function saveAction() {
$r = $this->request;
//var_dump($r);exit;
$id = $r->id;
if(is_numeric($id) && $id > 0) {
$mode = "edit";
$product = new Product($id);
if(!$product->id) {
$this->layout()->setFlash("Produkt nicht gefunden", "error");
$this->redirect("Product");
}
} else {
$id = false;
$mode = "add";
}
$data = [];
$data['name'] = $r->name;
$data['description'] = $r->description;
$data['sla_id'] = $r->sla_id;
$data['external'] = ($r->external == 1) ? "1" : "0";
$data['price_nne'] = Layout::commaToDot($r->price_nne);
$data['price_nbe'] = Layout::commaToDot($r->price_nbe);
$data['price'] = Layout::commaToDot($r->price);
$data['price_setup'] = Layout::commaToDot($r->price_setup);
$data['billing_period'] = $r->billing_period;
$data['billing_delay'] = $r->billing_delay;
$data['ivt_id'] = ($r->ivt_id) ? $r->ivt_id : null;
$data['note'] = $r->note;
if(is_numeric($r->producttech_id)) {
$data['producttech_id'] = $r->producttech_id;
} else {
$data['producttech_id'] = null;
}
if(is_numeric($r->productgroup_id)) {
$data['productgroup_id'] = $r->productgroup_id;
} else {
$data['productgroup_id'] = null;
}
$data['edit_by'] = $this->me->id;
if($mode == "add") {
$data['create_by'] = $this->me->id;
$product = ProductModel::create($data);
} else {
$product->update($data);
}
//var_dump($address);exit;
$new_id = $product->save();
if(!$new_id) {
$this->layout()->setFlash("Fehler beim Speichern", "error");
$this->layout()->set("product", $product);
return $this->add();
}
// delete all networks to save networks
$pnets = ProductNetworkModel::search(['product_id' => $new_id]);
foreach($pnets as $pnet) {
$pnet->delete();
}
if(is_array($r->networks) && count($r->networks)) {
foreach($r->networks as $network_id) {
$network = new Network($network_id);
if(!$network->id) {
// ignore non-existing networks
continue;
}
$pnet = ProductNetworkModel::create(['product_id' => $new_id, 'network_id' => $network_id]);
$pnet->save();
}
}
// create new product group and tech
if($r->productgroup_id == "new") {
$ng = [];
$ng['name'] = $r->productgroup_new_name;
$ng['description'] = $r->productgroup_new_description;
$ng['note'] = $r->productgroup_new_note;
$group = ProductgroupModel::create($ng);
$group_id = $group->save();
$product->productgroup_id = $group_id;
$product->save();
}
if($r->producttech_id == "new") {
$nt = [];
$nt['name'] = $r->producttech_new_name;
$nt['rtrcode'] = $r->producttech_new_rtrcode;
$nt['customer_type'] = ($r->producttech_new_customer_type == "business") ? "business" : "residential";
$nt['description'] = $r->producttech_new_description;
$nt['note'] = $r->producttech_new_note;
$tech = ProducttechModel::create($nt);
$tech_id = $tech->save();
$product->producttech_id = $tech_id;
$product->save();
}
if(is_array($r->attributes) && count($r->attributes)) {
foreach($r->attributes as $pta_id => $attribute_value) {
$attrib = ProductAttributeModel::getFirst(['product_id' => $new_id, 'producttechattribute_id' => $pta_id]);
if(!$attrib) {
$attrib = ProductAttributeModel::create([
'product_id' => $new_id,
'producttechattribute_id' => $pta_id,
]);
//var_dump($attrib);exit;
}
$attrib->value = $attribute_value;
$attrib->edit_by = $this->me->id;
$attrib->save();
}
}
$this->layout()->setFlash("Produkt erfolgreich gespeichert.", "success");
$this->redirect("Product", "Edit", ['id' => $new_id]);
}
protected function delete() {
$id = $this->request->id;
$product = new Product($id);
if(!$product->id || $product->id != $id) {
$this->layout()->setFlash("Produkt nicht gefunden.", "error");
$this->redirect("Product");
}
// check if Product is unused
$product->delete();
$this->redirect("Product");
}
}

View File

@@ -0,0 +1,144 @@
<?php
class ProductModel {
public $name = null;
public $description = null;
public $sla_id = null;
public $external = null;
public $productgroup_id = null;
public $producttech_id = null;
public $price = null;
public $price_nne = null;
public $price_nbe = null;
public $billing_period = null;
public $ivt_id = null;
public $note = null;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(Array $data) {
$model = new Product();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
$model ->$field = $value;
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id) {
if(!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("Product", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Product($data);
}
return $item;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("Product", "*", "1 = 1 ORDER BY producttech_id, name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Product($data);
}
}
return $items;
}
public static function getFirst() {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Product", "*", "$where ORDER BY producttech_id, name LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Product($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Product", "*", "$where ORDER BY producttech_id, name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Product($data);
}
}
return $items;
}
private function getSqlFilter($filter) {
$where = "1=1 ";
$db = FronkDB::singleton();
//var_dump($filter);exit;
if(array_key_exists("productgroup_id", $filter)) {
$productgroup_id = $filter['productgroup_id'];
if(is_numeric($productgroup_id)) {
$where .= " AND productgroup_id=$productgroup_id";
}
}
if(array_key_exists("producttech_id", $filter)) {
$producttech_id = $filter['producttech_id'];
if(is_numeric($producttech_id)) {
$where .= " AND producttech_id=$producttech_id";
}
}
if(array_key_exists("name", $filter)) {
$name = $db->escape($filter['name']);
if($name) {
$where .= " AND `name` like '$name'";
}
}
if(array_key_exists("nameLike", $filter)) {
$name = $db->escape($filter['nameLike']);
if($name) {
$where .= " AND `name` like '%$name%'";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,33 @@
<?php
class ProductAttribute extends mfBaseModel {
public function getProperty($name) {
if($this->$name == null) {
if($name == "networks") {
$this->networks = [];
$productNetworks = ProductNetworkModel::search(['product_id' => $this->id]);
foreach($productNetworks as $pnet) {
$this->networks[$pnet->network_id] = new Network($pnet->network_id);
}
return $this->networks;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}

View File

@@ -0,0 +1,18 @@
<?php
class ProductAttributeController extends mfBaseController {
protected function init() {
$this->needlogin=true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me",$me);
/*
if(!$me->isAdmin()) {
$this->redirect("Dashboard");
}*/
}
}

View File

@@ -0,0 +1,121 @@
<?php
class ProductAttributeModel {
public $product_id = null;
public $producttechattribute_id = null;
public $value = null;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(Array $data) {
$model = new ProductAttribute();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
$model->$field = $value;
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id) {
if(!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("ProductAttribute", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new ProductAttribute($data);
}
return $item;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("ProductAttribute", "*", "1 = 1 ORDER BY product_id, producttechattribute_id");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[$data->id] = new ProductAttribute($data);
}
}
return $items;
}
public static function getFirst($filter) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("ProductAttribute", "*", "$where ORDER BY product_id, producttechattribute_id");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new ProductAttribute($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("ProductAttribute", "*", "$where ORDER BY name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[$data->id] = new ProductAttribute($data);
}
}
return $items;
}
private function getSqlFilter($filter) {
$where = "1=1 ";
$db = FronkDB::singleton();
if(array_key_exists("product_id", $filter)) {
$product_id = $filter['product_id'];
if(is_numeric($product_id)) {
$where .= " AND `product_id` = $product_id";
}
}
if(array_key_exists("producttechattribute_id", $filter)) {
$producttechattribute_id = $filter['producttechattribute_id'];
if(is_numeric($producttechattribute_id)) {
$where .= " AND `producttechattribute_id` = $producttechattribute_id";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,5 @@
<?php
class ProductNetwork extends mfBaseModel {
}

View File

@@ -0,0 +1,120 @@
<?php
class ProductNetworkModel {
public $product_id = null;
public $network_id = null;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(Array $data) {
$model = new ProductNetwork();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
$model ->$field = $value;
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id) {
if(!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("ProductNetwork", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new ProductNetwork($data);
}
return $item;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("ProductNetwork", "*", "1 = 1 ORDER BY product_id, network_id");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[$data->id] = new ProductNetwork($data);
}
}
return $items;
}
public static function getFirst() {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("ProductNetwork", "*", "$where ORDER BY product_id, network_id LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new ProductNetwork($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("ProductNetwork", "*", "$where ORDER BY product_id, network_id");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[$data->id] = new ProductNetwork($data);
}
}
return $items;
}
private function getSqlFilter($filter) {
$where = "1=1 ";
$db = FronkDB::singleton();
//var_dump($filter);exit;
if(array_key_exists("product_id", $filter)) {
$product_id = $filter['product_id'];
if(is_numeric($product_id)) {
$where .= " AND product_id=$product_id";
}
}
if(array_key_exists("network_id", $filter)) {
$network_id = $filter['network_id'];
if(is_numeric($network_id)) {
$where .= " AND network_id=$network_id";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,5 @@
<?php
class Productgroup extends mfBaseModel {
}

View File

@@ -0,0 +1,30 @@
<?php
class ProductgroupController extends mfBaseController {
protected function init() {
$this->needlogin=true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me",$me);
/*
if(!$me->isAdmin()) {
$this->redirect("Dashboard");
}*/
}
protected function indexAction() {
}
protected function addAction() {
}
protected function editAction() {
}
}

View File

@@ -0,0 +1,122 @@
<?php
class ProductgroupModel {
public $name = null;
public $description = null;
public $note = null;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(Array $data) {
$model = new Productgroup();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
$model ->$field = $value;
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id) {
if(!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("Productgroup", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Productgroup($data);
}
return $item;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("Productgroup", "*", "1 = 1 ORDER BY name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[$data->id] = new Productgroup($data);
}
}
return $items;
}
public static function getFirst() {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Productgroup", "*", "$where ORDER BY name");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Productgroup($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Productgroup", "*", "$where ORDER BY name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[$data->id] = new Productgroup($data);
}
}
return $items;
}
private function getSqlFilter($filter) {
$where = "1=1 ";
$db = FronkDB::singleton();
//var_dump($filter);exit;
if(array_key_exists("name", $filter)) {
$name = $db->escape($filter['name']);
if($name) {
$where .= " AND `name` like '$name'";
}
}
if(array_key_exists("nameLike", $filter)) {
$name = $db->escape($filter['nameLike']);
if($name) {
$where .= " AND `name` like '%$name%'";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,32 @@
<?php
class Producttech extends mfBaseModel {
private $attributes;
public function getProperty($name) {
if($this->$name == null) {
if($name == "attributes") {
$this->attributes = [];
$producttechAttributes = ProducttechAttributeModel::search(['producttech_id' => $this->id]);
foreach($producttechAttributes as $pta) {
$this->attributes[$pta->id] = $pta;
}
return $this->attributes;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}

View File

@@ -0,0 +1,133 @@
<?php
class ProducttechController extends mfBaseController {
protected function init() {
$this->needlogin=true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me",$me);
/*
if(!$me->isAdmin()) {
$this->redirect("Dashboard");
}*/
}
protected function indexAction() {
$this->layout()->setTemplate("Producttech/Index");
$this->layout()->set("producttechs", ProducttechModel::getAll());
}
protected function addAction() {
$this->layout()->setTemplate("Producttech/Form");
}
protected function editAction() {
$tech_id = $this->request->id;
$tech = new Producttech($tech_id);
if(!$tech->id) {
$this->layout()->setFlash("Technologie nicht gefunden.", "error");
$this->redirect("Producttech");
}
$this->layout()->set("producttech", $tech);
return $this->addAction();
}
protected function saveAction() {
$r = $this->request;
//var_dump($r);
//var_dump($r->attributes);
//exit;
$id = $r->id;
if(is_numeric($id) && $id > 0) {
$mode = "edit";
$producttech = new Producttech($id);
if(!$producttech->id) {
$this->layout()->setFlash("Technologie nicht gefunden", "error");
$this->redirect("Producttech");
}
} else {
$id = false;
$mode = "add";
}
$data = [];
$data['name'] = $r->name;
$data['customer_type'] = $r->customer_type;
$data['description'] = $r->description;
$data['note'] = $r->note;
$data['edit_by'] = $this->me->id;
if($mode == "add") {
$data['create_by'] = $this->me->id;
$producttech = ProducttechModel::create($data);
} else {
$producttech->update($data);
}
//var_dump($address);exit;
$new_id = $producttech->save();
if(!$new_id) {
$this->layout()->setFlash("Fehler beim Speichern", "error");
$this->layout()->set("producttech", $producttech);
return $this->add();
}
// handle ProductAttributes
if(is_array($r->attributes) && count($r->attributes)) {
foreach($r->attributes as $aid => $attribute) {
if(!trim($attribute['name']) || !trim($attribute['displayname'])) {
continue;
}
$a = [];
$a['name'] = $attribute['name'];
$a['producttech_id'] = $new_id;
$a['displayname'] = $attribute['displayname'];
$a['value'] = $attribute['value'];
$a['description'] = $attribute['description'];
$a['note'] = $attribute['note'];
$a['edit_by'] = $this->me->id;
if($aid == "new") {
$attrib = ProducttechAttributeModel::create($a);
} elseif(is_numeric($aid) && $aid > 0) {
$attrib = new ProducttechAttribute($aid);
$attrib->update($a);
} else {
continue;
}
$attrib->save();
}
}
$this->layout()->setFlash("Technologie erfolgreich gespeichert.", "success");
$this->redirect("Producttech", "edit", ['id' => $new_id]);
}
protected function delete() {
$id = $this->request->id;
$tech = new Producttech($id);
if(!$tech->id || $tech->id != $id) {
$this->layout()->setFlash("Technologie nicht gefunden.", "error");
$this->redirect("Producttech");
}
if(ProductModel::search(["producttech_id" => $tech->id])) {
$this->layout()->setFlash("Technologie kann nicht gelöscht werden, da sie in Verwendung ist.", "error");
$this->redirect("Producttech");
}
// check if Product is unused
$tech->delete();
$this->redirect("Producttech");
}
}

View File

@@ -0,0 +1,135 @@
<?php
class ProducttechModel {
public $name = null;
public $rtrcode = null;
public $customer_type = null;
public $description = null;
public $note = null;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(Array $data) {
$model = new Producttech();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
$model->$field = $value;
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id) {
if(!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("Producttech", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Producttech($data);
}
return $item;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("Producttech", "*", "1 = 1 ORDER BY name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[$data->id] = new Producttech($data);
}
}
return $items;
}
public static function getFirst() {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Producttech", "*", "$where ORDER BY name");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Producttech($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Producttech", "*", "$where ORDER BY name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[$data->id] = new Producttech($data);
}
}
return $items;
}
private function getSqlFilter($filter) {
$where = "1=1 ";
$db = FronkDB::singleton();
//var_dump($filter);exit;
if(array_key_exists("name", $filter)) {
$name = $db->escape($filter['name']);
if($name) {
$where .= " AND `name` like '$name'";
}
}
if(array_key_exists("nameLike", $filter)) {
$name = $db->escape($filter['nameLike']);
if($name) {
$where .= " AND `name` like '%$name%'";
}
}
if(array_key_exists("rtrcode", $filter)) {
$rtrcode = $db->escape($filter['rtrcode']);
if($rtrcode) {
$where .= " AND `code` like '$rtrcode'";
}
}
if(array_key_exists("customer_type", $filter)) {
$customer_type = ($customer_type == "business") ? "business" : "residential";
$where .= " AND `customer_type`='$customer_type'";
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,23 @@
<?php
class ProducttechAttribute extends mfBaseModel {
private $producttech;
public function getProperty($name) {
if($this->$name == null) {
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}

View File

@@ -0,0 +1,37 @@
<?php
class ProducttechAttributeController extends mfBaseController {
protected function init() {
$this->needlogin=true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me",$me);
/*
if(!$me->isAdmin()) {
$this->redirect("Dashboard");
}*/
}
protected function deleteAction() {
$id = $this->request->id;
$ta = new ProducttechAttribute($id);
if(!$ta->id || $ta->id != $id) {
$this->layout()->setFlash("Attribut nicht gefunden.", "error");
$this->redirect("Producttech");
}
/*if(ProductModel::search(["producttech_id" => $tech->id])) {
$this->layout()->setFlash("Technologie kann nicht gelöscht werden, da sie in Verwendung ist.", "error");
$this->redirect("Producttech");
}*/
$producttech_id = $ta->producttech_id;
// check if Product is unused
$ta->delete();
$this->redirect("Producttech", "edit", ['id' => $producttech_id]);
}
}

View File

@@ -0,0 +1,132 @@
<?php
class ProducttechAttributeModel {
public $producttech_id = null;
public $name = null;
public $displayname = null;
public $value = null;
public $description = null;
public $note = null;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(Array $data) {
$model = new ProducttechAttribute();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
$model->$field = $value;
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id) {
if(!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("ProducttechAttribute", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new ProducttechAttribute($data);
}
return $item;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("ProducttechAttribute", "*", "1 = 1 ORDER BY name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[$data->id] = new ProducttechAttribute($data);
}
}
return $items;
}
public static function getFirst() {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("ProducttechAttribute", "*", "$where ORDER BY name");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new ProducttechAttribute($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("ProducttechAttribute", "*", "$where ORDER BY name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[$data->id] = new ProducttechAttribute($data);
}
}
return $items;
}
private function getSqlFilter($filter) {
$where = "1=1 ";
$db = FronkDB::singleton();
//var_dump($filter);exit;
if(array_key_exists("name", $filter)) {
$name = $db->escape($filter['name']);
if($name) {
$where .= " AND `name` like '$name'";
}
}
if(array_key_exists("nameLike", $filter)) {
$name = $db->escape($filter['nameLike']);
if($name) {
$where .= " AND `name` like '%$name%'";
}
}
if(array_key_exists("producttech_id", $filter)) {
$producttech_id = $db->escape($filter['producttech_id']);
if(is_numeric($producttech_id)) {
$where .= " AND `producttech_id` = $producttech_id";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

5
application/Sla/Sla.php Normal file
View File

@@ -0,0 +1,5 @@
<?php
class Sla extends mfBaseModel {
}

View File

@@ -0,0 +1,122 @@
<?php
class SlaModel {
public $name = null;
public $description = null;
public $note = null;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(Array $data) {
$model = new Sla();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
$model ->$field = $value;
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id) {
if(!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("Sla", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Sla($data);
}
return $item;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("Sla", "*", "1 = 1 ORDER BY name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Sla($data);
}
}
return $items;
}
public static function getFirst() {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Sla", "*", "$where ORDER BY name LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Sla($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Sla", "*", "$where ORDER BY name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Sla($data);
}
}
return $items;
}
private function getSqlFilter($filter) {
$where = "1=1 ";
$db = FronkDB::singleton();
//var_dump($filter);exit;
if(array_key_exists("name", $filter)) {
$name = $db->escape($filter['name']);
if($name) {
$where .= " AND `name` like '$name'";
}
}
if(array_key_exists("nameLike", $filter)) {
$name = $db->escape($filter['nameLike']);
if($name) {
$where .= " AND `name` like '%$name%'";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,100 @@
CREATE TABLE `Product` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL,
`description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci,
`sla_id` int NOT NULL,
`external` tinyint(1) NOT NULL DEFAULT '0',
`producttech_id` int DEFAULT NULL,
`productgroup_id` int DEFAULT NULL,
`price_nne` decimal(14,4) DEFAULT NULL,
`price_nbe` decimal(14,4) DEFAULT NULL,
`price` decimal(14,4) NOT NULL,
`price_setup` decimal(14,4) NOT NULL DEFAULT '0',
`billing_delay` int NOT NULL DEFAULT '0' COMMENT 'in months',
`billing_period` int NOT NULL COMMENT 'in months',
`ivt_id` int DEFAULT NULL,
`note` text COLLATE utf8mb4_unicode_520_ci,
`create_by` int NOT NULL,
`edit_by` int NOT NULL,
`create` int NOT NULL,
`edit` int NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
CREATE TABLE `ProductNetwork` (
`id` int NOT NULL AUTO_INCREMENT,
`product_id` int NOT NULL,
`network_id` int NOT NULL,
`create_by` int NOT NULL,
`edit_by` int NOT NULL,
`create` int NOT NULL,
`edit` int NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
CREATE TABLE `ProductAttribute` (
`id` int NOT NULL AUTO_INCREMENT,
`product_id` int NOT NULL,
`producttechattribute_id` int NOT NULL,
`value` varchar(1024) COLLATE utf8mb4_unicode_520_ci NOT NULL,
`create_by` int NOT NULL,
`edit_by` int NOT NULL,
`create` int NOT NULL,
`edit` int NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
CREATE TABLE `Productgroup` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(1024) COLLATE utf8mb4_unicode_520_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_520_ci NOT NULL,
`note` text COLLATE utf8mb4_unicode_520_ci NOT NULL,
`create_by` int NOT NULL,
`edit_by` int NOT NULL,
`create` int NOT NULL,
`edit` int NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
CREATE TABLE `Producttech` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(1024) COLLATE utf8mb4_unicode_520_ci NOT NULL,
`rtrcode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL,
`customer_type` enum('residential','business') COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT 'residential',
`description` text COLLATE utf8mb4_unicode_520_ci NOT NULL,
`note` text COLLATE utf8mb4_unicode_520_ci NOT NULL,
`create_by` int NOT NULL,
`edit_by` int NOT NULL,
`create` int NOT NULL,
`edit` int NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
CREATE TABLE `ProducttechAttribute` (
`id` int NOT NULL AUTO_INCREMENT,
`producttech_id` int NOT NULL,
`name` varchar(1024) COLLATE utf8mb4_unicode_520_ci NOT NULL,
`displayname` varchar(1024) COLLATE utf8mb4_unicode_520_ci NOT NULL,
`value` varchar(1024) COLLATE utf8mb4_unicode_520_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_520_ci NOT NULL,
`note` text COLLATE utf8mb4_unicode_520_ci NOT NULL,
`create_by` int NOT NULL,
`edit_by` int NOT NULL,
`create` int NOT NULL,
`edit` int NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
CREATE TABLE `Sla` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(1024) COLLATE utf8mb4_unicode_520_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_520_ci NOT NULL,
`note` text COLLATE utf8mb4_unicode_520_ci NOT NULL,
`create_by` int NOT NULL,
`edit_by` int NOT NULL,
`create` int NOT NULL,
`edit` int NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
INSERT INTO `Sla` VALUES (1,'12h/6T - Working Hours','','',1,1,1625495944,1625495944),(2,'24h/7T - 2h/6h Emergency','','',1,1,1625495944,1625495944),(3,'8h/5T - Next Business Day','','',1,1,1625495985,1625495985),(4,'8h/5T - Residential','','',1,1,1625495985,1625495985);

View File

@@ -18,6 +18,7 @@ $l['supplier'] = "Lieferant";
$l['suppliers'] = "Lieferanten";
$l['contact'] = "Kontakt";
$l['billing'] = "Verrechnungsadresse";
$l['business'] = "Business";
$l['residential'] = "Residential";
$lang['de'] = $l;

View File

@@ -19,4 +19,8 @@ class Layout extends mfLayout {
public function dotToComma($num) {
return str_replace(".", ",", $num);
}
public function commaToDot($num) {
return str_replace(",", ".", $num);
}
}