made preorderlogistics working again
This commit is contained in:
@@ -184,7 +184,11 @@
|
||||
function(success) {
|
||||
console.log(success);
|
||||
if(success.status == "OK") {
|
||||
$("#sent-label-" + success.result.preorder_id).show();
|
||||
if(checked) {
|
||||
$("#sent-label-" + success.result.preorder_id).show();
|
||||
} else {
|
||||
$("#sent-label-" + success.result.preorder_id).hide();
|
||||
}
|
||||
}
|
||||
},
|
||||
"json"
|
||||
|
||||
@@ -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)) {
|
||||
@@ -958,9 +970,9 @@ class PreorderModel
|
||||
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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -220,9 +228,13 @@ class PreorderlogisticsController extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
$qrimg = $plog->getCifQrPng($preorder->cifurl);
|
||||
$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) {
|
||||
@@ -277,27 +287,37 @@ 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];
|
||||
}
|
||||
}
|
||||
1802
lib/QRCode/QRCode.php
Normal file
1802
lib/QRCode/QRCode.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user