From 2b997611e20d7dba4f49a011f0e0cfde41b2d390 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 21 Nov 2023 17:56:15 +0100 Subject: [PATCH] Preorderlogistics QR Code WIP --- Layout/default/Preorderlogistics/Index.php | 8 +- Layout/default/Preorderlogistics/Print.php | 83 +++++- application/Preorder/PreorderModel.php | 8 +- .../Preorderlogistics/Preorderlogistics.php | 26 ++ .../PreorderlogisticsController.php | 19 +- .../PreorderlogisticsModel.php | 249 ++++++++++++++++++ ...0124014_create_preorderlogistics_table.php | 39 +++ public/assets/css/print.css | 4 +- public/assets/images/qr-placeholder.png | Bin 0 -> 1445 bytes 9 files changed, 425 insertions(+), 11 deletions(-) create mode 100644 application/Preorderlogistics/Preorderlogistics.php create mode 100644 application/Preorderlogistics/PreorderlogisticsModel.php create mode 100644 db/migrations/20231120124014_create_preorderlogistics_table.php create mode 100644 public/assets/images/qr-placeholder.png diff --git a/Layout/default/Preorderlogistics/Index.php b/Layout/default/Preorderlogistics/Index.php index dc1ca6157..307d3a3d9 100644 --- a/Layout/default/Preorderlogistics/Index.php +++ b/Layout/default/Preorderlogistics/Index.php @@ -97,8 +97,8 @@ - - + + @@ -145,7 +145,9 @@ diff --git a/Layout/default/Preorderlogistics/Print.php b/Layout/default/Preorderlogistics/Print.php index 30d74d258..b21bbd85f 100644 --- a/Layout/default/Preorderlogistics/Print.php +++ b/Layout/default/Preorderlogistics/Print.php @@ -1 +1,82 @@ -test \ No newline at end of file +setReturnValue([ + 'filename' => "ichwillglasfaser-versand-".$preorder->ucode.".pdf" + ]); +?> + + + + + Ichwillglasfaser Hausanschlussversand + + + + + + + + + +
+   +
+ + + +
+ +

Wichtige Information

+ +
+ +
+ company): ?> + company)?>
+ + lastname): ?> + firstname?> lastname?>
+ + street?>
+ zip?> city?> +
+ +
+ +
+

Sehr geehrte Damen und Herren,

+

Vielen Dank, dass Sie sich für einen Glasfaseranschluss entschieden haben.

+

In diesem Paket finden Sie das Lehrrohr, welches auf Ihrem Grundstück eingegrageb + werden muss.

+

Sobald die Lehrrohrinstallation Ihrerseits erledigt wurde, teilen Sie uns dies bitte mit. + Scannen Sie dazu einfach den folgenden QR-Code auf Ihrem Smartphone ein und bestätigen Sie + uns die Fertigstellung der Installation:

+
+ +
+ +
+ +
+ +
+ +
+

Sollten Sie noch Fragen haben wenden Sie sich bitte an Ihrem Internetprovider.

+
+ +
+ +
+

Mit besten Grüßen,

+ +

RML Infrastruktur Liezen

