Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function order_json()
- {
- $users = 'diolsem';
- $password = 'diolsem2023';
- if ((!empty($_POST['users']) && $_POST['users'] == $users) && (!empty($_POST['password']) && $_POST['password'] == $password)) {
- $orders = $this->db->where('1c', 0)->get('orders')->result_array();
- $array_orders = array();
- $payment = array(
- '1' => 'Numarar',
- '3' => 'Card',
- );
- foreach ($orders as $order) {
- if ($order['payment'] == 3) $payment_id = 2; else $payment_id = $order['payment'];
- $products = $this->db->select('product_id as id, qty as quantity,price,
- (SELECT products.SKU FROM products WHERE products.id=orders_products.product_id) as SKU')->where('order_id', $order['id'])->get('orders_products')->result_array();
- $array_orders[] = array(
- 'id' => $order['order_id'],
- 'status' => $order['status'],
- 'total' => $order['total'],
- 'delivery_price' => $order['delivery_price'],
- 'name' => $order['name'],
- 'payment_name' => $payment[$order['payment']],
- 'payment' => $payment_id,
- 'email' => $order['email'],
- 'phone' => $order['phone'],
- 'city' => $order['city'],
- 'street' => $order['street'],
- 'home' => $order['home'],
- 'room' => $order['room'],
- 'scara' => $order['scara'],
- 'mesaj' => $order['mesaj'],
- 'added' => $order['added'],
- 'products' => $products,
- );
- }
- echo json_encode($array_orders, JSON_UNESCAPED_UNICODE);
- } else {
- echo 'Error..';
- }
- }
- public function order_check()
- {
- $users = 'diolsem';
- $password = 'diolsem2023';
- if ((!empty($_POST['users']) && $_POST['users'] == $users) && (!empty($_POST['password']) && $_POST['password'] == $password)) {
- if (!empty($_POST['id'])) {
- $order = $this->db->where('order_id', $_POST['id'])->get('orders')->row_array();
- if (empty($order)) {
- echo json_encode('Заказ не найден', JSON_UNESCAPED_UNICODE);
- } else {
- $this->db->where('id', $order['id']);
- $this->db->update('orders', array('1c' => 1));
- $payment = array(
- '1' => 'Cash',
- '3' => 'Card',
- );
- if ($order['payment'] == 3) $payment_id = 2; else $payment_id = $order['payment'];
- $products = $this->db->select('product_id as id, qty as quantity,price,
- (SELECT products.SKU FROM products WHERE products.id=orders_products.product_id) as SKU')->where('order_id', $order['id'])->get('orders_products')->result_array();
- $array_orders = array(
- 'id' => $order['order_id'],
- 'status' => $order['status'],
- 'total' => $order['total'],
- 'delivery_price' => $order['delivery_price'],
- 'payment_name' => $payment[$order['payment']],
- 'payment' => $payment_id,
- 'name' => $order['name'],
- 'email' => $order['email'],
- 'phone' => $order['phone'],
- 'city' => $order['city'],
- 'street' => $order['street'],
- 'home' => $order['home'],
- 'room' => $order['room'],
- 'scara' => $order['scara'],
- 'mesaj' => $order['mesaj'],
- 'added' => $order['added'],
- 'products' => $products,
- );
- echo json_encode($array_orders, JSON_UNESCAPED_UNICODE);
- }
- } else {
- echo json_encode('id не указан', JSON_UNESCAPED_UNICODE);
- }
- } else {
- echo 'Error..';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement