public function overwriteRead($return)
 {
     $objs = $return['objs'];
     foreach ($objs as $obj) {
         if (isset($obj->id_restaurant)) {
             $resto = new MasterRestaurantModel();
             $resto->getByID($obj->id_restaurant);
             $obj->id_restaurant = $resto->name;
         }
         if (isset($obj->id_bank)) {
             $bank = new BankModel();
             $bank->getByID($obj->id_bank);
             $obj->id_bank = $bank->bank_name;
         }
         if (isset($obj->start_fee)) {
             $date = new DateTime($obj->start_fee);
             $obj->start_fee = $date->format('d.m.Y');
         }
         if (isset($obj->end_fee)) {
             $dateEnd = new DateTime($obj->end_fee);
             $obj->end_fee = $dateEnd->format('d.m.Y');
         }
     }
     return $return;
 }
    public function overwriteRead($return)
    {
        $objs = $return['objs'];
        foreach ($objs as $obj) {
            $obj->removeAutoCrudClick = array("status");
            if (isset($obj->status)) {
                $idR = $obj->id_request;
                if ($obj->status == "1") {
                    $obj->status = '<button type="button" id="button' . $idR . '" onclick="updateStatusCashout(' . $obj->status . ',' . $idR . ')" style="width: 100%;" class="btn btn-success">Paid</button>';
                } else {
                    if ($obj->status == "0") {
                        $obj->status = '<button type="button" id="button' . $idR . '" onclick="updateStatusCashout(' . $obj->status . ',' . $idR . ')" style="width: 100%;" class="btn btn-danger">Pay Now</button>';
                    }
                }
            }
            if (isset($obj->id_restaurant)) {
                if ($obj->id_restaurant != "") {
                    $r = new MasterRestaurantModel();
                    $r->getByID($obj->id_restaurant);
                    $obj->id_restaurant = $r->name;
                }
            }
            if (isset($obj->datetime_request)) {
                $d = strtotime("{$obj->datetime_request}");
                $obj->datetime_request = date("d M, y h:m a", $d);
            }
        }
        ?>
        <script>
            function updateStatusCashout(status, id) {
                if (status == "1") {
                    alert("ID " + id + " Already Paid");
                    return;
                } else {
                    if (!confirm("Set Request to Paid?")) {
                        return;
                    }
                }

                $.ajax({
                    method: "GET",
                    url: _sppath + "MasterCashOutRequest/setCashOutPaid",
                    data: {id_request: id}
                })
                    .done(function (msg) {
                        console.log(msg);
                        var json_obj = $.parseJSON(msg);//parse JSON
                        var statusCode = json_obj.status_code;
                        if (statusCode == 0) {
                            alert(json_obj.status_message);
                        } else {
                            alert(json_obj.status_message);
                        }
                        lwrefresh('CashOutRequest');
                    });
            }
        </script>
        <?php 
        return $return;
    }
 public function overwriteRead($return)
 {
     $objs = $return['objs'];
     foreach ($objs as $obj) {
         if (isset($obj->id_restaurant)) {
             if ($obj->id_restaurant == "0") {
                 $obj->id_restaurant = "Nothing Selected";
             } else {
                 $r = new MasterRestaurantModel();
                 $r->getByID($obj->id_restaurant);
                 $obj->id_restaurant = $r->name;
             }
         }
         if (isset($obj->id_dish)) {
             if ($obj->id_dish == "0") {
                 $obj->id_dish = "Nothing Selected";
             } else {
                 $d = new MasterDishModel();
                 $d->getByID($obj->id_dish);
                 $obj->id_dish = $d->name;
             }
         }
     }
     return $return;
 }
 public function overwriteForm($return, $returnfull)
 {
     $return['status'] = new Leap\View\InputSelect(array("1" => "Free", "0" => "Occupied"), "status", "status", $this->status);
     $return['availability'] = new Leap\View\InputSelect(array("1" => "Active", "0" => "Inactive"), "availability", "availability", $this->availability);
     $resto = new MasterRestaurantModel();
     $resto->getByID($this->id_restaurant);
     $return['id_restaurant'] = new \Leap\View\InputText("hidden", "id_restaurant", "id_restaurant", $this->id_restaurant);
     $return['resto_name'] = new \Leap\View\InputText("text", "resto_name", "resto_name", $resto->name);
     $return['resto_name']->setReadOnly(true);
     return $return;
 }
 public function overwriteRead($return)
 {
     $objs = $return['objs'];
     foreach ($objs as $obj) {
         if (isset($obj->id_restaurant)) {
             $resto = new MasterRestaurantModel();
             $resto->getByID($obj->id_restaurant);
             $obj->id_restaurant = $resto->name;
         }
     }
     return $return;
 }
 public function overwriteRead($return)
 {
     $objs = $return['objs'];
     foreach ($objs as $obj) {
         if (isset($obj->id_restaurant)) {
             $resto = new MasterRestaurantModel();
             $resto->getByID($obj->id_restaurant);
             $obj->id_restaurant = $resto->name;
         }
         if (isset($obj->start)) {
             $date = new DateTime($obj->start);
             $obj->start = $date->format('d.m.Y');
         }
         if (isset($obj->end)) {
             $dateEnd = new DateTime($obj->end);
             $obj->end = $dateEnd->format('d.m.Y');
         }
         ?>
         <script>
             $(document).ready(function () {
                 var date = new Date();
                 var i = 1;
                 while ($('#id_MR_' + i).text().trim()) {
                     var dateEndNow = $('#end_' + i).text().trim();
                     var dt1 = parseInt(dateEndNow.substring(0, 2));
                     var mon1 = parseInt(dateEndNow.substring(3, 5));
                     var yr1 = parseInt(dateEndNow.substring(6, 10));
                     var dateEnd = new Date(yr1, mon1 - 1, dt1);
                     var diff = dateEnd - date, sign = diff < 0 ? -1 : 1, milliseconds, seconds, minutes, hours, days;
                     diff = (diff - (milliseconds = diff % 1000)) / 1000;
                     diff = (diff - (seconds = diff % 60)) / 60;
                     diff = (diff - (minutes = diff % 60)) / 60;
                     days = (diff - (hours = diff % 24)) / 24;
                     if(days <2){
                         $("#MRDiscountModel_" + i).css("background-color", "red");
                     }
                     else{
                         
                         $("#MRDiscountModel_" + i).css("background-color", "yellow");
                     }
                     i = i + 1;
                 }
             });
             </script>
             <?php 
     }
     return $return;
 }
 public function requestCashOut()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $idResto = Generic::mustCheck($_GET['id_restaurant'], "No ID Restaurant Found");
     $amount = Generic::mustCheck($_GET['amount'], "No Amount Found");
     if ($amount == "0") {
         Generic::errorMsg("Zero Amount not Allowed");
     }
     $bankAcc = new RestoBankAccModel();
     $arrBank = $bankAcc->getWhere("id_restaurant='{$idResto}'");
     if (count($arrBank) <= 0) {
         Generic::errorMsg("You Have Not Set Your Cash Out Account");
     }
     $req = new MasterCashOutRequestModel();
     $arrReq = $req->getWhere("id_restaurant='{$idResto}' AND status='0'");
     if (count($arrReq) > 0) {
         Generic::errorMsg("You Already Request Cash Out");
     }
     $resto = new MasterRestaurantModel();
     $resto->getByID($idResto);
     $cashOut = new MasterCashOutRequestModel();
     $cashOut->id_restaurant = $idResto;
     $cashOut->datetime_request = leap_mysqldate();
     $cashOut->amount = $amount;
     $cashOut->status = 0;
     $idNewRequest = $cashOut->save();
     $tr = new MasterRestoTransactionModel();
     $tr->id_request = $idNewRequest;
     $tr->id_restaurant = $idResto;
     $tr->gross_amount = (double) $amount * -1;
     $tr->net_amount = (double) $amount * -1;
     $tr->approved = "0";
     $tr->type_transaction = "2";
     $tr->datetime_transaction = leap_mysqldate();
     $tr->mr_fee = 0;
     $tr->credit_card_fee = 0;
     $tr->other_fee = 0;
     $tr->bank_disc = 0;
     $tr->save();
     $json['status_code'] = 1;
     $json['results']['messages'] = "success";
     echo json_encode($json);
     die;
 }
 public function requestRestoPermission($userModel, $tableModel, $paymentMethod)
 {
     $resto = new MasterRestaurantModel();
     $resto->getByID($tableModel['id_restaurant']);
     //TODO CHECK RESTAURANT EMPTY, IF EMPTY goto ERROR()  -> sdh di kerjakan
     if ($resto == null) {
         Generic::errorMsg("Restaurant is empty");
     }
     $msg = $userModel->user_name . " want to open table no. " . $tableModel['table_number'];
     $j["user_id"] = $userModel->id_user;
     $j["user_name"] = $userModel->full_name;
     $j["user_pic"] = _BPATH . _PHOTOURL . $userModel->pic;
     $j["id_table"] = $tableModel['id_table'];
     $j["table_number"] = $tableModel['table_number'];
     $j["payment_method"] = $paymentMethod;
     $j['datetime'] = date('Y-m-d H:i:s');
     $restoId = $tableModel['id_restaurant'];
     $this->pushToRestoCashier($tableModel['id_restaurant'], $msg, json_encode($j), Push::$typeRequestOpenTable);
 }
 public function overwriteRead($return)
 {
     $objs = $return['objs'];
     //        pr($objs);
     foreach ($objs as $obj) {
         if (isset($obj->status)) {
             if ($obj->status == "1") {
                 $obj->status = "Active";
             } else {
                 $obj->status = "Inactive";
             }
         }
         if (isset($obj->id_restaurant)) {
             $resto = new MasterRestaurantModel();
             $resto->getByID($obj->id_restaurant);
             $obj->id_restaurant = $resto->name;
         }
     }
     return $return;
 }
 /**
  * Invoice constructor.
  */
 public function __construct($idOrder, $calcPending = 1)
 {
     $this->calcPending = $calcPending;
     $this->idOrder = $idOrder;
     $order = new MasterOrderModel();
     $order->getByID($idOrder);
     $restaurant = new MasterRestaurantModel();
     $restaurant->getByID($order->id_restaurant);
     $this->idRestaurant = $order->id_restaurant;
     $this->restaurantName = $restaurant->name;
     $user = new UserModel();
     $user->getByID($order->id_user);
     $this->idUser = $order->id_user;
     $this->userName = $user->full_name;
     $this->paymentMethod = $order->payment_method;
     $this->discRestaurant = $restaurant->disc_resto;
     $this->discMR = Util::getDiscountMR($order->id_restaurant);
     $this->feeMR = Util::getFeeMR($order->id_restaurant);
     if ($order->payment_method == Keys::$PAYMENT_TYPE_CREDIT_CARD) {
         $this->discBank = Util::getDiscountCreditCard($order->id_restaurant, $user->payment_bank_id);
         $this->feeNominalBank = Util::getFeeNominalCreditCard($order->id_restaurant, $user->payment_bank_id);
         $this->feePercentBank = Util::getFeePercentCreditCard($order->id_restaurant, $user->payment_bank_id);
     } else {
         if ($order->payment_method == Keys::$PAYMENT_TYPE_DOKU_WALLET) {
             $this->discBank = 0;
             $this->feeNominalBank = 0;
             $this->feePercentBank = 0;
         } else {
             $this->discBank = 0;
             $this->feeNominalBank = 0;
             $this->feePercentBank = 0;
         }
     }
     $this->serviceCharge = $restaurant->service_charge;
     $this->taxCharge = $restaurant->tax_pb_1;
     $this->otherCharge = $restaurant->other_charge;
     $this->updateSubTotal();
     $this->assignValue();
 }
 public function overwriteRead($return)
 {
     $objs = $return['objs'];
     foreach ($objs as $obj) {
         if (isset($obj->id_restaurant)) {
             if ($obj->id_restaurant != "") {
                 $r = new MasterRestaurantModel();
                 $r->getByID($obj->id_restaurant);
                 $obj->id_restaurant = $r->name;
             }
         }
         if (isset($obj->type_transaction)) {
             if ($obj->type_transaction == "1") {
                 $obj->type_transaction = "User Transaction";
             } elseif ($obj->type_transaction == "2") {
                 $obj->type_transaction = "Cash Out Request";
             } else {
                 $obj->type_transaction = "Error";
             }
         }
         if (isset($obj->approved)) {
             if ($obj->approved == "1") {
                 $obj->approved = "Yes";
             } elseif ($obj->approved == "0") {
                 $obj->approved = "No";
             } else {
                 $obj->approved = "Error";
             }
         }
         if (isset($obj->datetime_transaction)) {
             $d = strtotime("{$obj->datetime_transaction}");
             $obj->datetime_transaction = date("d M Y h:m a", $d);
         }
     }
     return $return;
 }
 public function getCategoriesByResto()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $idRestaurant = Generic::mustCheck($_GET['id_restaurant'], Keys::$ERR_NOT_FOUND_ID_RESTAURANT);
     $objResto = new MasterRestaurantModel();
     $objResto->getByID($idRestaurant);
     if (!Generic::IsNullOrEmptyString($objResto->id_categories)) {
         $arrCategories = explode(",", $objResto->id_categories);
     } else {
         $arrCategories = array();
     }
     $categories = array();
     foreach ($arrCategories as $idCat) {
         $c = new MasterCategoryModel();
         $c->getByID($idCat);
         if ($c->id_category) {
             $categories[] = $c->name;
         }
     }
     //        pr($arrCategories);
     //        pr($categories);
     $results['categories'] = $categories;
     $rawTags = array();
     $id_dish = isset($_GET['id_dish']) ? addslashes($_GET['id_dish']) : "";
     if ($id_dish) {
         $dish = new MasterDishModel();
         $dish->getByID($id_dish);
         $tagsIds = explode(",", $dish->dish_tags);
         if (count($tagsIds) != 0) {
             foreach ($tagsIds as $tagsId) {
                 if ($tagsId == null || $tagsId == "") {
                     continue;
                 }
                 $dishTag = new MasterDishTagModel();
                 $dishTag->getByID($tagsId);
                 $b["id_tag"] = $dishTag->id_tag;
                 $b["name"] = $dishTag->name;
                 $rawTags[] = $b;
             }
         }
     }
     $results['raw_tags'] = $rawTags;
     Generic::finish($results);
 }
 public function setRestoCategories()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $json = array();
     $json['status_code'] = 1;
     $id_restaurant = isset($_POST['id_restaurant']) ? addslashes($_POST['id_restaurant']) : "";
     if (!$id_restaurant) {
         Generic::errorMsg("Restaurant ID not Found");
     }
     $category = isset($_POST['categories']) ? $_POST['categories'] : "";
     if (!$category) {
         Generic::errorMsg("Category ID not found!");
     }
     $resto = new MasterRestaurantModel();
     $resto->getByID($id_restaurant);
     $arrOldCategories = explode(",", $resto->id_categories);
     $jsonCategories = json_decode($category);
     $jsonCategorieshlp = array();
     foreach ($jsonCategories as $cat) {
         $jsonCategorieshlp[] = $cat->category_name;
     }
     if (!in_array("OTHERS", $jsonCategorieshlp)) {
         $jsonCategorieshlp[] = "OTHERS";
     }
     $jsonCategorieshlp = array_unique($jsonCategorieshlp);
     $objCategory = new MasterCategoryModel();
     $idCategories = array();
     foreach ($jsonCategorieshlp as $category) {
         $arrCategory = $objCategory->getWhere("name = '{$category}'");
         if (count($arrCategory) == 0 && !Generic::IsNullOrEmptyString($category)) {
             $oc = new MasterCategoryModel();
             $oc->name = strtoupper($category);
             $oc->status = "1";
             $oc->is_drink = "0";
             $oc->save();
         }
     }
     foreach ($jsonCategorieshlp as $category) {
         $arrCategory = $objCategory->getWhere("name = '{$category}'");
         foreach ($arrCategory as $val) {
             $idCategories[] = $val->id_category;
         }
     }
     //compare old categories to new categories
     //cari yang dulu ada sekarang ga ada
     //migrasi dish ke others
     $missingCategories = array_diff($arrOldCategories, $idCategories);
     foreach ($missingCategories as $category) {
         $d = new MasterDishModel();
         $arrDishes = $d->getWhere("id_category = '{$category}' AND id_restaurant = '{$id_restaurant}'");
         foreach ($arrDishes as $dish) {
             $dish->load = 1;
             $dish->id_category = "0";
             $dish->save();
         }
     }
     $objRestaurant = new MasterRestaurantModel();
     $arrResto = $objRestaurant->getWhere("id_restaurant = '{$id_restaurant}'");
     if (count($arrResto) == 0) {
         $json['status_code'] = 0;
         $json['status_message'] = "No ID Found";
         echo json_encode($json);
         die;
     }
     $idCategories = implode(",", $idCategories);
     $arrResto[0]->id_categories = $idCategories;
     $arrResto[0]->load = 1;
     $idSave = $arrResto[0]->save();
     if (!$idSave) {
         Generic::errorMsg(Lang::t('save failed'));
     } else {
         $json['status_code'] = 1;
         $json['results'] = "Success";
     }
     echo json_encode($json);
     die;
 }
 public function addDishToMyFavorite()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $idUser = Generic::mustCheck($_GET['id_user'], "User ID not Found");
     $idDish = Generic::mustCheck($_GET['id_dish'], "Dish ID not Found");
     $user = new UserModel();
     $user->getByID($idUser);
     $arrFavDishIds = explode(',', $user->fav_dishes_ids);
     $alreadyInFavorite = count($arrFavDishIds) <= 0 ? false : in_array($idDish, $arrFavDishIds);
     if ($alreadyInFavorite) {
         Generic::errorMsg("Already Favorited");
     }
     if (count($arrFavDishIds) <= 0) {
         $user->fav_dishes_ids = $idDish;
     } else {
         $arrFavDishIds[] = $idDish;
         $arrFavDishIds = array_unique($arrFavDishIds);
         $user->fav_dishes_ids = implode(',', $arrFavDishIds);
     }
     $dish = new MasterDishModel();
     $dish->getByID($idDish);
     $dish->fav = $dish->fav + 1;
     $dish->save();
     $resto = new MasterRestaurantModel();
     $resto->getByID($dish->id_restaurant);
     $resto->fav = $resto->fav + 1;
     $resto->save();
     $user->save();
     $this->success();
 }
 public function clearRestoCats()
 {
     $catIdDefault = $this->createCategories("OTHERS");
     $rm = new MasterRestaurantModel();
     $arrResto = $rm->getAll();
     foreach ($arrResto as $r) {
         $resto = new MasterRestaurantModel();
         $resto->getByID($r->id_restaurant);
         $resto->id_categories = $catIdDefault;
         $resto->save();
     }
 }
 public function updateRestoMRFee()
 {
     $idsResto = Generic::mustCheck($_POST['id_restaurant'], "No Restaurant IDs Found");
     $fee = Generic::mustCheck($_POST['fee'], "No Fee Found");
     if (!is_numeric($fee)) {
         Generic::errorMsg("Fee Must Numbers");
     }
     if (doubleval($fee) > 100) {
         Generic::errorMsg("Fee Max 100%");
     }
     $ids = explode(',', $idsResto);
     if (count($ids) <= 0) {
         Generic::errorMsg("Empty Id");
     }
     $updateAll = in_array('0', $ids);
     if ($updateAll) {
         $r = new MasterRestaurantModel();
         $arrR = $r->getAll();
         foreach ($arrR as $singleR) {
             unset($resto);
             $resto = new MasterRestaurantModel();
             $resto->getByID($singleR->id_restaurant);
             $log = new LogDiscFeeModel();
             $log->id_reference = $singleR->id_restaurant;
             $log->change_type = "Fee MR";
             $log->change_from = Generic::IsNullOrEmptyString($resto->mr_fee) ? "0" : $resto->mr_fee;
             $log->change_to = $fee;
             $log->change_date_time = leap_mysqldate();
             $log->save();
             $resto->mr_fee = $fee;
             $resto->save();
         }
     } else {
         foreach ($ids as $id) {
             unset($resto);
             $resto = new MasterRestaurantModel();
             $resto->getByID($id);
             $log = new LogDiscFeeModel();
             $log->id_reference = $id;
             $log->change_type = "Fee MR";
             $log->change_from = Generic::IsNullOrEmptyString($resto->mr_fee) ? "0" : $resto->mr_fee;
             $log->change_to = $fee;
             $log->change_date_time = leap_mysqldate();
             $log->save();
             $resto->mr_fee = $fee;
             $resto->save();
         }
     }
     $json['status_code'] = 1;
     $json['status_message'] = "success";
     echo json_encode($json);
     die;
 }
    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');
    }
 public function getAllActiveRestoUser()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $id_restaurant = isset($_POST['id_restaurant']) ? addslashes($_POST['id_restaurant']) : "";
     if (!$id_restaurant) {
         $json['status_code'] = 0;
         $json['status_message'] = "No ID Found";
         echo json_encode($json);
         die;
     }
     $json = array();
     $json['status_code'] = 1;
     $objRestoUsers = new RestaurantUserModel();
     $arrRestoUsers = $objRestoUsers->getWhere("id_restaurant = '{$id_restaurant}' AND status = '1'");
     MasterDish::checkCount($arrRestoUsers);
     $sem = array();
     foreach ($arrRestoUsers as $val) {
         $sem["users"][] = RestaurantUser::getRestaurantUser($val->id_user);
     }
     $resto = new MasterRestaurantModel();
     $resto->getByID($id_restaurant);
     $sem['now_open'] = $resto->now_open;
     $sem['order_number'] = $resto->order_number;
     $json['results'] = $sem;
     echo json_encode($json);
     die;
 }
 public function deleteDish()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $json = array();
     $json['status_code'] = 1;
     $id_dish = isset($_POST['id_dish']) ? addslashes($_POST['id_dish']) : "";
     $id_restaurant = isset($_POST['id_restaurant']) ? addslashes($_POST['id_restaurant']) : "";
     if (!$id_dish) {
         Generic::errorMsg("No Dish ID Found");
     }
     $dish = new MasterDishModel();
     $dish->getByID($id_dish);
     if (!$id_restaurant) {
         Generic::errorMsg("No Restaurant ID Found");
     }
     $resto = new MasterRestaurantModel();
     $resto->getByID($id_restaurant);
     if ($dish->id_restaurant != $resto->id_restaurant) {
         Generic::errorMsg("Mismatch Dish and Restaurant");
     }
     if ($dish->status == "0") {
         Generic::errorMsg("Dish Already Deleted");
     } else {
         $dish->status = "0";
         $dish->save();
     }
     $json['status_message'] = 'Success';
     echo json_encode($json);
     die;
 }
 public function updateStatusProgress()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $idDish = $_GET["id_dish"];
     $idOrder = $_GET["id_order"];
     $idResto = $_GET["id_restaurant"];
     //TODO cek id_resto di order header apakah sama degan $Resto
     $objOrder = new MasterOrderModel();
     $arrOrder = $objOrder->getWhere("id_order='{$idOrder}' AND order_now='1' AND status_payment='0'");
     //        $objOrder->getByID($idOrder);
     if ($arrOrder[0]->id_restaurant != $idResto) {
         Generic::errorMsg("ID Resto in Order is not same as id resto!");
     }
     $resto = new MasterRestaurantModel();
     $resto->getByID($idResto);
     $od = new OrderDetailModel();
     $arrOrDetails = $od->getWhere("id_order='{$idOrder}' AND id_dish='{$idDish}' AND status_progress > 3");
     Generic::checkCountWithMsg($arrOrDetails, "Dish already out!");
     //pr($arrOrDetails);
     foreach ($arrOrDetails as $oDetails) {
         if ($oDetails->status_progress < 2) {
             pr($oDetails->status_progress);
             $oDetails->status_progress = $oDetails->status_progress + 1;
             $oDetails->load = 1;
             $oDetails->save();
             $sp = $oDetails->status_progress;
         } else {
             //TODO ERROR order already out
         }
     }
     $order = $this->updateOrderHeaderStatusProgress($idOrder);
     $ids = $order->user_guest_id + "," + $order->id_user;
     $msg = "Your ";
     if ($order->type_order == "0") {
         $msg .= "Dine In ";
     } elseif ($order->type_order == "3") {
         $msg .= "Take Away ";
     } else {
         $json["status_code"] = 1;
         $json["results"]["id_dish"] = $idDish;
         $json["results"]["id_order"] = $idDish;
         $json["results"]["id_restaurant"] = $idDish;
         $json["results"]["status_progress"] = $sp;
         $json["results"]["order_status_progress"] = $order->status_progress;
         echo json_encode($json);
         die;
     }
     $msg .= "order's status at {$resto->name} has been updated";
     $j["id_order"] = $idOrder;
     $json = json_encode($j);
     $_POST["ids"] = $ids;
     $_POST["msg"] = $msg;
     $_POST["json"] = $json;
     $_POST["type"] = 41;
     $p = new PushTo();
     $p->users();
     echo json_encode($json);
     die;
 }
 public function settlePayment()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $id_order = $_GET["id_order"];
     $id_user = $_GET["id_user"];
     $user = new UserModel();
     $user->getByID($id_user);
     $order = new MasterOrderModel();
     $order->getByID($id_order);
     $objResto = new MasterRestaurantModel();
     $objResto->getByID($order->id_restaurant);
     if ($user->payment_id == null || $user->payment_id == "0") {
         Generic::errorMsg("No Payment Method");
     }
     try {
         $result = Braintree_PaymentMethodNonce::create($user->braintree_id);
         $nonce = $result->paymentMethodNonce->nonce;
         $resultSale = Braintree_Transaction::sale(['amount' => $order->grand_total, 'paymentMethodNonce' => $nonce, 'options' => ['submitForSettlement' => True]]);
     } catch (Exception $e) {
         Generic::errorMsg($e->getMessage());
     }
     //        $transaction = $resultSale->transaction;
     //        $order->transaction_id = $transaction->id;
     //        $order->load = 1;
     //        $order->status_payment = '1';
     //        $orderObj->nonce_cc = $nonce;
     //        $order->isPaid = '1';
     //        $order->save();
     pr($resultSale);
     //        $json['results'] = "Your Payment was successful with ID Order " . $id_order;
     //        echo json_encode($json);
     //,
     //                        'descriptor' => [
     //                            'name' => $objResto->name . " - " . $objResto->order_number
     //                        ]
     //        die();
 }
 public function updateRestoMRDiscount()
 {
     $idsResto = Generic::mustCheck($_POST['id_restaurant'], "No Restaurant IDs Found");
     $disc = Generic::mustCheck($_POST['discount'], "No Discount Found");
     if (!is_numeric($disc)) {
         Generic::errorMsg("Discount Must Numbers");
     }
     if (strlen(trim($disc)) > 2) {
         Generic::errorMsg("Discount Max 2 Digits");
     }
     $ids = explode(',', $idsResto);
     if (count($ids) <= 0) {
         Generic::errorMsg("Empty Id");
     }
     $updateAll = in_array('0', $ids);
     if ($updateAll) {
         $r = new MasterRestaurantModel();
         $arrR = $r->getAll();
         foreach ($arrR as $singleR) {
             unset($resto);
             $resto = new MasterRestaurantModel();
             $resto->getByID($singleR->id_restaurant);
             unset($logdisc);
             $logdisc = new LogDiscFeeModel();
             $logdisc->id_reference = $resto->id_restaurant;
             $logdisc->change_type = "Discount MR";
             $logdisc->change_from = Generic::IsNullOrEmptyString($resto->disc_mr) ? "0" : $resto->disc_mr;
             $logdisc->change_to = $disc;
             $logdisc->change_date_time = leap_mysqldate();
             $logdisc->save();
             $resto->disc_mr = $disc;
             $resto->save();
         }
     } else {
         foreach ($ids as $id) {
             unset($resto);
             $resto = new MasterRestaurantModel();
             $resto->getByID($id);
             unset($logdisc);
             $logdisc = new LogDiscFeeModel();
             $logdisc->id_reference = $resto->id_restaurant;
             $logdisc->change_type = "Discount MR";
             $logdisc->change_from = Generic::IsNullOrEmptyString($resto->disc_mr) ? "0" : $resto->disc_mr;
             $logdisc->change_to = $disc;
             $logdisc->change_date_time = leap_mysqldate();
             $logdisc->save();
             $resto->disc_mr = $disc;
             $resto->save();
         }
     }
     $json['status_code'] = 1;
     $json['status_message'] = "success";
     echo json_encode($json);
     die;
 }
 public static function isRestaurantOpen($idResto)
 {
     $resto = new MasterRestaurantModel();
     $resto->getByID($idResto);
     return $resto->now_open == "1";
 }
 public function requestRestoPermission($userModel, $tableModel)
 {
     $resto = new MasterRestaurantModel();
     $resto->getByID($tableModel->id_restaurant);
     // persiapan push message
     $msg = $userModel->user_name . " want to open table no. " . $tableModel->table_number;
     $j["user"] = $userModel;
     $j["table"] = $tableModel;
     //simpan di tracker untuk nantinya dilihat di inbox
     $tracker = new TrackerRequestModel();
     $tracker->id_from = $userModel->id_user;
     $tracker->id_to = $tableModel->id_restaurant;
     $tracker->id_reference = $tableModel->id_table;
     $tracker->type = $this->typeRequestOpenTable;
     $tracker->title = "Request Open Table";
     $tracker->message = $msg;
     $tracker->image = "";
     $tracker->readed = 0;
     $tracker->answered = 0;
     $tracker->canceled = 0;
     $tracker->status = 1;
     $tracker->save();
     $this->pushToRestoCashier($tableModel->id_restaurant, $msg, json_encode($j), $this->typeRequestOpenTable);
 }
 public function sendwithreturn()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $json = array();
     $json['status_code'] = 1;
     $idOrder = $_GET['id_order'];
     $toEmail = $_GET['email'];
     $order = new MasterOrderModel();
     $order->getByID($idOrder);
     $resto = new MasterRestaurantModel();
     $resto->getByID($order->id_restaurant);
     $subject = "Your receipt from " . $restoName . " , Receipt#" . $idOrder;
     $od = new OrderDetailModel();
     $d = new MasterDishModel();
     //      $dompdf = new Dompdf\Dompdf();
     global $db;
     $q = "SELECT {$od->table_name}.id_dish, {$d->table_name}.name, SUM(quantity) AS sum_qty, {$d->table_name}.price,\nSUM({$od->table_name}.price) AS sum_price, status_progress FROM `{$od->table_name}`\nRIGHT JOIN {$d->table_name} ON {$od->table_name}.id_dish = {$d->table_name}.id_dish WHERE id_order='{$idOrder}' GROUP BY id_dish";
     $arrDetails = $db->query($q, 2);
     $css_boot = _BPATH . "themes/tbstheme_ori/css/bootstrap.min.css";
     $image1 = _BPATH . _PHOTOURL . $resto->image_logo;
     if ($image1 == "") {
         $image1 = _BPATH . _PHOTOURL . "noimage.jpg";
     }
     $head = "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
     $head = "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Notification email</title>";
     $head = $head . "<link href=" . $css_boot . " rel=\"stylesheet\">";
     $head = $head . "<link href=\"https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700&subset=latin,latin-ext\" rel=\"stylesheet\" type=\"text/css\">";
     $head = $head . "</head>";
     $html = "<div style=\"max-width: 800px; box-shadow: 0 0 10px rgba(0, 0, 0, .15); font-size: 16px; line-height: 24px; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; color: #555; margin: auto; padding: 30px; border: 1px solid #eee;\">\n<table style=\"width: 100%; line-height: inherit; text-align: left;\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align: top; padding: 5px;\" colspan=\"2\">\n<table style=\"width: 100%; line-height: inherit; text-align: left;\">\n<tbody>\n<tr>\n<td style=\"vertical-align: top; font-size: 45px; line-height: 45px; color: #333; width: 50%; display: block; text-align: left; padding: 5px 5px 20px;\" align=\"left\" valign=\"top\"><img style=\"width: 50%; max-width: 300px;\" src=" . $image1 . " alt=\"\" /></td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; width: 100%; display: block; text-align: left; padding: 5px 5px 40px;\" align=\"center\" valign=\"top\">";
     $html = $html . "<strong>" . $resto->name . "</strong><br />";
     $html = $html . $resto->district . " - " . $resto->city . " <br>";
     $html = $html . "Phone : " . $resto->phone_no . "</td>";
     $html = $html . "</tr>\n</tbody>\n</table>\n</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; padding: 5px;\" colspan=\"2\" valign=\"top\">\n<table style=\"width: 100%; line-height: inherit; text-align: left;\">\n<tbody>\n<tr>\n<td style=\"vertical-align: top; text-align: left; t width: 50%; display: block; padding: 5px 5px 20px;\" align=\"left\" valign=\"top\">";
     $html = $html . "</tr>";
     $html = $html . "Receipt #: " . $idOrder;
     $html = $html . "<br/>";
     $html = $html . "  Server : ";
     if ($order->type_order == "1" || $order->type_order == "3") {
         $html = $html . "Apps Order";
     } else {
         $html = $html . $order->server_name;
     }
     $html = $html . "<br/>";
     $html = $html . " Time Order : " . date("d M, Y H:m", strtotime($order->datetime_order));
     $html = $html . "<br/>";
     $html = $html . " Payment Method : " . Generic::selectPaymentMethod($order->status_payment);
     $html = $html . "<br/>";
     if ($order->type_order == "1" || $order->type_order == "3") {
         $html = $html . "Apps Order";
     } else {
         $html = $html . "Manual Order";
     }
     $html = $html . "<br/>";
     $html = $html . "</td>";
     $html = $html . "</tr> \n</tbody>\n</table>\n</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #ddd; font-weight: bold; background-color: #eee; padding: 5px;\" valign=\"top\" bgcolor=\"#eee\">Item</td>\n<td style=\"vertical-align: top; text-align: right; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #ddd; font-weight: bold; background-color: #eee; padding: 5px;\" align=\"center\" valign=\"top\" bgcolor=\"#eee\">#</td>\n<td style=\"vertical-align: top; text-align: right; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #ddd; font-weight: bold; background-color: #eee; padding: 5px;\" align=\"right\" valign=\"top\" bgcolor=\"#eee\">Price</td>\n  <td style=\"vertical-align: top; text-align: right; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #ddd; font-weight: bold; background-color: #eee; padding: 5px;\" align=\"right\" valign=\"top\" bgcolor=\"#eee\">Total</td>\n</tr>";
     foreach ($arrDetails as $details) {
         $void = "";
         if ($details->status_progress == "9") {
             $void = "<strong> Voided </strong>";
             $details->price = 0;
             $details->sum_price = 0;
         }
         $html = $html . "<tr><td style=\"vertical-align: top; border-bottom-width: 1px; border-bottom-color: #eee; border-bottom-style: solid; padding: 5px;\" valign=\"top\">" . $details->name . $void . "</td>";
         $html = $html . "<td style=\"vertical-align: top; text-align: right; border-bottom-width: 1px; border-bottom-color: #eee; border-bottom-style: solid; padding: 5px;\" align=\"right\" valign=\"top\">" . $details->sum_qty . "</td>";
         $html = $html . "<td style=\"vertical-align: top; text-align: right; border-bottom-width: 1px; border-bottom-color: #eee; border-bottom-style: solid; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($details->price) . "</td>";
         $html = $html . "<td style=\"vertical-align: top; text-align: right; border-bottom-width: 1px; border-bottom-color: #eee; border-bottom-style: solid; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($details->sum_price) . "</td></tr>";
     }
     $html = $html . "<tr>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Total : </td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->total_cost) . "</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Disc Resto : </td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->disc_resto) . "</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Disc Credit Card : </td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->disc_bank) . "</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Disc MR : </td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->disc_mr) . "</td>\n</tr>\n\n<tr>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Tax PB1 : </td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->tax_pb1) . "</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Service Charge : </td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->tax_pb1) . "</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Other Charge : </td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->tax_pb1) . "</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Grand Total :</td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->grand_total) . "</td>\n</tr>\n\n</tbody>\n</table>\n</div></html>";
     $html = $head . $html;
     $mail = new Leapmail();
     $res = $mail->sendEmailHTML($toEmail, $subject, $html);
     return $res;
 }
 private function viewSearchTerm($searchType, $searchTerm)
 {
     switch ($searchType) {
         case "1":
             $rt = new MasterRestaurantTypeModel();
             $rt->getByID($searchTerm);
             return $rt->name;
         case "2":
             $r = new MasterCategoryModel();
             $r->getByID($searchTerm);
             return $r->name;
         case "3":
             $r = new CuisineModel();
             $r->getByID($searchTerm);
             return $r->name_cuisine;
             //            case "4": {
             //                return new Leap\View\InputText("text", "search_term", "search_term", $this->search_term);
             //            }
             //            case "5": {
             //                $r = new MasterDishTagModel();
             //                $r->getByID($searchTerm);
             //                return $r->name;
             //            }
             //            case "6": {
             //                return new Leap\View\InputText("text", "search_term", "search_term", $this->search_term);
             //            }
         //            case "4": {
         //                return new Leap\View\InputText("text", "search_term", "search_term", $this->search_term);
         //            }
         //            case "5": {
         //                $r = new MasterDishTagModel();
         //                $r->getByID($searchTerm);
         //                return $r->name;
         //            }
         //            case "6": {
         //                return new Leap\View\InputText("text", "search_term", "search_term", $this->search_term);
         //            }
         case "7":
             $r = new MasterRestaurantModel();
             $r->getByID($searchTerm);
             return $r->name;
         case "8888":
             return "Not Available";
         default:
             return "Not Available";
     }
 }
