Added contract_term to Order/Product/Contract

This commit is contained in:
Frank Schubert
2024-02-06 20:46:05 +01:00
parent afac1ff9c9
commit e9937f2df8
7 changed files with 119 additions and 29 deletions

View File

@@ -498,6 +498,10 @@ class OrderController extends mfBaseController {
$mode = "add";
}
/*
* Contacts/Addresses and Billing data
*/
// validate owner
$owner = false;
$owner_new = false;
@@ -642,6 +646,7 @@ class OrderController extends mfBaseController {
if($billingaddress_new) {
if($r->billing_type == "sepa") {
$billing_data['billing_type'] = "sepa";
$billing_data['sepa_date'] = date("U");
} else {
$billing_data['billing_type'] = "invoice";
}
@@ -659,6 +664,7 @@ class OrderController extends mfBaseController {
} elseif($owner_new) {
if($r->billing_type == "sepa") {
$owner_data['billing_type'] = "sepa";
$owner_data['sepa_date'] = date("U");
} else {
$owner_data['billing_type'] = "invoice";
}
@@ -685,6 +691,20 @@ class OrderController extends mfBaseController {
$techcontact = AddressModel::create($techcontact_data);
}
// set sepa date if not yet set and sepa is active
if($billingaddress) {
if($billingaddress->billing_type == "sepa" && !$billingaddress->sepa_date) {
$billingaddress->sepa_date = date("U");
$billingaddress->save();
}
} else {
if($owner->billing_type == "sepa" && !$owner->sepa_date) {
$owner->sepa_date = date("U");
$owner->save();
}
}
// create or save Order object
$order_data = [];
@@ -703,7 +723,7 @@ class OrderController extends mfBaseController {
$order_data['allow_spin'] = ($r->allow_spin) ? 1 : 0;
$order_data['note'] = $r->note;
$order_data['order_date'] = Layout::dateToInt($r->order_date);
$order_data['order_date'] = ($order_data['order_date']) ? Layout::dateToInt($r->order_date) : null;
if($r->finish_after) {
$order_data['finish_after'] = Layout::dateToInt($r->finish_after);
@@ -876,6 +896,7 @@ class OrderController extends mfBaseController {
$product_data["billing_delay"] = 6;
}
$product_data["billing_period"] = $p["billing_period"];
$product_data["contract_term"] = $p["contract_term"];
$product_data['upgrade'] = $order_data['upgrade'];
@@ -912,6 +933,7 @@ class OrderController extends mfBaseController {
$product_data['voicenumber'] = null;
}
$product_data['edit_by'] = $this->me->id;
if(!$orderproduct_id) {
$product = OrderProductModel::create($product_data);

View File

@@ -284,6 +284,20 @@ class OrderModel {
}
}
if(array_key_exists("finish_date>", $filter)) {
$finish_date = $filter['finish_date>'];
if($finish_date) {
$where .= " AND `Order`.finish_date > $finish_date";
}
}
if(array_key_exists("finish_date<", $filter)) {
$finish_date = $filter['finish_date<'];
if($finish_date) {
$where .= " AND `Order`.finish_date < $finish_date";
}
}
if(array_key_exists("upgrade", $filter)) {
if($filter['upgrade'] == 1) {
$where .= " AND `Order`.upgrade = 1";

View File

@@ -15,6 +15,7 @@ class OrderProductModel
public $price_nbe;
public $billing_delay;
public $billing_period;
public $contract_term;
public $note;
public $create_by = null;

View File

@@ -156,6 +156,7 @@ class ProductController extends mfBaseController {
$data['price_setup'] = ($r->price_setup) ? Layout::commaToDot($r->price_setup) : 0;
$data['billing_period'] = $r->billing_period;
$data['billing_delay'] = ($r->billing_delay) ? $r->billing_delay : 0;
$data['contract_term'] = $r->contract_term;
$data['ivt_id'] = ($r->ivt_id) ? $r->ivt_id : null;
$data['note'] = $r->note;
@@ -316,7 +317,7 @@ class ProductController extends mfBaseController {
if(!$product->id) {
return false;
}
if(is_array($product->attributes) && count($product->attributes)) {
$attributes = $product->attributes;
$product->data->attributes = [];

View File

@@ -1,26 +1,27 @@
<?php
class ProductModel {
public $name = null;
public $description = null;
public $sla_id = null;
public $external = null;
public $name;
public $description;
public $sla_id;
public $external;
public $external_id;
public $productgroup_id = null;
public $producttech_id = null;
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 $productgroup_id;
public $producttech_id;
public $price;
public $price_setup;
public $price_nne;
public $price_nbe;
public $billing_delay;
public $billing_period;
public $contract_term;
public $ivt_id;
public $note = null;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public $note;
public $create_by;
public $edit_by;
public $create;
public $edit;
public static function create(Array $data) {