+
+ + + \ No newline at end of file diff --git a/application/Preorder/PreorderModel.php b/application/Preorder/PreorderModel.php index d41dbfc76..468b64778 100644 --- a/application/Preorder/PreorderModel.php +++ b/application/Preorder/PreorderModel.php @@ -465,10 +465,10 @@ class PreorderModel { } } - if(array_key_exists("cifcode", $filter)) { - $cifcode = FronkDB::singleton()->escape($filter['cifcode']); - if($cifcode) { - $where .= " AND cifcode LIKE '$cifcode'"; + if(array_key_exists("ciftoken", $filter)) { + $ciftoken = FronkDB::singleton()->escape($filter['ciftoken']); + if($ciftoken) { + $where .= " AND ciftoken LIKE '$ciftoken'"; } } diff --git a/application/Preorderlogistics/Preorderlogistics.php b/application/Preorderlogistics/Preorderlogistics.php new file mode 100644 index 000000000..9907b1d7a --- /dev/null +++ b/application/Preorderlogistics/Preorderlogistics.php @@ -0,0 +1,26 @@ +outputType = QROutputInterface::GDIMAGE_PNG; + $qr = new QRCode($qr_opts); + try { + $png_data = $qr->render("https://fronk.at/"); + } catch (Exception $ex) { + throw $ex; + } + + if(!$png_data) { + echo "Kein png data!";exit; + } + + var_dump($png_data); + exit; + + } +} \ No newline at end of file diff --git a/application/Preorderlogistics/PreorderlogisticsController.php b/application/Preorderlogistics/PreorderlogisticsController.php index bf0ebd08b..8a5eebfad 100644 --- a/application/Preorderlogistics/PreorderlogisticsController.php +++ b/application/Preorderlogistics/PreorderlogisticsController.php @@ -165,7 +165,7 @@ class PreorderlogisticsController extends mfBaseController { $this->layout()->setFlash("Vorbestellung nicht gefunden (3)", "error"); $this->redirect("Preorderlogistics"); } - var_dump($preorder->adb_hausnummer->netzgebiet_id, $user_network_ids); + //var_dump($preorder->adb_hausnummer->netzgebiet_id, $user_network_ids);exit; $network = NetworkModel::getFirst(["adb_network_id" => $preorder->adb_hausnummer->netzgebiet_id]); if(!$network) { @@ -186,10 +186,27 @@ class PreorderlogisticsController extends mfBaseController { $preorder->save(); } + $plog = PreorderlogisticsModel::getFirst(["preorder_id" => $preorder->id]); + if(!$plog) { + $plog = PreorderlogisticsModel::create([ + "preorder_id" => $preorder->id, + "sent" => 0 + ]); + if(!$plog->save()) { + $this->layout()->setFlash("Eintrag konnte nicht gespeichert werden"); + } + } + + + $this->layout()->set("preorder", $preorder); } + + private function setSentApi() { + + } } \ No newline at end of file diff --git a/application/Preorderlogistics/PreorderlogisticsModel.php b/application/Preorderlogistics/PreorderlogisticsModel.php new file mode 100644 index 000000000..ff2661f54 --- /dev/null +++ b/application/Preorderlogistics/PreorderlogisticsModel.php @@ -0,0 +1,249 @@ + $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("Building", "*", "$where ORDER BY network_id,pop_id,street,zip,city LIMIT 1"); + if ($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new Building($data); + if ($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function getAll() { + $items = []; + + $db = FronkDB::singleton(); + + $res = $db->select("Building", "*", "1=1 ORDER BY network_id,pop_id,street,zip,city"); + if ($db->num_rows($res)) { + while ($data = $db->fetch_object($res)) { + $items[] = new Building($data); + } + } + return $items; + } + + public static function count($filter) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT COUNT(*) as cnt FROM Building + LEFT JOIN Buildingtype ON (Buildingtype.id = Building.type_id) + LEFT JOIN Buildingstatus ON (Buildingstatus.id = Building.status_id) + 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 Building.* FROM Building + LEFT JOIN Buildingtype ON (Buildingtype.id = Building.type_id) + LEFT JOIN Buildingstatus ON (Buildingstatus.id = Building.status_id) + WHERE $where + ORDER BY network_id, pop_id, street, zip, city"; + + 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 Building($data); + } + } + return $items; + } + + private static function getSqlFilter($filter) { + $where = "1=1 "; + + if (array_key_exists("network_id", $filter)) { + $network_id = $filter['network_id']; + if (is_numeric($network_id)) { + $where .= " AND Building.network_id=$network_id"; + } elseif (is_array($network_id) && count($network_id)) { + $where .= " AND Building.network_id IN (" . implode(",", $network_id) . ")"; + } + } + + if (array_key_exists("networksection_id", $filter)) { + $networksection_id = $filter['networksection_id']; + if (is_numeric($networksection_id)) { + $where .= " AND Building.networksection_id=$networksection_id"; + } + } + + if (array_key_exists("status_id", $filter)) { + $status_id = $filter['status_id']; + if (is_numeric($status_id)) { + $where .= " AND Building.status_id=$status_id"; + } + } + + if (array_key_exists("pipeworker_id", $filter)) { + $pipeworker_id = $filter['pipeworker_id']; + if (is_numeric($pipeworker_id)) { + $where .= " AND Building.pipeworker_id=$pipeworker_id"; + } + } + + if (array_key_exists("type", $filter) && is_array($filter['type']) && count($filter['type'])) { + $ot = $filter['type']; + $in = []; + foreach ($ot as $type) { + $type = FronkDB::singleton()->escape($type); + $in[] = "Buildingtype.name = '$type'"; + } + + $or = ""; + if (count($in)) { + $or = implode(" OR ", $in); + $where .= " AND ( $or )"; + } + } + + if (array_key_exists("status", $filter)) { + if (in_array(substr($filter['status'], 1, 2), ["<=", ">="])) { + $op = substr($filter['status'], 1, 2); + $status = substr($filter['status'], 3); + } elseif (in_array(substr($filter['status'], 1, 1), ["<", ">"])) { + $op = substr($filter['status'], 1, 1); + $status = substr($filter['status'], 2); + } else { + $op = "="; + $status = $filter['status']; + } + + if (is_numeric($status)) { + $where .= " AND Buildingstatus.code $op $status"; + } else { + // get code of statusname + $code = Buildingstatus::getOne(["name" => $status]); + if ($code) { + $status = FronkDB::singleton()->escape($status); + $where .= " AND Buildingstatus.code $op '$status'"; + } + } + } + + if (array_key_exists("code", $filter)) { + $code = FronkDB::singleton()->escape($filter['code']); + if ($code) { + $where .= " AND Building.`code` like '%$code%'"; + } + } + + if (array_key_exists("oaid", $filter)) { + $oaid = FronkDB::singleton()->escape($filter['oaid']); + if ($oaid) { + $where .= " AND Building.`oaid` like '%$oaid%'"; + } + } + + if (array_key_exists("street", $filter)) { + $street = FronkDB::singleton()->escape($filter["street"]); + if ($street) { + $where .= " AND street like '%$street%'"; + } + } + + if (array_key_exists("=street", $filter)) { + $street = FronkDB::singleton()->escape($filter["=street"]); + if ($street) { + $where .= " AND street like '$street'"; + } + } + + if (array_key_exists("zip", $filter)) { + $zip = FronkDB::singleton()->escape($filter["zip"]); + if ($zip) { + $where .= " AND zip like '%$zip%'"; + } + } + + if (array_key_exists("=zip", $filter)) { + $zip = FronkDB::singleton()->escape($filter["=zip"]); + if ($zip) { + $where .= " AND zip like '$zip'"; + } + } + + if (array_key_exists("city", $filter)) { + $city = FronkDB::singleton()->escape($filter["city"]); + if ($city) { + $where .= " AND city like '%$city%'"; + } + } + + if (array_key_exists("=city", $filter)) { + $city = FronkDB::singleton()->escape($filter["=city"]); + if ($city) { + $where .= " AND city like '$city'"; + } + } + + //var_dump($filter, $where);exit; + return $where; + } + +} diff --git a/db/migrations/20231120124014_create_preorderlogistics_table.php b/db/migrations/20231120124014_create_preorderlogistics_table.php new file mode 100644 index 000000000..1ab4bd038 --- /dev/null +++ b/db/migrations/20231120124014_create_preorderlogistics_table.php @@ -0,0 +1,39 @@ +getEnvironment() == "thetool") { + $table = $this->table("Preorderlogistics"); + $table->addColumn("preorder_id", "integer", ["null" => false]); + $table->addColumn("sent", "integer", ["null" => false, "default" => 0]); + $table->addColumn("sent_by", "integer", ["null" => true, "default" => null]); + $table->addColumn("create_by", "integer", ["null" => false]); + $table->addColumn("edit_by", "integer", ["null" => false]); + $table->addColumn("create", "integer", ["null" => false]); + $table->addColumn("edit", "integer", ["null" => false]); + $table->create(); + + + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $this->table("Preorderlogistics")->drop()->save(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} diff --git a/public/assets/css/print.css b/public/assets/css/print.css index 0c88f0cfb..060b9e548 100644 --- a/public/assets/css/print.css +++ b/public/assets/css/print.css @@ -15,9 +15,9 @@ html { } body { - font-family: "Open Sans", "Dejavu Sans", dejavusans; + font-family: "Open Sans", "Dejavu Sans", dejavusans, sans-serif; font-size:11pt; - height:100%; + /*height:100%;*/ margin-top: 20pt; } diff --git a/public/assets/images/qr-placeholder.png b/public/assets/images/qr-placeholder.png new file mode 100644 index 0000000000000000000000000000000000000000..e89bdbedbeb85bb246f934bdb1983b7fb191950c GIT binary patch literal 1445 zcmeAS@N?(olHy`uVBq!ia0vp^OMrMO2OE&Q^fK%TkYXuz@(kesf*OvL4j^B$#5JNM zI6tkVJh3R1Aw4fYH&wSdxhOR?uQ(&W_vG^@|0iEsb0|fq ze$)4tXK%R1UN2>E`E%ndOT&Ia4-dr&6Py$jTOFLZ8e2q|I5k;>f;d!`{OPIu{Q7nF zj{W<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