GRAYBYTE WORDPRESS FILE MANAGER3209

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/public_html/Barga/application/modules/order/controllers/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/public_html/Barga/application/modules/order/controllers//Order.php
<?php
class Order extends Basecontroller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model('Product_model', 'Product');
		$this->load->model('users/Users_model', 'Users');
		$this->load->model('customers/Customers_model', 'Customers');
		$this->load->library('session');
		date_default_timezone_set("Asia/Kolkata");
		// $this->load->model('product/Product_model', 'Product_tb');
		$this->controller_name = "order";
		$this->folder = "order";
		$this->per_page = PER_PAGE;
		if(!$this->session->userdata('is_login')) { redirect('sessions','refresh'); }
    }

	public function index()
	{
		
		redirect($this->controller_name.'/orderList');
    }

    /*** Code for City start ***/
	public function orderList()
	{
		if(checkModuleAccessByUser(userInfo('user_role_id'), 75, "module_view") == 0){ redirect('errors/noPermission');} // Check user access permission
		$data = array();
		$conditions = array();
        //calc offset number
        $page = $this->input->post('page');
        if(!$page) $offset = 0;
        else $offset = $page;
        
        //set conditions for search
        $city_name = $this->input->post('city_name');
        if(!empty($city_name)){
            $conditions['search']['city_name'] = $city_name;
        }
        $total_record = count($this->Product->getTodoList($conditions));
        //pagination configuration
        $config['target']      = '#data_list';
        $config['base_url']    = base_url().$this->controller_name.'/ajaxOrderList';
        $config['total_rows']  = $total_record;
        $config['per_page']    = $this->per_page;
        $config['link_func']   = 'searchFilter';
        $this->ajax_pagination->initialize($config);
        
        //get the Qualification data
        $data['order'] = $this->Product->getTodoList(array('limit'=>$this->per_page));
        
        $data['title'] = "Order List";
		$data['total_record'] = $total_record;
		$data['sl_no'] = $page;
		//load the view
		// echo "<pre>";print_r($data);exit;
		$data['cities_html'] = $this->load->view('order/order/ajax_order_lists', $data, true);
		$this->template->admin('order/order/order_lists', $data);
    }
	
	public function ajaxOrderList()
	{		
        $conditions = array();
        //calc offset number
        $page = $this->input->post('page');
        if(!$page) $offset = 0;
        else $offset = $page;
        
        //set conditions for search
        $name = $this->input->post('name');
        if(!empty($name)){
            $conditions['search']['name'] = $name;
        }
        //total rows count
        $total_record = count($this->Product->getTodoList($conditions));
        
        //pagination configuration
        $config['target']      = '#data_list';
        $config['base_url']    = base_url().$this->controller_name.'/ajaxOrderList';
        $config['total_rows']  = $total_record;
        $config['per_page']    = $this->per_page;
        $config['link_func']   = 'searchFilter';
        $this->ajax_pagination->initialize($config);
        
        //set start and limit
        $conditions['start'] = $offset;
        $conditions['limit'] = $this->per_page;
        
        //get posts data
        $data['order'] = $this->Product->getTodoList($conditions);
        // echo "<pre>";print_r($data);exit;
        $data['title'] = "Order List";
		$data['total_record'] = $total_record;
		$data['sl_no'] = $page;
		//load the view

		$cities_html = $this->load->view('order/order/ajax_order_lists', $data, true);
		echo $cities_html;exit;
    }
	
	public function orderForm($order_id = 0)
	{
		if($order_id == "" || !is_numeric($order_id)){redirect('errors/invalidRequest');} // Check passing argument
		if(checkModuleAccessByUser(userInfo('user_role_id'), 76, "module_edit") == 0){ redirect('errors/noPermission');} // Check user access permission

		// 

			$data = array();
			$conditions = array();
			//calc offset number
			$page = $this->input->post('page');
			if(!$page) $offset = 0;
			else $offset = $page;
			
			//set conditions for search
			$name = $this->input->post('name');
			if(!empty($name)){
				$conditions['search']['name'] = $name;
			}

			$total_record = count($this->Product->getAllProductDataList($conditions));
			//pagination configuration
			$config['target']      = '#data_list';
			$config['base_url']    = base_url().$this->controller_name.'/ajaxOrderPageListingProduct';
			$config['total_rows']  = $total_record;
			$config['per_page']    = $this->per_page;
			$config['link_func']   = 'searchFilter';
			$this->ajax_pagination->initialize($config);
			
			//get the Qualification data
			$data['todo'] = $this->Product->getAllProductDataList(array('limit'=>$this->per_page));
			
			$data['title'] = "Product List";
			$data['total_record'] = $total_record;
			$data['sl_no'] = $page;
			//load the view
			$data['current_cart_order'] = $this->session->userdata('cart_order');
			$data['cart_total_amount'] = $this->session->userdata('total_amount');
			$data['order_list_html'] = $this->load->view('order/order/ajax_order_page_product_list', $data, true);
		// 












		$data['title'] = "Order Form";
		$data['order_id'] = $order_id;
		$productList = $this->Product->getAllProductData($order_id);
		$productHtml = '';
		foreach($productList as $product){
			$productHtml .= '<option value="'.$product->id.'-'.$product->price.'-'.$product->qty.'" data-price="'.$product->price.'" >'.$product->name.' - '.$product->price.' - '.$product->qty.'</option>';
		}
		$data['productHtml'] = $productHtml;
			
		if($order_id > 0) { 
			$data['order_data'] = $this->Product->getTodoData($order_id);
		}
		$order_code = generateJobCodeCount(mt_rand(),5);
		$order_code_value = RESTAURANTS_NAME.'-'.date("d-m-Y").''.$order_code;
		
		if($this->input->post()) {

			for($count = 0; $count < count($_POST["item_name"]); $count++){
				$product_id = explode("-", $_POST["item_name"][$count])[0];
				$product_details = $this->Product->getSingleProductData($product_id);


				// update product qty in product table | start
				$product_qty['qty'] = $product_details[0]->qty - $_POST["item_quantity"][$count];
				$this->Product->productSave($product_qty,$product_id);
				// update product qty in product table | end


				$product_deti['order_id'] = $order_code_value;
				$product_deti['table_no'] = $_POST["table_no"] > 0 ? $_POST["table_no"] : 0;
				$product_deti['user_id'] = userInfo('user_id');
				$product_deti['product_id'] = $product_details[0]->id;
				$product_deti['product_name'] = $product_details[0]->name;
				$product_deti['quantity'] =  $_POST["item_quantity"][$count];
				$product_deti['price'] = $product_details[0]->price;
				$product_deti['type'] = $product_details[0]->type;
				$product_deti['packing'] = $product_details[0]->packing;
				$product_deti['tax'] =  (@$product_details[0]->price * $_POST["item_quantity"][$count]) * @$product_details[0]->tax / 100;

				$product_deti['inventery'] = $product_details[0]->inventery;
				$product_deti['total'] = ($_POST["item_quantity"][$count] * $product_deti['price']) + $product_deti['tax'];
				$product_deti['doc'] = date('Y-m-d H:i:s');
				$this->Product->OrderDetailsSave($product_deti,0);
			}

				$order_deti['order_id'] = $order_code_value;
				$order_deti['cust_name'] = $_POST["cust_name"] != "" ? $_POST["cust_name"] : "";
				$order_deti['cust_number'] = $_POST["cust_number"] != "" ? $_POST["cust_number"] : "";
				$order_deti['cust_address'] = $_POST["cust_address"] != "" ? $_POST["cust_address"] : "";
				$order_deti['cust_gst'] = $_POST["cust_gst"] != "" ? $_POST["cust_gst"] : "";
				$order_deti['cust_note'] = $_POST["cust_note"] != "" ? $_POST["cust_note"] : "";
				$order_deti['room_number'] = $_POST["room_number"] != "" ? $_POST["room_number"] : "";
				$order_deti['doc'] = date('Y-m-d H:i:s');
				$this->Product->OrderDetailsTableSave($order_deti,0);


			$this->session->set_flashdata('msg_success', getMessage("record_saved", 3));
			redirect($this->controller_name.'/order/orderDetails/'.$order_code_value);
			// redirect($this->controller_name.'/order/orderForm/0');
		}
		$this->template->admin('order/order/order_form', $data);
	}

	public function orderDetails($order_code = 0, $order_id = "")
	{	
		$order_id = $order_code.'/'.$order_id;
		date_default_timezone_set('Asia/Kolkata');
		if($order_id == ""){redirect('errors/invalidRequest');} // Check passing argument
		$data['title'] = "Order Details";
		$data['order_data'] = $this->Product->getProductOrder($order_id);
		$data['order_details_data'] = $this->Product->getOrderDetails($order_id);

		$this->template->admin('order/order/order_details', $data);
	}

	public function orderInvoice($order_code = 0, $order_id = "")
	{
		$order_id = $order_code.'/'.$order_id;
		if($order_id == ""){redirect('errors/invalidRequest');}
		$data['title'] = "Order Details";
		$data['order_data'] = $this->Product->getProductOrder($order_id);
		$data['water_deti'] = array();
		if($data['order_data'][0]->user_id > 0){
			$data['water_deti'] = $this->Users->getUserData($data['order_data'][0]->user_id);
		}
		$data['order_details_data'] = $this->Product->getOrderDetails($order_id);
		if(!empty($data['order_details_data'][0])){
			$data['order_details_data'] = $data['order_details_data'][0];
		}
		$this->load->view('order/order/order_invoice', $data);
	}
	

	public function orderInvoiceByCustomer($order_code = 0, $order_id = "")
	{
		if($order_id == ""){redirect('errors/invalidRequest');}
		$order_id = $order_code.'/'.$order_id;
		$data['title'] = "Order Details";
		$data['order_data'] = $this->Product->getProductOrder($order_id);
		$data['water_deti'] = array();
		if($data['order_data'][0]->user_id > 0){
			$data['water_deti'] = $this->Users->getUserData($data['order_data'][0]->user_id);
		}
		$data['order_details_data'] = $this->Product->getOrderDetails($order_id);
		if(!empty($data['order_details_data'][0])){
			$data['order_details_data'] = $data['order_details_data'][0];
		}
		$this->load->view('order/order/order_invoice_by_customer', $data);
	}


	/*** Code for City end ***/


	public function orderExportCsv() 
	{	
		$conditions = array();
   	    $user_status = $this->input->post('user_status');
  		if(!empty($user_status)){
            $conditions['search']['user_status'] = $user_status;
        }
		$date = $this->input->post('date');
  		if(!empty($date)){
            $conditions['search']['date'] = $date;
        }	

		


        $file_name = "order-".date('dmYHis'); 
        header('Content-Type: text/csv; charset=utf-8');
		header('Content-Disposition: attachment; filename='.$file_name.'.csv');
		$output = fopen('php://output', 'w');
		$sl_no = 1;
		$csv_main_heading = array(
			'order_id',
			'table_no',
			'Total Amount',
			'Product Name',
			'Customer Name',
			'Customer Number',
			'Customer Address',
		);
		
		fputcsv($output, $csv_main_heading); 
		$order_csv_data = $this->Product->getTodoList($conditions);

        foreach ($order_csv_data as $csv) {

	        $order_data[0] = $csv->order_id;
			$order_data[1] = $csv->table_no;
			$order_data[2] = $csv->Total_Amt_val;
			$order_data[3] = $csv->product_name;
			$order_data[4] = $csv->cust_name;
			$order_data[5] = $csv->cust_number;
			$order_data[6] = $csv->cust_address;
         	fputcsv($output,$order_data);
			$sl_no++;
			
		}

		fclose($output);

	}









	public function ajaxOrderPageListingProduct()
	{
		$conditions = array();
        //calc offset number
        $page = $this->input->post('page');
        if(!$page) $offset = 0;
        else $offset = $page;
        
        //set conditions for search
        $name = $this->input->post('name');
        if(!empty($name)){
            $conditions['search']['name'] = $name;
        }
        //total rows count
        $total_record = count($this->Product->getAllProductDataList($conditions));
        
        //pagination configuration
        $config['target']      = '#data_list';
        $config['base_url']    = base_url().$this->controller_name.'/ajaxOrderPageListingProduct';
        $config['total_rows']  = $total_record;
        $config['per_page']    = $this->per_page;
        $config['link_func']   = 'searchFilter';
        $this->ajax_pagination->initialize($config);
        
        //set start and limit
        $conditions['start'] = $offset;
        $conditions['limit'] = $this->per_page;
        
        //get posts data
        $data['todo'] = $this->Product->getAllProductDataList($conditions);
        
        $data['title'] = "Order List";
		$data['total_record'] = $total_record;
		$data['sl_no'] = $page;
		//load the view
		$data['current_cart_order'] = $this->session->userdata('cart_order');
		$data['cart_total_amount'] = $this->session->userdata('total_amount');
		$order_list_html = $this->load->view('order/order/ajax_order_page_product_list',$data,true);
		echo $order_list_html;exit;
    }

	public function productAddToCartFunc()
	{
		$product_id = $this->input->post('productId');
		$quantity = $this->input->post('quantity');
		$product_qty_add = $quantity > 0 ? $quantity : 1;
		$pdata = count($this->session->userdata('cart_order')) > 0 ? $this->session->userdata('cart_order') : array();
		$product_details = $this->Product->getSingleProductData($product_id);
		$new_pdata = array();
		if(count($pdata) > 0){
			if(in_array($product_id, array_column($pdata, 'product_id'))) {
				foreach($pdata as $key => $value){
					if($value['product_id'] == $product_id){
						$pdata[$key]['product_qty_add'] = $product_qty_add;
						$pdata[$key]['product_price'] = $pdata[$key]['product_price'];
						$pdata[$key]['product_ttl_price'] = $pdata[$key]['product_qty_add'] * $pdata[$key]['product_price'];
						$pdata[$key]['product_tax'] = @$product_details[0]->tax > 0 ? @$product_details[0]->tax : 0;
					}
				}
			}else{
				$new_pdata[] = array(
					'product_id' => $product_id,
					'product_name' => $product_details[0]->name,
					'product_price' => $product_details[0]->price,
					'product_ttl_price' => $product_details[0]->price,
					'product_tax' => @$product_details[0]->tax > 0 ? @$product_details[0]->tax : 0,
					'product_qty_add'=>$product_qty_add, 

				);
			}
		}else{
			$pdata[] = array(
				'product_id' => $product_id,
				'product_name' => $product_details[0]->name,
				'product_price' => $product_details[0]->price,
				'product_ttl_price' => $product_details[0]->price,
				'product_tax' => @$product_details[0]->tax > 0 ? @$product_details[0]->tax : 0,
				'product_qty_add'=>$product_qty_add, 
			);
		}
		$mergePdata = array_merge($pdata,$new_pdata);
		$this->session->set_userdata('cart_order',$mergePdata);
		$current_cart_order = $this->session->userdata('cart_order');
		$total_amount = 0;
		foreach($current_cart_order as $cc){
			$total_amount += $cc['product_price'];
		}
		$this->session->set_userdata('total_amount',$total_amount);
	
		$jsonData = array('status'=>1,'message'=>'Product added successfully','data'=>$current_cart_order,'cart_total_amount'=>$total_amount);
		echo json_encode($jsonData);

	}

	public function productRemoveToCartFunc()
	{
		$product_id = $this->input->post('productId');
		$pdata = count($this->session->userdata('cart_order')) > 0 ? $this->session->userdata('cart_order') : array();
		$new_pdata = array();
		if(count($pdata) > 0){
			if(in_array($product_id, array_column($pdata, 'product_id'))) {
				foreach($pdata as $key => $value){
					if($value['product_id'] == $product_id){
						unset($pdata[$key]);
					}
				}
			}
		}
		$this->session->set_userdata('cart_order',$pdata);
		$current_cart_order = $this->session->userdata('cart_order');
		$total_amount = 0;
		foreach($current_cart_order as $cc){
			$total_amount += $cc['product_price'];
		}
		$this->session->set_userdata('total_amount',$total_amount);
		$jsonData = array('status'=>1,'message'=>'Product removed successfully','data'=>$current_cart_order,'cart_total_amount'=>$total_amount);
		echo json_encode($jsonData);
	}

	function cartItemsReset()
	{	
		$this->session->set_userdata('cart_order',array());
		$this->session->set_userdata('total_amount',0);
		$jsonData = array('status'=>1,'message'=>'Cart items reset successfully','current_cart_order'=>$current_cart_order);
		echo json_encode($jsonData);
	}


	public function orderFormFinal()
	{
		//if($order_id == "" || !is_numeric($order_id)){redirect('errors/invalidRequest');} // Check passing argument
		if(checkModuleAccessByUser(userInfo('user_role_id'), 76, "module_edit") == 0){ redirect('errors/noPermission');} // Check user access permission
		$data['order_id'] = currentOrderId();
		$data['current_cart_order'] = $this->session->userdata('cart_order');
		$data['total_amount']	    = $this->session->userdata('total_amount');
		$data['customer_data'] = $this->Customers->getAllCustomerData();
		$data['waiter_data'] = $this->Customers->getAllWaiterData();
		if($this->input->post()) {

			
			$cust_name= $_POST['cust_name'] ;
			$cust_number= $_POST['cust_number'] ;
			

			foreach($data['current_cart_order'] as $c){
				$product_deti['order_id'] = $data['order_id'];
				$product_deti['user_id'] = userInfo('user_id');
				$product_deti['product_id'] = $c['product_id'];
				$product_deti['product_name'] = $c['product_name'];
				$product_deti['quantity'] = $c['product_qty_add'];
				$product_deti['price'] = $c['product_price'];
				$product_deti['tax'] = $c['product_tax'];
				$product_deti['total'] = $c['product_price'] * $c['product_qty_add'];

				$product_deti['doc'] = date('Y-m-d H:i:s');
				$this->Product->OrderDetailsSave($product_deti,0);
			}

			$order_deti['order_id'] = $data['order_id'];
			$order_deti['cust_name'] = $cust_name != "" ? $cust_name : "";
			$order_deti['cust_number'] = $cust_number != "" ? $cust_number : "";
			$order_deti['room_number'] = $_POST["room_no"] != "" ? $_POST["room_no"] : "";
			$order_deti['total_amount'] = $data['total_amount'];

			$order_deti['payment_mode'] = $_POST['payment_mode'];
			$order_deti['waiter_name'] = $_POST['waiter_id'];
			$order_deti['cust_gst'] = $_POST['cust_gst_number'];
			$order_deti['cust_address'] = $_POST['cust_address'];
			$order_deti['doc'] = date('Y-m-d H:i:s');
			$this->Product->OrderDetailsTableSave($order_deti,0);

			
			$this->session->set_userdata('cart_order',array());
			$this->session->set_userdata('total_amount',0);
			$this->session->set_flashdata('msg_success', getMessage("record_saved", 3));
			redirect($this->controller_name.'/order/orderDetails/'.$data['order_id']);
		}
		
		$this->template->admin('order/order/final_order_form', $data);
		
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 27 2024 00:19:25
giriqfky / giriqfky
0755
Order.php
18.142 KB
July 27 2024 00:19:25
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF