Merge branch 'fronkdev' of code.fronk.at:fronk/thetool into fronkdev
This commit is contained in:
@@ -196,6 +196,38 @@ class Admin_RtrReporting {
|
||||
];
|
||||
}
|
||||
|
||||
public function activeVoiceNumbersReportAction() {
|
||||
$csv = "number_start;number_end;date_reported;type;csp;note\n";
|
||||
$today = new DateTime();
|
||||
$today_string = $today->format('Y-m-d');
|
||||
|
||||
foreach(VoicenumberModel::search(["contract_id" => true]) as $number) {
|
||||
//$ported = ($number->voicenumberblock_id) ? false : true;
|
||||
|
||||
if(in_array($number->number, [4331528575200,4331528575400,4331528575500]) ) {
|
||||
continue;
|
||||
}
|
||||
if(substr($number->number, 0, 9) == "437208004") continue;
|
||||
if(substr($number->number, 0, 8) == "43720102") continue;
|
||||
if(substr($number->number, 0, 8) == "43720103") continue;
|
||||
if(substr($number->number, 0, 10) == "4331154520") continue;
|
||||
|
||||
$csv .= $number->number.";";
|
||||
$csv .= $number->number.";";
|
||||
$csv .= $today_string.";";
|
||||
$csv .= "UA;";
|
||||
$csv .= ";";
|
||||
$csv .= ";\n";
|
||||
}
|
||||
|
||||
header("Content-type: text/csv; charset=utf-8");
|
||||
header('Content-disposition: attachment; filename="rtr-active-numbers-report-'.date('Y-m-d_H-i-s').'.csv"');
|
||||
|
||||
echo $csv;
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
public function a10reportAction() {
|
||||
// alle anschlüsse
|
||||
|
||||
|
||||
@@ -386,22 +386,46 @@ class ConstructionConsent extends mfBaseModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT
|
||||
ConstructionConsent.*,
|
||||
COALESCE(SUM(cwo.result = 'denied'), 0) AS denied_count,
|
||||
COALESCE(SUM(cwo.result = 'unresolvable'), 0) AS unresolvable_count,
|
||||
COALESCE(SUM(cwo.result = 'moved'), 0) AS moved_count,
|
||||
COALESCE(SUM(cwo.result = 'accepted'), 0) AS accepted_count,
|
||||
COUNT(cwo.id) AS total_owners,
|
||||
CASE
|
||||
WHEN COALESCE(SUM(cwo.result = 'denied'), 0) > 0 THEN 'red'
|
||||
WHEN COALESCE(SUM(cwo.result = 'unresolvable'), 0) > 0
|
||||
OR COALESCE(SUM(cwo.result = 'moved'), 0) > 0 THEN 'yellow'
|
||||
WHEN COALESCE(SUM(cwo.result = 'accepted'), 0) = COUNT(cwo.id)
|
||||
AND COUNT(cwo.id) > 0 THEN 'green'
|
||||
ELSE 'blue'
|
||||
END AS status_light
|
||||
FROM ConstructionConsent
|
||||
$sql = "SELECT ConstructionConsent.*,
|
||||
COALESCE(SUM(CASE
|
||||
WHEN ConstructionConsent.approve_override = 1 THEN 0
|
||||
ELSE (cwo.result = 'denied')
|
||||
END), 0) AS denied_count,
|
||||
COALESCE(SUM(CASE
|
||||
WHEN ConstructionConsent.approve_override = 1 THEN 0
|
||||
ELSE (cwo.result = 'unresolvable')
|
||||
END), 0) AS unresolvable_count,
|
||||
COALESCE(SUM(CASE
|
||||
WHEN ConstructionConsent.approve_override = 1 THEN 0
|
||||
ELSE (cwo.result = 'moved')
|
||||
END), 0) AS moved_count,
|
||||
COALESCE(SUM(CASE
|
||||
WHEN ConstructionConsent.approve_override = 1 THEN 1
|
||||
ELSE (cwo.result = 'accepted')
|
||||
END), 0) AS accepted_count,
|
||||
COUNT(cwo.id) AS total_owners,
|
||||
CASE
|
||||
WHEN ConstructionConsent.approve_override = 1 THEN 'green'
|
||||
WHEN COALESCE(SUM(CASE
|
||||
WHEN approve_override = 1 THEN 0
|
||||
ELSE (cwo.result = 'denied')
|
||||
END), 0) > 0 THEN 'red'
|
||||
WHEN COALESCE(SUM(CASE
|
||||
WHEN approve_override = 1 THEN 0
|
||||
ELSE (cwo.result = 'unresolvable')
|
||||
END), 0) > 0
|
||||
OR COALESCE(SUM(CASE
|
||||
WHEN approve_override = 1 THEN 0
|
||||
ELSE (cwo.result = 'moved')
|
||||
END), 0) > 0 THEN 'yellow'
|
||||
WHEN COALESCE(SUM(CASE
|
||||
WHEN approve_override = 1 THEN 1
|
||||
ELSE (cwo.result = 'accepted')
|
||||
END), 0) = COUNT(cwo.id)
|
||||
AND COUNT(cwo.id) > 0 THEN 'green'
|
||||
ELSE 'blue'
|
||||
END AS status_light
|
||||
FROM ConstructionConsent
|
||||
LEFT JOIN ConstructionConsentOwner cwo ON ConstructionConsent.id = cwo.constructionconsent_id
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer vh ON ConstructionConsent.adb_hausnummer_id = vh.hausnummer_id
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Strasse vs ON ConstructionConsent.adb_strasse_id = vs.id
|
||||
@@ -437,6 +461,8 @@ class ConstructionConsent extends mfBaseModel {
|
||||
$project_id = $filter['project_id'];
|
||||
if(is_numeric($project_id)) {
|
||||
$where .= " AND ConstructionConsent.constructionconsentproject_id=$project_id";
|
||||
} else if (is_array($project_id)) {
|
||||
$where .= " AND ConstructionConsent.constructionconsentproject_id IN (".implode(",", $project_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,11 @@ class ConstructionConsentController extends mfBaseController {
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908,2187]))) $this->redirect("Dashboard");
|
||||
if ($this->me->is("Admin")) $this->constructionConsentProjects = array_column(ConstructionConsentProject::getAll(), 'id');
|
||||
else {
|
||||
$constructionConsentProjects = json_decode((new WorkerFlag($this->me->id, "constructionConsent_projects"))->value() ?? '[]');
|
||||
empty($constructionConsentProjects) ? $this->redirect("Dashboard") : $this->constructionConsentProjects = $constructionConsentProjects;
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction() : void {
|
||||
@@ -54,6 +58,7 @@ class ConstructionConsentController extends mfBaseController {
|
||||
|
||||
//var_dump($_SESSION, $filter);exit;
|
||||
|
||||
$this->layout->set("allowed_projects", $this->constructionConsentProjects);
|
||||
$this->layout->set("filter", $filter);
|
||||
$filter = $this->getPreparedFilter($filter);
|
||||
|
||||
@@ -93,13 +98,20 @@ class ConstructionConsentController extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($new_filter['project_id']) && !in_array($new_filter['project_id'], $this->constructionConsentProjects) && strlen($new_filter['project_id']) > 0) {
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
if (empty($new_filter['project_id'])) {
|
||||
$new_filter['project_id'] = $this->constructionConsentProjects;
|
||||
}
|
||||
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
protected function viewAction() : void {
|
||||
$this->layout()->setTemplate("ConstructionConsent/View");
|
||||
$this->layout()->set("is_admin", $this->me->isAdmin());
|
||||
|
||||
$id = $this->request->id;
|
||||
if(!is_numeric($id) || $id < 1) {
|
||||
@@ -108,7 +120,7 @@ class ConstructionConsentController extends mfBaseController {
|
||||
}
|
||||
|
||||
$item = new ConstructionConsent($id);
|
||||
if(!$item || !$item->id) {
|
||||
if(!$item || !$item->id || !in_array($item->constructionconsentproject_id, $this->constructionConsentProjects)) {
|
||||
$this->layout()->setFlash("Zustimmungserklärung nicht gefunden", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
@@ -121,6 +133,7 @@ class ConstructionConsentController extends mfBaseController {
|
||||
if($this->request->project_id) {
|
||||
$this->layout()->set("project_id", $this->request->project_id);
|
||||
}
|
||||
$this->layout()->set("allowed_projects", $this->constructionConsentProjects);
|
||||
}
|
||||
|
||||
protected function editAction() : void {
|
||||
@@ -224,7 +237,10 @@ class ConstructionConsentController extends mfBaseController {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
//var_dump($r->get());exit;
|
||||
if (!in_array($r->constructionconsentproject_id, $this->constructionConsentProjects)) {
|
||||
$this->layout()->setFlash("Sie haben keine Berechtigung für dieses Projekt", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data["constructionconsentproject_id"] = $r->constructionconsentproject_id;
|
||||
@@ -1012,4 +1028,20 @@ class ConstructionConsentController extends mfBaseController {
|
||||
"status_light_green" => getFilteredCount("status_light", "green", $baseFilter)
|
||||
];
|
||||
}
|
||||
|
||||
protected function approveOverrideAction() {
|
||||
$consent_id = $this->request->consent_id;
|
||||
$checked = $this->request->checked;
|
||||
|
||||
$consent = new ConstructionConsent($consent_id);
|
||||
if(!$consent->id) {
|
||||
$this->returnJson(["status" => "error"]);
|
||||
}
|
||||
|
||||
$consent->update(["approve_override" => $checked]);
|
||||
$consent->save();
|
||||
|
||||
$this->returnJson(["status" => "OK"]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
class ConstructionConsentContact extends mfBaseModel {
|
||||
protected $forcestr = ["zip", "name", "phone", "fax", "email"];
|
||||
private $consent;
|
||||
|
||||
protected function beforeUpdate($data) {
|
||||
@@ -187,4 +188,4 @@ class ConstructionConsentContact extends mfBaseModel {
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,11 @@ class ConstructionConsentContactController extends mfBaseController
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $this->redirect("Dashboard");
|
||||
if ($this->me->is("Admin")) $this->constructionConsentProjects = array_column(ConstructionConsentProject::getAll(), 'id');
|
||||
else {
|
||||
$constructionConsentProjects = json_decode((new WorkerFlag($this->me->id, "constructionConsent_projects"))->value() ?? '[]');
|
||||
empty($constructionConsentProjects) ? $this->redirect("Dashboard") : $this->constructionConsentProjects = $constructionConsentProjects;
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveAction()
|
||||
@@ -38,6 +42,11 @@ class ConstructionConsentContactController extends mfBaseController
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
if (!in_array($cc->constructionconsentproject_id, $this->constructionConsentProjects)) {
|
||||
$this->layout()->setFlash("Sie sind nicht berechtigt, diese Zustimmungserklärung zu bearbeiten", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data["constructionconsent_id"] = $cc_id;
|
||||
$data["type"] = $r->type;
|
||||
@@ -88,6 +97,11 @@ class ConstructionConsentContactController extends mfBaseController
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
if (!in_array($cc->constructionconsentproject_id, $this->constructionConsentProjects)) {
|
||||
$this->layout()->setFlash("Sie sind nicht berechtigt, diese Zustimmungserklärung zu bearbeiten", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$contact->delete();
|
||||
|
||||
$this->layout()->setFlash("Ansprechpartner wurde gelöscht.", "success");
|
||||
|
||||
@@ -70,14 +70,14 @@ class ConstructionConsentHistory extends mfBaseModel {
|
||||
return "Nutzung Schacht/Verteiler/Abschluss";
|
||||
case "usage_owner":
|
||||
return "Nutzung Eigenvers. GE";
|
||||
|
||||
case "approve_override":
|
||||
return "Genehmigung überschreiben";
|
||||
case "rimo_plan":
|
||||
return "Plan/Skizze aus Rimo";
|
||||
case "plan_upload":
|
||||
return "Plan/Skizze Upload";
|
||||
case "constructionconsentproject_id":
|
||||
return "Projekt";
|
||||
|
||||
case "inspection_planner":
|
||||
return "Status Begehung mit Planer";
|
||||
case "inspection_electrician";
|
||||
|
||||
@@ -9,7 +9,11 @@ class ConstructionConsentJournalController extends mfBaseController {
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $this->redirect("Dashboard");
|
||||
if ($this->me->is("Admin")) $this->constructionConsentProjects = array_column(ConstructionConsentProject::getAll(), 'id');
|
||||
else {
|
||||
$constructionConsentProjects = json_decode((new WorkerFlag($this->me->id, "constructionConsent_projects"))->value() ?? '[]');
|
||||
empty($constructionConsentProjects) ? $this->redirect("Dashboard") : $this->constructionConsentProjects = $constructionConsentProjects;
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
@@ -28,6 +32,11 @@ class ConstructionConsentJournalController extends mfBaseController {
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
if (!in_array($consent->constructionconsentproject_id, $this->constructionConsentProjects)) {
|
||||
$this->layout()->setFlash("Sie sind nicht berechtigt, diese Zustimmungserklärung zu bearbeiten", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$text = trim(htmlentities($r->text));
|
||||
if(!$text) {
|
||||
$this->layout()->setFlash("Bitte Text eingeben", "error");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
class ConstructionConsentOwner extends mfBaseModel {
|
||||
protected $forcestr = ["zip", "phone", "phone2", "fax", "email"];
|
||||
private $consent;
|
||||
private $files;
|
||||
private $result_file;
|
||||
|
||||
@@ -11,19 +11,25 @@ class ConstructionConsentOwnerController extends mfBaseController
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908,2187]))) $this->redirect("Dashboard");
|
||||
if ($this->me->is("Admin")) $this->constructionConsentProjects = array_column(ConstructionConsentProject::getAll(), 'id');
|
||||
else {
|
||||
$constructionConsentProjects = json_decode((new WorkerFlag($this->me->id, "constructionConsent_projects"))->value() ?? '[]');
|
||||
empty($constructionConsentProjects) ? $this->redirect("Dashboard") : $this->constructionConsentProjects = $constructionConsentProjects;
|
||||
}
|
||||
}
|
||||
|
||||
protected function uploadDocumentAction() {
|
||||
$owner_id = $this->request->owner_id;
|
||||
$filename = trim($this->request->name);
|
||||
|
||||
$owner = new ConstructionConsentOwner($owner_id);
|
||||
if(!$owner->id) {
|
||||
$this->layout()->setFlash("Besitzer nicht gefunden!", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$constructionConsent = new ConstructionConsent($owner->constructionconsent_id);
|
||||
$filename = "ZU_KG" . $constructionConsent->kg . "_EZ" . $constructionConsent->ez . "_GST" . $constructionConsent->gst . "_" . $constructionConsent->name . "_" . $owner->lastname . ".pdf";
|
||||
$_FILES['consentOwnerUpload']['name'] = $filename;
|
||||
|
||||
if(is_array($_FILES) && array_key_exists("consentOwnerUpload", $_FILES) && !$_FILES['consentOwnerUpload']['error']) {
|
||||
try {
|
||||
// returns File object or throws Exception on error
|
||||
@@ -76,6 +82,11 @@ class ConstructionConsentOwnerController extends mfBaseController
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
if (!in_array($cc->constructionconsentproject_id, $this->constructionConsentProjects)) {
|
||||
$this->layout()->setFlash("Sie sind nicht berechtigt, diese Zustimmungserklärung zu bearbeiten", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data["constructionconsent_id"] = $cc_id;
|
||||
$data["title"] = $r->title;
|
||||
@@ -128,6 +139,11 @@ class ConstructionConsentOwnerController extends mfBaseController
|
||||
|
||||
$consent = $owner->consent;
|
||||
|
||||
if (!in_array($consent->constructionconsentproject_id, $this->constructionConsentProjects)) {
|
||||
$this->layout()->setFlash("Sie sind nicht berechtigt, diese Zustimmungserklärung zu bearbeiten", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
foreach($owner->files as $file) {
|
||||
$file->file->delete();
|
||||
$file->delete();
|
||||
@@ -207,4 +223,23 @@ class ConstructionConsentOwnerController extends mfBaseController
|
||||
return ["message" => "Result saved successfully", "update" => ["id" => $owner->id, "result" => $owner->result, "result_text" => __($owner->result, "consent")]];
|
||||
|
||||
}
|
||||
|
||||
protected function searchOwnerAction() {
|
||||
$search = $this->request->search;
|
||||
|
||||
$results = PreorderModel::search(['add-where' => " AND firstname LIKE '%$search%' OR lastname LIKE '%$search%'"]);
|
||||
self::returnJson(array_map(function($result) {
|
||||
return [
|
||||
'id' => $result->id,
|
||||
'firstname' => $result->firstname,
|
||||
'lastname' => $result->lastname,
|
||||
'street' => $result->street,
|
||||
'zip' => $result->zip,
|
||||
'city' => $result->city,
|
||||
'phone' => $result->phone,
|
||||
'email' => $result->email,
|
||||
'text' => $result->firstname . " " . $result->lastname . " (" . $result->street . ", " . $result->zip . " " . $result->city . ") [" . $result->phone . " | " . $result->email . "]"
|
||||
];
|
||||
}, $results));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,21 +152,16 @@ class ConstructionConsentProject extends mfBaseModel {
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM ConstructionConsentProject
|
||||
LEFT JOIN ConstructionConsentNetwork ON (ConstructionConsentNetwork.constructionconsentproject_id = ConstructionConsentNetwork.id)
|
||||
WHERE $where
|
||||
GROUP BY ConstructionConsentProject.id
|
||||
";
|
||||
$sql = "SELECT COUNT(*) AS cnt FROM ConstructionConsentProject WHERE $where";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
$result = $db->query($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
if ($result && $db->num_rows($result) > 0) {
|
||||
$data = $db->fetch_object($result);
|
||||
return (int)$data->cnt;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -217,6 +212,22 @@ class ConstructionConsentProject extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("id", $filter)) {
|
||||
if(is_numeric($filter["id"])) {
|
||||
$where .= " AND ConstructionConsentProject.id = ".$filter["id"];
|
||||
} elseif(is_array($filter["id"])) {
|
||||
$ids = [];
|
||||
foreach($filter["id"] as $id) {
|
||||
if(is_numeric($id)) {
|
||||
$ids[] = $id;
|
||||
}
|
||||
}
|
||||
if(count($ids)) {
|
||||
$where .= " AND ConstructionConsentProject.id IN (".implode(",", $ids).")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
|
||||
@@ -10,45 +10,39 @@ class ConstructionConsentProjectController extends mfBaseController {
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908,2187]))) $this->redirect("Dashboard");
|
||||
if ($this->me->is("Admin")) $this->constructionConsentProjects = array_column(ConstructionConsentProject::getAll(), 'id');
|
||||
else {
|
||||
$constructionConsentProjects = json_decode((new WorkerFlag($this->me->id, "constructionConsent_projects"))->value() ?? '[]');
|
||||
empty($constructionConsentProjects) ? $this->redirect("Dashboard") : $this->constructionConsentProjects = $constructionConsentProjects;
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction() : void {
|
||||
$this->layout()->setTemplate("ConstructionConsentProject/Index");
|
||||
$sessionKey = MFAPPNAME . '-ConstructionConsentProject-filter';
|
||||
|
||||
if ($this->request->resetFilter) {
|
||||
unset($_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter']);
|
||||
unset($_SESSION[$sessionKey]);
|
||||
}
|
||||
|
||||
$filter = [];
|
||||
if (is_array($this->request->filter)) {
|
||||
$filter = $this->request->filter;
|
||||
$_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter'] = $filter;
|
||||
} else {
|
||||
if (array_key_exists(MFAPPNAME . '-ConstructionConsentProject-filter', $_SESSION) && count($_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter'])) {
|
||||
$filter = $_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter'];
|
||||
}
|
||||
$filter = is_array($this->request->filter)
|
||||
? $this->request->filter
|
||||
: $_SESSION[$sessionKey] ?? [];
|
||||
|
||||
if (isset($this->request->filter)) {
|
||||
$_SESSION[$sessionKey] = $filter;
|
||||
}
|
||||
|
||||
$this->layout->set("filter", $filter);
|
||||
$filter = $this->getPreparedFilter($filter);
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 25;
|
||||
$pagination['maxItems'] = 0;
|
||||
|
||||
if (is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
//var_dump($filter);exit;
|
||||
$pagination['maxItems'] = ConstructionConsentProject::count($filter);
|
||||
|
||||
$projects = ConstructionConsentProject::getAll();
|
||||
$this->layout()->set("projects", $projects);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
$prepared = $this->getPreparedFilter($filter);
|
||||
$prepared["id"] = $this->constructionConsentProjects;
|
||||
|
||||
$this->layout()->setTemplate("ConstructionConsentProject/Index");
|
||||
$this->layout()->set("filter", $filter);
|
||||
$this->layout()->set("projects", ConstructionConsentProject::search($prepared));
|
||||
$this->layout()->set("pagination", [
|
||||
'start' => (int)($this->request->s ?? 0),
|
||||
'count' => 25,
|
||||
'maxItems' => ConstructionConsentProject::count($prepared)
|
||||
]);
|
||||
}
|
||||
|
||||
private function getPreparedFilter($filter) {
|
||||
|
||||
@@ -343,7 +343,7 @@ class PreorderModel
|
||||
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)) {
|
||||
} elseif (is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT " . $limit['count'];
|
||||
}
|
||||
}
|
||||
@@ -623,6 +623,18 @@ class PreorderModel
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("preorder_status_flags_disabled", $filter)) {
|
||||
$preorder_status_flags_disabled = $filter['preorder_status_flags_disabled'];
|
||||
if (is_array($preorder_status_flags_disabled) && count($preorder_status_flags_disabled)) {
|
||||
$where .= " AND tt_preorder.id NOT IN (
|
||||
SELECT psv.preorder_id
|
||||
FROM `" . FRONKDB_DBNAME . "`.PreorderStatusflagValue psv
|
||||
WHERE psv.flag_id IN (" . implode(',', $preorder_status_flags_disabled) . ")
|
||||
AND psv.value = 1
|
||||
)";
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("created_from", $filter)) {
|
||||
$created_from = $filter['created_from'];
|
||||
if (is_numeric($created_from)) {
|
||||
@@ -955,12 +967,26 @@ class PreorderModel
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("unit_count>=", $filter)) {
|
||||
$unit_count = $filter['unit_count>='];
|
||||
if (is_numeric($unit_count)) {
|
||||
$where .= " AND adb_hausnummer.unit_count >= $unit_count";
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("unit_count<=", $filter)) {
|
||||
$unit_count = $filter['unit_count<='];
|
||||
if (is_numeric($unit_count)) {
|
||||
$where .= " AND adb_hausnummer.unit_count <= $unit_count";
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("sent", $filter)) {
|
||||
$sent = $filter['sent'];
|
||||
if ($sent) {
|
||||
$where .= " AND sent > 0";
|
||||
$where .= " AND Preorderlogistics.sent > 0";
|
||||
} else {
|
||||
$where .= " AND (sent = 0 OR sent IS NULL)";
|
||||
$where .= " AND (Preorderlogistics.sent = 0 OR Preorderlogistics.sent IS NULL)";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,53 +1,9 @@
|
||||
<?php
|
||||
|
||||
//use \chillerlan\QRCode;
|
||||
use chillerlan\QRCode\QRCode;
|
||||
use chillerlan\QRCode\QROptions;
|
||||
use chillerlan\QRCode\Output\QROutputInterface;
|
||||
|
||||
class Preorderlogistics extends mfBaseModel {
|
||||
private $qrfilename;
|
||||
private $preorder;
|
||||
|
||||
|
||||
public function getCifQrPng($content) {
|
||||
/*$filename = $this->getProperty("qrfilename");
|
||||
if(!$filename) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$qrpath = MFUPLOAD_FILE_SAVE_PATH."/".TT_PREORDER_CIF_QR_SUBFOLDER."/$filename";
|
||||
var_dump($qrpath);*/
|
||||
$img = $this->generateCifQrFile($content);
|
||||
|
||||
return $img;
|
||||
}
|
||||
|
||||
public function generateCifQrFile($content) {
|
||||
$qr_opts = new QROptions();
|
||||
$qr_opts->outputType = QROutputInterface::GDIMAGE_PNG;
|
||||
$qr = new QRCode($qr_opts);
|
||||
try {
|
||||
$png_data = $qr->render($content);
|
||||
} catch (Exception $ex) {
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
if(!$png_data) {
|
||||
echo "Kein png data!";exit;
|
||||
}
|
||||
/*
|
||||
$filename = $this->getProperty("qrfilename");
|
||||
$qrpath = MFUPLOAD_FILE_SAVE_PATH."/".TT_PREORDER_CIF_QR_SUBFOLDER."/$filename";
|
||||
|
||||
$data_parts = explode(",", $png_data);
|
||||
file_put_contents($qrpath, base64_decode($data_parts[1]));
|
||||
*/
|
||||
return $png_data;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
include_once(BASEDIR."/lib/QRCode/QRCode.php");
|
||||
use Apirone\Lib\PhpQrCode\QrCode;
|
||||
|
||||
class PreorderlogisticsController extends mfBaseController {
|
||||
|
||||
@@ -79,7 +81,15 @@ class PreorderlogisticsController extends mfBaseController {
|
||||
$filter["status_code"] = 140;
|
||||
//$filter["<status_code"] = 800;
|
||||
$filter["deleted"] = 0;
|
||||
$filter["connection_type"] = ["single-dwelling", "business"];
|
||||
//$filter["connection_type"] = ["single-dwelling", "business"];
|
||||
$filter["unit_count<="] = 2;
|
||||
|
||||
$installation_kit_status_flag = PreorderStatusflagModel::getFirst(["code" => "145"]);
|
||||
if ($filter['sent'] !== true) {
|
||||
$filter["preorder_status_flags_disabled"] = [$installation_kit_status_flag->id];
|
||||
} else {
|
||||
$filter["preorder_status_flags"] = [$installation_kit_status_flag->id];
|
||||
}
|
||||
$pagination['maxItems'] = PreorderModel::countWithLogistics($filter);
|
||||
$preorders = PreorderModel::searchWithLogistics($filter, $pagination);
|
||||
|
||||
@@ -219,10 +229,12 @@ class PreorderlogisticsController extends mfBaseController {
|
||||
$this->layout()->setFlash("Eintrag konnte nicht gespeichert werden");
|
||||
}
|
||||
}
|
||||
|
||||
$qrimg = $plog->getCifQrPng($preorder->cifurl);
|
||||
|
||||
$this->layout()->set("qr_url", $qrimg);
|
||||
|
||||
$qr = QRCode::init($preorder->cifurl); // $data & $options are optional
|
||||
|
||||
$image_encoded = $qr->base64();
|
||||
|
||||
$this->layout()->set("qr_url", $image_encoded);
|
||||
$this->layout()->set("preorder", $preorder);
|
||||
|
||||
}
|
||||
@@ -253,9 +265,7 @@ class PreorderlogisticsController extends mfBaseController {
|
||||
|
||||
|
||||
private function saveSentApi() {
|
||||
if(!$this->me->is(["Preorderlogistics"])) {
|
||||
return false;
|
||||
}
|
||||
if(!$this->me->is(["Preorderlogistics"])) return false;
|
||||
|
||||
$preorder_id = $this->request->id;
|
||||
if(!is_numeric($preorder_id) || $preorder_id < 1) {
|
||||
@@ -276,28 +286,38 @@ class PreorderlogisticsController extends mfBaseController {
|
||||
|
||||
$sent = intval($this->request->sent);
|
||||
if($sent < 0 || $sent > 1) return false;
|
||||
|
||||
$installation_kit_status_flag = PreorderStatusflagModel::getFirst(["code" => "145"]);
|
||||
$flagvalue = PreorderStatusflagValueModel::getFirst(["preorder_id" => $preorder_id, "flag_id" => $installation_kit_status_flag->id]);
|
||||
// var_dump($flagvalue);
|
||||
// exit;
|
||||
if(!$flagvalue) {
|
||||
$flagvalue = PreorderStatusflagValueModel::create([
|
||||
"preorder_id" => $preorder_id,
|
||||
"flag_id" => $installation_kit_status_flag->id
|
||||
]);
|
||||
}
|
||||
$value = ($sent) ? 1 : 0;
|
||||
$flagvalue->value = $value;
|
||||
try {
|
||||
if(!$flagvalue->save()) {
|
||||
return false;
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->log->debug($e->getTraceAsString());
|
||||
die("hi");
|
||||
}
|
||||
|
||||
if($sent) {
|
||||
$plog->sent_by = $this->me->id;
|
||||
$plog->sent = date('U');
|
||||
|
||||
$new_status = PreorderstatusModel::getFirst(["code" => 145]);
|
||||
|
||||
if($preorder->status->code < $new_status->code) {
|
||||
$plog->prev_status_code = $preorder->status->code;
|
||||
$preorder->status_id = $new_status->id;
|
||||
$preorder->save();
|
||||
}
|
||||
|
||||
} else {
|
||||
$plog->sent_by = null;
|
||||
$plog->sent = 0;
|
||||
|
||||
|
||||
}
|
||||
if(!$plog->save()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!$plog->save()) return false;
|
||||
return ["preorder_id" => $preorder->id];
|
||||
}
|
||||
}
|
||||
@@ -286,6 +286,13 @@ class UserController extends mfBaseController
|
||||
$pn->delete();
|
||||
}
|
||||
|
||||
$constructionConsentProjects = $user->getFlag("constructionConsent_projects");
|
||||
if (is_array($r->constructionconsent_projects) && count($r->constructionconsent_projects)) {
|
||||
$constructionConsentProjects->value(json_encode($r->constructionconsent_projects));
|
||||
$constructionConsentProjects->save();
|
||||
} else {
|
||||
$constructionConsentProjects->delete();
|
||||
}
|
||||
|
||||
// employee number
|
||||
$enum = new WorkerFlag($user->id, "employee_number");
|
||||
|
||||
@@ -50,11 +50,13 @@ class WarehouseShippingNoteController extends TTCrud {
|
||||
}
|
||||
|
||||
protected function beforeUpdate($postData): bool {
|
||||
if (!$this->user->can('WarehouseAdmin')) {
|
||||
$this->validate($postData, [
|
||||
fn($p) => !in_array(WarehouseShippingNoteModel::get($p['id'])->status,
|
||||
['accepted', 'invoiced']) ?: 'Änderungen nicht mehr möglich',
|
||||
fn($p) => $this->validateHours($p['hoursEntries'])
|
||||
]);
|
||||
}
|
||||
$postData['positions'] = json_encode($postData['positions']);
|
||||
(new WarehouseHistoryController)->create($postData, $this->mod);
|
||||
return true;
|
||||
@@ -187,6 +189,11 @@ class WarehouseShippingNoteController extends TTCrud {
|
||||
$position['articleDescription'] = "";
|
||||
$position['articleUnit'] = 'Stk.';
|
||||
$positions[] = $position;
|
||||
} elseif (isset($position['article_text'])) {
|
||||
$position['articleTitle'] = $position['article_text'];
|
||||
$position['articleDescription'] = "";
|
||||
$position['articleUnit'] = 'Stk.';
|
||||
$positions[] = $position;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user