public function requestQR() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $idResto = $this->mustCheck($_POST["id_restaurant"], "Who Are You?"); $qty = $this->mustCheck($_POST["qty"], "No Qty?"); $c = new QRRequestModel(); $checkQR = $c->getWhere("id_restaurant='{$idResto}' AND status='0'"); if (count($checkQR) > 0) { Generic::errorMsg("You Still Have " . $checkQR[0]->quantity . " QR Code(s) Request"); } $rQR = new QRRequestModel(); $rQR->id_restaurant = $idResto; $rQR->quantity = $qty; $rQR->status = "0"; $rQR->createdOn = leap_mysqldate(); $rQR->save(); $this->success(null); }
public function createQRbyRestoID() { $id_restaurant = $_GET['id_restaurant']; $quantityQR = $_GET['quantityQR']; $id_request = $_GET['id_request']; $objResto = new MasterRestaurantModel(); $objResto->getByID($id_restaurant); $objResto->table_quantity = $objResto->table_quantity + $quantityQR; $objResto->load = 1; $objResto->save(); // pr($objResto); $objQRRequest = new QRRequestModel(); $objQRRequest->getByID($id_request); $objQRRequest->createdOn = leap_mysqldate(); // pr($objQRRequest); $objQRRequest->status = "1"; $objQRRequest->load = 1; $objQRRequest->save(); $objQR = new QRModel(); global $db; $qtydiDB = "SELECT max(id_qr) as max from menurevo__QR"; $arr = $db->query($qtydiDB, 1); for ($i = $arr->max + 1; $i <= $quantityQR + $arr->max; $i++) { $encode = addslashes(base64_encode($i)); $q = "INSERT INTO menurevo__QR (id_qr, textQR,status) VALUES({$i},'{$encode}',0)"; $id = $db->query($q, 1); } $pdf = new FPDF(); $myarray = array(1, 2, 3); $pdf->SetFont('Arial', 'B', 16); for ($i = $arr->max + 1; $i <= $quantityQR + $arr->max; $i++) { $pdf->AddPage(); $pdf->Image("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chld=L|0&chl=" . base64_encode($i), 60, 30, 90, 0, 'PNG'); $pdf->Text(85, 130, "Menu Revolution"); } $pdf->Output(); ?> <html> <head> <title>Print QR-Code</title> <style> body{ margin: 0; padding: 0; font-family: verdana;} </style> </head> <body> <?php for ($i = $arr->max + 1; $i <= $quantityQR + $arr->max; $i++) { ?> <!-- <div style="width:800px; border-bottom: 3px dashed #aaaaaa; margin-bottom: 20px;"> <img src="<?php echo _SPPATH; ?> images/headerleap.jpg" width="100%">--> <div style="padding:40px; text-align: center;"> <!--<div style="letter-spacing: 2px; font-size: 18px; font-weight: bold; padding-bottom: 20px;"> <?php echo $mur->admin_nama_depan; ?> </div>--> <img src="<?php echo "https://chart.googleapis.com/chart?chs=150x150&cht=qr&chld=L|0&chl=" . base64_encode($i); ?> "alt="QR"> </div> <!--</div>--> <?php } ?> </body> </html><?php die('finished'); }