���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /var/www/nitsch.de/wp-includes/php-compat/classes.zip
���ѧ٧ѧ�
PK ! )6^/ customer.class.phpnu ��̗� <?php class Customer{ private $sql = false; private $mailer = false; function __construct(){ global $sql; $this->sql = $sql; global $mailer; $this->mailer = $mailer; } /** * Add Customer * @param object $p * @return boolean */ public function add($p){ $color = generateLightColor(); return $this->sql->insert('customer','customerNr,company,name,firstName,email,phone,color,created,changed',[$p->customerNr,$p->company,$p->name,$p->firstName,$p->email,$p->phone,$color,NOW,NOW]); } /** * Change Customer * @param object $p * @return boolean */ public function change($p){ return $this->sql->update('customer','customerNr,company,name,firstName,email,phone,color,changed',[$p->customerNr,$p->company,$p->name,$p->firstName,$p->email,$p->phone,$p->color,NOW],'id=?',$p->customerID); } /** * Get all Customers * @return array */ public function getAll(){ return $this->sql->select('c.id, c.customerNr,c.company, c.name, c.firstName,IF(c.company != "",c.company,CONCAT(c.firstName," ",c.name)) AS nameShow, c.email, c.phone, c.color, count(p.id) AS countProducts','customer c LEFT JOIN product p ON c.id = p.customerID GROUP BY c.id ORDER BY c.company ASC'); } /** * Get Customer by ID * @param int $customerID * @return object */ public function getCustomer($customerID){ return $this->sql->select('id, loginActive, customerNr, company, name, firstName,IF(company != "",company,CONCAT(firstName," ",name)) AS nameShow, email, phone, color','customer','id=?',$customerID,1); } /** * Login Active * @param object $p * @return boolean */ public function loginActive($p){ $customer = $this->getCustomer($p->customerID); $pw = createStr(20, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*()_+'); $password = $this->createHash($pw); $customer->email = 'jt@kockzius.de'; $hash = md5(date('YmdHis').mt_rand(0,999999)); if($this->sql->insert('customer_login','customerID,email,firstName,name,rights,hash,active,password,forceChangePW,color',[$p->customerID,$customer->email,$customer->firstName,$customer->name,1,$hash,1,$password,1,$customer->color])){ $this->sendPwMail($customer,$pw); return $this->sql->update('customer','loginActive,changed',[1,NOW],'id=?',$p->customerID); } return false; } /** * Send Password Mail * @param object $p * @param string $pw * @return boolean */ private function sendPwMail($p,$pw){ $subject = 'Ihr Zugang für das Kockzius Kundenportal'; $message = '<p>Hallo '.$p->firstName.' '.$p->name.',<br /><br /> wir haben einen Account für Sie angelegt.<br /> Ihr Benutzername lautet: '.$p->email.'<br /> Ihr Passwort lautet: '.$pw.'</p> <p>Nach dem Login müssen Sie Ihr Passwort ändern.</p> <p><a href="https://kunde.kockzius.de/">Zum Login</a><br /></p> Viele Grüße<br /> Ihre Firma Kockzius'; return $this->mailer->myMail($p->email,$subject,$message); } private function createHash($input){ $hash = hash('whirlpool', $input); return hash('sha256', $hash); } } ?>PK ! /ۢ�@ @ scss.class.phpnu ��̗� <?php use ScssPhp\ScssPhp\Compiler; class SCSS{ public function makeCache($scssDo,$scssFile,$dir='gen/'){ if(!isset($scssDo,$scssFile)) die(); $scss = new Compiler(); $scss->setImportPaths(CSSPATH); $scss->setFormatter('ScssPhp\ScssPhp\Formatter\Crunched'); $_css = ''; foreach($scssDo AS $file) $_css .= file_get_contents(CSSPATH.$file.'.scss'); $css = $scss->compile($_css); file_put_contents(CSSPATH.$dir.$scssFile.'.css',$css); } public function getCache($scssFile,$dir='gen/'){ return file_get_contents(CSSPATH.$dir.$scssFile.'.css'); } }PK ! ���l� � session.class.phpnu ��̗� <?php class Session{ private $sql = false; function __construct() { global $sql; $this->sql = $sql; } /** * get Order Material Inspection * @param int $sessionID * @return object */ public function getOrderMaterialInspection($sessionID){ $ordermaterialinspection = $this->sql->select('o.amountIs','order_material_inspection o','o.sessionID=? ',[$sessionID]); return $ordermaterialinspection; } /** * get Order Part * @param int $sessionID * @return object */ public function getOrderPart($sessionID){ $orderpart = $this->sql->select('pbp.name, p.badpartID, SUM(p.amount) AS amount','order_part p, product_badpart pbp','pbp.id = p.badpartID AND p.sessionID=? GROUP BY badpartID',[$sessionID]); return $orderpart; } /** * get Order Part * @param int $sessionID * @return object */ public function getOrderCalibration($sessionID){ $ordercalibration = $this->sql->select('c.amountGoodPart, c.amountBadPart','order_calibration c','c.sessionID=? ',[$sessionID]); return $ordercalibration; } /** * Get Order * @param int $orderID * @param boolean $noMachine * @return object */ public function getSession($sessionID){ $session = $this->sql->select('p.userID,p.amount','orders_task p','p.sessionID=? ',[$sessionID]); /* $order = $this->sql->select($select, $tbl, $where, $orderID, 1); $order->amountBadPart = 0; $order->amountGoodPart = 0; $order->part = $this->sql->select('p.userID,p.badpartID,p.amount,p.info,p.sessionID,b.reportingAmount,b.name,p.created,b.sort','order_part p, product_badpart b','b.id = p.badpartID AND p.orderID=? AND p.productID=? ORDER BY p.created ASC',[$order->id,$order->productID]); if($order->part){ foreach($order->part AS $part){ if($part->badpartID) $order->amountBadPart += $part->amount; else $order->amountGoodPart += $part->amount; } $badpartSum = array_reduce($order->part, function($accumulator, $item) { if (!isset($accumulator[$item->badpartID])) { $accumulator[$item->badpartID] = (object) ['reportingAmount' => $item->reportingAmount,'badpartID' => $item->badpartID, 'name' => $item->name, 'totalAmount' => 0, 'sort' => $item->sort, 'alert' => false]; } $accumulator[$item->badpartID]->totalAmount += $item->amount; if($accumulator[$item->badpartID]->totalAmount >= $accumulator[$item->badpartID]->reportingAmount) $accumulator[$item->badpartID]->alert = true; else $accumulator[$item->badpartID]->alert = false; return $accumulator; }, []); sort($badpartSum); $order->badpartSum = $badpartSum; } $order->task = $this->sql->select('o.taskID,o.amount,o.info,o.sessionID, DATE_FORMAT(o.created,"%d.%m.%Y") AS createdDateShow, DATE_FORMAT(o.created,"%H:%i") AS createdTimeShow, o.created, t.name AS taskName, t.nextTaskID, u.name as userName, u.firstName AS userFirstName','orders_task o, task t, user u','o.orderID=? AND t.id = o.taskID AND u.id = o.userID ORDER BY o.created DESC',$order->id); $order->sessionAmount = $this->countUniqueSessionIDs($order->task); $order->statusName = $this->getStatusName($order->status,$order->incomingGoodsInspection); $order->amountWithdrawal = $this->sql->select('SUM(w.amount) AS amount, u.firstName, u.name','order_withdrawal w, user u','u.id = w.userID AND w.orderID=? AND w.productID=? GROUP BY w.userID',[$order->id,$order->productID]); $order->deviationReports = $this->sql->select('id,DATE_FORMAT(created,"%d.%m.%Y") as batchFinishedDate,DATE_FORMAT(created,"%H:%i") as batchFinishedTime','order_part','orderID=? AND batchFinished=1',$order->id); $order->orderReports = $this->sql->select('id,DATE_FORMAT(created,"%d.%m.%Y") as batchFinishedDate,DATE_FORMAT(created,"%H:%i") as batchFinishedTime','order_part','orderID=? AND orderFinished=1',$order->id,1); $order->customerRequests = $this->sql->select('id,orderID,request,info,sort','order_customer_request','accepted=0 AND declined=0 AND orderID=?',$order->id);*/ return $session; } }PK ! U�� � tooling.class.phpnu ��̗� <?php class Tooling { private $sql = false; function __construct() { global $sql; $this->sql = $sql; } /** * Add Tooling * @param object $p * @return boolean */ public function add($p) { $color = generateLightColor(); return $this->sql->insert('tooling', 'name,description,color,customerID,created,changed', [$p->name, $p->description, $color, $p->customerID, NOW, NOW]); } /** * Change Tooling * @param object $p * @return boolean */ public function change($p) { return $this->sql->update('tooling', 'name,description,color,changed', [$p->name, $p->description, $p->color, NOW], 'id=?', $p->toolingID); } /** * Get all Toolings * @return array */ public function getAll($productID=false,$customerID=false) { if($customerID){ return $this->sql->select('id,name,description,color', 'tooling', 'customerID = ? ORDER BY name ASC', $customerID); } if($productID){ return $this->sql->select('t.id,t.name,t.description,t.color', 'tooling t, product_tooling p','t.id = p.toolingID AND p.productID = ? ORDER BY name ASC', $productID); } return $this->sql->select('t.id,t.name,t.description,t.color,t.customerID,c.company', 'tooling t, customer c WHERE c.id = t.customerID ORDER BY name ASC'); } /** * Get Tooling by ID * @param int $toolingID * @return object */ public function getTooling($toolingID){ return $this->sql->select('id,name,description,color,customerID', 'tooling','id = ?', $toolingID, 1); } /** * Get Tooling by ID * @param int $toolingID * @return object */ public function getMachine($toolingID) { return $this->sql->select('id,machineTypeID,name,location,description,color', 'machine', 'id=?', $toolingID, 1); } /** * Get all Tollings for a specific Product * @param int $productID * @return array */ public function getTypeAllByProduct($productID) { return $this->sql->select('t.id,t.name,t.description,t.color', 'tooling t, product_tooling p','t.id = p.toolingID AND p.productID=? ORDER BY t.name ASC', $productID); } /** * Get all Toolings without existing ones for a specific Product * @param int $productID * @return array */ public function getToolingsAllWithoutExisting($productID) { return $this->sql->select('t.id,t.name', 'tooling t','t.id NOT IN (SELECT p.toolingID FROM product_tooling p WHERE p.productID=?) ORDER BY t.name ASC', $productID); } /** * Get all Machinetypes for a specific Tooling * @param int $productID * @return array */ public function getMachineTypesOfTooling($toolingID){ return $this->sql->select('t.id,t.name,t.nameShort', 'machineType t, tooling_machineType p','t.id = p.machineTypeID AND p.toolingID=? ORDER BY t.name ASC', $toolingID); } /** * Get all Machinetypes without existing ones for a specific Tooling * @param int $toolingID * @return array */ public function getMachineTypesAllWithoutExisting($toolingID) { return $this->sql->select('m.id,m.name,m.nameShort', 'machineType m','m.id NOT IN (SELECT t.machineTypeID FROM tooling_machineType t WHERE t.toolingID=?) ORDER BY m.name ASC', $toolingID); } /** * Add MachineType to Tooling * @param object $p * @return boolean */ public function addMachineType($p){ return $this->sql->insert('tooling_machineType', 'toolingID,machineTypeID,created', [$p->toolingID, $p->machineTypeID, NOW]); } /** * Delete MachineType from Tooling * @param object $p * @return boolean */ public function deleteMachineType($p){ return $this->sql->delete('tooling_machineType', 'toolingID=? AND machineTypeID=?', [$p->toolingID, $p->machineTypeID]); } /** * Get all Machines for a specific Tooling * @param int $toolingID * @return array */ public function getAvailiableMachinesByToolingAndMachineType($toolingID){ return $this->sql->select('m.id,m.name,mt.nameShort AS machineTypeNameShow', 'machine m, machineType mt, tooling_machineType t','m.machineTypeID = t.machineTypeID AND mt.id = t.machineTypeID AND t.toolingID=? ORDER BY m.name ASC', $toolingID); } } ?>PK ! V�(7 7 product.class.phpnu ��̗� <?php class Product{ private $sql = false; public $path = 'files/calibration/'; function __construct() { global $sql; $this->sql = $sql; } /** * Add Product * @param object $p * @return boolean */ public function add($p) { $color = generateLightColor(); return $this->sql->insert('product', 'customerID,name,color,icon,batchSize,exactBatchSize,machinePieceCounter,buttonSmallAmount,buttonBigAmount,sidesAmount,briefing,created,changed', [$p->customerID,$p->name, $color, $p->icon, $p->batchSize, $p->exactBatchSize, $p->machinePieceCounter, $p->buttonSmallAmount, $p->buttonBigAmount, $p->sidesAmount, $p->briefing, NOW, NOW]); } /** * Change Product * @param object $p * @return boolean */ public function change($p) { return $this->sql->update('product', 'customerID,name,color,icon,batchSize,exactBatchSize,machinePieceCounter,buttonSmallAmount,buttonBigAmount,sidesAmount,briefing,changed', [$p->customerID,$p->name, $p->color, $p->icon, $p->batchSize, $p->exactBatchSize, $p->machinePieceCounter, $p->buttonSmallAmount,$p->buttonBigAmount, $p->sidesAmount, $p->briefing, NOW], 'id=?', $p->productID); } /** * Get all Products * @param int $customerID * @return array */ public function getAll($customerID=false,$toolingID=false) { if($toolingID !== false && $customerID) return $this->sql->select('p.id,p.exactBatchSize,p.machinePieceCounter,p.name,p.color,p.icon,p.batchSize,p.buttonSmallAmount,p.buttonBigAmount,p.sidesAmount,p.briefing,p.customerID,IF(c.company != "",c.company,CONCAT(c.firstName," ",c.name)) AS customerNameShow', 'product p, customer c','p.customerID = ? AND p.id IN (SELECT productID FROM product_tooling WHERE toolingID = ?) AND c.id = p.customerID ORDER BY name ASC',[$customerID,$toolingID]); if($customerID && $toolingID === false) return $this->sql->select('p.id,p.exactBatchSize,p.machinePieceCounter,p.name,p.color,p.icon,p.batchSize,p.buttonSmallAmount,p.buttonBigAmount,p.sidesAmount,p.briefing,p.customerID,IF(c.company != "",c.company,CONCAT(c.firstName," ",c.name)) AS customerNameShow', 'product p, customer c','p.customerID = ? AND c.id = p.customerID ORDER BY name ASC',[$customerID]); return $this->sql->select('p.id,p.exactBatchSize,p.machinePieceCounter,p.name,p.color,p.icon,p.batchSize,p.buttonSmallAmount,p.buttonBigAmount,p.sidesAmount,p.briefing,p.customerID,IF(c.company != "",c.company,CONCAT(c.firstName," ",c.name)) AS customerNameShow', 'product p, customer c WHERE c.id = p.customerID ORDER BY name ASC'); } /** * Get Single Product * @param number $productID * @return object */ public function getSingle($productID) { $r = $this->sql->select('p.id,p.name,p.color,p.icon,p.batchSize,p.exactBatchSize,p.machinePieceCounter,p.buttonSmallAmount,p.buttonBigAmount,p.sidesAmount,p.briefing,p.customerID,IF(c.company != "",c.company,CONCAT(c.firstName," ",c.name)) AS customerNameShow', 'product p, customer c','c.id = p.customerID AND p.id=?',$productID,1); if(!$r) return false; $r->calibrations = $this->getCalibrationsByProduct($productID); $r->todos = $this->getTodoByProduct($productID); return $r; } /** * Get Product Calibration * @param number $productID * @return array */ public function getCalibrationsByProduct($productID) { return $this->sql->select('c.id,c.productID,c.name,c.description,c.optimum,c.deviationNegative,c.deviationPositive,c.decimals,c.image,c.unitID, u.name AS unitName', 'product_calibration c, unit u', 'c.unitID = u.id AND c.productID=?', $productID); } /** * Get single Calibration * @param number $calibrationID * @return object */ public function getCalibration($calibrationID) { return $this->sql->select('c.id,c.productID,c.name,c.description,c.optimum,c.deviationNegative,c.deviationPositive,c.decimals,c.image,c.unitID, u.name AS unitName', 'product_calibration c, unit u', 'c.unitID = u.id AND c.id=?', $calibrationID, 1); } /** * Add Product Calibration * @param object $p * @return boolean */ public function addCalibration($p,$f,$copyImage=false) { $calibrationID = $this->sql->insert('product_calibration', 'productID,name,description,optimum,deviationNegative,deviationPositive,decimals,unitID,created,changed', [$p->productID,$p->name,$p->description,($p->optimum),($p->deviationNegative),($p->deviationPositive),$p->decimals,$p->unitID,NOW,NOW]); if($calibrationID && $f && is_uploaded_file($f->image->tmp_name)){ // Create Dir if not exists if(!is_dir(DIR.$this->path)) mkdir(DIR.$this->path, 0777, true); $imagick = new Imagick($f->image->tmp_name); $imagick->scaleImage(1000, 1000, true); $imagick->setImageFormat("webp"); $imagick->setImageCompressionQuality(90); $imagick->setCompressionQuality(90); $imagick->setOption('webp:method', '6'); $imagick->writeImage(DIR.$this->path.$calibrationID.'.webp'); $image = $this->path.$calibrationID.'.webp'; $r = $this->sql->update('product_calibration','image,imageChanged',[$image,NOW],'id=?',$calibrationID); } if($copyImage){ $r = $this->sql->update('product_calibration','image,imageChanged',[$copyImage,NOW],'id=?',$calibrationID); } return $calibrationID; } /** * Change Product Calibration * @param object $p * @return boolean */ public function changeCalibration($p,$f) { $r = $this->sql->update('product_calibration', 'productID,name,description,optimum,deviationNegative,deviationPositive,decimals,unitID,changed', [$p->productID,$p->name,$p->description,($p->optimum),($p->deviationNegative),($p->deviationPositive),$p->decimals,$p->unitID,NOW], 'id=?', $p->calibrationID); if($r && $f && is_uploaded_file($f->image->tmp_name)){ // Create Dir if not exists if(!is_dir(DIR.$this->path)) mkdir(DIR.$this->path, 0777, true); $imagick = new Imagick($f->image->tmp_name); $imagick->scaleImage(1000, 1000, true); $imagick->setImageFormat("webp"); $imagick->setImageCompressionQuality(90); $imagick->setCompressionQuality(90); $imagick->setOption('webp:method', '6'); $imagick->writeImage(DIR.$this->path.$p->calibrationID.'.webp'); $image = $this->path.$p->calibrationID.'.webp'; $r = $this->sql->update('product_calibration','image,imageChanged',[$image,NOW],'id=?',$p->calibrationID); } return $r; } /** * Delete Product Calibration * @param object $p * @return boolean */ public function deleteCalibration($p) { $r = $this->sql->delete('product_calibration', 'id=? AND productID=?', [$p->calibrationID,$p->productID]); if($r){ // Delete Image if(file_exists(DIR.$this->path.$p->calibrationID.'.webp')) unlink(DIR.$this->path.$p->calibrationID.'.webp'); } return $r; } /** * Get Material for Product */ public function getMaterialByProduct($productID) { return $this->sql->select('id, nameShort, name, amount', 'product_material', 'productID=?', $productID); } /** * Get single Material * @param number $materialID * @return object */ public function getMaterial($materialID) { return $this->sql->select('id, productID, nameShort, name, amount', 'product_material', 'id=?', $materialID, 1); } /** * Add Material To Product * @param object $p * @return boolean */ public function addMaterial($p) { return $this->sql->insert('product_material', 'productID,nameShort, name,amount,created,changed', [$p->productID,$p->nameShort,$p->name,$p->amount,NOW,NOW]); } /** * Change Material To Product * @param object $p * @return boolean */ public function changeMaterial($p) { return $this->sql->update('product_material', 'nameShort,name,amount,changed', [$p->nameShort,$p->name,$p->amount,NOW], 'id=?', $p->materialID); } /** * Delete Material To Product * @param object $p * @return boolean */ public function deleteMaterial($p) { return $this->sql->delete('product_material', 'id=? AND productID=?', [$p->materialID,$p->productID]); } /** Get bad Parts of Product * @param number $productID * @return array */ public function getBadpartByProduct($productID) { return $this->sql->select('id, name, reportingAmount, sort', 'product_badpart', 'productID=? ORDER BY sort DESC', $productID); } /** * Get single Badpart * @param number $badpartID * @return object */ public function getBadpart($badpartID) { return $this->sql->select('id, productID, name, reportingAmount, sort', 'product_badpart', 'id=?', $badpartID, 1); } /** * Add Badpart To Product * @param object $p * @return boolean */ public function addBadpart($p) { return $this->sql->insert('product_badpart', 'productID,name,reportingAmount,sort,created,changed', [$p->productID,$p->name,$p->reportingAmount,$p->sort,NOW,NOW]); } /** * Change Badpart To Product * @param object $p * @return boolean */ public function changeBadpart($p) { return $this->sql->update('product_badpart', 'name,reportingAmount,sort,changed', [$p->name,$p->reportingAmount,$p->sort,NOW], 'id=?', $p->badpartID); } /** * Delete Badpart To Product * @param object $p * @return boolean */ public function deleteBadpart($p) { return $this->sql->delete('product_badpart', 'id=? AND productID=?', [$p->badpartID,$p->productID]); } /** * Get Todo for Product * @param number $productID * @return array */ public function getTodoByProduct($productID) { return $this->sql->select('p.id, p.name, p.description, p.todoMainID, t.name AS todoName, t.color AS todoColor, p.sort', 'product_todo p, todo t', 't.id = p.todoMainID AND p.productID=? ORDER BY p.todoMainID, p.sort ASC', $productID); } /** * Get single Todo * @param number $todoID * @return object */ public function getTodo($todoID) { return $this->sql->select('id, productID, name, description, todoMainID, sort', 'product_todo', 'id=?', $todoID, 1); } /** * Add Todo To Product * @param object $p * @return boolean */ public function addTodo($p) { return $this->sql->insert('product_todo', 'productID,name,description,todoMainID, sort,created,changed', [$p->productID,$p->name,$p->description,$p->todoMainID,$p->sort,NOW,NOW]); } /** * Change Todo To Product * @param object $p * @return boolean */ public function changeTodo($p) { return $this->sql->update('product_todo', 'name,description,todoMainID, sort,changed', [$p->name,$p->description,$p->todoMainID,$p->sort,NOW], 'id=?', $p->todoID); } /** * Delete Todo To Product * @param object $p * @return boolean */ public function deleteTodo($p) { return $this->sql->delete('product_todo', 'id=? AND productID=?', [$p->todoID,$p->productID]); } /** * Get Todos */ public function getTodoAll() { return $this->sql->select('id, name, color', 'todo ORDER BY sort ASC, id ASC'); } /** * Get all Units * @return array */ public function getUnitAll() { return $this->sql->select('id,name', 'unit ORDER BY id ASC'); } /** * Get ToolingIDs of Product * @param number $productID * @return array */ private function getToolingByProduct($productID){ return $this->sql->select('toolingID', 'product_tooling', 'productID=?', $productID); } /** * Add Tooling to Product * @param object $p * @return boolean */ public function addProductTooling($p){ return $this->sql->insert('product_tooling', 'productID,toolingID,created', [$p->productID,$p->toolingID,NOW]); } /** * Delete Tooling from Product * @param object $p * @return boolean */ public function deleteProductTooling($p){ return $this->sql->delete('product_tooling', 'toolingID=? AND productID=?', [$p->toolingID,$p->productID]); } /** * Copy Product * @param number $productID * @return boolean | int */ public function copy($p){ $product = $this->getSingle($p->productID); $new = new stdClass; $new->customerID= $product->customerID; $new->name = $p->name; $new->icon = $product->icon; $new->batchSize = $product->batchSize; $new->exactBatchSize = $product->exactBatchSize; $new->buttonSmallAmount = $product->buttonSmallAmount; $new->buttonBigAmount = $product->buttonBigAmount; $new->sidesAmount = $product->sidesAmount; $new->briefing = $product->briefing; $new->machinePieceCounter = $product->machinePieceCounter; $newID = $this->add($new); if(!$newID) return false; if(isset($p->material)){ $materials = $this->getMaterialByProduct($p->productID); foreach($materials AS $m){ $new = new stdClass; $new->productID = $newID; $new->nameShort = $m->nameShort; $new->name = $m->name; $new->amount = $m->amount; $this->addMaterial($new); } } if(isset($p->badpart)){ $badparts = $this->getBadpartByProduct($p->productID); foreach($badparts AS $b){ $new = new stdClass; $new->productID = $newID; $new->name = $b->name; $new->reportingAmount = $b->reportingAmount; $new->sort = $b->sort; $this->addBadpart($new); } } if(isset($p->calibration)){ $calibrations = $this->getCalibrationsByProduct($p->productID); foreach($calibrations AS $c){ $new = new stdClass; $new->productID = $newID; $new->name = $c->name; $new->description = $c->description; $new->optimum = $c->optimum; $new->deviationNegative = $c->deviationNegative; $new->deviationPositive = $c->deviationPositive; $new->decimals = $c->decimals; $new->unitID = $c->unitID; $new->image = $c->image; $this->addCalibration($new,false,$new->image); } } if(isset($p->todos)){ $todos = $this->getTodoByProduct($p->productID); foreach($todos AS $t){ $new = new stdClass; $new->productID = $newID; $new->name = $t->name; $new->description = $t->description; $new->todoMainID = $t->todoMainID; $new->sort = $t->sort; $this->addTodo($new); } } if(isset($p->tooling)){ $toolings = $this->getToolingByProduct($p->productID); foreach($toolings AS $t){ $new = new stdClass; $new->productID = $newID; $new->toolingID = $t->toolingID; $this->addProductTooling($new); } } return $product->customerID.'/'.$newID; } }PK ! ���So+ o+ user.class.phpnu ��̗� <?php class User{ private $sql = false; public $id = false; public $name = ''; public $firstName = ''; public $rights = false; public $hash = ''; public $email = ''; public $color = ''; public $image = false; public $loggedIn = false; public $reg = false; public $path = 'files/user/'; private $mailer = false; function __construct(){ global $sql; $this->sql = $sql; global $mailer; $this->mailer = $mailer; if(isset($_COOKIE['kft_u']) && $_COOKIE['kft_u'] && !preg_match('/^[\w]+$/', ((base64_decode($_COOKIE['kft_u'])-1328)/128))){ $this->logout(); } } public function showTabletOnly($tabletOnly){ switch($tabletOnly){ case 10: return 'Produktion & Wareneingang'; break; case 30: return 'Nur Wareneingang'; break; case 50: return 'Nur Produktion'; break; default: return 'Unbekannt'; break; } } public function showProfileImage(){ $r = '<div class="profil-image '.((!$this->image?'text':'')).'">'; if($this->image) $r .= '<img src="'.$this->image.'?'.filemtime(DIR.$this->image).'" alt="'.$this->name.'"/>'; else $r .= substr($this->firstName,0,1).substr($this->name,0,1); $r .= '</div>'; return $r; } public function checkIfEmailExists($email){ return $this->sql->select('id,email','user','email = ?',$email,1); } /** * Add User with all data and profile image -> Used in Admin Panel * @param object $p * @param array $f * @return bool */ public function add($p,$f){ $hash = md5(date('YmdHis').mt_rand(0,999999)); if($p->tabletOnly == 100){ if($p->email == '') return false; if($this->checkIfEmailExists($p->email)) return false; $pw = createStr(20, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*()_+'); $password = $this->createHash($pw); $sendMail = true; $rights = 1; $p->tabletOnly = 10; }else{ $sendMail = false; $password = ''; $rights = 0; } $color = generateLightColor(); $userID = $this->sql->insert('user','email,name,firstName,password,active,tabletOnly,pin,color,rights,created,changed,hash', [$p->email,$p->name,$p->firstName,$password,1,$p->tabletOnly,$p->pin,$color,$rights,NOW,NOW,$hash]); if($userID && $f && is_uploaded_file($f->image->tmp_name)){ // Create Dir if not exists if(!is_dir(DIR.$this->path)) mkdir(DIR.$this->path, 0777, true); $imagick = new Imagick($f->image->tmp_name); $imagick->scaleImage(350, 350, true); $imagick->setImageFormat("webp"); $imagick->setImageCompressionQuality(70); $imagick->setCompressionQuality(70); $imagick->setOption('webp:method', '6'); $imagick->writeImage(DIR.$this->path.$userID.'.webp'); $image = $this->path.$userID.'.webp'; $r = $this->sql->update('user','image,imgChanged',[$image,NOW],'id=?',$userID); } if($userID && $sendMail){ $this->sendPwMail($p,$pw); } return $userID; } /** * Change User with all data and profile image -> Used in Admin Panel * @param object $p * @param object $f * @return boolean */ public function change($p,$f){ $sendMail = false; if($p->tabletOnly == 100){ // This is an Admin with full rights if($p->email == '') return false; if($p->emailOld == '' || $p->hasPW == "0"){ $sendMail = true; $pw = createStr(20, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*()_+'); $password = $this->createHash($pw); } if($checkMail = $this->checkIfEmailExists($p->email)){ if($p->userID != $checkMail->id) return false; } $rights = 1; $p->tabletOnly = 10; }else{ $password = ''; $rights = 0; } $r = $this->sql->update('user','firstName,name,email,color,active,tabletOnly,pin,rights,changed',[$p->firstName,$p->name,$p->email,$p->color,$p->active,$p->tabletOnly,$p->pin,$rights,NOW],'id=?',$p->userID); if($r && $f && is_uploaded_file($f->image->tmp_name)){ // Create Dir if not exists if(!is_dir(DIR.$this->path)) mkdir(DIR.$this->path, 0777, true); $imagick = new Imagick($f->image->tmp_name); $imagick->scaleImage(350, 350, true); $imagick->setImageFormat("webp"); $imagick->setImageCompressionQuality(70); $imagick->setCompressionQuality(70); $imagick->setOption('webp:method', '6'); $imagick->writeImage(DIR.$this->path.$this->id.'.webp'); $this->image = $this->path.$this->id.'.webp'; $r = $this->sql->update('user','image,imgChanged',[$this->image,NOW],'id=?',$p->userID); } if($r && $sendMail){ $this->sql->update('user','password=?',[$password],'id=?',$p->userID); $this->sendPwMail($p,$pw); } return $r; } /** * Send Password Mail * @param object $p * @param string $pw * @return boolean */ private function sendPwMail($p,$pw){ $subject = 'Dein Zugang zu '.SITENAME; $message = 'Hallo '.$p->firstName.' '.$p->name.',<br /><br /> wir haben einen Account für dich angelegt.<br /> Dein Benutzername lautet: '.$p->email.'<br /> Dein Passwort lautet: '.$pw.'<br /><br /> <a href="'.HOST.'">Zum Login</a><br /><br /> Viele Grüße<br /> '.SITENAME; return $this->mailer->myMail($p->email,$subject,$message); } /** * Delete User -> Used in Admin Panel */ public function delete($p){ if(!$p->deleteUser) return false; return $this->sql->delete('user','id=? AND id != ?',[$p->userID,$this->id]); } /** * Add User with random password -> Used only for first user in setup * @param object $p * @return boolean */ public function addUser($p){ $hash = md5(date('YmdHis').mt_rand(0,999999)); $pw = createStr(20, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*()_+'); $password = $this->createHash($pw); return $this->sql->insert('user','email,name,firstName,password,active,created,changed,hash',[$p->email,$p->name,$p->firstName,$password,1,NOW,NOW,$hash]); } public function changeMe($p,$f){ $r = $this->sql->update('user','firstName,name,email,color, changed',[$p->firstName,$p->name,$p->email,$p->color,NOW],'id=?',$this->id); if($r && $f && is_uploaded_file($f["image"]->tmp_name)){ // Create Dir if not exists if(!is_dir(DIR.$this->path)) mkdir(DIR.$this->path, 0777, true); $imagick = new Imagick($f["image"]->tmp_name); $imagick->scaleImage(350, 350, true); $imagick->setImageFormat("webp"); $imagick->setImageCompressionQuality(70); $imagick->setCompressionQuality(70); $imagick->setOption('webp:method', '6'); $imagick->writeImage(DIR.$this->path.$this->id.'.webp'); $this->image = $this->path.$this->id.'.webp'; $r = $this->sql->update('user','image,imgChanged',[$this->image,NOW],'id=?',$this->id); } return $r; } public function changeMePassword($p){ if($p->password_new != $p->f_password_new_2) return false; $pwHash = $this->createHash($p->password_old); if(!$this->sql->select("id","user","id = ? AND password = ?",[$this->id,$pwHash],1)) return false; $password = $this->createHash($p->password_new); return $this->sql->update('user','password,changed',[$password,NOW],'id=?',$this->id); } public function getAll(){ return $this->sql->select('id,active,rights,email,name,firstName,pin,tabletOnly,color','user ORDER BY firstName ASC, name ASC'); } public function getUser($userID){ return $this->sql->select('id,active,rights,email,name,firstName,pin,tabletOnly,color,IF(password = "",0,1) AS hasPW','user','id = ?',[$userID],1); } public function setUser(){ if(!isset($_COOKIE["kft_u"],$_COOKIE["kft_p"],$_COOKIE["kft_e"])){ $this->id = false; return false; } $id = (base64_decode($_COOKIE['kft_u'])-1328)/128; $password = $this->decodeRand(base64_decode($_COOKIE['kft_p'])); $email = $this->decodeRand(base64_decode($_COOKIE['kft_e'])); $u = $this->sql->select('id,email,name,firstName,rights,hash,image,color','user','id = ? AND password = ? AND email = ? AND active = 1',[$id,$password,$email],1); if(!$u) return $this->logout(); if($id != $u->id) return $this->logout(); $this->id = $u->id; $this->rights = $u->rights; $this->email = $u->email; $this->name = $u->name; $this->firstName = $u->firstName; $this->hash = $u->hash; $this->loggedIn = true; $this->image = ($u->image)?$u->image:false; $this->color = $u->color; $this->refreshCookies(); } private function encodeRand($str) { mt_srand(SEED); $out = array(); for ($x=0, $l=strlen($str); $x<$l; $x++) $out[$x] = (ord($str[$x]) * 7) + mt_rand(1531, 35987); mt_srand(); return implode('-', $out); } private function decodeRand($str) { mt_srand(SEED); $blocks = explode('-', $str); $out = array(); foreach ($blocks as $block) { $ord = (intval($block) - mt_rand(1531, 35987)) / 7; $out[] = chr($ord); } mt_srand(); return implode('', $out); } public function login($p){ $pwHash = $this->createHash($p->password); $email = $p->email; $u = $this->sql->select("id,rights,password,email","user","email = ?",$email,1); //$this->decodeRand(base64_decode($u->password)); if(!$u){ $this->logout(); return false; } $_u = $this->sql->select("id","user","email = ? AND password = ?",[$email,$pwHash],1); if(!$_u){ $this->logout(); return false; } $UserID = base64_encode(($u->id*128)+1328); $Hash = base64_encode($this->encodeRand($u->password)); $login = base64_encode($this->encodeRand($u->email)); $sess_neu = base64_encode($this->encodeRand(session_id())); setcookie('kft_s', $sess_neu, strtotime("+12 month"), "/"); setcookie('kft_u', $UserID, strtotime("+12 month"), "/"); setcookie('kft_p', $Hash, strtotime("+12 month"), "/"); setcookie('kft_e', $login, strtotime("+12 month"), "/"); setcookie('kft_r', $u->rights, strtotime ("+12 month"), "/"); $_COOKIE['kft_s'] = $sess_neu; $_COOKIE['kft_u'] = $UserID; $_COOKIE['kft_p'] = $Hash; $_COOKIE['kft_e'] = $login; $_COOKIE['kft_r'] = $u->rights; $this->loggedIn = false; $this->setUser(); return 1; } private function refreshCookies(){ setcookie('kft_s', $_COOKIE['kft_s'], strtotime("+12 month"), "/"); setcookie('kft_u', $_COOKIE['kft_u'], strtotime("+12 month"), "/"); setcookie('kft_p', $_COOKIE['kft_p'], strtotime("+12 month"), "/"); setcookie('kft_e', $_COOKIE['kft_e'], strtotime("+12 month"), "/"); setcookie('kft_r', $_COOKIE['kft_r'], strtotime("+12 month"), "/"); } public function logout(){ setcookie('kft_s', "", time() -1, "/"); setcookie("kft_u", "", time() -1, "/"); setcookie("kft_p", "", time() -1, "/"); setcookie("kft_e", "", time() -1, "/"); setcookie("kft_r", "", time() -1, "/"); $_COOKIE['kft_s'] = false; $_COOKIE['kft_u'] = false; $_COOKIE['kft_p'] = false; $_COOKIE['kft_e'] = false; $_COOKIE['kft_r'] = false; unset($_COOKIE['kft_s']); unset($_COOKIE['kft_u']); unset($_COOKIE['kft_p']); unset($_COOKIE['kft_e']); unset($_COOKIE['kft_r']); //youtube: $_SESSION['token'] = false; unset($_SESSION['token']); $this->setUser(); return true; } private function createHash($input){ $hash = hash('whirlpool', $input); return hash('sha256', $hash); } }PK ! ��߆� � order.class.phpnu ��̗� <?php class Order{ private $sql = false; public $path = 'files/order/'; private $user = false; private $mailer = false; function __construct() { global $sql; $this->sql = $sql; global $user; $this->user = $user; global $mailer; $this->mailer = $mailer; } /***************** * STATUS * 1: Neu / Erstellt => Von Endkunden gekommen * 7: Neu / Erstellt => von Backend gekommen * 5: Angenommen -> Nur relevant falls Auftrag direkt von Kunden kommt * 6: Abgelehnt -> Nur relevant falls Auftrag direkt von Kunden kommt * * 10: Zur Produktion Freigegeben * 13: Wareneingangskontrolle * 15: Auftrag in Produktion * * 20: Auftrag pausiert * * 30: Auftrag on Hold * 31: Auftrag on Hold -> Warten auf Material * 32: Auftrag on Hold -> Warten auf Maschine * 33: Auftrag on Hold -> Zu viele Falschteile produziert! * * 80: Storniert * 98: Auftrag erfolgreich abgeschlossen -> muss noch abgenommen werden * 99: Auftrag erfolgreich abgeschlossen * * REIHENFOLGE: * Wird über 'sort' in order festgelegt pro Maschine * Sortierung ist ASC -> 0 ist zuerst * Sortierung wirkt sich nur auf Aufträge aus, die den Status 10 haben. * * ABLAUF Auftrag kommt von Kockzius: * 0 -> 10 * Um einen Auftrag freizugeben, kann er als "nächstes", als "letztes" oder an einer bestimmten Position freigegeben werden. * Beginnt ein Tablet die Arbeit, wird geprüft, ob ein Auftrag auf 20 gesetzt ist, wenn ja, wird er auf 15 gesetzt -> Auftrag in Produktion * Falls kein Auftrag mit 20 vorhanden ist, wird der erste Auftrag aus der Liste mit 10 auf 15 gesetzt. -> Auftrag in Produktion * Pausiert ein Mitarbeiter einen Auftrag (Schichtwechsel oder Tag beendet), wird der Status auf 20 gesetzt. * Falls ein Auftrag vor erst nicht weitergemacht werden kann (Warten auf Material, Maschine oder Mitarbeiter), wird der Status auf 30 gesetzt. -> Auftrag on Hold -> Ggf. Kunden informieren * Dann wird wieder mit 10 weitergemacht. * Um einen Auftrag aus dem Status 30 zu holen, muss der Status auf 10 gesetzt werden und ggf. neu priorisiert werden. -> Zur Produktion Freigegeben * Ist ein Auftrag abgeschlossen, wird der Status entweder auf 98 oder auf 99 gesetzt und sort wird auf 0 gesetzt. * 98 wenn der Auftrag noch abgenommen werden muss -> das hängt von Kundeneinstellung "approveOrder" ab -> wird in Funktion finishOrder im Tablet gesetzt. * 99 wenn der Auftrag abgeschlossen ist ohne Kundenprüfung. * 95 wenn der Auftrag nicht angenommen wurde, sondern reklamiert wurde * * ABLAUF Auftrag kommt von Kunde: * 0 -> 5 * Wird ein Auftrag von einem Kunden erstellt, wird der Status auf 5 gesetzt. -> Angenommen -> Kunde wird benachrichtigt * Wird der Auftrag abgelehnt, wird der Status auf 6 gesetzt. -> Abgelehnt -> Kunde wird benachrichtigt inkl. Freitext-Info und kann Auftrag neu erstellen. * Wird der Auftrag angenommen, kann der Status auf 10 gesetzt werden. -> Zur Produktion Freigegeben * Rest wie oben * * incomingGoodsInspection: * 0: Nicht geprüft * 1: Geprüft und bestanden * 2: Geprüft und nicht bestanden * 5: Nicht geprüft, aber übersprungen ******************/ public function getStatusName($status,$incomingGoodsInspection = false){ if(!$incomingGoodsInspection && $status < 21 && $status > 7) return 'Wareneingangskontrolle'; switch($status){ case 1: return 'Neu v. Kunde'; // von Kunden case 7: return 'Neu'; // vom Backend case 5: return 'Angenommen'; // Gibt es nicht -> Ist immer Status 10 case 6: return 'Abgelehnt'; case 10: return 'Freigabe Produktion'; case 13: return 'Wareneingangskontrolle'; case 15: return 'In Produktion'; case 20: return 'Auftrag pausiert'; case 30: case 31: case 32: case 33: return 'On Hold'; case 80: return 'Storniert'; case 95: return 'Reklamation'; case 98: return 'Warte auf Kundenabnahme'; case 99: return 'Abgeschlossen'; default: return 'Unbekannt'; } } /** * Add Order * @param object $p * @return boolean */ public function add($p) { if($this->checkCustomerOrderNr($p->customerOrderNr,$p->customerID)) return false; $color = generateLightColor(); $hash = $this->getHash(); $p->machineID = 0; $status = 7; $sort = 9; $approveOrder = $this->sql->select('approveOrder', 'customer', 'id=?', $p->customerID, 1); return $this->sql->insert('orders', 'approveOrder,customerID,machineID,productID,toolingID,customerOrderNr,hash,amountTarget,briefing,status,color,sort,created,changed', [$approveOrder, $p->customerID,$p->machineID,$p->productID,$p->toolingID,$p->customerOrderNr,$hash,$p->amountTarget,$p->briefing,$status,$color,$sort,NOW, NOW]); } /** * Check if customerOrderNr already exists * @param integer $customerOrderNr * @return integer */ public function checkCustomerOrderNr($customerOrderNr,$customerID){ return $this->sql->select('id', 'orders', 'customerOrderNr=? AND customerID = ?', [$customerOrderNr,$customerID], 1); } /** * Get Tablet Hash */ public function getHash() { $hash = createHash(12); if($this->sql->select('id', 'orders', 'hash=?', $hash, 1)) return $this->getHash(); return $hash; } /** * Delete Order * @param int $orderID * @return boolean */ public function delete($p) { return $this->sql->update('orders', 'status', 80, 'id=?', [$p->orderID]); } /** * Change Status * @param object $p * @return boolean */ public function changeStatus($p) { if(isset($p->resetIncomingGoodsInspection) && $p->resetIncomingGoodsInspection) $this->resetIncomingGoodsInspection($p); $oldStatus = $this->sql->select('status', 'orders', 'id=?', $p->orderID, 1); if($oldStatus == "1"){ $order = $this->getOrder($p->orderID); $customerLogin = $this->getCustomerLoginDetails($order->customerLoginID); if($p->status == 10 && $customerLogin){ $body = 'Hallo '.$customerLogin->firstName.' '.$customerLogin->name.',<br /> <br /> wir haben Ihren Auftrag '.$order->customerOrderNr.' angenommen und zur Produktion freigegeben.<br /> Über diese Link können Sie Ihren Auftrag abrufen: <a href="https://kunde.kockzius.de/auftrage/'.$order->hash.'/">Auftrag öffnen</a><br /><br /> Mit freundlichen Grüßen<br /> Ihr Kockzius-Team'; $this->mailer->myMail($customerLogin->email, 'Ihr Auftrag '.$order->customerOrderNr.' wurde angenommen', $body); }elseif($p->status == 6 && $customerLogin){ $this->sql->insert('order_declined','orderID,userID,request,info',[ $p->orderID, $this->user->id, 'order.new', $p->info]); $body = 'Hallo '.$customerLogin->firstName.' '.$customerLogin->name.',<br /> <br /> leider konnten wir Ihren Auftrag '.$order->customerOrderNr.' nicht annehmen:<br /> '.nl2br($p->info).'<br /><br /> Bitte prüfen Sie den Auftrag und erstellen Sie diesen erneut.<br /> Über diese Link können Sie Ihren Auftrag abrufen: <a href="https://kunde.kockzius.de/auftrage/'.$order->hash.'/">Auftrag öffnen</a><br /><br /> Mit freundlichen Grüßen<br /> Ihr Kockzius-Team'; $this->mailer->myMail($customerLogin->email, 'Ihr Auftrag '.$order->customerOrderNr.' wurde abgelehnt', $body); } } return $this->sql->update('orders', 'currentTaskID,status,changed', [0,$p->status,NOW], 'id=?', $p->orderID); } /** * Reset Incoming Goods Inspection * @param object $p * @return boolean */ public function resetIncomingGoodsInspection($p) { return $this->sql->update('orders', 'incomingGoodsInspection,incomingGoodsInspectionDate,changed', [0,0,NOW], 'id=?', $p->orderID); } /** * Reset Incoming Goods Inspection * @param object $p * @return boolean */ public function skipIncomingGoodsInspection($p) { // TODO: Needs furhter development -> see tablet!! return $this->sql->update('orders', 'incomingGoodsInspection,incomingGoodsInspectionDate,changed', [5,NOW,NOW], 'id=?', $p->orderID); } /** * Change Order * @param object $p * @return boolean */ public function change($p) { return $this->sql->update('orders', 'customerID,machineID,productID,toolingID,customerOrderNr,amountTarget,briefing,status,color,changed', [$p->customerID,$p->machineID,$p->productID,$p->toolingID,$p->customerOrderNr,$p->amountTarget,$p->briefing,$p->status,$p->color,NOW], 'id=?', $p->orderID); } /** Change Prio of order * @param object $p * @return boolean */ public function changePrio($p) { return $this->sql->update('orders', 'sort,changed', [$p->sort,NOW], 'hash=?', $p->hash); } /** * Start Order * @param object $p * @return boolean */ public function start($p){ return $this->sql->update('orders', 'machineID,briefing,sort,status,changed', [$p->machineID,$p->briefing,$p->sort,10,NOW], 'id=?', $p->orderID); } /** * Get Order ID by Hash * @param object $hash * @return int */ public function getOrderIDbyHash($hash){ return $this->sql->select('id', 'orders', 'hash=?', $hash, 1); } /** * Get ToDo for Dashboard by Status * @param int $status * @return string */ public function getOrderToDo($status, $deviationReportPrinted){ if($status === 1) return 'Auftrag freigeben'; if($status >= 30 && $status <= 33) return 'Auftrag prüfen'; if($status > 90 && !$deviationReportPrinted) return 'Abweichungsbericht drucken'; } /** * Get Order * @param int $orderID * @param boolean $noMachine * @return object */ public function getOrder($orderID,$noMachine=false){ if($noMachine){ $select = 'o.customerLoginID, o.approveOrder, o.deviationReportPrinted,o.hash,o.id,o.customerID,o.productID,o.toolingID,o.customerOrderNr,o.amountTarget,o.amountFinished,o.briefing,o.status,o.color,o.sort,o.created,o.changed,o.incomingGoodsInspection,o.incomingGoodsInspectionDate,DATE_FORMAT(o.dateFinished,"%d.%m.%Y") AS dateFinishedShow,IF(c.company != "",c.company,CONCAT(c.firstName," ",c.name)) AS customerNameShow, CONCAT(c.firstName," ",c.name) AS customerUserName,p.name AS productNameShow, p.batchSize, p.exactBatchSize, t.name AS toolingNameShow, "" AS machineNameShow'; $tbl = 'orders o, customer c, product p, tooling t'; $where = 'o.id=? AND c.id = o.customerID AND p.id = o.productID AND t.id = o.toolingID'; }else{ $select = 'o.customerLoginID, o.approveOrder, o.deviationReportPrinted,o.hash,o.id,o.customerID,o.machineID,o.productID,o.toolingID,o.customerOrderNr,o.amountTarget,o.amountFinished,o.briefing,o.status,o.color,o.sort,o.created,o.changed,o.incomingGoodsInspection,o.incomingGoodsInspectionDate,DATE_FORMAT(o.dateFinished,"%d.%m.%Y") AS dateFinishedShow,IF(c.company != "",c.company,CONCAT(c.firstName," ",c.name)) AS customerNameShow, CONCAT(c.firstName," ",c.name) AS customerUserName,m.name AS machineNameShow, p.name AS productNameShow, p.batchSize, p.exactBatchSize, t.name AS toolingNameShow'; $tbl = 'orders o, customer c, machine m, product p, tooling t'; $where = 'o.id=? AND c.id = o.customerID AND m.id = o.machineID AND p.id = o.productID AND t.id = o.toolingID'; } $order = $this->sql->select($select, $tbl, $where, $orderID, 1); $order->amountBadPart = 0; $order->amountGoodPart = 0; $order->part = $this->sql->select('p.userID,p.badpartID,p.amount,p.info,p.sessionID,b.reportingAmount,b.name,p.created,b.sort','order_part p, product_badpart b','b.id = p.badpartID AND p.orderID=? AND p.productID=? ORDER BY p.created ASC',[$order->id,$order->productID]); if($order->part){ foreach($order->part AS $part){ if($part->badpartID) $order->amountBadPart += $part->amount; else $order->amountGoodPart += $part->amount; } $badpartSum = array_reduce($order->part, function($accumulator, $item) { if (!isset($accumulator[$item->badpartID])) { $accumulator[$item->badpartID] = (object) ['reportingAmount' => $item->reportingAmount,'badpartID' => $item->badpartID, 'name' => $item->name, 'totalAmount' => 0, 'sort' => $item->sort, 'alert' => false]; } $accumulator[$item->badpartID]->totalAmount += $item->amount; if($accumulator[$item->badpartID]->totalAmount >= $accumulator[$item->badpartID]->reportingAmount) $accumulator[$item->badpartID]->alert = true; else $accumulator[$item->badpartID]->alert = false; return $accumulator; }, []); sort($badpartSum); $order->badpartSum = $badpartSum; } $order->task = $this->sql->select('o.taskID,o.amount,o.info,o.sessionID, DATE_FORMAT(o.created,"%d.%m.%Y") AS createdDateShow, DATE_FORMAT(o.created,"%H:%i") AS createdTimeShow, o.created, t.name AS taskName, t.nextTaskID, u.name as userName, u.firstName AS userFirstName','orders_task o, task t, user u','o.orderID=? AND t.id = o.taskID AND u.id = o.userID ORDER BY o.created DESC',$order->id); $order->sessionAmount = $this->countUniqueSessionIDs($order->task); $order->statusName = $this->getStatusName($order->status,$order->incomingGoodsInspection); $order->amountWithdrawal = $this->sql->select('SUM(w.amount) AS amount, u.firstName, u.name','order_withdrawal w, user u','u.id = w.userID AND w.orderID=? AND w.productID=? GROUP BY w.userID',[$order->id,$order->productID]); $order->deviationReports = $this->sql->select('id,DATE_FORMAT(created,"%d.%m.%Y") as batchFinishedDate,DATE_FORMAT(created,"%H:%i") as batchFinishedTime,amount','order_part','orderID=? AND batchFinished=1',$order->id); $order->orderReports = $this->sql->select('id,DATE_FORMAT(created,"%d.%m.%Y") as batchFinishedDate,DATE_FORMAT(created,"%H:%i") as batchFinishedTime','order_part','orderID=? AND orderFinished=1',$order->id,1); $order->customerRequests = $this->sql->select('id,orderID,request,info,sort','order_customer_request','accepted=0 AND declined=0 AND orderID=?',$order->id); return $order; } private function countUniqueSessionIDs($array) { if(!is_array($array)) return 0; $sessionIDs = array_map(function($element) { return $element->sessionID; }, $array); $uniqueSessionIDs = array_unique($sessionIDs); return count($uniqueSessionIDs); } /** * Count Parts betweend two dates * @param array $parts * @param string $begin * @param string $end * @return object */ public function countPartsByCreated($parts, $begin, $end){ $r = false; if($parts){ foreach($parts AS $part){ if($part->created >= $begin && $part->created <= $end && $part->amount){ if(!$r){ $r = new stdClass; $r->amount = 0; $r->badParts = 0; $r->goodParts = 0; } $r->amount += $part->amount; if($part->badpartID) $r->badParts += $part->amount; else $r->goodParts += $part->amount; $badpartSum = array_reduce($parts, function($accumulator, $item) { if (!isset($accumulator[$item->badpartID])) { $accumulator[$item->badpartID] = (object) ['reportingAmount' => $item->reportingAmount,'badpartID' => $item->badpartID, 'name' => $item->name, 'totalAmount' => 0, 'alert' => false]; } $accumulator[$item->badpartID]->totalAmount += $item->amount; if($accumulator[$item->badpartID]->totalAmount >= $accumulator[$item->badpartID]->reportingAmount) $accumulator[$item->badpartID]->alert = true; else $accumulator[$item->badpartID]->alert = false; return $accumulator; }, []); sort($badpartSum); $r->badparts = $badpartSum; } } } return $r; } /** * Set Timestamp when DeviationReport was pritned for the first time * @param int $orderID * @return boolean */ public function changeDeviationReportPrinted($orderID){ return $this->sql->update('orders','deviationReportPrinted,deviationReportPrintedDate',[1,NOW],'id=?',$orderID); } public function getRequests(){ $orderIDs = $this->sql->select('orderID,request,info,sort','order_customer_request','accepted=0 AND declined=0'); if(!$orderIDs) return false; $r = []; foreach($orderIDs AS $orderID){ $order = $this->getOrder($orderID->orderID); $order->request = $this->requestToText($orderID->request); $order->info = $orderID->info; $order->sort = $orderID->sort; $r[] = $order; } return $r; } public function requestToText($request){ if($request == 'order.storno') return 'Stornierungsanfrage'; if($request == 'order.sort') return 'Priorisierungänderungssanfrage'; if($request == 'order.complain') return 'Reklamation'; } public function customerRequestHandle($p){ if($p->decision == 'accepted'){ $this->sql->update('order_customer_request','accepted,acceptedDate',[1,NOW],'id=?',$p->requestID); if($p->request == 'order.storno'){ $p->status = 80; return $this->changeStatus($p); } if($p->request == 'order.complain'){ $p->status = 99; return $this->changeStatus($p); } if($p->request == 'order.sort'){ return $this->changePrio($p); } }elseif($p->decision == 'declined'){ $order = $this->getOrder($p->orderID); $customerLoginID = $this->getCustomerLoginID($p->requestID); $customerLogin = $this->getCustomerLoginDetails($customerLoginID); $this->sql->update('order_customer_request','declined,declinedDate',[1,NOW],'id=?',$p->requestID); $body = 'Hallo '.$customerLogin->firstName.' '.$customerLogin->name.',<br /> <br /> leider konnten wir Ihre '.$this->requestToText($p->request).' zum Auftrag '.$order->customerOrderNr.' nicht annehmen:<br /> '.nl2br($p->info).'<br /><br /> Über diese Link können Sie Ihren Auftrag abrufen: <a href="https://kunde.kockzius.de/auftrage/'.$order->hash.'/">Auftrag öffnen</a><br /><br /> Mit freundlichen Grüßen<br /> Ihr Kockzius-Team'; $this->mailer->myMail($customerLogin->email, $this->requestToText($p->request).' zum Auftrag '.$order->customerOrderNr, $body); if($p->request == 'order.complain'){ $p->status = 98; return $this->changeStatus($p); } return $this->sql->insert('order_declined','orderID,userID,requestID,request,info',[$p->orderID, $this->user->id, $p->requestID, $p->request, $p->info]); } } private function getCustomerLoginDetails($customerLoginID){ return $this->sql->select('email,firstName,name','customer_login','id=?',$customerLoginID,1); } private function getCustomerLoginID($requestID){ return $this->sql->select('customerLoginID','order_customer_request','id=?',$requestID,1); } /** * Get all Orders * @return array | boolean */ public function getAll($_status,$hasDeviationReport=false,$limit=false,$sort=false) { if(!is_array($_status)) $_status = [$_status]; $select = 'o.dateFinished,o.deviationReportPrinted, o.incomingGoodsInspection,o.hash,o.id,o.customerID,o.machineID,o.productID,o.customerOrderNr,o.amountTarget,o.amountFinished,o.briefing,o.status,o.color,o.sort,o.created,o.changed,IF(c.company != "",c.company,CONCAT(c.firstName," ",c.name)) AS customerNameShow, m.name AS machineNameShow, p.name AS productNameShow, t.name AS toolingNameShow'; $tbl = 'orders o, customer c, machine m, product p, tooling t'; $where = 'o.status=? AND c.id = o.customerID AND m.id = o.machineID AND p.id = o.productID AND t.id = o.toolingID'; $selectNoMachine = 'o.dateFinished,o.deviationReportPrinted,o.incomingGoodsInspection,o.hash,o.id,o.customerID,o.productID,o.customerOrderNr,o.amountTarget,o.amountFinished,o.briefing,o.status,o.color,o.sort,o.created,o.changed,IF(c.company != "",c.company,CONCAT(c.firstName," ",c.name)) AS customerNameShow, p.name AS productNameShow, "" AS machineNameShow, "" AS toolingNameShow'; $tblNoMachine = 'orders o, customer c, product p'; $whereNoMachine = 'o.status=? AND c.id = o.customerID AND p.id = o.productID'; $r = []; foreach($_status AS $status){ if(in_array($status, [0])){ $h = $this->sql->select($selectNoMachine, $tblNoMachine,$whereNoMachine.' ORDER BY o.sort ASC, o.created ASC',[$status]); if($h) array_unshift($r, $h); } elseif(in_array($status, [1,2,5,6])){ $h = $this->sql->select($select, $tbl,$where.' ORDER BY o.sort ASC, o.created ASC',[$status]); if($h) $r[] = $h; } elseif(in_array($status, [10])){ $h = $this->sql->select($select, $tbl,$where.' AND incomingGoodsInspection > 0 ORDER BY o.sort ASC, o.created ASC',[$status]); if($h) $r[] = $h; } elseif(in_array($status, [15,20])){ $h = $this->sql->select($select, $tbl,$where.' AND incomingGoodsInspection > 0 ORDER BY o.dateStarted ASC',[$status]); if($h) $r[] = $h; } elseif(in_array($status, [30,31,32,33])){ $h = $this->sql->select($select, $tbl,$where.' AND incomingGoodsInspection > 0 ORDER BY o.created ASC',[$status]); if($h) $r[] = $h; }elseif(in_array($status, [95,98,99]) && $hasDeviationReport){ $h = $this->sql->select($select, $tbl,$where.' AND deviationReportPrinted = 0 ORDER BY o.created DESC',[$status]); if($h) $r[] = $h; }elseif(in_array($status, [80,95,98,99])){ $h = $this->sql->select($select, $tbl,$where.' ORDER BY o.dateFinished DESC',[$status]); if($h) $r[] = $h; } else{ $h = $this->sql->select($select, $tbl,$where.' AND incomingGoodsInspection > 0 ORDER BY o.dateFinished DESC',[$status]); if($h) $r[] = $h; } } if(empty($r)) return false; $result = array_reduce($r, function ($carry, $item) { return array_merge($carry, $item); }, []); if($sort){ usort($result, function($a, $b) { if ($a->dateFinished == $b->dateFinished) { return ($a->created < $b->created) ? 1 : -1; } return ($a->dateFinished < $b->dateFinished) ? 1 : -1; }); } if($limit){ $result = array_slice($result, 0, $limit); } return ($result); } /** * Get all Orders without Incoming Goods Inspection * @return array | boolean */ public function getAllNoIncomingGoodsInspection(){ $select = 'o.incomingGoodsInspection,o.hash,o.id,o.customerID,o.machineID,o.productID,o.customerOrderNr,o.amountTarget,o.amountFinished,o.briefing,o.status,o.color,o.sort,o.created,o.changed,IF(c.company != "",c.company,CONCAT(c.firstName," ",c.name)) AS customerNameShow, p.name AS productNameShow, DATE_FORMAT(o.created,"%d.%m.%Y") AS createDateShow'; $tbl = 'orders o, customer c, product p'; $where = 'o.incomingGoodsInspection=0 AND status >= 7 AND status <= 20 AND c.id = o.customerID AND p.id = o.productID'; $r = $this->sql->select($select, $tbl.' WHERE '.$where.' ORDER BY o.sort ASC, o.created ASC'); if(empty($r)) return false; return ($r); } public function searchOrder($q){ $select = 'o.incomingGoodsInspection, o.hash, o.id, o.customerID, o.machineID, o.productID, o.customerOrderNr, o.amountTarget, o.amountFinished, o.briefing, o.status, o.color, o.sort, o.created, o.changed, m.name AS machineNameShow, t.name AS toolingNameShow, IF(c.company != "", c.company, CONCAT(c.firstName, " ", c.name)) AS customerNameShow, p.name AS productNameShow, DATE_FORMAT(o.created, "%d.%m.%Y") AS createDateShow'; $tbl = 'orders o LEFT JOIN customer c ON c.id = o.customerID LEFT JOIN product p ON p.id = o.productID LEFT JOIN machine m ON m.id = o.machineID LEFT JOIN tooling t ON t.id = o.toolingID'; $where = '(o.customerOrderNr LIKE ? OR p.name LIKE ? OR c.company LIKE ? OR CONCAT(c.firstName, " ", c.name) LIKE ?)'; $return = $this->sql->select($select, $tbl,$where.' ORDER BY o.sort ASC, o.created ASC',['%'.$q.'%','%'.$q.'%','%'.$q.'%','%'.$q.'%']); if(!$return) $return = []; $i = 0; foreach($return AS $r){ $return[$i]->statusName = $this->getStatusName($r->status,$r->incomingGoodsInspection); $return[$i]->name = showOrderName($r); $i++; } return ($return); } /** * Print Deviation Report (Abweichungsbericht) * @param object $p * @param boolean $showBrowser * @return boolean */ public function printDeviationReport($p,$showBrowser=false){ $orderID = $this->getOrderIDbyHash($p->hash); if(!$orderID){ return false; } $order = $this->getOrder($orderID); $path = 'files/reports/'.$p->hash.'/'; if(!is_dir(DIR.$path)) mkdir(DIR.$path, 0777, true); $filename = showOrderName($order).'-abweichungsbericht.pdf'; if($p->reportCount){ $filename = showOrderName($order).'-bericht-kiste-'.$p->reportCount.'.pdf'; } $amountTables = $this->getAmountTablePDF($order,$p->reportCount); $date = $order->dateFinishedShow; $creator = ''; foreach($order->task AS $task){ if($task->taskID == 9){ $creator = $task->userFirstName.' '.$task->userName; } } $html = '<!DOCTYPE html> <html> <head> <link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;700&display=swap" rel="stylesheet"> <style> *{ font-family: "Ubuntu"; font-size: 20px; } h1,h2,h3,h4,strong{ font-weight: 700; } .wp100{ width: 100%; } h1, h2{ font-size: 24px; } @page { margin: 20px 80px 20px; } .ta-right{ text-align: right; } header{ position: fixed; top: 0px; left: 0px; right: 0px; color: #999; } main{ margin-top: 50px; page-break-after: always; } footer{ width: 100%; position: fixed; height: 0; bottom: 30px; left: 0; right: 0; color: #999; font-size: 10px; } table{ width: 100%; margin: 0; td{ width: 40%; text-align: left; } td.b{ width: 60%; border: 2px solid #000; padding: 10px; } } </style> </head> <title>Abweichungsbericht '.showOrderName($order).'</title> <body> <header style="text-align: right;"> <img src="'.HOST.'/assets/logo/logo-dark.png" style="width: 200px;" /> </header>'; foreach($amountTables AS $amountTable){ $html .= '<main class="all"> <h2>Abweichungsbericht</h2> <table> <tr> <td>Kunde:</td> <td class="b">'.$order->customerNameShow.'</td> </tr> <tr> <td>Auftragsnummer:</td> <td class="b">'.showOrderName($order).'</td> </tr> <tr> <td>Datum:</td> <td class="b">'.$date.'</td> </tr> <tr> <td>Artikel:</td> <td class="b">'.$order->productNameShow.'</td> </tr> </table> <h2 style="margin-top: 50px;">Stückzahlen</h2> '.$amountTable.' <table style="margin-top: 50px;"> <tr> <td>Name des Erstellers:</td> <td class="b">'.$creator.'</td> </tr> </table> </main>'; } $html .= '</body> </html>'; $fontDirectory = '/var/www/html/kft/assets/fonts'; //change to the diretory where you fonts is located on your server $options = new Dompdf\Options(); $options->set('enable_php',true); $options->set('isRemoteEnabled', true); $options->set('isHtml5ParserEnabled', true); $options->setIsRemoteEnabled(true); $options->setChroot($fontDirectory); $dompdf = new Dompdf\Dompdf($options); $dompdf->getFontMetrics()->registerFont( ['family' => 'Ubuntu', 'style' => 'normal', 'weight' => 'normal'], $fontDirectory . '/ubuntu-v20-latin-regular.ttf' ); $dompdf->getFontMetrics()->registerFont( ['family' => 'Ubuntu', 'style' => 'normal', 'weight' => 'bold'], $fontDirectory . '/ubuntu-v20-latin-700.ttf' ); $dompdf->loadHtml($html); $dompdf->render(); $output = $dompdf->output(); if(!$order->deviationReportPrinted){ $this->changeDeviationReportPrinted($orderID); } if($showBrowser){ echo $dompdf->stream($output, ["Attachment" => false]); exit(0); } file_put_contents(DIR.$path.$filename, $output); return HOST.'/'.$path.$filename.'?'.filemtime(DIR.$path.$filename); } private function getAmountTablePDF($order,$reportCount,$countPages=0,$badpartIDs=[]){ $newBadpartIDs = []; $amountTable = ''; $goodParts = 0; if(!$reportCount){ // Display all in one Table: $amountTable .= '<table> <tr> <td>Gute Teile:</td> <td class="b">'.$order->amountGoodPart.' St.</td> </tr>'; foreach($order->badpartSum AS $badpart){ if($badpart->badpartID) $amountTable .= '<tr> <td>'.$badpart->name.':</td> <td class="b">'.$badpart->totalAmount.' St.</td> </tr>'; } $amountTable .= '<tr> <td>Summe:</td> <td class="b">'.($order->amountGoodPart + $order->amountBadPart).' St.</td> </tr> </table>'; }else{ $taskCounter = 0; $reportCounter = 1; $prevBatch = '0000-00-00'; $reportCount++; $date = $order->dateFinishedShow; $amountTable = '<table>'; if($order->exactBatchSize && !$badpartIDs){ $goodParts = $order->batchSize > 0 ? $order->amountGoodPart % $order->batchSize : $order->amountGoodPart; $amountTable .= '<tr> <td>Gute Teile:</td> <td class="b">'.$goodParts.' St.</td> </tr>'; }else{ foreach($order->task AS $task){ // Good Parts if the batchSize is not exact -> uses the times when the batch was created if(($task->taskID == 8 || $task->taskID == 9) && $parts = $this->countPartsByCreated($order->part, $prevBatch, $task->created)){ if($reportCount == $reportCounter){ $amountTable .= '<tr> <td>Gute Teile:</td> <td class="b">'.$parts->goodParts.' St.</td> </tr>'; $goodParts = $parts->goodParts; $date = $task->createdDateShow.', '.$task->createdTimeShow.' Uhr'; } $prevBatch = $task->created; $reportCounter++; } $taskCounter++; } } // Is not batchsize is defined in product -> the batchSize is always the amount of good parts + bad parts if(!$order->batchSize){ $order->batchSize = $order->amountBadPart + $goodParts; } usort($order->badpartSum, function($a, $b) { return $b->sort - $a->sort; }); $actualBatchSize = $goodParts; if($order->badpartSum){ foreach($order->badpartSum AS $badpart){ if(!$badpart->badpartID || $badpart->badpartID === 1) continue; $foundKey = array_search($badpart->badpartID, array_column($badpartIDs, 'badpartID')); if(!$badpartIDs || $foundKey !== false){ if(!$badpartIDs && $badpart->totalAmount > $order->batchSize){ //Falls mehr als eine Batch an schlechten Teilen vorhanden sind: if($order->batchSize > 0){ $fullBatches = intdiv($badpart->totalAmount, $order->batchSize); $rest = $order->batchSize > 0 ? $badpart->totalAmount % $order->batchSize : $badpart->totalAmount; }else{ $fullBatches = 1; $rest = 0; } for ($i = 0; $i < $fullBatches; $i++) { $newBadpartIDs[] = [ 'badpartID' => $badpart->badpartID, 'amount' => $order->batchSize ]; } if ($rest > 0) { $newBadpartIDs[] = [ 'badpartID' => $badpart->badpartID, 'amount' => $rest ]; } }elseif($foundKey !== false && isset($badpartIDs[$foundKey]["amount"]) && $badpartIDs[$foundKey]["amount"] + $actualBatchSize <= $order->batchSize){ $amountTable .= '<tr> <td>'.$badpart->name.':</td> <td class="b">'.$badpartIDs[$foundKey]["amount"].' St.</td> </tr>'; $actualBatchSize += $badpartIDs[$foundKey]["amount"]; unset($badpartIDs[$foundKey]); }elseif($badpart->totalAmount + $actualBatchSize > $order->batchSize){ // Falls die aktuellen Teile nicht mehr in die Kiste passen: $newBadpartIDs[] = ['badpartID' => $badpart->badpartID, 'amount' => $badpart->totalAmount]; }else{ $amountTable .= '<tr> <td>'.$badpart->name.':</td> <td class="b">'.$badpart->totalAmount.' St.</td> </tr>'; $actualBatchSize += $badpart->totalAmount; } } } } $amountTable .= '<tr> <td>Summe:</td> <td class="b">'.($actualBatchSize).' St.</td> </tr> </table>'; /* Every Abweichungsbericht for each batch: $taskCounter = 0; $reportCounter = 1; $prevBatch = 0; foreach($order->task AS $task){ $nextTask = isset($order->task[$taskCounter+1])?$order->task[$taskCounter+1]:false; if($task->taskID == 8 && $parts = $this->countPartsByCreated($order->part, $prevBatch, $task->created)){ if($p->reportCount == $reportCounter){ $amountTable .= '<table> <tr> <td>Gute Teile:</td> <td class="b">'.$parts->goodParts.' St.</td> </tr>'; foreach($parts->badparts AS $badpart){ if($badpart->badpartID) $amountTable .= '<tr> <td>'.$badpart->name.':</td> <td class="b">'.$badpart->totalAmount.' St.</td> </tr>'; } $amountTable .= '<tr> <td>Summe:</td> <td class="b">'.($parts->goodParts + $parts->badParts).' St.</td> </tr> </table>'; $date = $task->createdDateShow.', '.$task->createdTimeShow.' Uhr'; } $prevBatch = $task->created; $reportCounter++; } $taskCounter++; } */ } $r[] = $amountTable; if($badpartIDs){ $newBadpartIDs = array_values($badpartIDs); } if($newBadpartIDs){ $r = array_merge(array_values($r), array_values($this->getAmountTablePDF($order,$reportCount,($countPages+1),$newBadpartIDs))); } return $r; } }PK ! i�� � machine.class.phpnu ��̗� <?php class Machine { private $sql = false; function __construct() { global $sql; $this->sql = $sql; } /** * Add Machine * @param object $p * @return boolean */ public function add($p) { $color = generateLightColor(); return $this->sql->insert('machine', 'machineTypeID,name,location,description,color,created,changed', [$p->machineTypeID, $p->name, $p->location, $p->description, $color, NOW, NOW]); } /** * Change Machine * @param object $p * @return boolean */ public function change($p) { return $this->sql->update('machine', 'name,location,description,color,changed', [$p->name, $p->location, $p->description, $p->color, NOW], 'id=?', $p->machineID); } /** * Get all Machines * @return array */ public function getAll() { return $this->sql->select('m.id,m.machineTypeID,m.name,m.location,m.description,m.color,t.nameShort as typeNameShort', 'machine m, machineType t WHERE t.id = m.machineTypeID ORDER BY name ASC'); } /** * Get Machine by ID * @param int $machineID * @return object */ public function getMachine($machineID) { return $this->sql->select('id,machineTypeID,name,location,description,color', 'machine', 'id=?', $machineID, 1); } /** * Get all Machine Types * @return array */ public function getTypeAll() { return $this->sql->select('id,name,nameShort', 'machineType ORDER BY name ASC'); } /** * Get Machine Type by ID * @param int $machineTypeID * @return object */ public function getType($machineTypeID) { return $this->sql->select('id,name,nameShort', 'machineType', 'id=?', $machineTypeID, 1); } /** * Add Machine Type * @param object $p * @return boolean */ public function addType($p) { return $this->sql->insert('machineType', 'name,nameShort,created,changed', [$p->name, $p->nameShort, NOW, NOW]); } /** * Change Machine Type * @param object $p * @return boolean */ public function changeType($p) { return $this->sql->update('machineType', 'name,nameShort,changed', [$p->name, $p->nameShort, NOW], 'id=?', $p->machineTypeID); } /** * Get all Machinetypes for a specific Product * @param int $productID * @return array */ public function getTypeAllByProduct($productID) { return $this->sql->select('t.id,t.name,t.nameShort', 'machineType t, product_machineType p','t.id = p.machineTypeID AND p.productID=? ORDER BY t.name ASC', $productID); } /** * Get all Machinetypes without existing ones for a specific Product * @param int $productID * @return array */ public function getTypesAllWithoutExisting($productID) { return $this->sql->select('t.id,t.name', 'machineType t','t.id NOT IN (SELECT p.machineTypeID FROM product_machineType p WHERE p.productID=?) ORDER BY t.name ASC', $productID); } /** * Add Machine Type to Product * @param object $p * @return boolean */ public function addTypeProduct($p) { return $this->sql->insert('product_machineType', 'productID,machineTypeID,created', [$p->productID, $p->machineTypeID, NOW]); } /** * Delete Machine Type from Product * @param object $p * @return boolean */ public function deleteTypeProduct($p) { return $this->sql->delete('product_machineType', 'productID=? AND machineTypeID=?', [$p->productID, $p->machineTypeID]); } }PK ! E|C C mailer.class.phpnu ��̗� <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; class Mailer{ private $sql; private $mail; private $host = 'smtp.ionos.de'; private $username = 'noreply@kockzius.com'; private $password = 'yG!E?Z_TiE1e*BO6_87Rh'; private $port = 587; private $secure = 'STARTTLS'; private $from = 'noreply@kockzius.com'; private $fromName = 'Kockzius | Maschinentool'; public function __construct(){ global $sql; $this->sql = $sql; } public function myMail($email,$subject,$html,$attachments=false,$cc=false){ $mailID = $this->logMail($email,$subject,$html,$attachments); $mail = new PHPMailer(true); try { // $mail->Timeout = 10; // $mail->SMTPDebug = PHPMailer\PHPMailer\SMTP::DEBUG_SERVER; $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = $this->host; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $this->username; // SMTP username $mail->Password = $this->password; // SMTP password $mail->SMTPSecure = $this->secure; // Enable TLS encryption, `ssl` also accepted $mail->Port = $this->port; // TCP port to connect to $mail->CharSet = "UTF-8"; $mail->setFrom($this->from, $this->fromName); if(!is_array($email)) $email = [$email]; foreach($email AS $e) $mail->addAddress($e); if ($attachments) { if (is_array($attachments)) { foreach ($attachments as $a) $mail->addAttachment($a); } else $mail->addAttachment($attachments); } $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $html; $mail->send(); $this->logMailStatus($mailID,1); return true; }catch (Exception $e) { // echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; $this->logMailStatus($mailID,0,1,$mail->ErrorInfo); } return false; } private function logMail($email,$subject,$html,$attachments){ if(!is_array($email)) $email = [$email]; $attachments = ($attachments)?json_encode($attachments):''; return $this->sql->insert('log_mail','fromMail,toMail,subject,message,attachments',[$this->from,implode(',',$email),$subject,$html,$attachments]); } private function logMailStatus($mailID,$success=0,$error=0,$errorMsg=''){ return $this->sql->update('log_mail','success,error,errorMsg',[$success,$error,$errorMsg],'id = ?',$mailID); } }PK ! *k!�&