public function Scan()
 {
     $userId = $_GET["user_id"];
     $qr = $_GET["QR"];
     $qrs = new QRModel();
     //////validate QR Code
     $resQrs = $qrs->getWhere("textQR='{$qr}'");
     if (count($resQrs) == 1) {
         if ($resQrs[0]->status == 0) {
             $this->error("Unasigned QR Code!");
         }
     } else {
         $this->error("Wrong QR Code!");
     }
     ///////fetch user details
     $user = new UserModel();
     $user->getByID($userId);
     //        pr($user);
     if ($user->user_name == null || $user->user_name == "") {
         $this->error("Who Are You ?!");
     }
     ///////validate Table
     $ta = new MasterTableModel();
     $arr = $ta->getWhere("QR='{$qr}'");
     if (count($arr) == 1) {
         //status 0 = OCCUPIED
         if ($arr[0]->status == 0) {
             if ($arr[0]->id_order == 0) {
                 $this->error("Empty Order ID");
             } else {
                 $this->requestJoinTable($user, $arr[0]->id_order);
             }
         } else {
             $this->requestRestoPermission($user, $arr[0]);
         }
     } else {
         $this->error("Wrong Table!");
     }
     die;
 }
 public static function updateTableAtrributByQR($QR, $attr, $value)
 {
     $objTable = new MasterTableModel();
     $arr = $objTable->getWhere("QR='{$QR}'");
     if (count($arr) > 0) {
         $arr[0]->{$attr} = $value;
         $arr[0]->load = 1;
         $arr[0]->save();
     }
 }
 public static function getTableModelByQR($QR)
 {
     $table = new MasterTableModel();
     $arrTable = $table->getWhere("QR='{$QR}'");
     if (count($arrTable) < 1) {
         return false;
     } else {
         $tableReturn = new MasterTableModel();
         $tableReturn->getByID($arrTable[0]->id_table);
         return $tableReturn;
     }
 }
 public static function getRestoIDByTable($id_table)
 {
     $objTable = new MasterTableModel();
     $arrTable = $objTable->getWhere("id_table = '{$id_table}'");
     pr($arrTable);
 }
 private function checkTablePosition($id_restaurant, $position)
 {
     $return = false;
     $objTable = new MasterTableModel();
     $arr = $objTable->getWhere("id_restaurant = {$id_restaurant} AND table_position = {$position}");
     if (count($arr) == 0) {
         //            echo "true";
         $return = true;
     }
     return $return;
 }
 public static function getAllTableIDNowNachRestoID($id_restaurant)
 {
     $objTables = new MasterTableModel();
     $arrTables = $objTables->getWhere("id_restaurant='{$id_restaurant}' AND order_now ='1' ORDER BY id_order asc");
     return $arrTables;
 }