made preorderlogistics working again
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
include_once(BASEDIR."/lib/QRCode/QRCode.php");
|
||||
use Apirone\Lib\PhpQrCode\QrCode;
|
||||
|
||||
class PreorderlogisticsController extends mfBaseController {
|
||||
|
||||
@@ -76,10 +78,16 @@ class PreorderlogisticsController extends mfBaseController {
|
||||
|
||||
$filter['network_id'] = $my_network_ids;
|
||||
|
||||
$filter["status_code"] = 140;
|
||||
// $filter["status_code"] = 140;
|
||||
//$filter["<status_code"] = 800;
|
||||
$filter["deleted"] = 0;
|
||||
$filter["connection_type"] = ["single-dwelling", "business"];
|
||||
$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 +227,14 @@ class PreorderlogisticsController extends mfBaseController {
|
||||
$this->layout()->setFlash("Eintrag konnte nicht gespeichert werden");
|
||||
}
|
||||
}
|
||||
|
||||
$qrimg = $plog->getCifQrPng($preorder->cifurl);
|
||||
|
||||
$this->layout()->set("qr_url", $qrimg);
|
||||
|
||||
$qrimg = $plog->getCifQrPng($preorder->cifurl);
|
||||
|
||||
$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];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user