コード例 #1
1
ファイル: UsersClass.php プロジェクト: veron123/BaseW
 public function getUsers($restId)
 {
     $db = new Db();
     $table = "rest" . $restId . "_users";
     $checkRest = restExists($table);
     if ($checkRest != true) {
         return $checkRest;
     }
     $local_query = "SELECT * FROM `{$table}`";
     $result = $db->select($local_query);
     $userCount = count($result);
     $configurationTable = "rest" . $restId . "_userConfigurations";
     $configurationMappingTable = "rest" . $restId . "_userConfigurationMapping";
     $userTable = "rest" . $restId . "_users";
     $local_query = "SELECT M.`userID`,M.`configurationID`, C.`configurationName`,C.`configurationDisplayText`, C.`configurationType`, \n\t\tC.`configurationTag`, C.`configurationValueBinary`, C.`configurationValueText`, C.`configurationValueDecimal`, C.`comments`,M.`isAllowed` FROM \n\t\t`{$configurationMappingTable}` AS M INNER JOIN `{$configurationTable}` AS C ON `M`.`configurationID` = `C`.`configurationID`  \n\t\tORDER BY   M.`userID`, M.`configurationID`";
     $resultConfiguration = $db->select($local_query);
     $configurationCount = count($resultConfiguration);
     for ($i = 0; $i < $userCount; $i++) {
         $result[$i]['Permissions'] = array();
         for ($j = 0; $j < $configurationCount; $j++) {
             if ($result[$i]['ID'] == $resultConfiguration[$j]['userID']) {
                 array_push($result[$i]['Permissions'], $resultConfiguration[$j]);
             }
         }
     }
     for ($i = 0; $i < $userCount; $i++) {
         for ($j = 0; $j <= count($result[$i]['Permissions']); $j++) {
             unset($result[$i]['Permissions'][$j]['userID']);
         }
     }
     $response = array();
     $response["Users"] = $result;
     return $response;
 }
コード例 #2
0
ファイル: DiscountClass.php プロジェクト: veron123/BaseW
 public function getDiscountInfo($restId)
 {
     $table = "rest" . $restId . "_discountMaster";
     $checkRest = restExists($table);
     if ($checkRest != true) {
         return $checkRest;
     }
     $discountVoucherTable = "rest" . $restId . "_discountVoucher";
     $discountSlotsTable = "rest" . $restId . "_discountSlots";
     $db = new Db();
     $local_query = "SELECT * FROM `{$table}`";
     $result = $db->select($local_query);
     foreach ($result as $key => $value) {
         if ($value["isVoucherEnabled"]) {
             $temp = $value["discountID"];
             $voucher_query = "SELECT `ID`, `voucherCode`, `validFromUTC`,\n  \t\t\t `validFromLocal`, `validToUTC`, `validToLocal`, `timeZone`, `isUsed`,\n  \t\t\t  `orderIDUsedOn`, `customerID` FROM `{$discountVoucherTable}` WHERE discountID = '{$temp}'";
             $voucher = $db->select($voucher_query);
             $result[$key]["Voucher Details"] = $voucher;
         }
     }
     foreach ($result as $key => $value) {
         if ($value["isSlotted"]) {
             $temp = $value["discountID"];
             $slot_query = "SELECT * FROM `{$discountSlotsTable}` WHERE discountID = '{$temp}'";
             $slot = $db->select($voucher_query);
             $result[$key]["Slot Details"] = $slot;
         }
     }
     return $result;
 }
コード例 #3
0
ファイル: Additional_Charges.php プロジェクト: veron123/BaseW
 public function getAC($restId)
 {
     $table = "rest" . $restId . "_additionalCharges";
     $checkRest = restExists($table);
     if ($checkRest) {
         $local_query = "SELECT * FROM `{$table}` ";
         $db = new Db();
         $resultArray = $db->select($local_query);
         if ($resultArray != false) {
             $endArray["AdditionalCharges"] = $resultArray;
             return $endArray;
         } else {
             $response = array();
             $response["error"] = "Restaurant ID is correct.No Reference to the information.";
             return $response;
         }
     } else {
         return $checkRest;
     }
 }
