Gekündigte Produkte
diff --git a/Layout/default/Contract/ProductchangeForm.php b/Layout/default/Contract/ProductchangeForm.php
index 2b3b7e5a4..c21563a7b 100644
--- a/Layout/default/Contract/ProductchangeForm.php
+++ b/Layout/default/Contract/ProductchangeForm.php
@@ -1,6 +1,11 @@
is("Admin")) {
+ $hide_credit = false;
+}
+
?>
diff --git a/Layout/default/Contract/include/productchange-action.php b/Layout/default/Contract/include/productchange-action.php
index a93ce9cda..bb35b2f30 100644
--- a/Layout/default/Contract/include/productchange-action.php
+++ b/Layout/default/Contract/include/productchange-action.php
@@ -199,8 +199,8 @@
cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?>
+ name="links[=$link->id?>][action]" value="keep"
+ =($linkcontract->cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?>
onchange="linkActionChange(=$link->id?>)" />
type == "credit"): ?>
(Gutschrift wird neu erstellt)
diff --git a/Layout/default/Emailtemplates/order/productchange-ticket-order.php b/Layout/default/Emailtemplates/order/productchange-ticket-order.php
new file mode 100644
index 000000000..98e602ea4
--- /dev/null
+++ b/Layout/default/Emailtemplates/order/productchange-ticket-order.php
@@ -0,0 +1,37 @@
+setReturnValue([
+ 'subject' => "[ESTMK] Produktwechsel ".$order->owner->getCompanyOrName(),
+ 'from_email' => "workspace.admin@xinon.at",
+ 'from_email_name' => "thetool"
+]);
+
+$url_prefix = "http".($_SERVER["HTTPS"] ? "s" : "")."://".$_SERVER["HTTP_HOST"];
+?>
+project: storungen-and-support
+type: Produktwechsel
+status: Neu
+priority: Residential
+Kundenname: =str_replace(["\n", "\r"], "", $order->owner->getCompanyOrName())?>
+
+Telefon: =$order->owner->phone?>
+
+e-Mail: =$order->owner->email?>
+
+Kundennummer: =$order->owner->customer_number?>
+
+Kunde: =str_replace(["\n", "\r"], "", $order->owner->getCompanyOrName())?>
+
+
+### Neue Produkte:
+products as $product): ?>
+=$product->product->name?>
+
+
+
+=$url_prefix?>=self::getUrl("Order", "", ["id" => $order->id])?>
+
+
+⚠️ Upgradebestellung muss nach der technischen Umstellung in thetool ABGESCHLOSSEN werden.
diff --git a/Layout/default/Order/Form.php b/Layout/default/Order/Form.php
index df6b57189..f3a7be14b 100644
--- a/Layout/default/Order/Form.php
+++ b/Layout/default/Order/Form.php
@@ -544,7 +544,14 @@
Produkte
@@ -605,6 +612,7 @@
billing_period == 1) ? "selected='selected'" : ""?>>Monatlich
billing_period == 12) ? "selected='selected'" : ""?>>Jährlich
+ billing_period == 0) ? "selected='selected'" : ""?>>Einmalig
@@ -772,6 +780,7 @@
Monatlich
Jährlich
+ Einmalig
@@ -1244,7 +1253,15 @@
$('#price_setup-' + id).val(p.price_setup);
$('#price_nne-' + id).val(p.price_nne);
$('#price_nbe-' + id).val(p.price_nbe);
-
+
+ var period = Number.parseInt(p.billing_period);
+ var price = Number.parseFloat(p.price);
+ if(!period && !price) {
+ $('#price-' + id).prop("disabled", true);
+ } else {
+ $('#price-' + id).prop("disabled", false);
+ }
+
console.log(p.attributes);
console.log("form_id: " + id);
if(typeof p.attributes === 'object' && "termination_required" in p.attributes && p.attributes.termination_required == 1) {
@@ -1266,6 +1283,7 @@
} else {
$('#voicenumber-' + id + '-line').hide();
}
+
},
'json');
@@ -1671,6 +1689,7 @@
\
Monatlich \
Jährlich \
+ Einmalig \
\
\
\
diff --git a/Layout/default/Order/Index.php b/Layout/default/Order/Index.php
index ad50c05d8..20dc02aa3 100644
--- a/Layout/default/Order/Index.php
+++ b/Layout/default/Order/Index.php
@@ -143,7 +143,9 @@
@@ -177,9 +179,15 @@
Nur Sonderprodukte/Projekte
-
+ address_id != 209): ?>
+
+ $filter])?>">
+ Upgrades
+
+
+
diff --git a/Layout/default/Order/ProductchangeForm.php b/Layout/default/Order/ProductchangeForm.php
index b3673bebc..ad90d0b74 100644
--- a/Layout/default/Order/ProductchangeForm.php
+++ b/Layout/default/Order/ProductchangeForm.php
@@ -1,6 +1,10 @@
is("Admin")) {
+ $hide_credit = false;
+}
?>
diff --git a/Layout/default/Order/Upgrades.php b/Layout/default/Order/Upgrades.php
new file mode 100644
index 000000000..2cacc1374
--- /dev/null
+++ b/Layout/default/Order/Upgrades.php
@@ -0,0 +1,307 @@
+getUrl("Order","Upgrades");
+$pagination_baseurl_params = ["filter" => $filter];
+$pagination_entity_name = "Upgrades";
+//var_dump($mynetworks);
+
+$sorted_networks = [];
+if(is_array($mynetworks) && count($mynetworks)) {
+ foreach($mynetworks as $net) {
+ $sorted_networks[$net->name] = $net->id;
+ }
+}
+ksort($sorted_networks);
+
+//var_dump($mynetworks);
+//var_dump($sorted_networks);exit;
+
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Contact ID
+ Bisheriger Vertragsinhaber
+ Bestehendes Produkt Matchcode
+ Verknüpfte Produkte
+ Rechnungsperiode
+ Preis Preis Setup
+ Fertigstellungssdatum (Falls vorhanden)
+ Neuer Vertragsinhaber
+ Neues Produkt Matchcode
+ Preis Preis Setup
+
+
+
+
+
+
+
+ =$upgrade->origin->id?>
+ =$upgrade->origin->owner->getCompanyOrName()?> =($upgrade->origin->owner->customer_number) ? " [".$upgrade->origin->owner->customer_number."]" : ""?>
+
+ =$upgrade->origin->product_name?>
+ =$upgrade->origin->matchcode?>
+
+ =$upgrade->origin->countActiveLinks()?>
+ =__($upgrade->origin->billing_period, "billing_period")?>
+
+ € =number_format($upgrade->origin->price, 4, ",", ".")?>
+ € =number_format($upgrade->origin->price_setup, 4, ",", ".")?>
+
+
+
+ contract->finish_date): ?>
+ =date("d.m.Y", $upgrade->contract->finish_date)?>
+ origin->cancel_date): ?>
+ =date("d.m.Y", $upgrade->origin->cancel_date)?>
+
+
+
+
+ =$upgrade->contract->owner->getCompanyOrName()?>
+
+ =$upgrade->contract->product_name?>
+ =$upgrade->contract->matchcode?>
+
+
+ € =number_format($upgrade->contract->price, 4, ",", ".")?>
+ € =number_format($upgrade->contract->price_setup, 4, ",", ".")?>
+
+
+
+
+
+
+
+
+
+
+
+
Verknüpfte bestehende Produkte
+
+
+ Contact ID
+ Vertragsinhaber
+ Produkt Matchcode
+ Rechnungsperiode
+ Preis Preis Setup
+ Übernahmeaktion
+
+ origin->linksWithCredit as $link): ?>
+ contract_id == $upgrade->origin_contract_id) {
+ $linkcontract = $link->origin;
+ } else {
+ $linkcontract = $link->contract;
+ }
+
+ if($linkcontract->price < 0) continue;
+
+ if($linkcontract->isCancelled()) continue;
+ ?>
+
+ =$linkcontract->id?>
+ =$linkcontract->owner->getCompanyOrName()?>
+
+ =$linkcontract->product_name?>
+ =$linkcontract->matchcode?>
+
+ =__($linkcontract->billing_period, "billing_period")?>
+
+ € =number_format($linkcontract->price, 4, ",", ".")?>
+ € =number_format($linkcontract->price_setup, 4, ",", ".")?>
+
+
+ cancel_date): ?>
+ Kündigung am =date("d.m.Y", $linkcontract->cancel_date)?>
+ change_action == "cancel"): ?>
+ Kündigung bei Fertigstellung
+
+ Wird übernommen
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Keine Upgrades zu den Suchkriterien gefunden
+
+
+
+
+
+
+
+
+
+
diff --git a/Layout/default/Product/Form.php b/Layout/default/Product/Form.php
index 46f898abb..630c6625a 100644
--- a/Layout/default/Product/Form.php
+++ b/Layout/default/Product/Form.php
@@ -180,7 +180,7 @@
@@ -334,7 +334,18 @@
$('#producttech_form').hide();
}
});
-
+
+ $("#billing_period").change(() => {
+ var price = Number.parseFloat($("#price").val().replace(",","."));
+ var period = Number.parseInt($("#billing_period").val());
+
+ if(!period && !price) {
+ $("#price").prop("disabled", true);
+ } else {
+ $("#price").prop("disabled", false);
+ }
+ });
+
// disable mousewheel on input number field when in focus
$('form').on('focus', 'input[type=number]', function (e) {
$(this).on('wheel.disableScroll', function (e) {
diff --git a/Layout/default/Product/Index.php b/Layout/default/Product/Index.php
index 2caf94507..85a01487e 100644
--- a/Layout/default/Product/Index.php
+++ b/Layout/default/Product/Index.php
@@ -153,8 +153,7 @@
=$product->producttech->name?>=(is_array($product->attributes) && array_key_exists(TT_ATTRIB_RTRTECHCODE_NAME, $product->attributes)) ? " (".$product->attributes[TT_ATTRIB_RTRTECHCODE_NAME]->value.")" : "" ?>
=__($product->producttech->customer_type)?>
=$product->price?>
- =__($product->billing_period, "billing_period")?>
-
+ =__($product->billing_period, "billing_period")?>
=$product->sla->name?>
=$product->ivt_id?>
diff --git a/application/Contract/Contract.php b/application/Contract/Contract.php
index 359bbe5a5..18b9b889c 100644
--- a/application/Contract/Contract.php
+++ b/application/Contract/Contract.php
@@ -241,6 +241,17 @@ class Contract extends mfBaseModel {
return false;
}
+ public function countActiveLinks($with_credit = false) {
+ $links = $this->getProperty("links");
+
+ if(is_array($links) && count($links)) {
+ return count($links);
+ }
+
+ return 0;
+
+ }
+
public function generateMatchcode() {
$owner_address = $this->getProperty("owner")->street . ", " . $this->getProperty("owner")->zip . " " . $this->getProperty("owner")->city;
diff --git a/application/Contract/ContractController.php b/application/Contract/ContractController.php
index f5b33fd58..2ce35032c 100644
--- a/application/Contract/ContractController.php
+++ b/application/Contract/ContractController.php
@@ -429,6 +429,21 @@ class ContractController extends mfBaseController
$contract_data['termination_id'] = null;
}
+ //var_dump($r->links);
+ // lookup credit contract and if it's missing in $r->links
+ if(!$this->me->is("Admin")) {
+ $credit_link = ContractLinkModel::includesContractId($contract->id, ["type" => "credit"]);
+ if($credit_link) {
+ if(is_array($r->links) && !array_key_exists($credit_link->id, $r->links)) {
+ $r->links[$credit_link->id] = [];
+ }
+ $r->links[$credit_link->id]["action"] = "keep";
+
+ }
+ }
+
+ //var_dump($r->links);exit;
+
$new_contract->update($contract_data);
$new_contract_id = $new_contract->save();
@@ -455,6 +470,8 @@ class ContractController extends mfBaseController
]);
$journal->save();
+
+
if (is_array($r->links) && count($r->links)) {
foreach ($r->links as $link_id => $link_data) {
$action = $link_data["action"];
@@ -597,7 +614,7 @@ class ContractController extends mfBaseController
$this->layout()->setFlash("Produktwechsel erfolgreich erstellt", "success");
if($f == "o") {
- $this->redirect("Order");
+ $this->redirect("Order","Upgrades");
} else {
$this->redirect("Contract", "view", ["contract_id" => $new_contract_id]);
}
@@ -749,6 +766,7 @@ class ContractController extends mfBaseController
$contract_data["product_info"] = $r->product_info;
$contract_data['amount'] = ($r->amount) ? (float)$r->amount : 1;
$contract_data['vatgroup_id'] = $r->vatgroup_id;
+ $contract_data['sla_id'] = (float)$r->sla_id;
$contract_data['price'] = (float)$r->price;
$contract_data['price_setup'] = (float)$r->price_setup;
$contract_data['price_nne'] = (float)$r->price_nne;
@@ -790,10 +808,6 @@ class ContractController extends mfBaseController
-
-
-
-
//var_dump($contract_data);exit;
if ($mode == "add") {
diff --git a/application/ContractLink/ContractLinkModel.php b/application/ContractLink/ContractLinkModel.php
index a2344459f..18063ea3c 100644
--- a/application/ContractLink/ContractLinkModel.php
+++ b/application/ContractLink/ContractLinkModel.php
@@ -100,7 +100,7 @@ class ContractLinkModel {
$where = self::getSqlFilter($filter);
$sql = "SELECT COUNT(*) as cnt FROM ContractLink
LEFT JOIN Contract ON (ContractLink.contract_id = Contract.id)
- LEFT JOIN Address AS Owner ON (Contract.owner_id = Owner.id)
+ LEFT JOIN Address ON (Contract.owner_id = Address.id)
LEFT JOIN Worker ON (ContractLink.create_by = Worker.id)
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
@@ -123,7 +123,7 @@ class ContractLinkModel {
$where = self::getSqlFilter($filter);
$sql = "SELECT ContractLink.* FROM ContractLink
LEFT JOIN Contract ON (ContractLink.contract_id = Contract.id)
- LEFT JOIN Address AS Owner ON (Contract.owner_id = Owner.id)
+ LEFT JOIN Address ON (Contract.owner_id = Address.id)
LEFT JOIN Worker ON (ContractLink.create_by = Worker.id)
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
@@ -230,6 +230,84 @@ class ContractLinkModel {
}
}
+ if(array_key_exists("owner_id", $filter)) {
+ $owner_id = $filter['owner_id'];
+ if(is_numeric($owner_id)) {
+ $where .= " AND Contract.owner_id=$owner_id";
+ }
+ }
+
+ if(array_key_exists("billingaddress_id", $filter)) {
+ $billingaddress_id = $filter['billingaddress_id'];
+ if(is_numeric($billingaddress_id)) {
+ $where .= " AND Contract.billingaddress_id=$billingaddress_id";
+ }
+ }
+
+ if(array_key_exists("product_id", $filter)) {
+ $product_id = $filter['product_id'];
+ if(is_numeric($product_id)) {
+ $where .= " AND Contract.product_id=$product_id";
+ }
+ }
+
+ if(array_key_exists("orderproduct_id", $filter)) {
+ $orderproduct_id = $filter['orderproduct_id'];
+ if(is_numeric($orderproduct_id)) {
+ $where .= " AND Contract.orderproduct_id=$orderproduct_id";
+ }
+ }
+
+ if(array_key_exists("product_name", $filter)) {
+ $product_name = $db->escape($filter['product_name']);
+ if($product_name) {
+ $where .= " AND (Contract.`product_name` like '%$product_name%' OR Product.name like '%$product_name%')";
+ }
+ }
+
+
+ if(array_key_exists("matchcode", $filter)) {
+ $matchcode = $db->escape($filter['matchcode']);
+ if($matchcode) {
+ $where .= " AND Contract.`matchcode` like '%$matchcode%'";
+ }
+ }
+
+ if(array_key_exists("rtr_code", $filter)) {
+ $rtr_code = $filter['rtr_code'];
+ if(is_numeric($rtr_code)) {
+ $where .= " AND Contract.rtr_code=$rtr_code";
+ }
+ }
+
+ if(array_key_exists("customer_number", $filter)) {
+ $customer_number = $filter['customer_number'];
+ if(is_numeric($customer_number)) {
+ $where .= " AND Address.customer_number=$customer_number";
+ }
+ }
+
+ if(array_key_exists("owner", $filter)) {
+ $owner = FronkDB::singleton()->escape($filter["owner"]);
+ if($owner) {
+ $where .= " AND (Address.customer_number like '$owner' OR Address.company like '%$owner%' OR (CONCAT(Address.firstname, ' ', Address.lastname) like '%$owner%' OR CONCAT(Address.lastname, ' ', Address.firstname) like '%$owner%' ))";
+ }
+ }
+
+ if(array_key_exists("imported_from", $filter)) {
+ $imported_from = FronkDB::singleton()->escape($filter["imported_from"]);
+ if($imported_from) {
+ $where .= " AND Contract.imported_from like '$imported_from'";
+ }
+ }
+
+ if(array_key_exists("imported_data", $filter)) {
+ $imported_data = FronkDB::singleton()->escape($filter["imported_data"]);
+ if($imported_data) {
+ $where .= " AND Contract.imported_data like '$imported_data'";
+ }
+ }
+
if(array_key_exists("price<", $filter)) {
$price = $filter['price<'];
if(is_numeric($price)) {
@@ -256,6 +334,13 @@ class ContractLinkModel {
}
}
+ if(array_key_exists("billing_period", $filter)) {
+ $billing_period = $filter['billing_period'];
+ if(is_numeric($billing_period)) {
+ $where .= " AND Contract.billing_period=$billing_period";
+ }
+ }
+
if(array_key_exists("finish_date", $filter)) {
$finish_date = $filter['finish_date'];
if(is_numeric($finish_date)) {
@@ -270,13 +355,6 @@ class ContractLinkModel {
}
}
- if(array_key_exists("finish_date_null_or_gte", $filter)) {
- $finish_date = $filter['finish_date_null_or_gte'];
- if(is_numeric($finish_date)) {
- $where .= " AND (Contract.finish_date IS NULL OR Contract.finish_date >= $finish_date)";
- }
- }
-
if(array_key_exists("finish_date<", $filter)) {
$finish_date = $filter['finish_date<'];
if(is_numeric($finish_date)) {
@@ -284,10 +362,17 @@ class ContractLinkModel {
}
}
+ if(array_key_exists("finish_date_null_or_gte", $filter)) {
+ $cancel_date = $filter['finish_date_null_or_gte'];
+ if(is_numeric($cancel_date)) {
+ $where .= " AND (Contract.finish_date IS NULL OR Contract.finish_date >= $cancel_date)";
+ }
+ }
+
if(array_key_exists("finish_date_null_or_lte", $filter)) {
- $finish_date = $filter['finish_date_null_or_lte'];
- if(is_numeric($finish_date)) {
- $where .= " AND (Contract.finish_date IS NULL OR Contract.finish_date <= $finish_date)";
+ $cancel_date = $filter['finish_date_null_or_lte'];
+ if(is_numeric($cancel_date)) {
+ $where .= " AND (Contract.finish_date IS NULL OR Contract.finish_date <= $cancel_date)";
}
}
diff --git a/application/Order/Order.php b/application/Order/Order.php
index f922ad2c3..664775cdb 100644
--- a/application/Order/Order.php
+++ b/application/Order/Order.php
@@ -264,7 +264,31 @@ class Order extends mfBaseModel {
return true;
}
}
-
+
+ public function sendUpgradeEmail() {
+ $tk_tpl = new Layout();
+ $tk_tpl->setTemplate("Emailtemplates/order/productchange-ticket-order");
+
+ $tpl_vars = [
+ "order" => $this,
+ ];
+
+ foreach($tpl_vars as $name => $val) {
+ $tk_tpl->set($name, $val);
+ }
+
+ $tk_body = $tk_tpl->render();
+ $tk_values = $tk_tpl->getReturnedValue();
+
+ $tk_email = new Emailnotification();
+ $tk_email->setSubject($tk_values["subject"]);
+ $tk_email->setBody($tk_body);
+ $tk_email->setFrom($tk_values["from_email"], $tk_values["from_email_name"]);
+ $tk_email->setTo("workspace@xinon.at");
+ $tk_email->setHeader("X-" . MFAPPNAME . "-Cid", $this->id);
+ $tk_email->send();
+ }
+
public function sendFileuploadEmail(OrderFile $file) {
$filetype = $file->name;
diff --git a/application/Order/OrderController.php b/application/Order/OrderController.php
index 45eff9cfb..0633a37a8 100644
--- a/application/Order/OrderController.php
+++ b/application/Order/OrderController.php
@@ -479,13 +479,14 @@ class OrderController extends mfBaseController {
$pagination['start'] = intval($this->request->s);
}
- $upgrade_search = [
- "type" => "upgrade",
- "contract_creator_address_id" => $this->me->address_id,
- "finish_date_null_or_gte" => date("U"),
- "price>=" => 0
- ];
+ unset($filter["finish_date"]);
+ $upgrade_search = $filter;
+
+ $upgrade_search["type"] = "upgrade";
+ $upgrade_search["contract_creator_address_id"] = $this->me->address_id;
+ $upgrade_search["finish_date_null_or_gte"] = date("U");
+ $upgrade_search["price>="] = 0;
$pagination["maxItems"] = ContractLinkModel::countWithContracts($upgrade_search);
@@ -493,6 +494,7 @@ class OrderController extends mfBaseController {
$this->layout()->set("upgrades", $upgrades);
$this->layout()->set("pagination", $pagination);
}
+
protected function addUpgrade() {
//$this->layout()->setTemplate("Order/Productchange");
Helper::renderVue($this, "OrderProductchange", "Neuer Produktwechsel", ["CONTRACT_API_URL" => $this->getUrl("Contract", "api"),
@@ -1084,7 +1086,12 @@ class OrderController extends mfBaseController {
} else {
$this->log->debug(__CLASS__."::save(): NOT creating new SPIN for ".$owner->getCompanyOrName()." (".$owner->id."): SPIN exists or owner of Order was changed or external products");
}
-
+
+
+ if($mode == "add" && $order->upgrade) {
+ // send upgrade ticket
+ $order->sendUpgradeEmail();
+ }
}
//var_dump($_FILES['OrderFileUpload']);exit;
diff --git a/application/Order/OrderModel.php b/application/Order/OrderModel.php
index 48527d8f2..97e0067ad 100644
--- a/application/Order/OrderModel.php
+++ b/application/Order/OrderModel.php
@@ -244,7 +244,7 @@ class OrderModel {
if(array_key_exists("owner", $filter)) {
$owner = FronkDB::singleton()->escape($filter['owner']);
if($owner) {
- $where .= " AND (Address.company like '%$owner%' OR Address.firstname like '%$owner%' OR Address.lastname like '%$owner%' OR Address.customer_number like '%$owner%')";
+ $where .= " AND (Address.customer_number like '$owner' OR Address.company like '%$owner%' OR Address.firstname like '%$owner%' OR Address.lastname like '%$owner%' OR Address.customer_number like '%$owner%')";
}
}
diff --git a/application/Sla/SlaModel.php b/application/Sla/SlaModel.php
index 5d389ef3c..9ff474c4a 100644
--- a/application/Sla/SlaModel.php
+++ b/application/Sla/SlaModel.php
@@ -48,12 +48,17 @@ class SlaModel {
return $item;
}
- public static function getAll() {
+ public static function getAll($order = false) {
$items = [];
-
+
+ $_order = "name";
+ if($order) {
+ $_order = $order;
+ }
+
$db = FronkDB::singleton();
- $res = $db->select("Sla", "*", "1 = 1 ORDER BY name");
+ $res = $db->select("Sla", "*", "1 = 1 ORDER BY $_order");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Sla($data);