Exemplo n.º 27
0
 public function updateStatusProgress()
 {
     $idDish = $_GET["id_dish"];
     $idOrder = $_GET["id_order"];
     $idResto = $_GET["id_restaurant"];
     //TODO cek id_resto di order header apakah sama degan $Resto
     $resto = new MasterRestaurantModel();
     $resto->getByID($resto);
     $od = new OrderDetailModel();
     $arrOrDetails = $od->getWhere("id_order='{$idOrder}' AND id_dish='{$idDish}'");
     foreach ($arrOrDetails as $oDetails) {
         if ($oDetails->status_progress < 2) {
             $oDetails->status_progress++;
             $sp = $oDetails->status_progress;
         } else {
             //TODO ERROR order already out
         }
     }
     $order = $this->updateOrderHeaderStatusProgress($idOrder);
     $ids = $order->user_guest_id + "," + $order->id_user;
     $msg = "Your ";
     if ($order->type_order == "0") {
         $msg .= "Dine In ";
     } elseif ($order->type_order == "3") {
         $msg .= "Take Away ";
     } else {
         $json["status_code"] = 1;
         $json["results"]["id_dish"] = $idDish;
         $json["results"]["id_order"] = $idDish;
         $json["results"]["id_restaurant"] = $idDish;
         $json["results"]["status_progress"] = $sp;
         $json["results"]["order_status_progress"] = $order->status_progress;
         die;
     }
     $msg .= "order's status at {$resto->name} has been updated";
     $j["id_order"] = $idOrder;
     $json = json_encode($j);
     $_POST["ids"] = $ids;
     $_POST["msg"] = $msg;
     $_POST["json"] = $json;
     $_POST["type"] = 41;
     $p = new PushTo();
     $p->users();
     die;
 }