コード例 #4
0
ファイル: CustomerClass.php プロジェクト: veron123/BaseW
 public function deleteCustomerAddress($restId, $custId)
 {
     $db = new Db();
     $table = "rest" . $restId . "_customers";
     $checkRest = restExists($table);
     if ($checkRest) {
         $input_json = "{\"addressLine1\":\"\",\"addressLine2\":\"\",\"city\":\"Glasgfrfrfow Village\",\"state\":\"\",\"country\":\"\",\"pincode\":\"199444\"}";
         $data = json_decode($input_json, true);
         foreach ($data as $key => $value) {
             if ($key == "pincode") {
                 $local_query = "UPDATE `{$table}` SET `{$key}`= 0 WHERE customerID = '{$custId}';";
                 echo $local_query;
                 // echo $local_query;
                 $result = $db->query($local_query);
                 if ($result == false) {
                     echo "FAILED!";
                 } else {
                     echo "DONE!";
                 }
             } else {
                 if ($key != "customerID") {
                     $local_query = "UPDATE `{$table}` SET `{$key}`=\"\" WHERE customerID = '{$custId}';";
                     echo $local_query;
                     // echo $local_query;
                     $result = $db->query($local_query);
                     if ($result == false) {
                         echo "FAILED!";
                     } else {
                         echo "DELETED!";
                     }
                 }
             }
         }
     } else {
         return $checkRest;
     }
 }
コード例 #5
0
ファイル: ResturantClass.php プロジェクト: veron123/BaseW
 public function getOfficialTime($restId)
 {
     $db = new Db();
     $table = "rest" . $restId . "_info";
     $checkRest = restExists($table);
     if ($checkRest != true) {
         return $checkRest;
     }
     $local_query = "SELECT openingHoursUTc,openingHoursLocal,closingHoursUTc,closingHoursLocal FROM `{$table}` WHERE restaurantID = '{$restId}' ";
     $result = $db->select($local_query);
     return $result;
 }
コード例 #6
0
ファイル: EmployeeClass.php プロジェクト: veron123/BaseW
 public function deleteEmployee($restId, $userid)
 {
     $db = new Db();
     $table = "rest" . $restId . "_users";
     $checkRest = restExists($table);
     if ($checkRest != true) {
         return $checkRest;
     }
     $local_query = "UPDATE `{$table}` SET isActive = 0 WHERE ID ='{$userid}' ";
     $result = $db->query($local_query);
     if ($result == false) {
         return "FAILED!";
     } else {
         return "DONE!";
     }
 }
コード例 #7
0
ファイル: TaxClass.php プロジェクト: veron123/BaseW
 private function deleteTax($input_json)
 {
     $data = json_decode($input_json, true);
     $restId = $data['restId'];
     $taxId = $data['taxId'];
     $table = "rest" . $this->restId . "_taxes";
     $checkRest = restExists($table);
     if ($checkRest != true) {
         return $checkRest;
     }
     $local_query = "DELETE FROM {$table} WHERE taxId = {$taxId}";
     // Execute Atomically
     try {
         $dbh->beginTransaction();
         $dbh->exec($local_query);
         $dbh->commit();
         echo "New Record Successfully created!";
     } catch (PDOException $e) {
         // Rollback transaction if not commit
         $dbh->rollback();
         echo "Transaction Rolled! Couldn't create record!";
     }
 }
