Merge branch 'master' into fronkdev
This commit is contained in:
@@ -792,4 +792,189 @@ class Contract extends mfBaseModel {
|
||||
$this->log->debug("Cloned Contract $old_id");
|
||||
}
|
||||
|
||||
// ---- CONTRACT VIEW UTILITY FUNCTIONS START ----
|
||||
public function getContractDetails($getUrl): array {
|
||||
$contract = $this;
|
||||
$contract->getProperty("billingaddress");
|
||||
$contract->getProperty("owner");
|
||||
$contract->getProperty("product");
|
||||
$contract->getProperty("sla");
|
||||
$contract->getProperty("finisher");
|
||||
$contract->getProperty("canceler");
|
||||
$contract->getProperty("creator");
|
||||
$contract->getProperty("editor");
|
||||
$contract->getProperty("vatrate");
|
||||
$contract->getProperty("configvalues");
|
||||
$contract->getProperty("orderproduct");
|
||||
|
||||
|
||||
$contract_details = [];
|
||||
$contract_details['matchcode'] = ['label' => 'Matchcode', 'value' => $contract->matchcode];
|
||||
$contract_details['owner'] = ['label' => 'Kunde',
|
||||
'value' => $contract->owner->getCompanyOrName(),
|
||||
'url' => $getUrl('Address', 'View', ['id' => $contract->billingaddress->id])];
|
||||
if ($contract->billingaddress_id) {
|
||||
$contract_details['billingaddress'] = ['label' => 'Rechnungsadresse',
|
||||
'value' => $contract->billingaddress->getCompanyOrName(),
|
||||
'url' => $getUrl('Address', 'View', ['id' => $contract->billingaddress->id])];
|
||||
}
|
||||
|
||||
$productName = $contract->product->name;
|
||||
$contractProductName = $contract->product_name;
|
||||
$productId = $contract->product_id;
|
||||
|
||||
$contract_details['product'] = ['label' => 'Produkt',
|
||||
'value' => "$contractProductName ($productName) [$productId]",
|
||||
'url' => $getUrl('Product', 'Edit', ['id' => $contract->product_id])];
|
||||
|
||||
if ($contract->prduct_info) {
|
||||
$contract_details['product_info'] = ['label' => 'Produktinfo', 'value' => $contract->product_info];
|
||||
}
|
||||
|
||||
$contract_details['sla'] = ['label' => 'SLA', 'value' => $contract->sla->name];
|
||||
$contract_details['external_product'] = ['label' => 'Externes Produkt', 'value' => $contract->product_external ? "Ja" : "Nein"];
|
||||
$contract_details['amount'] = ['label' => 'Menge', 'value' => Helper::formatNumber($contract->amount, 3)];
|
||||
$contract_details['price_net'] = ['label' => 'Preis Periodisch Netto',
|
||||
'value' => "€ " . Helper::formatNumber($contract->price * $contract->amount, 4),
|
||||
'class' => $contract->price < 0 ? 'text-danger' : null];
|
||||
if ($contract->vatrate) {
|
||||
$contract_details['price_gross'] = ['label' => 'Preis Periodisch Brutto',
|
||||
'value' => "€ " . Helper::formatNumber($contract->price * $contract->amount * floatval("1." . intval($contract->vatrate)), 4),
|
||||
'class' => $contract->price < 0 ? 'text-danger' : null];
|
||||
}
|
||||
|
||||
$contract_details['billing_period'] = ['label' => 'Abrechnungsperiode', 'value' => __($contract->billing_period, "billing_period")];
|
||||
|
||||
if ($contract->price_setup > 0) {
|
||||
$vatRateMultiplier = $contract->vatrate ? ("1." . intval($contract->vatrate)) : 1;
|
||||
$price_net = Helper::formatNumber($contract->price_setup, 4);
|
||||
$sum_net = Helper::formatNumber($contract->price_setup * $contract->amount, 4);
|
||||
$price_gross = Helper::formatNumber($contract->price_setup * $contract->amount * $vatRateMultiplier, 4);
|
||||
$sum_gross = Helper::formatNumber($contract->price_setup * $contract->amount * $vatRateMultiplier, 4);
|
||||
|
||||
$contract_details['price_setup'] = ['label' => 'Einrichtungsgebühr',
|
||||
'value' => "Netto: € {$price_net} (Gesamt: € {$sum_net})\nBrutto: € {$price_gross} (Gesamt: € {$sum_gross})"];
|
||||
}
|
||||
|
||||
if ($contract->billing_delay) $contract_details['billing_delay'] = ['label' => 'Abrechnungsverzögerung',
|
||||
'value' => $contract->billing_delay . " Monate"];
|
||||
$contract_details['order_date'] = ['label' => 'Bestelldatum', 'value' => date('d.m.Y', $contract->order_date)];
|
||||
if ($contract->finish_date) $contract_details['finish_date'] = ['label' => 'Fertigstellung',
|
||||
'value' => date('d.m.Y', $contract->finish_date) . " (" . $contract->finisher->name . ")"];
|
||||
if ($contract->cancel_date) $contract_details['cancel_date'] = ['label' => 'Kündigungsdatum',
|
||||
'value' => date('d.m.Y', $contract->cancel_date) . " (" . $contract->canceler->name . ")"];
|
||||
$contract_details['create'] = ['label' => 'Erstellt', 'value' => date('d.m.Y', $contract->create) . " (" . $contract->creator->name . ")"];
|
||||
$contract_details['edit'] = ['label' => 'Geändert', 'value' => date('d.m.Y', $contract->edit) . " (" . $contract->editor->name . ")"];
|
||||
|
||||
return $contract_details;
|
||||
}
|
||||
|
||||
public function getContractActions($getUrl): array {
|
||||
$contract = $this;
|
||||
|
||||
$contract_actions = [];
|
||||
$contract_actions['contractconfig'] = ['url' => $getUrl("Contractconfig", "edit", ["contract_id" => $contract->id]),
|
||||
'class' => 'btn-outline-info',
|
||||
'icon' => 'far fa-list-dropdown fa-fw',
|
||||
'text' => 'Konfiguration bearbeiten'];
|
||||
$contract_actions['contractaccessletter'] = ['url' => $getUrl("Contractaccessletter", "view", ["contract_id" => $contract->id]),
|
||||
'class' => 'btn-outline-success',
|
||||
'icon' => 'far fa-list-numeric fa-fw',
|
||||
'text' => 'Zugangsdaten anzeigen'];
|
||||
if ($contract->finish_date && $contract->finish_date < date('U')) {
|
||||
$contract_actions['contractownerchange'] = ['class' => 'btn-outline-secondary',
|
||||
'icon' => 'far fa-people-arrows fa-fw',
|
||||
'text' => 'Inhaberwechsel'];
|
||||
$contract_actions['productchange'] = ['url' => $getUrl("Contract", "productchange", ["contract_id" => $contract->id]),
|
||||
'class' => 'btn-outline-purple',
|
||||
'icon' => 'far fa-truck-container fa-fw',
|
||||
'text' => 'Produkt-/Standortwechsel'];
|
||||
$contract_actions['cancel'] = ['url' => $getUrl("Contract", "cancel", ["contract_id" => $contract->id]),
|
||||
'class' => 'btn-outline-danger',
|
||||
'icon' => 'far fa-axe fa-fw',
|
||||
'text' => 'Kündigen'];
|
||||
} else if (!$contract->finish_date) {
|
||||
$contract_actions['contractconfig'] = ['url' => $getUrl("Contract", "finishContract", ['contract_id' => $contract->id]),
|
||||
'class' => 'btn-success',
|
||||
'icon' => 'far fa-face-confused fa-fw',
|
||||
'text' => 'Jetzt fertigstellen',
|
||||
'confirmText' => 'Jetzt fertigstellen und in Verrechnung geben?'];
|
||||
}
|
||||
|
||||
return $contract_actions;
|
||||
}
|
||||
|
||||
public function getContractJournal($getUrl): array {
|
||||
$contract = $this;
|
||||
$contract->getProperty("journals");
|
||||
$contract->getProperty("orderproduct");
|
||||
$contract->getProperty("product");
|
||||
|
||||
$contract_journal = [];
|
||||
if (is_array($contract->journals) && count($contract->journals)) {
|
||||
foreach ($contract->journals as $j) {
|
||||
$entry = [];
|
||||
|
||||
$entry['create'] = date('d.m.Y H:i:s', $j->create);
|
||||
$entry['creator'] = $j->creator->name;
|
||||
|
||||
if ($j->type === "text" || $j->type === "phone") {
|
||||
$entry['icon'] = $j->type === "text" ? "fas fa-comment-dots text-warning " : "fas fa-phone text-warning ";
|
||||
$entry['iconTitle'] = $j->type === "text" ? "Textnachricht" : "Telefonat";
|
||||
$entry['text'] = $j->text;
|
||||
} else if ($j->type === "file") {
|
||||
$entry['icon'] = "fas fa-download text-primary ";
|
||||
$entry['iconTitle'] = "Datei";
|
||||
$entry['text'] = "[URL]";
|
||||
$entry['url'] = $getUrl("File", "download", ["id" => $j->contractfile->file_id]);
|
||||
$entry['urlText'] = $j->contractfile->name;
|
||||
} else if ($j->type === "created_from") {
|
||||
$entry['icon'] = "fas fa-cogs text-secondary ";
|
||||
$entry['iconTitle'] = "Vertrag erstellt";
|
||||
$entry['textClass'] = "font-italic";
|
||||
if ($j->value == "manual") {
|
||||
$entry['text'] = "Contract manuell erstellt";
|
||||
} else if ($j->value == "import") {
|
||||
$entry['text'] = "Contract importiert: " . $j->text;
|
||||
} else if ($j->value == "order") {
|
||||
$entry['text'] = "Vertrag aus Bestellung [URL] erstellt";
|
||||
$entry['url'] = $getUrl("Order", "", ["id" => $contract->orderproduct->order_id]);
|
||||
$entry['urlText'] = "#" . $contract->orderproduct->order_id;
|
||||
} else if ($j->value == "productchange") {
|
||||
$entry['text'] = "Vertrag erstellt:" . $j->text;
|
||||
}
|
||||
} else if ($j->type === "contract_finished") {
|
||||
$entry['icon'] = "fas fa-flag-checkered text-success ";
|
||||
$entry['iconTitle'] = "Vertrag fertiggestellt";
|
||||
$entry['text'] = "Vertrag fertiggestelt";
|
||||
$entry['textClass'] = "font-italic";
|
||||
} else if ($j->type === "credit_created") {
|
||||
$entry['icon'] = "fas fa-credit-card text-gray ";
|
||||
$entry['iconTitle'] = "Gutschrift";
|
||||
$entry['text'] = "Gutschrift Vertrag [URL] erstellt";
|
||||
$entry['textClass'] = "font-italic";
|
||||
$entry['url'] = $getUrl("Contract", "View", ["contract_id" => $j->value]);
|
||||
$entry['urlText'] = $j->value;
|
||||
} else if ($j->type === "link") {
|
||||
$link = new Contract($j->value);
|
||||
$entry['icon'] = "fas fa-link text-secondary ";
|
||||
$entry['iconTitle'] = "Verknüpfung";
|
||||
$entry['text'] = "Verknüpfung mit [URL] erstellt";
|
||||
$entry['textClass'] = "font-italic";
|
||||
$entry['url'] = $getUrl("Contract", "view", ['contract_id' => $link->id]);
|
||||
$entry['urlText'] = $link->id . " - " . $link->product_name . " - [" . $link->matchcode . "]";
|
||||
} else if ($j->type === "canceled") {
|
||||
$entry['icon'] = "fas fa-skull-crossbones bg-danger text-white ";
|
||||
$entry['iconTitle'] = "Kündigung";
|
||||
$entry['textClass'] = "font-italic";
|
||||
$entry['text'] = "Vertrag gekündigt";
|
||||
}
|
||||
$contract_journal[] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
return $contract_journal;
|
||||
}
|
||||
// ---- CONTRACT VIEW UTILITY FUNCTIONS END ----
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user