contracts can be added and saved
This commit is contained in:
@@ -262,7 +262,7 @@
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
|
||||
<?php if(array_key_exists($type, $address->links)): ?>
|
||||
<?php if(is_array($address->links) && count($address->links) && array_key_exists($type, $address->links)): ?>
|
||||
<?php foreach($address->links[$type] as $link): ?>
|
||||
<tr>
|
||||
<td class="font-weight-bold"><?=__($type)?></td>
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
<?php
|
||||
$urlfilter = [];
|
||||
if($s) {
|
||||
$urlfilter['s'] = $s;
|
||||
}
|
||||
if(is_array($filter) && count($filter)) {
|
||||
$urlfilter["filter"] = $filter;
|
||||
}
|
||||
$posturl = self::getUrl("Contract", "save", $urlfilter);
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
@@ -23,11 +33,14 @@
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-2"><?=($contract->id) ? "Vertrag bearbeiten" : "Neuer Vertrag"?></h4>
|
||||
|
||||
<form class="form-horizontal" method="post" action="<?=self::getUrl("Contract", "save")?>">
|
||||
<form class="form-horizontal" method="post" action="<?=$posturl?>">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<input type="hidden" name="id" value="<?=$contact->id?>" />
|
||||
<input type="hidden" name="id" value="<?=$contract->id?>" />
|
||||
<input type="hidden" name="f" value="<?=$f?>" />
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="owner_id">Vertragsinhaber *</label>
|
||||
<div class="col-lg-10">
|
||||
@@ -95,7 +108,7 @@
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price_setup">Preis Setup</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="price" id="price_setup" value="<?=$contract->price_setup?>">
|
||||
<input type="text" class="form-control" name="price_setup" id="price_setup" value="<?=$contract->price_setup?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -115,7 +128,7 @@
|
||||
<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="form-control" name="products[<?=$i?>][billing_period]" id="billing_period-<?=$i?>" placeholder="Verrechnungsperiode">
|
||||
<select class="form-control" name="billing_period" id="billing_period" placeholder="Verrechnungsperiode">
|
||||
<option value="1" <?=($product->billing_period == 1) ? "selected='selected'" : ""?>>Monatlich</option>
|
||||
<option value="12" <?=($product->billing_period == 12) ? "selected='selected'" : ""?>>Jährlich</option>
|
||||
</select>
|
||||
@@ -134,14 +147,14 @@
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="finish_date">Fertigstellungsdatum</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="finish_date" id="finish_date" value="<?=$contract->finish_date?>">
|
||||
<input type="text" class="form-control" name="finish_date" id="finish_date" value="<?=($contract->finish_date) ? date("d.m.Y",$contract->finish_date) : ""?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="cancel_date">Kündigungsdatum</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="cancel_date" id="cancel_date" value="<?=$contract->cancel_date?>">
|
||||
<input type="text" class="form-control" name="cancel_date" id="cancel_date" value="<?=($contract->cancel_date) ? date("d.m.Y", $contract->cancel_date) : ""?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -173,8 +186,8 @@
|
||||
<option value="productchange">Produktwechsel von</option>
|
||||
</select>
|
||||
</div>
|
||||
<!--input type="text" class="form-control" name="links[<?=$linknum?>][contract_id]" id="links_<?=$linknum?>_contract_id" placeholder="Contact ID oder Suche nach Produkt, Matchcode, Kunde" value="<?=$contract->cancel_date?>"-->
|
||||
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[<?=$linknum?>][contract_id]" id="links_<?=$linknum?>_contract_id" data-linknum="<?=$linknum?>" data-url="<?=self::getUrl('Contract','api')?>?do=findContract&autocomplete=1" placeholder="Contact ID oder Suche nach Produkt, Matchcode, Kunde" data-noresults-text="Keine Suchergebnisse">
|
||||
<!--input type="text" class="form-control" name="links[<?=$linknum?>][contract_id]" id="links_<?=$linknum?>_contract_id" placeholder="Contract ID oder Suche nach Produkt, Matchcode, Kunde" value="<?=$contract->cancel_date?>"-->
|
||||
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[<?=$linknum?>][contract_id]" id="links_<?=$linknum?>_contract_id" data-linknum="<?=$linknum?>" data-url="<?=self::getUrl('Contract','api')?>?do=findContract&autocomplete=1" placeholder="Contract ID oder Suche nach Produkt, Matchcode, Kunde" data-noresults-text="Keine Suchergebnisse">
|
||||
<option></option>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
@@ -396,7 +409,7 @@
|
||||
<option value="productchange">Produktwechsel von</option> \
|
||||
</select> \
|
||||
</div> \
|
||||
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[' + linknum + '][contract_id]" id="links_' + linknum + '_contract_id" data-linknum="' + linknum + '" data-url="<?=self::getUrl('Contract','api')?>?do=findContract&autocomplete=1" placeholder="Contact ID oder Suche nach Produkt, Matchcode, Kunde" data-noresults-text="Keine Suchergebnisse"> \
|
||||
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[' + linknum + '][contract_id]" id="links_' + linknum + '_contract_id" data-linknum="' + linknum + '" data-url="<?=self::getUrl('Contract','api')?>?do=findContract&autocomplete=1" placeholder="Contract ID oder Suche nach Produkt, Matchcode, Kunde" data-noresults-text="Keine Suchergebnisse"> \
|
||||
<option></option> \
|
||||
</select> \
|
||||
<div class="input-group-append"> \
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="card-body mb-3">
|
||||
<h4 class="header-title mb-3">Filter</h4>
|
||||
|
||||
<form method="get" action="<?=self::getUrl("Building")?>">
|
||||
<form method="get" action="<?=self::getUrl("Contract")?>">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-1">
|
||||
@@ -56,7 +56,7 @@
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("Building")?>">Filter zurücksetzen</a>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("Contract")?>">Filter zurücksetzen</a>
|
||||
</div>
|
||||
<!--<div class="col">
|
||||
<button class="btn btn-info" type="button" onclick="refreshMap()"><i class="far fa-map"></i> Auf Karte anzeigen</button>
|
||||
@@ -127,9 +127,9 @@
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->create)?><br /><?=$contract->creator->name?></td>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->edit)?><br /><?=$contract->editor->name?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Contract", "view", ["id" => $contract->id])?>"><i class="far fa-eyes" title="Vertrag anzeigen"></i></a>
|
||||
<a href="<?=self::getUrl("Contract", "edit", ["id" => $contract->id])?>"><i class="far fa-edit" title="Vertrag bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Contract", "cancel", ["id" => $contract->id])?>" class="text-danger" title="Vertrag kündigen"><i class="far fa-file-slash"></i></a>
|
||||
<a href="<?=self::getUrl("Contract", "view", ["id" => $contract->id, "s" => $s, "filter" => $filter])?>"><i class="far fa-eyes" title="Vertrag anzeigen"></i></a>
|
||||
<a href="<?=self::getUrl("Contract", "edit", ["id" => $contract->id, "s" => $s, "filter" => $filter])?>"><i class="far fa-edit" title="Vertrag bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Contract", "cancel", ["id" => $contract->id, "s" => $s, "filter" => $filter])?>" class="text-danger" title="Vertrag kündigen"><i class="far fa-file-slash"></i></a>
|
||||
<?php if($contract->orderproduct_id): ?><a href="<?=self::getUrl("Order", "edit", ["id" => $contract->orderproduct->order_id])?>"><i class="far fa-file-signature" title="Bestellung anzeigen"></i></a><?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
178
Layout/default/Contract/View.php
Normal file
178
Layout/default/Contract/View.php
Normal file
@@ -0,0 +1,178 @@
|
||||
<?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("Contract")?>">Verträge</a></li>
|
||||
<li class="breadcrumb-item active"><?=$contract->product_name?> [<?=$contract->matchcode?>]</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title"><?=$contract->product_name?> [<?=$contract->matchcode?>] (<?=$contract->id?>)</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Contract","Index", ['filter' => $filter, 's' => $s])?>" class="btn btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsübersicht</a>
|
||||
<a href="<?=self::getUrl("Contract","edit", ['id' => $contract->id, 'filter' => $filter, 's' => $s, 'f' => "view"])?>" class="btn btn-outline-success"><i class="fas fa-edit"></i> Vertrag bearbeiten</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>Vertragsinhaber</h4>
|
||||
|
||||
<table class="table table-sm table-striped view-table">
|
||||
<tr>
|
||||
<th>ID:</th>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner->id])?>"><?=$contract->owner->id?></a></td>
|
||||
</tr><tr>
|
||||
<th>Kundennummer:</th>
|
||||
<td><?=$contract->owner->customer_number?></td>
|
||||
</tr><tr>
|
||||
<th>Adresse:</th>
|
||||
<td>
|
||||
<?=($contract->owner->company) ? nl2br($contract->owner->company)."<br />" : ""?>
|
||||
<?=$contract->owner->firstname?> <?=$contract->owner->lastname?><br />
|
||||
<?=$contract->owner->street?><br />
|
||||
<?=$contract->owner->zip?> <?=$contract->owner->city?>
|
||||
<?=($contract->owner->country) ? "<br />".$contract->owner->country : "" ?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th>Kontakt:</th>
|
||||
<td>
|
||||
<?=($contract->owner->phone) ? "Telefon: ".$contract->owner->phone."<br />" : ""?>
|
||||
<?=($contract->owner->mobile) ? "Mobil: ".$contract->owner->mobile."<br />" : ""?>
|
||||
<?=($contract->owner->fax) ? "Fax: ".$contract->owner->fax."<br />" : ""?>
|
||||
<?=($contract->owner->email) ? "Email: ".$contract->owner->email."<br />" : ""?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th></th>
|
||||
<td></td>
|
||||
</tr><tr>
|
||||
<th>Service PIN:</th>
|
||||
<td><?=$contract->owner->spin?></td>
|
||||
</tr><tr>
|
||||
<th>Einwilligungen:</th>
|
||||
<td>
|
||||
<p><i class="mr-1 fas <?=($contract->owner->allow_contact) ? "fa-check text-success" : "fa-xmark-large text-danger"?>"></i> Informationen per Post/Email/Telefon</p>
|
||||
<p><i class="mr-1 fas <?=($contract->owner->allow_spin) ? "fa-check text-success" : "fa-xmark-large text-danger"?>"></i>Auskunft mit Service PIN</p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if($contract->billingaddress_id): ?>
|
||||
<tr>
|
||||
<td colspan="2" class="bg-white"><h4>Rechungsempfänger</h4></td>
|
||||
</tr><tr>
|
||||
<th>ID:</th>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->billingaddress->id])?>"><?=$contract->billingaddress->id?></a></td>
|
||||
</tr><tr>
|
||||
<th>Kundennummer:</th>
|
||||
<td><?=$contract->billingaddress->customer_number?></td>
|
||||
</tr><tr>
|
||||
<th>Adresse:</th>
|
||||
<td>
|
||||
<?=($contract->billingaddress->company) ? nl2br($contract->billingaddress->company)."<br />" : ""?>
|
||||
<?php if($contract->billingaddress->firstname || $contract->billingaddress->lastname): ?><?=$contract->billingaddress->firstname?> <?=$contract->billingaddress->lastname?><br /><?php endif; ?>
|
||||
<?=$contract->billingaddress->street?><br />
|
||||
<?=$contract->billingaddress->zip?> <?=$contract->billingaddress->city?>
|
||||
<?=($contract->billingaddress->country) ? "<br />".$contract->billingaddress->country : "" ?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th>Kontakt:</th>
|
||||
<td>
|
||||
<?=($contract->billingaddress->phone) ? "Telefon: ".$contract->billingaddress->phone."<br />" : ""?>
|
||||
<?=($contract->billingaddress->mobile) ? "Mobil: ".$contract->billingaddress->mobile."<br />" : ""?>
|
||||
<?=($contract->billingaddress->fax) ? "Fax: ".$contract->billingaddress->fax."<br />" : ""?>
|
||||
<?=($contract->billingaddress->email) ? "Email: ".$contract->billingaddress->email."<br />" : ""?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
|
||||
<h4>Vertrag</h4>
|
||||
<table class="table table-sm table-striped view-table">
|
||||
<tr>
|
||||
<th>Matchcode:</th>
|
||||
<td><?=$contract->matchcode?></td>
|
||||
</tr><tr>
|
||||
<th>Produkt:</th>
|
||||
<td><?=$contract->product_name?></td>
|
||||
</tr><tr>
|
||||
<th>Produkt Info:</th>
|
||||
<td><?=$contract->product_info?></td>
|
||||
</tr><tr>
|
||||
<th>SLA:</th>
|
||||
<td><?=$contract->sla->name?></td>
|
||||
</tr><tr>
|
||||
<th>Externes Produkt:</th>
|
||||
<td><?=($contract->product_external) ? "Ja" : "Nein"?></td>
|
||||
</tr><tr>
|
||||
<th>Setup Preis:</th>
|
||||
<td>€ <?=$contract->price_setup?></td>
|
||||
</tr><tr>
|
||||
<th>Preis Periodisch:</th>
|
||||
<td>€ <?=$contract->price?></td>
|
||||
</tr><tr>
|
||||
<th>Verrechnungsperiode:</th>
|
||||
<td>
|
||||
<?=($contract->billing_period == 1) ? "Monatlich" : ""?>
|
||||
<?=($contract->billing_period == 12) ? "Jährlich" : ""?>
|
||||
<?=($contract->billing_period == 24) ? "Zweijährlich" : ""?>
|
||||
<?=($contract->billing_period == 36) ? "Dreijährlich" : ""?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th>Verrechnungsstart Verzögerung:</th>
|
||||
<td><?=$contract->billing_delay?> Monate</td>
|
||||
</tr><tr>
|
||||
<th></th>
|
||||
<td></td>
|
||||
</tr><tr>
|
||||
<th>Bestelldatum:</th>
|
||||
<td class="text-monospace"><?=($contract->order_date) ? date('d.m.Y',$contract->order_date) : ""?></td>
|
||||
</tr><tr>
|
||||
<th>Fertigstellungsdatum:</th>
|
||||
<td class="text-monospace">
|
||||
<?=($contract->finish_date) ? date('d.m.Y',$contract->finish_date) : ""?>
|
||||
<?=($contract->finish_date_by) ? "(".$contract->finisher->name.")" : ""?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th>Kündigungsdatum:</th>
|
||||
<td class="text-monospace">
|
||||
<?=($contract->cancel_date) ? date('d.m.Y',$contract->cancel_date) : ""?>
|
||||
<?=($contract->cancel_date_by) ? "(".$contract->canceler->name.")" : ""?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th></th>
|
||||
<td></td>
|
||||
</tr><tr>
|
||||
<th>Erstellt:</th>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i:s',$contract->create)?> (<?=$contract->creator->name?>)</td>
|
||||
</tr><tr>
|
||||
<th>Zuletzte bearbeitet:</th>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i:s',$contract->edit)?> (<?=$contract->editor->name?>)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Contract","Index", ['filter' => $filter, 's' => $s])?>" class="btn btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsübersicht</a>
|
||||
<a href="<?=self::getUrl("Contract","edit", ['id' => $contract->id, 'filter' => $filter, 's' => $s, 'f' => "view"])?>" class="btn btn-outline-success"><i class="fas fa-edit"></i> Vertrag bearbeiten</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
class Contract extends mfBaseModel {
|
||||
private $owner;
|
||||
private $creator;
|
||||
private $billingaddress;
|
||||
private $product;
|
||||
private $orderproduct;
|
||||
private $termination;
|
||||
private $sla;
|
||||
private $finisher;
|
||||
private $canceler;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
|
||||
@@ -29,6 +32,7 @@ class Contract extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($name == "billingaddress") {
|
||||
|
||||
$this->billingaddress = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->billingaddress_id);
|
||||
if($this->billingaddress === null) {
|
||||
$this->billingaddress = new Address($this->billingaddress_id);
|
||||
@@ -61,6 +65,28 @@ class Contract extends mfBaseModel {
|
||||
return $this->orderproduct;
|
||||
}
|
||||
|
||||
if($name == "finisher") {
|
||||
$this->finisher = mfValuecache::singleton()->get("Worker-id-".$this->finish_date_by);
|
||||
if($this->finisher === null) {
|
||||
$this->finisher = new User($this->finish_date_by);
|
||||
if($this->finisher->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->finish_date_by, $this->finisher);
|
||||
}
|
||||
}
|
||||
return $this->finisher;
|
||||
}
|
||||
|
||||
if($name == "canceler") {
|
||||
$this->canceler = mfValuecache::singleton()->get("Worker-id-".$this->cancel_date_by);
|
||||
if($this->canceler === null) {
|
||||
$this->canceler = new User($this->cancel_date_by);
|
||||
if($this->canceler->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->cancel_date_by, $this->canceler);
|
||||
}
|
||||
}
|
||||
return $this->canceler;
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
if($this->creator === null) {
|
||||
|
||||
@@ -56,6 +56,32 @@ class ContractController extends mfBaseController {
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
protected function viewAction() {
|
||||
$this->layout()->setTemplate("Contract/View");
|
||||
|
||||
$id = $this->request->id;
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$contract = new Contract($id);
|
||||
if(!$contract->id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$this->layout()->set("contract", $contract);
|
||||
|
||||
if($this->request->filter) {
|
||||
$this->layout()->set("filter", $this->request->filter);
|
||||
}
|
||||
if($this->request->s) {
|
||||
$this->layout()->set("filter", $this->request->s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("Contract/Form");
|
||||
}
|
||||
@@ -75,11 +101,125 @@ class ContractController extends mfBaseController {
|
||||
|
||||
$this->layout()->set("contract", $contract);
|
||||
|
||||
if($this->request->f == "view") $this->layout()->set("f", "view");
|
||||
if($this->request->f != "view") $this->layout()->set("f", "index");
|
||||
|
||||
if($this->request->filter) {
|
||||
$this->layout()->set("filter", $this->request->filter);
|
||||
}
|
||||
if($this->request->s) {
|
||||
$this->layout()->set("filter", $this->request->s);
|
||||
}
|
||||
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
//var_dump($r);
|
||||
|
||||
/*
|
||||
* add or edit
|
||||
*/
|
||||
$id = $r->id;
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$contract = new Contract($id);
|
||||
if(!$contract->id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
} else {
|
||||
$id = false;
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
//var_dump($r->get());exit;
|
||||
$contract_data = [];
|
||||
$contract_data["owner_id"] = (int)$r->owner_id;
|
||||
$contract_data["billingaddress_id"] = ($r->billingaddress_id) ? (int)$r->billingaddress_id : null;
|
||||
$contract_data["product_id"] = (int)$r->product_id;
|
||||
$contract_data["matchcode"] = $r->matchcode;
|
||||
$contract_data["product_name"] = $r->product_name;
|
||||
$contract_data["product_info"] = $r->product_info;
|
||||
$contract_data['amount'] = ($r->amount) ? (float)$r->amount : 1;
|
||||
$contract_data['price'] = (float)$r->price;
|
||||
$contract_data['price_setup'] = (float)$r->price_setup;
|
||||
$contract_data['price_nne'] = (float)$r->price_nne;
|
||||
$contract_data['price_nbe'] = (float)$r->price_nbe;
|
||||
$contract_data['billing_period'] = (int)$r->billing_period;
|
||||
$contract_data['billing_delay'] = (int)$r->billing_delay;
|
||||
$contract_data['finish_date'] = ($r->finish_date) ? $this->dateToTimestamp($r->finish_date) : null;
|
||||
$contract_data['cancel_date'] = ($r->cancel_date) ? $this->dateToTimestamp($r->cancel_date) : null;
|
||||
$contract_data['note'] = $r->note;
|
||||
|
||||
|
||||
//var_dump($contract_data);exit;
|
||||
|
||||
if($mode == "add") {
|
||||
$contract = ContractModel::create($contract_data);
|
||||
} else {
|
||||
$contract->update($contract_data);
|
||||
}
|
||||
|
||||
$this->layout()->set("contract", $contract);
|
||||
|
||||
if(!$contract_data["owner_id"]) {
|
||||
$this->layout()->setFlash("Bitte Vertragsinhaber auswählen.", "error");
|
||||
return $this->addAction();
|
||||
}
|
||||
if(!$contract_data["product_id"]) {
|
||||
$this->layout()->setFlash("Bitte Produkt auswählen.", "error");
|
||||
return $this->addAction();
|
||||
}
|
||||
if(!$contract_data['billing_period']) {
|
||||
$this->layout()->setFlash("Bitte Rechnungsperiode auswählen.", "error");
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
if(!$contract->product_name) {
|
||||
$product = new Product($contract_data["product_id"]);
|
||||
if(!$product->id) {
|
||||
$this->layout()->setFlash("Ungültiges Produkt.", "error");
|
||||
return $this->addAction();
|
||||
}
|
||||
$contract->product_name = $product->name;
|
||||
}
|
||||
|
||||
//var_dump($contract);exit;
|
||||
|
||||
$contract_id = $contract->save();
|
||||
if(!$contract_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern.", "error");
|
||||
$this->layout()->set("contract", $contract);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Vertrag erfolgreich gespeichert.", "success");
|
||||
|
||||
|
||||
|
||||
|
||||
$query = [];
|
||||
if($r->s) {
|
||||
$query['s'] = $r->s;
|
||||
}
|
||||
if($r->filter) {
|
||||
$query["filter"] = $r->filter;
|
||||
}
|
||||
if($r->return != "index") {
|
||||
$query['id'] = $contract_id;
|
||||
}
|
||||
|
||||
$qs = http_build_query($query);
|
||||
|
||||
if($mode == "add" || $r->f == "view") {
|
||||
$this->redirect("Contract", "view", $qs, "contract=$contract_id");
|
||||
} else {
|
||||
$this->redirect("Contract", "Index", $qs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function apiAction() {
|
||||
if(!$this->me->is(["Admin"])) {
|
||||
|
||||
@@ -1,20 +1,29 @@
|
||||
<?php
|
||||
|
||||
class ContractModel {
|
||||
public $name = null;
|
||||
public $description = null;
|
||||
public $orderproduct_id;
|
||||
public $owner_id;
|
||||
public $billingaddress_id;
|
||||
public $termination_id;
|
||||
public $product_id;
|
||||
public $product_name;
|
||||
public $product_info;
|
||||
public $matchcode;
|
||||
public $amount;
|
||||
public $sla_id = null;
|
||||
public $external = null;
|
||||
public $external_id;
|
||||
public $productgroup_id = null;
|
||||
public $producttech_id = null;
|
||||
public $product_external;
|
||||
public $product_external_id;
|
||||
public $price = null;
|
||||
public $price_setup = null;
|
||||
public $price_nne = null;
|
||||
public $price_nbe = null;
|
||||
public $billing_delay = null;
|
||||
public $billing_period = null;
|
||||
public $ivt_id = null;
|
||||
public $order_date;
|
||||
public $finish_date;
|
||||
public $finish_date_by;
|
||||
public $cancel_date;
|
||||
public $cancel_date_by;
|
||||
|
||||
public $note = null;
|
||||
public $create_by = null;
|
||||
|
||||
Reference in New Issue
Block a user