<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class API extends CI_Controller {
	
    var $main_menu_name = "purchases";
	var $sub_menu_name = "categories";

      function __construct() 
      {
        parent::__construct();
        $this->load->model('purchases_model');
        $this->load->model('common_model');
		$this->load->model('Sequerty_Model');
        $this->load->library('form_validation');
		$this->load->model('User_Model');
		$this->load->model('Batch_Process_Model');
		$this->load->model('Stock_Counter_Model');
		$this->load->model('Product_Discount_Model');

      }
    public function index($e=0)
    {
      $data['error'] = $e;
      $data['main_menu_name'] = $this->main_menu_name;
      $data['sub_menu_name'] = "list_purchases";
      $this->load->view('purchases_list',$data);
    }
    function get_product_list(){
        $order_list       = $this->Customer_Order_Process_Model->get_delivary_order_items($delivery_id);
        $data             = array();
        foreach ($order_list as $row) {
            $nested_date = array(
                'order_id' => $row['cus_order_master_id'],
                'order_item_id' => $row['cus_order_item_id'],
                'product_id' => $row['product_id'],
                'product_name' => $row['product_name'],
                'product_code' => $row['product_code'],
                'product_price' => $row['product_price'],
                'product_cost' => $row['product_price'],
                'product_qty' => $row['order_qty'],
                'issue_qty' => $row['issue_qty'],
                'total_price' => $row['total_price'],
                'add_sales_discount_price' => $row['add_sales_discount_price'],
                'discount_defualt' => $row['discount_defualt'],
                'default_discount_price' => $row['default_discount_price'],
                'after_discount_added_price' => $row['after_discount_added_price'],
                'total_item_discount' => $row['total_item_discount'],
                'total_added_discount_value' => $row['total_added_discount_value'],
                'batch_id'=>1,
                
            );
            $data[]      = $nested_date;
        }
        $json_array = array(
            'order_item_list' => $data
        );
        echo json_encode($json_array);
    }
    }
}