diff --git a/Layout/default/Preorder/include/preorder-detail.php b/Layout/default/Preorder/include/preorder-detail.php
index 321e76e18..1982a68c8 100644
--- a/Layout/default/Preorder/include/preorder-detail.php
+++ b/Layout/default/Preorder/include/preorder-detail.php
@@ -354,7 +354,7 @@
=$preorder->adb_wohneinheit->rimo_ex_state?>
|
| Home Operational State: |
- =($preorder->adb_wohneinheit->rimo_op_state != "Undefined") ? $preorder->adb_wohneinheit->rimo_op_state : ""?>
+ | =($preorder->adb_wohneinheit->rimo_op_state != "Undefined") ? $preorder->adb_wohneinheit->rimo_op_state : ""?>
|
diff --git a/application/Admin/functions/IvtContractImport.php b/application/Admin/functions/IvtContractImport.php
index 5bd14a773..cf513212d 100644
--- a/application/Admin/functions/IvtContractImport.php
+++ b/application/Admin/functions/IvtContractImport.php
@@ -1006,7 +1006,8 @@ class Admin_IvtContractImport {
// import Voiceplan
$this->getVoiceplan($voice_contract);
- $voice_contract->matchcode = implode(", ", $contract_matchcode_numbers);
+ //$voice_contract->matchcode = implode(", ", $contract_matchcode_numbers);
+ $voice_contract->matchcode = "";
$voice_contract->save();
diff --git a/application/Admin/functions/IvtCreditImport.php b/application/Admin/functions/IvtCreditImport.php
index e636f31eb..1179d8488 100644
--- a/application/Admin/functions/IvtCreditImport.php
+++ b/application/Admin/functions/IvtCreditImport.php
@@ -166,10 +166,11 @@ class Admin_IvtCreditImport {
if($building->networksection_id) {
$matchcode .= $building->networksection->name;
}
- $matchcode .= $customer->getCompanyOrName();
- $matchcode .= "; ".$building->street.", ".$building->zip." ".$building->city;
+ $matchcode .= "; ".$customer->getCompanyOrName();
+ $matchcode .= ", ".$building->street.", ".$building->zip." ".$building->city;
} else {
- $matchcode .= "; ".$customer->street.", ".$customer->zip." ".$customer->city;
+ $matchcode .= $customer->getCompanyOrName();
+ $matchcode .= ", ".$customer->street.", ".$customer->zip." ".$customer->city;
}
diff --git a/application/Billing/BillingController.php b/application/Billing/BillingController.php
index 19fac8430..8d674b311 100644
--- a/application/Billing/BillingController.php
+++ b/application/Billing/BillingController.php
@@ -448,7 +448,6 @@ class BillingController extends mfBaseController {
}
$voiceplan = new Voiceplan($voiceplan_id);
-
// always look for whole month
// numbers usually don't change owner without at least a few months being stale
if($voice_start_date->format("d") > 1) {
@@ -467,11 +466,21 @@ class BillingController extends mfBaseController {
//var_dump($call);
$number = $call->voice_account;
$dest_nummer = $call->destination;
+ if(substr($dest_nummer, 0, 2) == "00") {
+ $dest_nummer = substr($dest_nummer, 2);
+ }
+
+ if(substr($dest_nummer, 0, 1) == "+") {
+ $dest_nummer = substr($dest_nummer, 1);
+ }
if (array_key_exists($dest_nummer, $destinations_cache)) {
$destination = $destinations_cache[$dest_nummer];
} else {
$destination = $voiceplan->getDestinationByNumber($dest_nummer);
+ if(!$destination) {
+ die("Destination für Zielrufnummer ".$call->destination." nicht gefunden");
+ }
$destinations_cache[$dest_nummer] = $destination;
}
//var_dump($destination);
@@ -520,43 +529,35 @@ class BillingController extends mfBaseController {
$voicebills[$number][$zone->id]["zone_total"] += $call_price;
$voicebills[$number][$zone->id]["duration"] += $call->duration;
}
- if(!count($voicebills)) {
- continue;
- }
- //var_dump($voicebills);exit;
+ }
- foreach($voicebills as $vbnumber => $zones) {
- foreach($zones as $zone_id => $vb) {
- $vbdata = [];
- $vbdata["billing_id"] = $billing->id;
- $vbdata["contract_id"] = $contract->id;
- $vbdata["voicenumber"] = $vbnumber;
- $vbdata["start_date"] = $voice_start_date->format("Y-m-d");
- $vbdata["end_date"] = $voice_end_date->format("Y-m-d");
- $vbdata["voiceplan"] = $vb["voiceplan"];
- $vbdata["zone"] = $vb["zone_name"];
- $vbdata["call_count"] = $vb["count"];
- $vbdata["duration"] = $vb["duration"];
- $vbdata["price"] = $vb["price"];
- $vbdata["price_total"] = $vb["zone_total"];
- $vbdata["increment"] = $vb["increment"];
- $vbdata["increment_first"] = $vb["increment_first"];
+ // save to BillingVoicenumber
+ foreach($voicebills as $vbnumber => $zones) {
+ foreach($zones as $zone_id => $vb) {
+ $vbdata = [];
+ $vbdata["billing_id"] = $billing->id;
+ $vbdata["contract_id"] = $contract->id;
+ $vbdata["voicenumber"] = $vbnumber;
+ $vbdata["start_date"] = $voice_start_date->format("Y-m-d");
+ $vbdata["end_date"] = $voice_end_date->format("Y-m-d");
+ $vbdata["voiceplan"] = $vb["voiceplan"];
+ $vbdata["zone"] = $vb["zone_name"];
+ $vbdata["call_count"] = $vb["count"];
+ $vbdata["duration"] = $vb["duration"];
+ $vbdata["price"] = $vb["price"];
+ $vbdata["price_total"] = $vb["zone_total"];
+ $vbdata["increment"] = $vb["increment"];
+ $vbdata["increment_first"] = $vb["increment_first"];
- $bill_voice = BillingVoicenumberModel::create($vbdata);
- if(!$bill_voice->save()) {
- var_dump($vbdata);
- die("Error saving Billing Voicenumber!");
- }
+ $bill_voice = BillingVoicenumberModel::create($vbdata);
+ if(!$bill_voice->save()) {
+ var_dump($vbdata);
+ die("Error saving Billing Voicenumber!");
}
}
- $v++;
-
- // save to BillingVoicenumber
-
-
-
-
}
+ $v++;
+ //var_dump($voicebills);exit;
}
diff --git a/application/BillingVoicenumber/BillingVoicenumberModel.php b/application/BillingVoicenumber/BillingVoicenumberModel.php
index 0d155f480..f44184c85 100644
--- a/application/BillingVoicenumber/BillingVoicenumberModel.php
+++ b/application/BillingVoicenumber/BillingVoicenumberModel.php
@@ -168,15 +168,6 @@ class BillingVoicenumberModel {
}
}
- if(array_key_exists("approved", $filter)) {
- $approved = $filter['approved'];
- if($approved) {
- $where .= " AND BillingVoicenumber.approved = 1";
- } else {
- $where .= " AND BillingVoicenumber.approved = 0";
- }
- }
-
if(array_key_exists("billing_id", $filter)) {
$billing_id = $filter['billing_id'];
if(is_numeric($billing_id)) {
diff --git a/application/Invoice/Invoice.php b/application/Invoice/Invoice.php
index 871693ebb..1bc9fade9 100644
--- a/application/Invoice/Invoice.php
+++ b/application/Invoice/Invoice.php
@@ -2,6 +2,7 @@
class Invoice extends mfBaseModel {
private $positions;
+ private $voicenumbers;
public function getProperty($name) {
if($this->$name == null) {
@@ -17,6 +18,12 @@ class Invoice extends mfBaseModel {
return $this->positions;
}
+ if($name == "voicenumbers") {
+ $voicenumbers = InvoiceVoicenumberModel::search(["invoice_id" => $this->id]);
+ $this->voicenumbers = $voicenumbers;
+ return $this->voicenumbers;
+ }
+
if($name == "creator") {
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
if($this->creator === null) {
diff --git a/application/Invoice/InvoiceController.php b/application/Invoice/InvoiceController.php
index 52cb2f4ac..32f935fd5 100644
--- a/application/Invoice/InvoiceController.php
+++ b/application/Invoice/InvoiceController.php
@@ -117,7 +117,7 @@ class InvoiceController extends mfBaseController {
$headerHtml = str_replace("{{ addressLine_4 }}", $invoice->zip . " " . $invoice->city, $headerHtml);
$headerHtml = str_replace("{{ addressLine_5 }}", $invoice->country != "Österreich" ? $invoice->country : "", $headerHtml);
$headerHtml = str_replace("{{ customerNumber }}", $invoice->customer_number, $headerHtml);
- $headerHtml = str_replace("{{ billingAccount }}", "testtest", $headerHtml);
+ $headerHtml = str_replace("{{ billingAccount }}", $invoice->fibu_account_number, $headerHtml);
$headerHtml = str_replace("{{ invoiceNumber }}", $invoice->invoice_number, $headerHtml);
$headerHtml = str_replace("{{ invoiceDate }}", date("d.m.Y", $invoice->invoice_date), $headerHtml);
$headerHtml = str_replace("{{ vatHtml }}", $invoice->uid ? "| Ihre UID: | " . $invoice->uid . " |
" : "", $headerHtml);
@@ -166,6 +166,7 @@ XINON GmbH";
$bill_positions = [];
$credit_positions = [];
+ $invoice_voicenumbers = [];
$billing_rows = BillingModel::search(["owner_id" => $owner_id,
"billingaddress_id" => $billingaddress_id,
@@ -244,6 +245,112 @@ XINON GmbH";
}
+ /*
+ * ***************************************
+ * Get Voicenumber Billing to Billing row
+ * ***************************************
+ */
+
+ $voicebills = BillingVoicenumberModel::search(["billing_id" => $bill->id]);
+ //var_dump($voicebills);exit;
+ if(count($voicebills)) {
+ $voice_start_date = reset($voicebills)->start_date;
+ $voice_end_date = reset($voicebills)->end_date;
+ $voiceplan = reset($voicebills)->voiceplan;
+ $inc = reset($voicebills)->increment;
+ $inc_first = reset($voicebills)->increment_first;
+
+ $voice_rows = [];
+ foreach($voicebills as $voicebill) {
+ $number = $voicebill->voicenumber;
+ $zone = $voicebill->zone;
+ $call_count = $voicebill->call_count;
+ $duration = $voicebill->duration;
+ $price = $voicebill->price;
+ $price_total = $voicebill->price_total;
+
+
+ if(!array_key_exists($number, $voice_rows)) {
+ $voice_rows[$number] = [];
+ }
+
+ if(!array_key_exists($zone, $voice_rows[$number])) {
+ $voice_rows[$number][$zone] = [];
+ }
+
+ if(!array_key_exists($price, $voice_rows[$number][$zone])) {
+ $voice_rows[$number][$zone][$price] = [];
+ $voice_rows[$number][$zone][$price]["call_count"] = 0;
+ $voice_rows[$number][$zone][$price]["duration"] = 0;
+ $voice_rows[$number][$zone][$price]["price_total"] = 0;
+ }
+
+ $voice_rows[$number][$zone][$price]["call_count"] += $call_count;
+ $voice_rows[$number][$zone][$price]["duration"] = $duration;
+ $voice_rows[$number][$zone][$price]["price_total"] = $price_total;
+ }
+
+ //var_dump($voice_rows);exit;
+
+ $total_voice_price = 0;
+
+ foreach($voice_rows as $number => $zones) {
+ $voicenumber_data = [];
+ $voicenumber_data["voicenumber"] = $number;
+ $voicenumber_data["start_date"] = $voice_start_date;
+ $voicenumber_data["end_date"] = $voice_end_date;
+ $voicenumber_data["voiceplan"] = $voiceplan;
+ $voicenumber_data["increment"] = $inc;
+ $voicenumber_data["increment_first"] = $inc_first;
+
+ $invoice_voicenumber = InvoiceVoicenumberModel::create($voicenumber_data);
+ $invoice_voicenumber->voicenumberzones = [];
+
+
+
+ foreach($zones as $zone => $prices) {
+ foreach($prices as $price => $row_values) {
+ $zone_data = [];
+ $zone_data["zone"] = $zone;
+ $zone_data["call_count"] = $row_values["call_count"];
+ $zone_data["duration"] = $row_values["duration"];
+ $zone_data["price"] = $price;
+ $zone_data["price_total"] = $row_values["price_total"];
+ $zone_data["price_total_gross"] = $row_values["price_total"];
+ if($invoice_vatrate) {
+ $zone_data["price_total_gross"] = $row_values["price_total"] + (($row_values["price_total"] / 100) * $invoice_vatrate);
+ }
+ $zone_data["vatrate"] = $invoice_vatrate;
+ $total_voice_price += $row_values["price_total"];
+
+ $voicenumber_zone = InvoiceVoicenumberZoneModel::create($zone_data);
+ //var_dump($voicenumber_zone);
+ $invoice_voicenumber->data->voicenumberzones[] = $voicenumber_zone;
+ }
+ }
+ //var_dump($invoice_voicenumber);exit;
+ $invoice_voicenumbers[] = $invoice_voicenumber;
+ }
+ //var_dump($invoice_voicenumbers);exit;
+
+
+ $this->log->debug("Adding Voice Invoiceposition for Contract ID " . $bill->contract_id);
+ $voice_data = $position_data;
+ $voice_data["product_name"] = "Gesprächsgebühren zu " . $bill->product_name;
+ $voice_data["product_info"] = null;
+ $voice_data["matchcode"] = null;
+ $voice_data["price"] = $total_voice_price;
+ $voice_data["price_total"] = $total_voice_price;
+ $voice_data["price_gross"] = $total_voice_price + (($total_voice_price / 100) * 20);
+ $voice_data["vatrate"] = $invoice_vatrate;
+ $voice_data["start_date"] = $voice_start_date;
+ $voice_data["end_date"] = $voice_end_date;
+ $voice_position = InvoicepositionModel::create($voice_data);
+ $voice_position->setOption("timerange_month_only", true);
+ $bill_positions[] = $voice_position;
+ }
+
+
/*if($bill->price >= 0 || $bill->price_setup >= 0) {
$bill_positions[] = InvoicepositionModel::create($position_data);
} else {
@@ -285,9 +392,11 @@ XINON GmbH";
}
- //var_dump($bill_positions, $credit_positions);exit;
-
-
+ /*
+ * *******************************
+ * Save invoice and add positions
+ * *******************************
+ */
// create Invoice
$invoice = InvoiceModel::create($invoice_data);
$invoice->startTransaction();
@@ -346,29 +455,51 @@ XINON GmbH";
$invoice->rollbackTransaction();
die("Error saving totals in Invoice");
}
- // generate Invoice number
+ if(count($invoice_voicenumbers)) {
+ foreach($invoice_voicenumbers as $inv_vn) {
+ $invnz_s = $inv_vn->voicenumberzones;
+ unset($inv_vn->voicenumberzones);
+
+ $inv_vn->invoice_id = $invoice->id;
+ if(!$inv_vn->save()) {
+ $invoice->rollbackTransaction();
+ die("Error saving InvoiceVoicenumber");
+ }
+ foreach($invnz_s as $invnz) {
+ $invnz->invoicevoicenumber_id = $inv_vn->id;
+ if(!$invnz->save()) {
+ $invoice->rollbackTransaction();
+ die("Error saving InvoiceVoicenumberZone");
+ }
+ }
+ }
+ }
+
+ // generate Invoice number
$new_num = InvoiceModel::getNextInvoiceNUmber();
$invoice->invoice_number = $new_num;
$invoice->invoice_date = date("U");
+ // voicenumbers
+ //var_dump($invoice_voicenumbers);exit;
+
if (!$invoice->save()) {
$invoice->rollbackTransaction();
die("Error saving Invoice number and date");
}
-
- // commit transaction
- $invoice->commitTransaction();
- $i++;
} catch (Exception $e) {
if ($invoice) {
$invoice->rollbackTransaction();
}
die("Error saving Invoice!\n");
-
}
+ // commit transaction
+ $invoice->commitTransaction();
+ $i++;
+
// Create Invoice PDF
diff --git a/application/InvoiceVoicenumber/InvoiceVoicenumber.php b/application/InvoiceVoicenumber/InvoiceVoicenumber.php
new file mode 100644
index 000000000..7baf3a960
--- /dev/null
+++ b/application/InvoiceVoicenumber/InvoiceVoicenumber.php
@@ -0,0 +1,60 @@
+$name == null) {
+
+ if(!$this->id) {
+ return null;
+ }
+
+
+ if($name == "zones") {
+ $zones = InvoiceVoicenumberZoneModel::search(["invoicevoicenumber_id" => $this->id]);
+ $this->zones = $zones;
+ return $this->zones;
+ }
+
+ if($name == "creator") {
+ $this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
+ if($this->creator === null) {
+ $this->creator = new User($this->create_by);
+ if($this->creator->id) {
+ mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
+ }
+ }
+ return $this->creator;
+ }
+
+ if($name == "editor") {
+ $this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
+ if($this->editor === null) {
+ $this->editor = new User($this->edit_by);
+ if($this->editor->id) {
+ mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
+ }
+ }
+ return $this->editor;
+ }
+
+ $classname = ucfirst($name);
+ $idfield = $name."_id";
+ $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
+ if(!$this->$name) {
+ $this->$name = new $classname($this->$idfield);
+ }
+
+ if($this->$name->id) {
+ mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
+ return $this->$name;
+ } else {
+ return null;
+ }
+
+ }
+
+ return $this->$name;
+ }
+}
\ No newline at end of file
diff --git a/application/InvoiceVoicenumber/InvoiceVoicenumberModel.php b/application/InvoiceVoicenumber/InvoiceVoicenumberModel.php
new file mode 100644
index 000000000..6bd9a8f2f
--- /dev/null
+++ b/application/InvoiceVoicenumber/InvoiceVoicenumberModel.php
@@ -0,0 +1,137 @@
+ $value) {
+ if(property_exists(get_called_class(), $field)) {
+ $model ->$field = $value;
+ }
+ }
+
+ $me = new User();
+ $me->loadMe();
+
+ if($model->create_by === null) {
+ $model->create_by = $me->id;
+ }
+ if($model->edit_by === null) {
+ $model->edit_by = $me->id;
+ }
+
+ return $model;
+ }
+
+ public static function getFirst($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT * FROM InvoiceVoicenumber
+ WHERE $where
+ ORDER BY invoice_id,voicenumber,start_date LIMIT 1";
+ //var_dump($sql);exit;
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new InvoiceVoicenumber($data);
+ if($item->id) {
+ return $item;
+ } else {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static function count($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT COUNT(*) as cnt FROM InvoiceVoicenumber
+ WHERE $where";
+
+ //mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ return $data->cnt;
+ }
+ return 0;
+ }
+
+ public static function search($filter, $limit = false, $order = false) {
+ //var_dump($filter);exit;
+ $items = [];
+
+ if(!$order) {
+ $order = "invoice_id,voicenumber,start_date";
+ }
+
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT * FROM InvoiceVoicenumber
+ WHERE $where
+ ORDER BY $order";
+
+ if(is_array($limit) && count($limit)) {
+ if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
+ } elseif(is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['count'];
+ }
+ }
+
+ mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[$data->id] = new InvoiceVoicenumber($data);
+ }
+ }
+
+ return $items;
+ }
+
+ private static function getSqlFilter($filter) {
+ $where = "1=1 ";
+
+ $db = FronkDB::singleton();
+
+ //var_dump($filter);exit;
+
+ if(array_key_exists("invoice_id", $filter)) {
+ $invoice_id = $filter['invoice_id'];
+ if(is_numeric($invoice_id)) {
+ $where .= " AND InvoiceVoicenumber.invoice_id=$invoice_id";
+ }
+ }
+
+
+ if(array_key_exists("add-where", $filter)) {
+ $where .= " ".$filter['add-where'];
+ }
+
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+
+}
diff --git a/application/InvoiceVoicenumberZone/InvoiceVoicenumberZone.php b/application/InvoiceVoicenumberZone/InvoiceVoicenumberZone.php
new file mode 100644
index 000000000..cf581f706
--- /dev/null
+++ b/application/InvoiceVoicenumberZone/InvoiceVoicenumberZone.php
@@ -0,0 +1,5 @@
+ $value) {
+ if(property_exists(get_called_class(), $field)) {
+ $model ->$field = $value;
+ }
+ }
+
+ $me = new User();
+ $me->loadMe();
+
+ if($model->create_by === null) {
+ $model->create_by = $me->id;
+ }
+ if($model->edit_by === null) {
+ $model->edit_by = $me->id;
+ }
+
+ return $model;
+ }
+
+ public static function getFirst($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT * FROM InvoiceVoicenumberZone
+ WHERE $where
+ ORDER BY invoicevoicenumber_id,zone,price LIMIT 1";
+ //var_dump($sql);exit;
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new InvoiceVoicenumberZone($data);
+ if($item->id) {
+ return $item;
+ } else {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static function count($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT COUNT(*) as cnt FROM InvoiceVoicenumberZone
+ WHERE $where";
+
+ //mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ return $data->cnt;
+ }
+ return 0;
+ }
+
+ public static function search($filter, $limit = false, $order = false) {
+ //var_dump($filter);exit;
+ $items = [];
+
+ if(!$order) {
+ $order = "invoicevoicenumber_id,zone,price";
+ }
+
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT * FROM InvoiceVoicenumberZone
+ WHERE $where
+ ORDER BY $order";
+
+ if(is_array($limit) && count($limit)) {
+ if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
+ } elseif(is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['count'];
+ }
+ }
+
+ mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[$data->id] = new InvoiceVoicenumberZone($data);
+ }
+ }
+
+ return $items;
+ }
+
+ private static function getSqlFilter($filter) {
+ $where = "1=1 ";
+
+ $db = FronkDB::singleton();
+
+ //var_dump($filter);exit;
+
+ if(array_key_exists("invoicevoicenumber_id", $filter)) {
+ $invoicevoicenumber_id = $filter['invoicevoicenumber_id'];
+ if(is_numeric($invoicevoicenumber_id)) {
+ $where .= " AND InvoiceVoicenumberZone.invoicevoicenumber_id=$invoicevoicenumber_id";
+ }
+ }
+
+
+ if(array_key_exists("add-where", $filter)) {
+ $where .= " ".$filter['add-where'];
+ }
+
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+
+}
diff --git a/application/Invoiceposition/Invoiceposition.php b/application/Invoiceposition/Invoiceposition.php
index 9c045f4a3..203ba60e6 100644
--- a/application/Invoiceposition/Invoiceposition.php
+++ b/application/Invoiceposition/Invoiceposition.php
@@ -2,7 +2,41 @@
class Invoiceposition extends mfBaseModel {
+ public function setOption($name, $value) {
+ $options = $this->getOptions;
+ if($options) {
+ $options = json_decode($this->options);
+ if(json_last_error() !== JSON_ERROR_NONE) {
+ $options = new stdClass();
+ }
+ } else {
+ $options = new stdClass();
+ }
+
+ $options->$name = $value;
+
+ $this->options = json_encode($options);
+ }
+
+ public function getOption($name) {
+ if(!$this->options) return null;
+
+ $this->log->debug("getOptions ($name): ".print_r($this->options, true));
+
+ $options = json_decode($this->options);
+ if(json_last_error() !== JSON_ERROR_NONE) {
+ $this->log->debug("getOptions ($name) decoding failed");
+ return null;
+ }
+
+ if(property_exists($options, $name)) {
+
+ return $options->$name;
+ }
+
+ return null;
+ }
public function __clone() {
$me = new User;
$me->loadMe();
diff --git a/application/Invoiceposition/InvoicepositionModel.php b/application/Invoiceposition/InvoicepositionModel.php
index 1b793c999..27f8e6a92 100644
--- a/application/Invoiceposition/InvoicepositionModel.php
+++ b/application/Invoiceposition/InvoicepositionModel.php
@@ -19,6 +19,7 @@ class InvoicepositionModel {
public $fibu_cost_account_legacy;
public $fibu_taxcode;
public $billing_period;
+ public $options;
public $create_by;
public $edit_by;
@@ -106,7 +107,7 @@ class InvoicepositionModel {
$items = [];
if(!$order) {
- $order = "invoice_id,contract_id,start_date,matchcode ASC";
+ $order = "invoice_id,contract_id,id ASC";
}
$db = FronkDB::singleton();
diff --git a/application/Voiceplandestination/VoiceplandestinationModel.php b/application/Voiceplandestination/VoiceplandestinationModel.php
index c1f5f0b47..0ea2ff412 100644
--- a/application/Voiceplandestination/VoiceplandestinationModel.php
+++ b/application/Voiceplandestination/VoiceplandestinationModel.php
@@ -59,7 +59,7 @@ class VoiceplandestinationModel {
WHERE $where
ORDER BY destination,prefix LIMIT 1
";
- mfLoghandler::singleton()->debug($sql);
+ //mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
//$res = $db->select("Voiceplandestination", "*", "$where ORDER BY destination,prefix");
if($db->num_rows($res)) {
@@ -114,7 +114,7 @@ class VoiceplandestinationModel {
$res = $db->query($sql);
- mfLoghandler::singleton()->debug($sql);
+ //mfLoghandler::singleton()->debug($sql);
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
diff --git a/db/migrations/20240625162005_create_invoice_tables.php b/db/migrations/20240625162005_create_invoice_tables.php
index 3b5a426c8..2a24c6f62 100644
--- a/db/migrations/20240625162005_create_invoice_tables.php
+++ b/db/migrations/20240625162005_create_invoice_tables.php
@@ -12,6 +12,7 @@ final class CreateInvoiceTables extends AbstractMigration
$invoice->addColumn("invoice_number", "string", ["null" => true, "default" => null]); // RN2024-X000001
$invoice->addColumn("invoice_date", "integer", ["default" => 0]);
+ $invoice->addColumn("owner_id", "integer", ["null" => false]);
$invoice->addColumn("billingaddress_id", "integer", ["null" => false]);
$invoice->addColumn("customer_number", "integer", ["null" => false]);
$invoice->addColumn("company", "string", ["null" => true, "default" => null, "length" => 1024]);
diff --git a/db/migrations/20240706181205_create_invoice_voicenumber_tables.php b/db/migrations/20240706181205_create_invoice_voicenumber_tables.php
new file mode 100644
index 000000000..957435da0
--- /dev/null
+++ b/db/migrations/20240706181205_create_invoice_voicenumber_tables.php
@@ -0,0 +1,62 @@
+getEnvironment() == "thetool") {
+ $iv = $this->table("InvoiceVoicenumber");
+ $iv->addColumn("invoice_id", "integer", ["null" => false]);
+ $iv->addColumn("voicenumber", "string", ["null" => false, "length" => 64]);
+ $iv->addColumn("start_date", "date", ["null" => false]);
+ $iv->addColumn("end_date", "date", ["null" => false]);
+ $iv->addColumn("voiceplan", "string", ["null" => false, "length" => 64]);
+ $iv->addColumn("increment", "integer", ["null" => false]);
+ $iv->addColumn("increment_first", "integer", ["null" => false]);
+
+ $iv->addColumn("create_by", "integer", ["null" => false]);
+ $iv->addColumn("edit_by", "integer", ["null" => false]);
+ $iv->addColumn("create", "integer", ["null" => false]);
+ $iv->addColumn("edit", "integer", ["null" => false]);
+
+ $iv->create();
+
+ $ivz = $this->table("InvoiceVoicenumberZone");
+ $ivz->addColumn("invoicevoicenumber_id", "integer", ["null" => false]);
+ $ivz->addColumn("zone", "string", ["null" => false, "length" => 64]);
+ $ivz->addColumn("call_count", "integer", ["null" => false]);
+ $ivz->addColumn("duration", "integer", ["null" => false]);
+ $ivz->addColumn("price", "decimal", ["null" => false, "precision" => 14, "scale" => 8]);
+ $ivz->addColumn("price_total", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
+ $ivz->addColumn("price_total_gross", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
+ $ivz->addColumn("vatrate", "decimal", ["null" => false, "default" => 0, "precision" => 6, "scale" => 2]);
+
+
+ $ivz->addColumn("create_by", "integer", ["null" => false]);
+ $ivz->addColumn("edit_by", "integer", ["null" => false]);
+ $ivz->addColumn("create", "integer", ["null" => false]);
+ $ivz->addColumn("edit", "integer", ["null" => false]);
+
+ $ivz->create();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if($this->getEnvironment() == "thetool") {
+ $this->table("InvoiceVoicenumberZone")->drop()->save();
+ $this->table("InvoiceVoicenumber")->drop()->save();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}
diff --git a/db/migrations/20240706192917_invoiceposition_add_options.php b/db/migrations/20240706192917_invoiceposition_add_options.php
new file mode 100644
index 000000000..4d0f43b46
--- /dev/null
+++ b/db/migrations/20240706192917_invoiceposition_add_options.php
@@ -0,0 +1,31 @@
+getEnvironment() == "thetool") {
+ $table = $this->table("Invoiceposition");
+ $table->addColumn("options", "json", ["null" => true, "default" => null, "after" => "billing_period"]);
+ $table->update();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if($this->getEnvironment() == "thetool") {
+ $this->table("Invoiceposition")->removeColumn("options")->update();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}
diff --git a/lib/mvcfronk/mfLayout/mfLayout.php b/lib/mvcfronk/mfLayout/mfLayout.php
index afd3a6742..717ad93ff 100644
--- a/lib/mvcfronk/mfLayout/mfLayout.php
+++ b/lib/mvcfronk/mfLayout/mfLayout.php
@@ -198,6 +198,10 @@ class mfLayout {
return $url;
}
+ public static function getHumanReadableInterval($seconds) {
+ return sprintf("%02d:%02d:%02d", floor($seconds / 3600), ($seconds / 60) % 60, $seconds % 60);
+ }
+
public static function getResourcePath() {
if (MFUSEFANCYURLS) {
$path = MFFANCYBASEURL;