コード例 #8
0
ファイル: OrdersClass.php プロジェクト: veron123/BaseW
 public function getOrder($restId, $orderID)
 {
     $db = new Db();
     $table = "rest" . $restId . "_orderSummary";
     $local_query = "SELECT * FROM `{$table}` WHERE orderID = '{$orderID}';";
     $result = $db->select($local_query);
     $response = array();
     $count = count($result);
     $checkRest = restExists($table);
     if ($checkRest != true) {
         return $checkRest;
     }
     if ($result == false || $count != 1) {
         $response['error'] = "true";
         $response['message'] = "Invalid input";
         return $response;
     } else {
         // return $result;
         //create array for additional charges
         $additionalChargeIDs = my_explode(",", $result[0]['additionalChargeIDs']);
         $additionalChargeNames = my_explode(",", $result[0]['additionalChargeNames']);
         $additionalChargePrices = my_explode(",", $result[0]['additionalChargePrices']);
         $additionalChargeTotal = $result[0]['additionalChargeValue'];
         unset($result[0]['additionalChargeIDs']);
         unset($result[0]['additionalChargeNames']);
         unset($result[0]['additionalChargePrices']);
         unset($result[0]['additionalChargeValue']);
         $result[0]['additionalCharges'] = array();
         $additionalChargeCount = count($additionalChargeIDs);
         $additionalChargeArray = array();
         for ($i = 0; $i < $additionalChargeCount; $i++) {
             $additionalChargeArray['id'] = $additionalChargeIDs[$i];
             $additionalChargeArray['name'] = $additionalChargeNames[$i];
             $additionalChargeArray['price'] = $additionalChargePrices[$i];
             array_push($result[0]['additionalCharges'], $additionalChargeArray);
         }
         //create array for discounts
         $discountIDs = my_explode(",", $result[0]['discountIDs']);
         $discountNames = my_explode(",", $result[0]['discountNames']);
         $discountValues = my_explode(",", $result[0]['discountValues']);
         $discountTotal = $result[0]['discountTotalValue'];
         unset($result[0]['discountIDs']);
         unset($result[0]['discountNames']);
         unset($result[0]['discountValues']);
         unset($result[0]['discountTotalValue']);
         $result[0]['discounts'] = array();
         $result[0]['discounts']['totalDiscount'] = $discountTotal;
         $discountCount = count($discountIDs);
         $discountArray = array();
         for ($i = 0; $i < $discountCount; $i++) {
             $discountArray['id'] = $discountIDs[$i];
             $discountArray['name'] = $discountNames[$i];
             $discountArray['value'] = $discountValues[$i];
             array_push($result[0]['discounts'], $discountArray);
         }
         unset($result[0]['cardNumbers']);
         unset($result[0]['cardAmounts']);
         unset($result[0]['orderCreationTimeUTC']);
         unset($result[0]['tableOccupyTimeUTC']);
         unset($result[0]['billSettleTimeUTC']);
         unset($result[0]['voidTimeUTC']);
         unset($result[0]['refunds']);
         unset($result[0]['lastModifiedTimeUTC']);
         //Rename keys
         $result[0]['orderCreationTime'] = $result[0]['orderCreationTimeLocal'];
         $result[0]['tableOccupyTime'] = $result[0]['tableOccupyTimeLocal'];
         $result[0]['voidTime'] = $result[0]['voidTimeLocal'];
         unset($result[0]['orderCreationTimeLocal']);
         unset($result[0]['tableOccupyTimeLocal']);
         unset($result[0]['voidTimeLocal']);
         unset($result[0]['ID']);
         $response['Order'] = $result;
         return $response;
     }
 }
コード例 #9
0
ファイル: ProductsClass.php プロジェクト: veron123/BaseW
 public function updateProducts($input_json, $productId, $restId)
 {
     $db = new Db();
     $data = json_decode($input_json, true);
     $table = "rest" . $restId . "_products";
     $checkRest = restExists($table);
     if ($checkRest != true) {
         return $checkRest;
     }
     foreach ($data as $key => $value) {
         if ($key != "restaurantID") {
             $local_query = "UPDATE `{$table}` SET {$key}='{$value}';";
             // echo $local_query;
             $result = $db->query($local_query);
             if ($result == false) {
                 echo "FAILED!";
             } else {
                 echo "DONE!";
             }
         }
     }
 }