<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$name = $utilities->clean($_POST['name']);
$area = $utilities->clean($_POST['area']);
$pincode = $utilities->clean($_POST['pincode']);
$latitude = $utilities->replaceZero($_POST['latitude']);
$longitude = $utilities->replaceZero($_POST['longitude']);
$log_datetime = $utilities->replaceNow();
$kitchenId = -1;
try {
    $insertQuery = "INSERT INTO " . " `kitchen` (name, area, pincode, latitude, longitude, log_datetime) " . " VALUES ('{$name}', '{$area}', '{$pincode}', '{$latitude}', '{$longitude}', '{$log_datetime}')";
    $statement = $dbConnection->prepare($insertQuery);
    try {
        $dbConnection->beginTransaction();
        if ($statement->execute()) {
            $kitchenId = $dbConnection->lastInsertId();
            $dbConnection->commit();
            $response = array('status' => $kitchenId, 'desc' => 'Success');
        } else {
            $status = -99;
            $dbError = $statement->errorInfo();
            $response = array('status' => $status, 'desc' => 'DB error occured' . $dbError[2]);
        }
    } catch (PDOExecption $e) {
        $status = -7;
        $error = "Exception: " . $e->getMessage();
include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$basket_code = uniqid("BSKT_");
/*
 * Json array with id, qunatity in this format.
 * [
 *  {'item':1,'name': 'xyz','quantity':2,'price':200},
 *  {'item':2,'name': 'abc','quantity':1,'price':150},
 *  {'item':3,'name': 'qwert','quantity':1,'price':20},
 *  {'item':4,'name': 'poiuyt','quantity':1,'price':30}
 * ]
 */
$item_quantity_price_json = $utilities->clean($_POST['item_quantity_price_json']);
$user_id = $utilities->replaceOne($_POST['user_id']);
$time_slot_id = $utilities->replaceOne($_POST['time_slot_id']);
$status = $utilities->replaceOne($_POST['status']);
$date = $utilities->replaceToday($_POST['date']);
$address_id = $utilities->replaceZero($_POST['address_id']);
$order_type_id = $utilities->replaceZero($_POST['order_type_id']);
$log_datetime = $utilities->replaceNow();
$order_id = -1;
try {
    $insertQuery = "INSERT INTO " . " `order` (basket_code, user_id, item_quantity_price_json, time_slot_id, status, date, address_id, log_datetime) " . " VALUES ('{$basket_code}', '{$user_id}', '{$item_quantity_price_json}', '{$time_slot_id}', '{$status}', '{$date}', '{$address_id}', '{$log_datetime}')";
    $statement = $dbConnection->prepare($insertQuery);
    try {
        $dbConnection->beginTransaction();
        if ($statement->execute()) {
            $order_id = $dbConnection->lastInsertId();
<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$street_address = $utilities->clean($_POST['street_address']);
$landmark = $utilities->clean($_POST['landmark']);
$city = $utilities->clean($_POST['city']);
$state = $utilities->clean($_POST['state']);
$country = $utilities->clean($_POST['country']);
$pincode = $utilities->clean($_POST['pincode']);
$phone_number = $utilities->clean($_POST['phone_number']);
$country_code = $utilities->clean($_POST['country_code']);
$is_default = $utilities->replaceZero($_POST['is_default']);
$user_id = $utilities->replaceZero($_POST['user_id']);
$log_datetime = $utilities->replaceNow();
$addressId = -1;
try {
    $insertQuery = "INSERT INTO " . " `address` (street_address, landmark, city, state, country, pincode, phone_number, country_code, is_default, user_id, log_datetime) " . " VALUES ('{$street_address}', '{$landmark}', '{$city}', '{$state}', '{$country}', '{$pincode}', '{$phone_number}', '{$country_code}', '{$is_default}', '{$user_id}', '{$log_datetime}')";
    $statement = $dbConnection->prepare($insertQuery);
    try {
        $dbConnection->beginTransaction();
        if ($statement->execute()) {
            $addressId = $dbConnection->lastInsertId();
            $dbConnection->commit();
            $response = array('status' => $addressId, 'desc' => 'Success');
        } else {
            $status = -99;
            $dbError = $statement->errorInfo();
<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$food_item_id = $utilities->clean($_POST['food_id']);
$user_id = $utilities->clean($_POST['user_id']);
$rating = $utilities->replaceZero($_POST['rating']);
$review = $utilities->replaceZero($_POST['review']);
$review_detail = $utilities->replaceZero($_POST['review_detail']);
$log_datetime = $utilities->replaceNow();
$likeId = -1;
$dataReviewd = array();
try {
    $query = "SELECT COUNT(*) AS is_reviewed\n                FROM `likes`\n                WHERE user_id = '{$user_id}'\n                    AND food_item_id = '{$food_item_id}';";
    $statement = $dbConnection->prepare($query);
    try {
        if ($statement->execute($bindParams)) {
            $dataReviewd = $statement->fetchAll(PDO::FETCH_ASSOC);
            $statement->closeCursor();
        } else {
            $errorCode = -99;
            $dbError = $statement->errorInfo();
            $statement->closeCursor();
            $response = array('status' => $errorCode, 'data' => array(), 'desc' => 'DB error occured' . $dbError[2]);
        }
    } catch (PDOExecption $e) {
        $errorCode = -7;
        $statement->closeCursor();
<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$device_imei = $utilities->clean($_POST['deviceIMEI']);
$dateTime = $utilities->replaceNow();
$status = 0;
try {
    $delQuery = "DELETE FROM `push_reg` WHERE device_imei = '{$device_imei}'";
    $statement = $dbConnection->prepare($delQuery);
    $statement->bindParam(":device_imei", $device_imei, PDO::PARAM_STR);
    try {
        $dbConnection->beginTransaction();
        if ($statement->execute()) {
            $dbConnection->commit();
            $response = array('status' => $status, 'desc' => 'Success');
        } else {
            $status = -99;
            $dbError = $statement->errorInfo();
            $response = array('status' => $status, 'desc' => 'DB error occured: ' . $dbError[2]);
        }
    } catch (PDOExecption $e) {
        $status = -7;
        $error = "Exception: " . $e->getMessage();
        $response = array('status' => $status, 'desc' => 'PDO exception occured' . $error);
    }
    $statement->closeCursor();
} catch (PDOExecption $e) {
Exemplo n.º 6
0
<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$userId = $utilities->clean($_POST['userId']);
$push_reg_token = $utilities->clean($_POST['pushRegToken']);
$device_imei = $utilities->clean($_POST['deviceIMEI']);
$os_id = $utilities->clean($_POST['osId']);
//1 - Android, 2 - iOS
$os_name = $os_id == 1 ? 'Android' : 'iOS';
$dateTime = $utilities->replaceNow();
$pushRegId = -1;
try {
    $queryRegPush = "SELECT COUNT(*) AS isPushReg FROM `push_reg` WHERE device_imei = '{$device_imei}' AND push_reg_token = '{$push_reg_token}';";
    $statement = $dbConnection->prepare($queryRegPush);
    $statement->execute();
    $dataRegPushArray = $statement->fetchAll(PDO::FETCH_ASSOC);
    $statement->closeCursor();
    if ($dataRegPushArray[0]['isPushReg'] == 0) {
        $insertQuery = "INSERT INTO " . " `push_reg` (user_id, push_reg_token, device_imei, os_id, os_name, datetime) " . " VALUES (:user_id, :push_reg_token, :device_imei, :os_id, :os_name, :datetime);";
        $statement = $dbConnection->prepare($insertQuery);
        $statement->bindParam(":user_id", $userId, PDO::PARAM_INT);
        $statement->bindParam(":push_reg_token", $push_reg_token, PDO::PARAM_STR);
        $statement->bindParam(":device_imei", $device_imei, PDO::PARAM_STR);
        $statement->bindParam(":os_id", $os_id, PDO::PARAM_INT);
        $statement->bindParam(":os_name", $os_name, PDO::PARAM_STR);
        $statement->bindParam(":datetime", $dateTime, PDO::PARAM_STR);
        try {
<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$f_name = $utilities->clean($_POST['f_name']);
$l_name = $utilities->clean($_POST['l_name']);
$country_code = $utilities->replaceDefaultCountryCode($_POST['country_code']);
$phone_number = $utilities->clean($_POST['phone_number']);
$image_url = $utilities->clean($_POST['image_url']);
$rating = $utilities->replaceZero($_POST['rating']);
$log_datetime = $utilities->replaceNow();
$chefId = -1;
try {
    $insertQuery = "INSERT INTO " . " `chef` (f_name, l_name, country_code, phone_number, image_url, rating, log_datetime) " . " VALUES ('{$f_name}', '{$l_name}', '{$country_code}', '{$phone_number}', '{$image_url}', '{$rating}', '{$log_datetime}')";
    $statement = $dbConnection->prepare($insertQuery);
    try {
        $dbConnection->beginTransaction();
        if ($statement->execute()) {
            $chefId = $dbConnection->lastInsertId();
            $dbConnection->commit();
            $response = array('status' => $chefId, 'desc' => 'Success');
        } else {
            $status = -99;
            $dbError = $statement->errorInfo();
            $response = array('status' => $status, 'desc' => 'DB error occured' . $dbError[2]);
        }
    } catch (PDOExecption $e) {
        $status = -7;
<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$isUpdate = $utilities->replaceZero($_POST['is_update_address']);
$address_id = $utilities->clean($_POST['address_id']);
$street_address = $utilities->clean($_POST['street_address']);
$landmark = $utilities->clean($_POST['landmark']);
$city = $utilities->clean($_POST['city']);
$state = $utilities->clean($_POST['state']);
$pincode = $utilities->clean($_POST['pincode']);
$phone_number = $utilities->clean($_POST['phone_number']);
$is_default = $utilities->replaceZero($_POST['is_default']);
$user_id = $utilities->clean($_POST['user_id']);
$log_datetime = $utilities->replaceNow();
$addressId = -1;
try {
    if ($isUpdate == 0) {
        $query = "INSERT INTO " . " `address` (street_address, landmark, city, state, country, pincode, phone_number, country_code, is_default, user_id, log_datetime) " . " VALUES ('{$street_address}', '{$landmark}', '{$city}','{$state}', 'country', '{$pincode}', '{$phone_number}', '+91', '{$is_default}', '{$user_id}' ,'{$log_datetime}')";
    } else {
        $query = "UPDATE `address` SET" . " street_address = '{$street_address}', " . " landmark = '{$landmark}', " . " city = '{$city}', " . " state = '{$state}', " . " country = '{$country}', " . " pincode = '{$pincode}', " . " phone_number = '{$phone_number}', " . " country_code = '+91', " . " is_default = '{$is_default}', " . " log_datetime = '{$log_datetime}'  " . " WHERE address_id = '{$address_id}';";
    }
    $statement = $dbConnection->prepare($query);
    try {
        $dbConnection->beginTransaction();
        if ($statement->execute()) {
            $addressId = $isUpdate == 0 ? $dbConnection->lastInsertId() : $address_id;
            $dbConnection->commit();
<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$address_id = $utilities->clean($_POST['address_id']);
$user_id = $utilities->clean($_POST['user_id']);
$log_datetime = $utilities->replaceNow();
try {
    $query = "UPDATE `address` SET" . " is_default = '0' " . " WHERE user_id = '{$user_id}';" . "" . "" . "UPDATE `address` SET" . " is_default = '1' " . " WHERE address_id = '{$address_id}';";
    $statement = $dbConnection->prepare($query);
    try {
        $dbConnection->beginTransaction();
        if ($statement->execute()) {
            $dbConnection->commit();
            $response = array('status' => $address_id, 'desc' => 'Success');
        } else {
            $status = -99;
            $dbError = $statement->errorInfo();
            $response = array('status' => $status, 'desc' => 'DB error occured' . $dbError[2]);
        }
    } catch (PDOExecption $e) {
        $status = -7;
        $error = "Exception: " . $e->getMessage();
        $response = array('status' => $status, 'desc' => 'PDO exception occured' . $error);
    }
    $statement->closeCursor();
} catch (PDOExecption $e) {
    $status = -8;
<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$name = $utilities->clean($_POST['name']);
$description = $utilities->clean($_POST['description']);
$ingredients = $utilities->clean($_POST['ingredients']);
$preparation_method = $utilities->clean($_POST['preparation_method']);
$nutrition = $utilities->clean($_POST['nutrition']);
$food_image_1 = $utilities->clean($_POST['food_image_1']);
$food_image_2 = $utilities->clean($_POST['food_image_2']);
$food_image_3 = $utilities->clean($_POST['food_image_3']);
$food_image_4 = $utilities->clean($_POST['food_image_4']);
$food_image_5 = $utilities->clean($_POST['food_image_5']);
$food_image_6 = $utilities->clean($_POST['food_image_6']);
$rating = $utilities->replaceZero($_POST['rating']);
$price = $utilities->replaceZero($_POST['price']);
$currency_id = $utilities->replaceOne($_POST['currency_id']);
$chef_id = $utilities->replaceZero($_POST['chef_id']);
$category_id = $utilities->replaceOne($_POST['category_id']);
$log_datetime = $utilities->replaceNow();
$foodId = -1;
try {
    $insertQuery = "INSERT INTO " . " `food_item` (name, description, ingredients, preparation_method, nutrition, food_image_1,food_image_2,food_image_3, food_image_4, food_image_5, food_image_6, rating, price, currency_id, chef_id, category_id, log_datetime) " . " VALUES ('{$name}', '{$description}', '{$ingredients}', '{$preparation_method}', '{$nutrition}', '{$food_image_1}', '{$food_image_2}','{$food_image_3}','{$food_image_4}','{$food_image_5}','{$food_image_6}', '{$rating}', '{$price}', '{$currency_id}', '{$chef_id}', '{$category_id}', '{$log_datetime}')";
    $statement = $dbConnection->prepare($insertQuery);
    try {
        $dbConnection->beginTransaction();
        if ($statement->execute()) {
<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$bill_code = uniqid("BILL_");
$bill_pay_through = $utilities->clean($_POST['bill_pay_through']);
$bill_date = $utilities->replaceToday($_POST['bill_date']);
$bill_discount = $utilities->clean($_POST['bill_discount']);
$bill_total_amount = $utilities->clean($_POST['bill_total_amount']);
$user_name = $utilities->clean($_POST['user_name']);
$user_email = $utilities->clean($_POST['user_email']);
$user_phone_number = $utilities->clean($_POST['user_phone_number']);
$use_delivery_address = $utilities->clean($_POST['use_delivery_address']);
$basket_code = $utilities->clean($_POST['basket_code']);
$item_quantity_price_json = $utilities->clean($_POST['item_quantity_price_json']);
$is_bill_payed = $utilities->replaceZero($_POST['is_bill_payed']);
$log_datetime = $utilities->replaceNow();
//Calculating bill amount...
$basketQunatityArray = array();
$totalAmount = 0;
$bill_item_count = 0;
$orderJSONArray = json_decode($item_quantity_price_json);
foreach ($orderJSONArray as $foodItem) {
    $subTotalPrice = $foodItem['qunatity'] * $foodItem['price'];
    $bill_item_count++;
    array_push($basketQunatityArray, array('item_name' => $foodItem['name'], 'qunatity' => $foodItem['qunatity'], 'unit_price' => $foodItem['price'], 'sub_total_price' => $subTotalPrice));
    $totalAmount += $subTotalPrice;
}
<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$f_name = $utilities->clean($_POST['f_name']);
$l_name = $utilities->clean($_POST['l_name']);
$country_code = $utilities->clean($_POST['country_code']);
$phone_number = $utilities->clean($_POST['phone_number']);
$email = $utilities->clean($_POST['email']);
$image_url = $utilities->clean($_POST['image_url']);
$verification_code = $utilities->clean($_POST['verification_code']);
$date_of_birth = $utilities->replaceDefaultDate($_POST['date_of_birth']);
$log_datetime = $utilities->replaceNow();
$userId = -1;
$datauser = array();
$sms_body = "FoodizHome: Please use {$verification_code} for validating your registration.";
try {
    $query = "SELECT user_id\n                FROM `user`\n                WHERE `user`.phone_number = '{$phone_number}';";
    $statement = $dbConnection->prepare($query);
    try {
        if ($statement->execute($bindParams)) {
            $datauser = $statement->fetchAll(PDO::FETCH_ASSOC);
            $statement->closeCursor();
            $userId = $datauser[0]['user_id'];
            $response = array('status' => $datauser[0]['user_id'], 'desc' => 'success');
        } else {
            $errorCode = -99;
            $dbError = $statement->errorInfo();