+
+
+
+
+
+ - ">=MFAPPNAME_SLUG?>
+ - ">Verträge
+ - =$contract->product_name?> [=$contract->matchcode?>]
+
+
+
=$contract->product_name?> [=$contract->matchcode?>] (=$contract->id?>)
+
+
+
+
+
+
+
+
+
+
+
+
+
Vertragsinhaber
+
+
+
+ | ID: |
+ $contract->owner->id])?>">=$contract->owner->id?> |
+
+ | Kundennummer: |
+ =$contract->owner->customer_number?> |
+
+ | Adresse: |
+
+ =($contract->owner->company) ? nl2br($contract->owner->company)." " : ""?>
+ =$contract->owner->firstname?> =$contract->owner->lastname?>
+ =$contract->owner->street?>
+ =$contract->owner->zip?> =$contract->owner->city?>
+ =($contract->owner->country) ? " ".$contract->owner->country : "" ?>
+ |
+
+ | Kontakt: |
+
+ =($contract->owner->phone) ? "Telefon: ".$contract->owner->phone." " : ""?>
+ =($contract->owner->mobile) ? "Mobil: ".$contract->owner->mobile." " : ""?>
+ =($contract->owner->fax) ? "Fax: ".$contract->owner->fax." " : ""?>
+ =($contract->owner->email) ? "Email: ".$contract->owner->email." " : ""?>
+ |
+
+ |
+ |
+
+ | Service PIN: |
+ =$contract->owner->spin?> |
+
+ | Einwilligungen: |
+
+ "> Informationen per Post/Email/Telefon
+ ">Auskunft mit Service PIN
+ |
+
+ billingaddress_id): ?>
+
+ Rechungsempfänger |
+
+ | ID: |
+ $contract->billingaddress->id])?>">=$contract->billingaddress->id?> |
+
+ | Kundennummer: |
+ =$contract->billingaddress->customer_number?> |
+
+ | Adresse: |
+
+ =($contract->billingaddress->company) ? nl2br($contract->billingaddress->company)." " : ""?>
+ billingaddress->firstname || $contract->billingaddress->lastname): ?>=$contract->billingaddress->firstname?> =$contract->billingaddress->lastname?>
+ =$contract->billingaddress->street?>
+ =$contract->billingaddress->zip?> =$contract->billingaddress->city?>
+ =($contract->billingaddress->country) ? " ".$contract->billingaddress->country : "" ?>
+ |
+
+ | Kontakt: |
+
+ =($contract->billingaddress->phone) ? "Telefon: ".$contract->billingaddress->phone." " : ""?>
+ =($contract->billingaddress->mobile) ? "Mobil: ".$contract->billingaddress->mobile." " : ""?>
+ =($contract->billingaddress->fax) ? "Fax: ".$contract->billingaddress->fax." " : ""?>
+ =($contract->billingaddress->email) ? "Email: ".$contract->billingaddress->email." " : ""?>
+ |
+
+
+
+
+
Vertrag
+
+
+ | Matchcode: |
+ =$contract->matchcode?> |
+
+ | Produkt: |
+ =$contract->product_name?> |
+
+ | Produkt Info: |
+ =$contract->product_info?> |
+
+ | SLA: |
+ =$contract->sla->name?> |
+
+ | Externes Produkt: |
+ =($contract->product_external) ? "Ja" : "Nein"?> |
+
+ | Setup Preis: |
+ € =$contract->price_setup?> |
+
+ | Preis Periodisch: |
+ € =$contract->price?> |
+
+ | Verrechnungsperiode: |
+
+ =($contract->billing_period == 1) ? "Monatlich" : ""?>
+ =($contract->billing_period == 12) ? "Jährlich" : ""?>
+ =($contract->billing_period == 24) ? "Zweijährlich" : ""?>
+ =($contract->billing_period == 36) ? "Dreijährlich" : ""?>
+ |
+
+ | Verrechnungsstart Verzögerung: |
+ =$contract->billing_delay?> Monate |
+
+ |
+ |
+
+ | Bestelldatum: |
+ =($contract->order_date) ? date('d.m.Y',$contract->order_date) : ""?> |
+
+ | Fertigstellungsdatum: |
+
+ =($contract->finish_date) ? date('d.m.Y',$contract->finish_date) : ""?>
+ =($contract->finish_date_by) ? "(".$contract->finisher->name.")" : ""?>
+ |
+
+ | Kündigungsdatum: |
+
+ =($contract->cancel_date) ? date('d.m.Y',$contract->cancel_date) : ""?>
+ =($contract->cancel_date_by) ? "(".$contract->canceler->name.")" : ""?>
+ |
+
+ |
+ |
+
+ | Erstellt: |
+ =date('d.m.Y H:i:s',$contract->create)?> (=$contract->creator->name?>) |
+
+ | Zuletzte bearbeitet: |
+ =date('d.m.Y H:i:s',$contract->edit)?> (=$contract->editor->name?>) |
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/Contract/Contract.php b/application/Contract/Contract.php
index 2607c62ac..80a373bcc 100644
--- a/application/Contract/Contract.php
+++ b/application/Contract/Contract.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) {
diff --git a/application/Contract/ContractController.php b/application/Contract/ContractController.php
index 2069beb4c..bf50a585b 100644
--- a/application/Contract/ContractController.php
+++ b/application/Contract/ContractController.php
@@ -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"])) {
diff --git a/application/Contract/ContractModel.php b/application/Contract/ContractModel.php
index d05f95155..41136cbe7 100644
--- a/application/Contract/ContractModel.php
+++ b/application/Contract/ContractModel.php
@@ -1,20 +1,29 @@