Exemplo n.º 28
0
 function createQRbyRestoID()
 {
     $id_restaurant = $_POST['id_restaurant'];
     $quantityQR = $_POST['quantityQR'];
     $objResto = new MasterRestaurantModel();
     $objResto->getByID($id_restaurant);
     $objResto->table_quantity = $objResto->table_quantity + $quantityQR;
     $objResto->load = 1;
     $objResto->save();
 }
    public function overwriteRead($return)
    {
        $objs = $return['objs'];
        $dateNow = new DateTime('now');
        foreach ($objs as $obj) {
            foreach ($obj as $key => $val) {
                if ($key == "end") {
                    $datetimeEnd = new DateTime($val);
                    $interval = $dateNow->diff($datetimeEnd);
                    if ($dateNow->format("Y.m.d") > $datetimeEnd->format("Y.m.d")) {
                    }
                    if ($interval->format('%R%a') >= 1) {
                    } else {
                    }
                }
            }
            if (isset($obj->id_restaurant)) {
                $resto = new MasterRestaurantModel();
                $resto->getByID($obj->id_restaurant);
                $obj->id_restaurant = $resto->name;
            }
            if (isset($obj->id_bank)) {
                $bank = new BankModel();
                $bank->getByID($obj->id_bank);
                $obj->id_bank = $bank->bank_name;
            }
            if (isset($obj->start)) {
                $date = new DateTime($obj->start);
                $obj->start = $date->format('d.m.Y');
            }
            if (isset($obj->end)) {
                $dateEnd = new DateTime($obj->end);
                $obj->end = $dateEnd->format('d.m.Y');
            }
            ?>
            <script>
                $(document).ready(function () {
                    var date = new Date();
                    var i = 1;
                    while ($('#id_bank_discount_' + i).text().trim()) {
                        var dateEndNow = $('#end_' + i).text().trim();
                        var dt1 = parseInt(dateEndNow.substring(0, 2));
                        var mon1 = parseInt(dateEndNow.substring(3, 5));
                        var yr1 = parseInt(dateEndNow.substring(6, 10));
                        var dateEnd = new Date(yr1, mon1 - 1, dt1);
                        var diff = dateEnd - date, sign = diff < 0 ? -1 : 1, milliseconds, seconds, minutes, hours, days;
                        diff = (diff - (milliseconds = diff % 1000)) / 1000;
                        diff = (diff - (seconds = diff % 60)) / 60;
                        diff = (diff - (minutes = diff % 60)) / 60;
                        days = (diff - (hours = diff % 24)) / 24;
                        if(days <2){
                            $("#BankDiscountModel_" + i).css("background-color", "red");
                        }
                        else{
                            
                            $("#BankDiscountModel_" + i).css("background-color", "yellow");
                        }
                        i = i + 1;
                    }
                });

            </script>
            <?php 
        }
        ?>


        <style>
            .table{
                background-color: red;
            }

            #BankDiscountModel_1{
                background-color: red;
            }

            #BankDiscountModel_{
                background-color: greenyellow;
            }
        </style>
        <?php 
        return $return;
    }
 public function overwriteRead($return)
 {
     $objs = $return['objs'];
     foreach ($objs as $obj) {
         if (isset($obj->datetime_order)) {
             $d = strtotime("{$obj->datetime_order}");
             $obj->datetime_order = date("d M, y h:m a", $d);
         }
         if (isset($obj->datetime_done)) {
             $d = strtotime("{$obj->datetime_done}");
             $obj->datetime_done = date("d M, y h:m a", $d);
         }
         if (isset($obj->type_order)) {
             $obj->type_order = $this->arrOrderType[$obj->type_order];
         }
         if (isset($obj->order_now)) {
             $obj->order_now = $this->arrOrderNow[$obj->order_now];
         }
         if (isset($obj->voided)) {
             $obj->voided = $this->arrYesNo[$obj->voided];
         }
         if (isset($obj->status_progress)) {
             $obj->status_progress = $this->arrStatusProgress[$obj->status_progress];
         }
         if (isset($obj->status)) {
             $obj->status = $this->arrStatusOrder[$obj->status];
         }
         if (isset($obj->id_table)) {
             if ($obj->id_table == "0") {
                 $obj->id_table = "Take Away";
             } else {
                 $tab = new MasterTableModel();
                 $tab->getByID($obj->id_table);
                 $obj->id_table = "Table ID " . $obj->id_table . " - Table No. " . $tab->table_number;
             }
         }
         if (isset($obj->id_restaurant)) {
             $resto = new MasterRestaurantModel();
             $resto->getByID($obj->id_restaurant);
             $obj->id_restaurant = $resto->name;
         }
     }
     return $return;
 }