+
is("preorderfront")) ? "selected='selected'" : ""?>>No
is("preorderfront")) ? "selected='selected'" : ""?>>Yes
@@ -78,7 +85,7 @@
+ Zusatzberechtigungen
+
+
+
+
+ can("Fibu")) ? "checked='checked'" : ""?> />
+ Buchhaltung
+
+
+
+
diff --git a/application/Address/Address.php b/application/Address/Address.php
index e4a79b023..84784c65a 100644
--- a/application/Address/Address.php
+++ b/application/Address/Address.php
@@ -2,6 +2,8 @@
class Address extends mfBaseModel {
protected $forcestr = ['street','company','zip','phone','fax','mobile','note'];
+ private $in_after_save = false;
+
private $parent;
private $childaddresses;
private $links = [];
@@ -14,6 +16,55 @@ class Address extends mfBaseModel {
private $phoneparts;
+ protected function afterSave() {
+ // prevent potential infinite loop
+ if($this->in_after_save) return true;
+ $this->in_after_save = true;
+
+ $this->syncToFibuMerge();
+ }
+
+ private function syncToFibuMerge() {
+ if(!$this->customer_number) return true;
+
+ //var_dump($this);exit;
+
+ if($this->fibu_account_number) {
+ $fibumerge = XinonFibuMergeModel::getFirst(["old_custnum" => $this->customer_number]);
+ if(!$fibumerge) {
+ // create fibu merge
+ $fibumerge = XinonFibuMergeModel::create([
+ "old_custnum" => $this->customer_number,
+ "new_custnum" => $this->fibu_account_number,
+ "name" => ($this->company) ? $this->company : $this->lastname,
+ "vorname" => ($this->company) ? "" : $this->firstname,
+ "strasse" => $this->street,
+ "plz" => $this->zip,
+ "ort" => $this->city,
+ ]);
+ $fibumerge->save();
+ return true;
+ }
+
+ if($fibumerge->new_custnum != $this->fibu_account_number) {
+ $fibumerge->new_custnum = $this->fibu_account_number;
+ $fibumerge->save();
+ }
+ } elseif($this->_old_data->fibu_account_number) {
+ // fibu account number was removed => remove fibumerge entry
+ $fibumerge = XinonFibuMergeModel::getFirst(["old_custnum" => $this->customer_number, "new_custnum" => $this->_old_data->fibu_account_number]);
+ //var_dump($fibumerge);exit;
+ if(!$fibumerge) return true;
+
+ $fibumerge->delete();
+
+ }
+
+
+ return true;
+
+ }
+
public function getFullName() {
// Assumes "Firma1 Firma2" or "firstname lastname" as readable form
$name = "";
@@ -146,6 +197,24 @@ class Address extends mfBaseModel {
}
}*/
+ public static function getNextSupplierNumber() {
+ $db = FronkDB::singleton();
+ $res = $db->select("Address","fibu_supplier_number", "fibu_supplier_number > 0 ORDER BY fibu_supplier_number DESC LIMIT 1");
+ if(!$db->num_rows($res)) {
+ return TT_FIRST_SUPPLIER_NUM;
+ }
+
+ $data = $db->fetch_object($res);
+ $last_num = $data->fibu_supplier_number;
+ if($last_num) {
+ $new_num = $last_num + 1;
+ } else {
+ $new_num = TT_FIRST_SUPPLIER_NUM;
+ }
+ return $new_num;
+
+ }
+
public function getProperty($name) {
if($this->$name == null) {
diff --git a/application/Address/AddressController.php b/application/Address/AddressController.php
index adf1ad19b..2ea7d8c14 100644
--- a/application/Address/AddressController.php
+++ b/application/Address/AddressController.php
@@ -73,6 +73,11 @@ class AddressController extends mfBaseController {
$new_filter["parents_only"] = 1;
}
+ if(array_key_exists("fibu_account_number", $filter) && $filter['fibu_account_number']) {
+ $new_filter['fibu_account_number'] = $filter['fibu_account_number']."%";
+ unset($filter['fibu_account_number']);
+ }
+
foreach($filter as $name => $value) {
$new_filter[$name] = $value;
}
@@ -177,6 +182,13 @@ class AddressController extends mfBaseController {
$data['email'] = $r->email;
$data['note'] = $r->note;
$data['uid'] = $r->uid;
+ $data['fibu_account_number'] = ($r->fibu_account_number) ? $r->fibu_account_number : null;
+ $data['fibu_supplier_number'] = ($r->fibu_supplier_number) ? $r->fibu_supplier_number : null;
+ if($r->fibu_primary_account) {
+ $data['fibu_primary_account'] = 1;
+ } else {
+ $data['fibu_primary_account'] = 0;
+ }
// billing data
@@ -236,6 +248,17 @@ class AddressController extends mfBaseController {
return $this->add();
}
+ // check for multiple primary fibu accounts, and remove from any other than this one
+ if($address->fibu_primary_account && $address->fibu_account_number) {
+ foreach(AddressModel::search(["fibu_primary_account" => true, "fibu_account_number" => $address->fibu_account_number]) as $fibu_primary) {
+ if($fibu_primary->id == $address->id) continue;
+ $fibu_primary->fibu_primary_account = 0;
+ $fibu_primary->save();
+ }
+ }
+
+
+ // save address types
$new_types = $r->addresstypes;
if(is_array($new_types)) {
foreach($address->types as $existing_type) {
@@ -258,6 +281,19 @@ class AddressController extends mfBaseController {
}
}
+ // generate new supplier account number if is supplier and supplier num empty
+ //var_dump($mode, $address->fibu_supplier_number, $address->types);exit;
+ if(!$address->fibu_supplier_number && array_key_exists("supplier", $address->types)) {
+ $supplier_num = Address::getNextSupplierNumber();
+ if(!$supplier_num) {
+ $this->layout()->setFlash("Lieferantennummer konnte nicht generiert werden.");
+ } else {
+ $this->log->debug("new supplier number: ". $supplier_num);
+ $address->fibu_supplier_number = $supplier_num;
+ $address->save();
+ }
+ }
+
$attribs = $r->attributes;
//var_dump($attribs);exit;
if(is_array($attribs) && count($attribs)) {
diff --git a/application/Address/AddressModel.php b/application/Address/AddressModel.php
index 1792778a5..977cc96cb 100644
--- a/application/Address/AddressModel.php
+++ b/application/Address/AddressModel.php
@@ -1,20 +1,23 @@
escape($fan);
+ $where .= " AND fibu_account_number LIKE '$fan'";
+ }
+ }
+ }
+
+ if(array_key_exists("fibu_supplier_number", $filter)) {
+ $fsn = $filter["fibu_supplier_number"];
+ if(is_numeric($fsn)) {
+ $where .= " AND fibu_supplier_number=$fsn";
+ }
+ }
+
+ if(array_key_exists("fibu_primary_account", $filter)) {
+ $fpa = $filter["fibu_primary_account"];
+ if($fpa) {
+ $where .= " AND fibu_primary_account=1";
+ } else {
+ $where .= " AND fibu_primary_account=0";
+ }
+ }
+
if(array_key_exists("spin", $filter)) {
$spin = FronkDB::singleton()->escape($filter["spin"]);
if($spin) {
diff --git a/application/Preorderlogistics/PreorderlogisticsController.php b/application/Preorderlogistics/PreorderlogisticsController.php
index fe12ce4cb..008fc9e26 100644
--- a/application/Preorderlogistics/PreorderlogisticsController.php
+++ b/application/Preorderlogistics/PreorderlogisticsController.php
@@ -160,7 +160,7 @@ class PreorderlogisticsController extends mfBaseController {
}
protected function printAction() {
- $this->layout()->setTemplate("Preorderlogistics/Print");
+ $this->layout()->setTemplate("Preorderlogistics/Print.template");
$id = $this->request->id;
if(!is_numeric($id) || $id < 1) {
$this->layout()->setFlash("Vorbestellung nicht gefunden", "error");
diff --git a/application/User/User.php b/application/User/User.php
index a176baed4..c9d2bbcd3 100644
--- a/application/User/User.php
+++ b/application/User/User.php
@@ -111,7 +111,7 @@ class User extends mfBaseModel {
$m = [];
if(preg_match('/^([^ ]+) ([^ ]+)(?: ([^ ]+))?$/', $this->name, $m)) {
$firstname = $m[1];
- if($m[3]) {
+ if(array_key_exists(3, $m) && $m[3]) {
$middlename = $m[2];
$lastname = $m[3];
} else {
@@ -261,7 +261,6 @@ class User extends mfBaseModel {
public function myNetworks($types) {
$typenets = [];
$my_networks = $this->getProperty("my_networks");
-
if(!is_array($types)) {
$types = [$types];
}
diff --git a/application/User/UserController.php b/application/User/UserController.php
index 722643fd1..eb6a396d6 100644
--- a/application/User/UserController.php
+++ b/application/User/UserController.php
@@ -188,6 +188,12 @@ class UserController extends mfBaseController
$user->permissions->admin = "false";
}
+ if ($r->employee == "true") {
+ $user->permissions->employee = "true";
+ } else {
+ $user->permissions->employee = "false";
+ }
+
if ($r->technician == "true") {
$user->permissions->technician = "true";
} else {
@@ -218,10 +224,11 @@ class UserController extends mfBaseController
$user->permissions->canVoipnumbering = "false";
$user->permissions->canPreorder = "false";
$user->permissions->canOrder = "false";
+ $user->permissions->canFibu = "false";
if($r->get("can") && is_array($r->can)) {
foreach($r->can as $key => $can) {
- var_dump($key . "=> ".$can);
+ //var_dump($key . "=> ".$can);
if($can) {
$user->permissions->{"can$key"} = "true";
}
diff --git a/application/WorkerPermission/WorkerPermission.php b/application/WorkerPermission/WorkerPermission.php
index e1bed311e..4fa25500a 100644
--- a/application/WorkerPermission/WorkerPermission.php
+++ b/application/WorkerPermission/WorkerPermission.php
@@ -2,7 +2,7 @@
class WorkerPermission extends mfBaseModel {
public $isAdmin = false;
- public $isTicketadmin = false;
+ public $isEmployee = false;
public $isTechnician = false;
public $isPreorderfront = false;
public $isPreorderaddressreporting = false;
@@ -26,8 +26,8 @@ class WorkerPermission extends mfBaseModel {
if($this->admin == 'true') {
$this->isAdmin = true;
}
- if($this->ticketadmin == 'true') {
- $this->isTicketadmin = true;
+ if($this->employee == 'true') {
+ $this->isEmployee = true;
}
if($this->technician == 'true') {
$this->isTechnician = true;
diff --git a/application/XinonFibuMerge/XinonFibuMerge.php b/application/XinonFibuMerge/XinonFibuMerge.php
new file mode 100644
index 000000000..e932c4896
--- /dev/null
+++ b/application/XinonFibuMerge/XinonFibuMerge.php
@@ -0,0 +1,35 @@
+$name == null) {
+
+ if(!$this->id) {
+ return null;
+ }
+
+ if($name == "address") {
+ if(!$this->old_custnum) return null;
+
+ $address = new Address($this->old_custnum);
+ if(!$address->id) return null;
+ return $address;
+ }
+
+
+ $classname = ucfirst($name);
+ $idfield = $name."_id";
+ $this->$name = new $classname($this->$idfield);
+
+ if($this->$name->id) {
+ return $this->$name;
+ } else {
+ return null;
+ }
+ }
+
+ return $this->$name;
+ }
+}
\ No newline at end of file
diff --git a/application/XinonFibuMerge/XinonFibuMergeModel.php b/application/XinonFibuMerge/XinonFibuMergeModel.php
new file mode 100644
index 000000000..2e46a3983
--- /dev/null
+++ b/application/XinonFibuMerge/XinonFibuMergeModel.php
@@ -0,0 +1,142 @@
+ $value) {
+ if (property_exists(get_called_class(), $field)) {
+ $model->$field = $value;
+ }
+ }
+
+ $me = mfValuecache::singleton()->get("me");
+ if (!$me) {
+ $me = new User();
+ $me->loadMe();
+ mfValuecache::singleton()->set("me", $me);
+ }
+
+ 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);
+ $res = $db->select("XinonFibuMerge", "*", "$where ORDER BY old_custnum LIMIT 1");
+ if ($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new XinonFibuMerge($data);
+ if ($item->id) {
+ return $item;
+ } else {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static function getAll() {
+ $items = [];
+
+ $db = FronkDB::singleton();
+
+ $res = $db->select("XinonFibuMerge", "*", "1=1 ORDER BY old_custnum");
+ if ($db->num_rows($res)) {
+ while ($data = $db->fetch_object($res)) {
+ $items[] = new XinonFibuMerge($data);
+ }
+ }
+ return $items;
+ }
+
+ public static function count($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT COUNT(*) as cnt FROM XinonFibuMerge
+ WHERE $where
+ ";
+
+ $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) {
+ $items = [];
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT * FROM XinonFibuMerge
+ WHERE $where
+ ORDER BY old_custnum";
+
+ mfLoghandler::singleton()->debug($sql);
+ if (is_array($limit) && count($limit)) {
+ if (is_numeric($limit['start']) && is_numeric($limit['count'])) {
+ $sql .= " LIMIT " . $limit['start'] . ", " . $limit['count'];
+ } elseif (is_numeric($count)) {
+ $sql .= " LIMIT " . $limit['count'];
+ }
+ }
+
+ $res = $db->query($sql);
+ if ($db->num_rows($res)) {
+ while ($data = $db->fetch_object($res)) {
+ $items[] = new XinonFibuMerge($data);
+ }
+ }
+ return $items;
+ }
+
+ private static function getSqlFilter($filter) {
+ $where = "1=1 ";
+
+
+
+ if(array_key_exists("old_custnum", $filter)) {
+ $old_custnum = $filter['old_custnum'];
+ if (is_numeric($old_custnum)) {
+ $where .= " AND XinonFibuMerge.old_custnum=$old_custnum";
+ }
+ }
+
+ if(array_key_exists("new_custnum", $filter)) {
+ $new_custnum = $filter['new_custnum'];
+ if (is_numeric($new_custnum)) {
+ $where .= " AND XinonFibuMerge.new_custnum=$new_custnum";
+ }
+ }
+
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+
+}
diff --git a/db/migrations/20231212142423_address_add_fibubillingnumber_suppliernumber.php b/db/migrations/20231212142423_address_add_fibubillingnumber_suppliernumber.php
new file mode 100644
index 000000000..8ec343038
--- /dev/null
+++ b/db/migrations/20231212142423_address_add_fibubillingnumber_suppliernumber.php
@@ -0,0 +1,37 @@
+getEnvironment() == "thetool") {
+ $table = $this->table("Address");
+ $table->addColumn("fibu_account_number","integer", ["null" => true, "default" => null, "after" => "customer_number"]);
+ $table->addColumn("fibu_supplier_number","integer", ["null" => true, "default" => null, "after" => "fibu_account_number"]);
+ $table->addColumn("fibu_primary_account","integer", ["null" => false, "default" => 0, "limit" => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, "after" => "fibu_supplier_number"]);
+ $table->update();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if($this->getEnvironment() == "thetool") {
+ $table = $this->table("Address");
+ $table->removeColumn("fibu_primary_account");
+ $table->removeColumn("fibu_supplier_number");
+ $table->removeColumn("fibu_account_number");
+ $table->save();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}
diff --git a/db/migrations/20231214141719_worker_permission_add_employee.php b/db/migrations/20231214141719_worker_permission_add_employee.php
new file mode 100644
index 000000000..013052ee5
--- /dev/null
+++ b/db/migrations/20231214141719_worker_permission_add_employee.php
@@ -0,0 +1,35 @@
+getEnvironment() == "thetool") {
+ $table = $this->table("WorkerPermission");
+ $table->addColumn("employee", "enum", ["values" => 'false,true', "default" => "false", "after" => "admin"]);
+ $table->addColumn("canFibu", "enum", ["values" => 'false,true', "default" => "false", "after" => "preorderlogistics"]);
+ $table->update();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if($this->getEnvironment() == "thetool") {
+ $table = $this->table("WorkerPermission");
+ $table->removeColumn("canFibu");
+ $table->removeColumn("employee");
+ $table->save();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}
diff --git a/public/assets/css/print.css b/public/assets/css/print.css
index 060b9e548..f7784fb07 100644
--- a/public/assets/css/print.css
+++ b/public/assets/css/print.css
@@ -9,8 +9,6 @@ and open the template in the editor.
*/
html {
- margin-left: 18pt;
- margin-right: 18pt;
height:100%;
}
@@ -21,6 +19,11 @@ body {
margin-top: 20pt;
}
+.container {
+ margin-left: 18pt;
+ margin-right: 18pt;
+}
+
.center {
text-align: center;
}
diff --git a/public/assets/images/rml-cif-cable-qr.png b/public/assets/images/rml-cif-cable-qr.png
new file mode 100644
index 000000000..9b089de4f
Binary files /dev/null and b/public/assets/images/rml-cif-cable-qr.png differ
diff --git a/public/assets/images/rml-logo-header.png b/public/assets/images/rml-logo-header.png
new file mode 100644
index 000000000..40baf8219
Binary files /dev/null and b/public/assets/images/rml-logo-header.png differ
diff --git a/public/assets/images/rml-preorderlogistic-footer.png b/public/assets/images/rml-preorderlogistic-footer.png
new file mode 100644
index 000000000..1e9b83939
Binary files /dev/null and b/public/assets/images/rml-preorderlogistic-footer.png differ