EVOLUTION-NINJA
Edit File: G_reports.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class g_reports extends CI_Controller { public function __construct() { parent::__construct(); ini_set('max_execution_time', 30000); $this->load->database(); $this->check_islogin(); //check user login session exist or not $this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT'); $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); $this->output->set_header('Pragma: no-cache'); $this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); $this->load->model('yarn_model'); $this->load->model('marketing_model'); $this->load->model('planning_yarn'); $this->load->model('planning_shade'); $this->load->model('madeups_model'); //$this->load->library('user_agent'); $this->load->model('vendor_model'); $this->load->model('outsource_model'); $this->load->model('store_model'); $this->load->model('pkg_list_model'); $this->load->model('request_model'); $this->load->model('design_weaving_model'); $this -> load -> library('form_validation'); date_default_timezone_set('asia/kolkata'); } public function log() { echo $_REQUEST['name'];exit; echo "login"; } //Checking the Login or not private function check_islogin() { if (!$this->session->userdata('logged_in')) { redirect(base_url(), 'refresh'); } } public function session_data_pass() { if ($this->session->userdata('logged_in')) { return $this->yarn_model->get_userdata(); } } public function access_details() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_by=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_by); $d=$this->marketing_model->fetch_main_data($table,$where); $data['user_type_id']=$d->user_type_id; $table='swansilk_access_controls'; $where=array('department_id'=>$data['user_type_id']); return $this->marketing_model->fetch_where_data($table,$where); } public function access_details_id() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_by=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_by); $d=$this->marketing_model->fetch_main_data($table,$where); $data['user_type_id']=$d->user_type_id; $table='swansilk_access_controls'; $where=array('department_id'=>$data['user_type_id']); return $this->marketing_model->fetch_main_data($table,$where); } public function access_id() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_by=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_by); $d=$this->marketing_model->fetch_main_data($table,$where); return $d->user_type_id; } public function set_year() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; $RT = substr($uri, strpos($uri, "/") + 12); if($RT == 'g_reports/set_year') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { $data1=array('year'=>$_POST['year']); $this->db->where('id','1'); $this->db->update('select_year',$data1); redirect(base_url().'g_reports/summery_report'); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function index() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; $RT = substr($uri, strpos($uri, "/") + 12); if($RT == 'g_reports') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { $this->db->select('*'); $this->db->from('packing_list_data'); $this->db->where('confirm','Yes'); //$this->db->where('shipped','Yes'); $this->db->group_by('financ_year'); $this->db->order_by('id','desc'); $query=$this->db->get(); $record = $query->result(); $year = array(); foreach ($record as $row) { $financ_year = $row->financ_year; array_push($year,$financ_year); } $data['years'] = $year; $this->load->view('templates/header_inside',$data); $this->load->view('g_report/g_report_v',$data); $this->load->view('templates/footer_inside'); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function summery_report() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; $RT = substr($uri, strpos($uri, "/") + 12); if($RT == 'g_reports/summery_report') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { $this->db->select('*'); $this->db->from('select_year'); $this->db->where('id','1'); $query=$this->db->get(); $year_record = $query->result(); $year = ''; foreach ($year_record as $row) { $year = $row->year; } $this->db->select('*'); $this->db->from('packing_list_data'); $this->db->where('financ_year',$year); $this->db->where('confirm','Yes'); $this->db->where('shipped','Yes'); $this->db->order_by('e_way_date', "desc"); $query=$this->db->get(); $record = $query->result(); $this->db->select('*'); $this->db->from('madeups_list_data'); $this->db->where('financ_year',$year); $this->db->where('confirm','Yes'); $this->db->where('shipped','Yes'); $this->db->order_by('e_way_date', "desc"); $query=$this->db->get(); $record_madeups = $query->result(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; foreach ($record as $row) { $e_way_date = $row->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ if($month == '04'){ $april += (($row->total_value)*($row->shipping_customs_ex_rate)); // echo ($row->invoice_num); // echo ("======"); // echo (($row->total_value)*($row->shipping_customs_ex_rate)); // echo ("======"); } else if($month == '05'){ $may += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '06'){ $june += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '07'){ $july += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '08'){ $aug += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '09'){ $sept += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '10'){ $oct += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '11'){ $nov += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '12'){ $dec += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '01'){ $jan += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '02'){ $feb += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '03'){ $march += (($row->total_value)*($row->shipping_customs_ex_rate)); } } } $products_fabric[] = array( 'day' => 'Apr', 'sell' => $april ); $products_fabric[] = array( 'day' => 'May', 'sell' => $may ); $products_fabric[] = array( 'day' => 'Jun', 'sell' => $june ); $products_fabric[] = array( 'day' => 'Jul', 'sell' => $july ); $products_fabric[] = array( 'day' => 'Aug', 'sell' => $aug ); $products_fabric[] = array( 'day' => 'Sep', 'sell' => $sept ); $products_fabric[] = array( 'day' => 'Oct', 'sell' => $oct ); $products_fabric[] = array( 'day' => 'Nov', 'sell' => $nov ); $products_fabric[] = array( 'day' => 'Dec', 'sell' => $dec ); $products_fabric[] = array( 'day' => 'Jan', 'sell' => $jan ); $products_fabric[] = array( 'day' => 'Feb', 'sell' => $feb ); $products_fabric[] = array( 'day' => 'Mar', 'sell' => $march ); $april1 = 0; $may1 = 0; $june1 = 0; $july1 = 0; $aug1 = 0; $sept1 = 0; $oct1 = 0; $nov1 = 0; $dec1 = 0; $jan1 = 0; $feb1 = 0; $march1 = 0; foreach ($record_madeups as $row) { $e_way_date = $row->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ if($month == '04'){ $april += (($row->total_value)*($row->shipping_customs_ex_rate)); $april1 += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '05'){ $may += (($row->total_value)*($row->shipping_customs_ex_rate)); $may1 += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '06'){ $june += (($row->total_value)*($row->shipping_customs_ex_rate)); $june1 += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '07'){ $july += (($row->total_value)*($row->shipping_customs_ex_rate)); $july1 += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '08'){ $aug += (($row->total_value)*($row->shipping_customs_ex_rate)); $aug1 += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '09'){ $sept += (($row->total_value)*($row->shipping_customs_ex_rate)); $sept1 += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '10'){ $oct += (($row->total_value)*($row->shipping_customs_ex_rate)); $oct1 += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '11'){ $nov += (($row->total_value)*($row->shipping_customs_ex_rate)); $nov1 += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '12'){ $dec += (($row->total_value)*($row->shipping_customs_ex_rate)); $dec1 += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '01'){ $jan += (($row->total_value)*($row->shipping_customs_ex_rate)); $jan1 += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '02'){ $feb += (($row->total_value)*($row->shipping_customs_ex_rate)); $feb1 += (($row->total_value)*($row->shipping_customs_ex_rate)); } else if($month == '03'){ $march += (($row->total_value)*($row->shipping_customs_ex_rate)); $march1 += (($row->total_value)*($row->shipping_customs_ex_rate)); } } } $products_madeups[] = array( 'day' => 'Apr', 'sell' => $april1 ); $products_madeups[] = array( 'day' => 'May', 'sell' => $may1 ); $products_madeups[] = array( 'day' => 'Jun', 'sell' => $june1 ); $products_madeups[] = array( 'day' => 'Jul', 'sell' => $july1 ); $products_madeups[] = array( 'day' => 'Aug', 'sell' => $aug1 ); $products_madeups[] = array( 'day' => 'Sep', 'sell' => $sept1 ); $products_madeups[] = array( 'day' => 'Oct', 'sell' => $oct1 ); $products_madeups[] = array( 'day' => 'Nov', 'sell' => $nov1 ); $products_madeups[] = array( 'day' => 'Dec', 'sell' => $dec1 ); $products_madeups[] = array( 'day' => 'Jan', 'sell' => $jan1 ); $products_madeups[] = array( 'day' => 'Feb', 'sell' => $feb1 ); $products_madeups[] = array( 'day' => 'Mar', 'sell' => $march1 ); //die(); $products[] = array( 'day' => 'Apr', 'sell' => $april ); $products[] = array( 'day' => 'May', 'sell' => $may ); $products[] = array( 'day' => 'Jun', 'sell' => $june ); $products[] = array( 'day' => 'Jul', 'sell' => $july ); $products[] = array( 'day' => 'Aug', 'sell' => $aug ); $products[] = array( 'day' => 'Sep', 'sell' => $sept ); $products[] = array( 'day' => 'Oct', 'sell' => $oct ); $products[] = array( 'day' => 'Nov', 'sell' => $nov ); $products[] = array( 'day' => 'Dec', 'sell' => $dec ); $products[] = array( 'day' => 'Jan', 'sell' => $jan ); $products[] = array( 'day' => 'Feb', 'sell' => $feb ); $products[] = array( 'day' => 'Mar', 'sell' => $march ); $data['products'] = $products; $data['products_fabric'] = $products_fabric; $data['products_madeups'] = $products_madeups; $this->db->select('sum(total_value*shipping_customs_ex_rate) as sum,customer_name'); $this->db->from('packing_list_data'); $this->db->where('financ_year',$year); $this->db->where('confirm','Yes'); $this->db->where('shipped','Yes'); $this->db->order_by('e_way_date', "desc"); $this->db->group_by('customer_name'); $query=$this->db->get(); $record = $query->result(); $a=array(); foreach ($record as $row) { array_push($a,ucfirst($row->customer_name),$row->sum); } $this->db->select('sum(total_value*shipping_customs_ex_rate) as sum,customer_name'); $this->db->from('madeups_list_data'); $this->db->where('financ_year',$year); $this->db->where('confirm','Yes'); $this->db->where('shipped','Yes'); $this->db->order_by('e_way_date', "desc"); $this->db->group_by('customer_name'); $query=$this->db->get(); $record_madeups = $query->result(); foreach ($record_madeups as $row) { if(array_search($row->customer_name,$a)){ $index = array_search($row->customer_name,$a); $cust = $a[$index]; $inr_val = $a[$index+1]; $total_c_val = $inr_val + $row->sum; $a[$index+1] = $total_c_val; } else{ array_push($a,ucfirst($row->customer_name),$row->sum); } } // $a = arsort($a); $i = 0; for($i = 0; $i <count($a); $i=$i+2){ $customer[] = array( 'day' => $a[$i], 'sell' => $a[$i+1] ); } $data['customer'] = $customer; $this->db->select('sum(total_value*shipping_customs_ex_rate) as sum,country'); $this->db->from('packing_list_data'); $this->db->where('financ_year',$year); $this->db->where('confirm','Yes'); $this->db->where('shipped','Yes'); $this->db->order_by('e_way_date', "desc"); $this->db->group_by('country'); $query=$this->db->get(); $record = $query->result(); $a_country=array(); foreach ($record as $row) { array_push($a_country,$row->country,$row->sum); } $this->db->select('sum(total_value*shipping_customs_ex_rate) as sum,country'); $this->db->from('madeups_list_data'); $this->db->where('financ_year',$year); $this->db->where('confirm','Yes'); $this->db->where('shipped','Yes'); $this->db->order_by('e_way_date', "desc"); $this->db->group_by('country'); $query=$this->db->get(); $record_madeups = $query->result(); foreach ($record_madeups as $row) { if(array_search($row->country,$a_country)){ $index = array_search($row->country,$a_country); $cust = $a_country[$index]; $inr_val = $a_country[$index+1]; $total_c_val = $inr_val + $row->sum; $a_country[$index+1] = $total_c_val; } else{ array_push($a_country,$row->country,$row->sum); } } // $a = arsort($a); $i = 0; for($i = 0; $i <count($a_country); $i=$i+2){ $country[] = array( 'day' => $a_country[$i], 'sell' => $a_country[$i+1] ); } $data['country'] = $country; // echo '<pre>'; // print_r($country); // echo '</pre>'; // die(); $data['year'] = $year; $data['total'] = '10'; //$this->load->view('templates/header_inside',$data); $this->load->view('g_report/summery_report',$data); //$this->load->view('templates/footer_inside'); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function fabric_reports() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; $RT = substr($uri, strpos($uri, "/") + 12); if($RT == 'g_reports/fabric_reports') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { // $this->db->select('packing_list_data.p_category,product_category.product_category'); // $this->db->from('packing_list_data'); // $this->db->join('product_category', 'packing_list_data.p_category = product_category.id'); // $this->db->where('packing_list_data.financ_year',$year); // $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); // $this->db->order_by('packing_list_data.e_way_date', "desc"); // $this->db->group_by('packing_list_data.p_category'); $this->db->select('*'); $this->db->from('select_year'); $this->db->where('id','1'); $query=$this->db->get(); $year_record = $query->result(); $year = ''; foreach ($year_record as $row) { $year = $row->year; } $this->db->select('invoice_packing.p_category,product_category.product_category,product_category.hs_code'); $this->db->from('packing_list_data'); $this->db->join('invoice_packing', 'packing_list_data.invoice_num = invoice_packing.invoice_num','left'); $this->db->join('product_category', 'invoice_packing.p_category = product_category.id'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); $this->db->order_by('packing_list_data.e_way_date', "desc"); $this->db->group_by('invoice_packing.p_category'); $query=$this->db->get(); $p_record = $query->result(); $a = array(); $hsn = array(); foreach ($p_record as $row) { $p_id = $row->p_category; array_push($a,$row->product_category); array_push($hsn,$row->hs_code); $this->db->select('sum(invoice_packing.stock_wt) as sum,packing_list_data.*'); $this->db->from('packing_list_data'); $this->db->join('invoice_packing', 'packing_list_data.invoice_num = invoice_packing.invoice_num','left'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('invoice_packing.p_category',$p_id); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); $this->db->order_by('packing_list_data.e_way_date', "desc"); $this->db->group_by('invoice_packing.invoice_num'); $query=$this->db->get(); $sum_record = $query->result(); //print_r($this->db->last_query()); //die(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $products = []; $b = array(); foreach ($sum_record as $row1) { $e_way_date = $row1->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; if($row1->units == 'YARDS'){ $value = $row1->sum*0.9144; } else{ $value = $row1->sum; } if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } array_push($b,$april); array_push($b,$may); array_push($b,$june); array_push($b,$july); array_push($b,$aug); array_push($b,$sept); array_push($b,$oct); array_push($b,$nov); array_push($b,$dec); array_push($b,$jan); array_push($b,$feb); array_push($b,$march); $fabric[$row->product_category] = $b; } $data['category'] = $a; $data['hsn'] = $hsn; // $data['products']= $fabric ; $this->db->select('sum(invoice_packing.stock_wt) as sum,packing_list_data.*'); $this->db->from('packing_list_data'); $this->db->join('invoice_packing', 'packing_list_data.invoice_num = invoice_packing.invoice_num','left'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); $this->db->order_by('packing_list_data.e_way_date', "desc"); $this->db->group_by('invoice_packing.invoice_num'); $this->db->where('packing_list_data.p_category !=',''); $query=$this->db->get(); $total_record = $query->result(); // print_r($this->db->last_query()); // die(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $products = []; $total_array = array(); foreach ($total_record as $row1) { $e_way_date = $row1->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; if($row1->units == 'YARDS'){ $value = $row1->sum*0.9144; } else{ $value = $row1->sum; } if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } array_push($total_array,$april); array_push($total_array,$may); array_push($total_array,$june); array_push($total_array,$july); array_push($total_array,$aug); array_push($total_array,$sept); array_push($total_array,$oct); array_push($total_array,$nov); array_push($total_array,$dec); array_push($total_array,$jan); array_push($total_array,$feb); array_push($total_array,$march); $data['total_array'] = $total_array; // echo'<pre>'; // print_r($total_array); // echo'</pre>'; // die(); $data['year'] = $year; $data['total'] = '10'; $this->load->view('g_report/fabric_report',$data); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function madeups_reports() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; $RT = substr($uri, strpos($uri, "/") + 12); if($RT == 'g_reports/madeups_reports') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { $this->db->select('*'); $this->db->from('select_year'); $this->db->where('id','1'); $query=$this->db->get(); $year_record = $query->result(); $year = ''; foreach ($year_record as $row) { $year = $row->year; } $this->db->select('madeups_invoice_packing.p_category,product_category.product_category,product_category.hs_code'); $this->db->from('madeups_list_data'); $this->db->join('madeups_invoice_packing', 'madeups_list_data.invoice = madeups_invoice_packing.invoice','left'); $this->db->join('product_category', 'madeups_invoice_packing.p_category = product_category.id'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); $this->db->order_by('madeups_list_data.e_way_date', "desc"); $this->db->group_by('madeups_invoice_packing.p_category'); $query=$this->db->get(); $p_record = $query->result(); $a = array(); $hsn = array(); foreach ($p_record as $row) { $p_id = $row->p_category; array_push($a,$row->product_category); array_push($hsn,$row->hs_code); $this->db->select('sum(madeups_invoice_packing.stock_qty) as sum,madeups_list_data.*'); $this->db->from('madeups_list_data'); $this->db->join('madeups_invoice_packing', 'madeups_list_data.invoice = madeups_invoice_packing.invoice','left'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_invoice_packing.p_category',$p_id); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); $this->db->order_by('madeups_list_data.e_way_date', "desc"); $this->db->group_by('madeups_invoice_packing.invoice'); $query=$this->db->get(); $sum_record = $query->result(); //die(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $products = []; $b = array(); foreach ($sum_record as $row1) { $e_way_date = $row1->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $value = $row1->sum; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } array_push($b,$april); array_push($b,$may); array_push($b,$june); array_push($b,$july); array_push($b,$aug); array_push($b,$sept); array_push($b,$oct); array_push($b,$nov); array_push($b,$dec); array_push($b,$jan); array_push($b,$feb); array_push($b,$march); $fabric[$row->product_category] = $b; } $data['category'] = $a; $data['hsn'] = $hsn; $data['products'] = $fabric; $this->db->select('sum(madeups_invoice_packing.stock_qty) as sum,madeups_list_data.*'); $this->db->from('madeups_list_data'); $this->db->join('madeups_invoice_packing', 'madeups_list_data.invoice = madeups_invoice_packing.invoice','left'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); $this->db->order_by('madeups_list_data.e_way_date', "desc"); $this->db->group_by('madeups_invoice_packing.invoice'); $this->db->where('madeups_list_data.p_category !=',''); $query=$this->db->get(); $total_record = $query->result(); //echo '=============='; // print_r($this->db->last_query()); // die(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $products = []; $total_array = array(); foreach ($total_record as $row1) { $e_way_date = $row1->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $value = $row1->sum; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } array_push($total_array,$april); array_push($total_array,$may); array_push($total_array,$june); array_push($total_array,$july); array_push($total_array,$aug); array_push($total_array,$sept); array_push($total_array,$oct); array_push($total_array,$nov); array_push($total_array,$dec); array_push($total_array,$jan); array_push($total_array,$feb); array_push($total_array,$march); $data['total_array'] = $total_array; // echo'<pre>'; // print_r($total_array); // echo'</pre>'; // die(); $data['total'] = '10'; $data['year'] = $year; //$this->load->view('templates/header_inside',$data); $this->load->view('g_report/madeups_report',$data); //$this->load->view('templates/footer_inside'); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function duty_drawback_report() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; $RT = substr($uri, strpos($uri, "/") + 12); if($RT == 'g_reports/duty_drawback_report') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { $this->db->select('*'); $this->db->from('select_year'); $this->db->where('id','1'); $query=$this->db->get(); $year_record = $query->result(); $year = ''; foreach ($year_record as $row) { $year = $row->year; } $this->db->select('*'); $this->db->from('packing_list_data'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); $this->db->order_by('packing_list_data.e_way_date', "desc"); $query=$this->db->get(); $p_record = $query->result(); $this->db->select('*'); $this->db->from('madeups_list_data'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); $this->db->order_by('madeups_list_data.e_way_date', "desc"); $query=$this->db->get(); $madeups_record = $query->result(); // print_r($this->db->last_query()); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $total_array = array(); foreach ($p_record as $row) { $e_way_date = $row->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $value = $row->drawack_amount; if($month == '04'){ $april += floatval($value); } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } foreach ($madeups_record as $row) { $e_way_date = $row->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $value = $row->drawack_amount; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += (float) $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } array_push($total_array,$april); array_push($total_array,$may); array_push($total_array,$june); array_push($total_array,$july); array_push($total_array,$aug); array_push($total_array,$sept); array_push($total_array,$oct); array_push($total_array,$nov); array_push($total_array,$dec); array_push($total_array,$jan); array_push($total_array,$feb); array_push($total_array,$march); $data['products'] = $total_array; $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; foreach ($p_record as $row) { $e_way_date = $row->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != '' && $row->drawback_credit_date != ''){ $value = 0; $value = $row->drawack_amount; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } foreach ($madeups_record as $row) { $e_way_date = $row->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != '' && $row->drawback_credit_date != ''){ $value = 0; $value = $row->drawack_amount; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } $recieved = array(); array_push($recieved,$april); array_push($recieved,$may); array_push($recieved,$june); array_push($recieved,$july); array_push($recieved,$aug); array_push($recieved,$sept); array_push($recieved,$oct); array_push($recieved,$nov); array_push($recieved,$dec); array_push($recieved,$jan); array_push($recieved,$feb); array_push($recieved,$march); // echo '<pre>'; // print_r($recieved); // echo '</pre>'; $data['recieved'] = $recieved; //==================================================================================== //Export $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $total_array = array(); foreach ($p_record as $row) { $e_way_date = $row->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $value = $row->export_incentive; if($month == '04'){ $april += floatval($value); } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } foreach ($madeups_record as $row) { $e_way_date = $row->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $value = $row->export_incentive; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += (float) $value; } else if($month == '07'){ $july += (float)$value; } else if($month == '08'){ $aug +=(float)$value; } else if($month == '09'){ $sept +=(float)$value; } else if($month == '10'){ $oct += (float)$value; } else if($month == '11'){ $nov += (float)$value; } else if($month == '12'){ $dec += (float)$value; } else if($month == '01'){ $jan += (float)$value; } else if($month == '02'){ $feb += (float)$value; } else if($month == '03'){ $march +=(float)$value; } } } $exports = array(); array_push($exports,$april); array_push($exports,$may); array_push($exports,$june); array_push($exports,$july); array_push($exports,$aug); array_push($exports,$sept); array_push($exports,$oct); array_push($exports,$nov); array_push($exports,$dec); array_push($exports,$jan); array_push($exports,$feb); array_push($exports,$march); $data['Export'] = $exports; $data['year'] = $year; $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; foreach ($p_record as $row) { $e_way_date = $row->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != '' && $row->incentive_credit_date != ''){ $value = 0; $value = $row->export_incentive; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } foreach ($madeups_record as $row) { $e_way_date = $row->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != '' && $row->incentive_credit_date != ''){ $value = 0; $value = $row->export_incentive; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } $exports_recieved = array(); array_push($exports_recieved,$april); array_push($exports_recieved,$may); array_push($exports_recieved,$june); array_push($exports_recieved,$july); array_push($exports_recieved,$aug); array_push($exports_recieved,$sept); array_push($exports_recieved,$oct); array_push($exports_recieved,$nov); array_push($exports_recieved,$dec); array_push($exports_recieved,$jan); array_push($exports_recieved,$feb); array_push($exports_recieved,$march); // echo '<pre>'; // print_r($recieved); // echo '</pre>'; $data['Export_recieved'] = $exports_recieved; $data['total'] = '10'; //$this->load->view('templates/header_inside',$data); $this->load->view('g_report/duty_drawback_report',$data); //$this->load->view('templates/footer_inside'); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function export_report() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; $RT = substr($uri, strpos($uri, "/") + 12,23); $m = substr($uri, strpos($uri, "/") + 36,4); // //echo $RT; // echo $m; // die(); if($RT == 'g_reports/export_report') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { $this->db->select('*'); $this->db->from('select_year'); $this->db->where('id','1'); $query=$this->db->get(); $year_record = $query->result(); $year = ''; foreach ($year_record as $row) { $year = $row->year; } $this->db->select('packing_list_data.*,country_table.rex,invoice_packing.contarct_type,sum(invoice_packing.stock_qty) as sum_qty,sum(invoice_packing.stock_wt) as sum_wt'); $this->db->from('packing_list_data'); $this->db->join('country_table', 'packing_list_data.country = country_table.country_name','left'); $this->db->join('invoice_packing', 'packing_list_data.invoice_num = invoice_packing.invoice_num','left'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); if($m != 'all' && $m != ''){ $this->db->like('packing_list_data.e_way_date','-'.$m.'-'); } $this->db->order_by('packing_list_data.e_way_date', "desc"); $this->db->group_by('invoice_packing.invoice_num', "desc"); $query=$this->db->get(); $p_record = $query->result(); $data['fabric'] = $p_record; $this->db->select('madeups_list_data.*,country_table.rex,madeups_invoice_packing.contarct_type,sum(madeups_invoice_packing.stock_qty) as sum_qty,sum(madeups_invoice_packing.stock_wt) as sum_wt'); $this->db->from('madeups_list_data'); $this->db->join('country_table', 'madeups_list_data.country = country_table.country_name','left'); $this->db->join('madeups_invoice_packing', 'madeups_list_data.invoice = madeups_invoice_packing.invoice','left'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); if($m != 'all' && $m != ''){ $this->db->like('madeups_list_data.e_way_date','-'.$m.'-'); } $this->db->order_by('madeups_list_data.e_way_date', "desc"); $this->db->group_by('madeups_invoice_packing.invoice_num', "desc"); $query=$this->db->get(); $madeups_record = $query->result(); $data['madeups'] = $madeups_record; $data['year'] = $year; $this->load->view('g_report/export_report',$data); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function rex_report() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; $RT = substr($uri, strpos($uri, "/") + 12); $RT = substr($uri, strpos($uri, "/") + 12,20); $m = substr($uri, strpos($uri, "/") + 33,4); // // echo $RT; //echo $m; // die(); if($RT == 'g_reports/rex_report') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { $this->db->select('*'); $this->db->from('select_year'); $this->db->where('id','1'); $query=$this->db->get(); $year_record = $query->result(); $year = ''; foreach ($year_record as $row) { $year = $row->year; } $this->db->select('packing_list_data.*,country_table.rex,invoice_packing.contarct_type,sum(invoice_packing.stock_qty) as sum_qty,sum(invoice_packing.values_es) as sum_values_es,sum(invoice_packing.stock_wt) as sum_wt,invoice_packing.hsn_code,product_category.product_category'); $this->db->from('packing_list_data'); $this->db->join('country_table', 'packing_list_data.country = country_table.country_name','left'); $this->db->join('invoice_packing', 'packing_list_data.invoice_num = invoice_packing.invoice_num','left'); $this->db->join('product_category', 'invoice_packing.p_category = product_category.id'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); if($m != 'all' && $m != ''){ $this->db->like('packing_list_data.e_way_date','-'.$m.'-'); } $this->db->where('country_table.rex','1'); $this->db->order_by('packing_list_data.invoice_date', "desc"); $this->db->group_by('invoice_packing.p_category'); $this->db->group_by('invoice_packing.invoice_num'); $query=$this->db->get(); $p_record = $query->result(); $data['fabric'] = $p_record; $this->db->select('madeups_list_data.*,country_table.rex,madeups_invoice_packing.contarct_type,sum(madeups_invoice_packing.stock_qty) as sum_qty,sum(madeups_invoice_packing.values_es) as sum_values_es,sum(madeups_invoice_packing.stock_wt) as sum_wt,madeups_invoice_packing.hsn_code,product_category.product_category'); $this->db->from('madeups_list_data'); $this->db->join('country_table', 'madeups_list_data.country = country_table.country_name','left'); $this->db->join('madeups_invoice_packing', 'madeups_list_data.invoice = madeups_invoice_packing.invoice','left'); $this->db->join('product_category', 'madeups_invoice_packing.p_category = product_category.id'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); if($m != 'all' && $m != ''){ $this->db->like('madeups_list_data.e_way_date','-'.$m.'-'); } $this->db->where('country_table.rex','1'); $this->db->order_by('madeups_list_data.invoice_date', "desc"); $this->db->group_by('madeups_invoice_packing.p_category'); $this->db->group_by('madeups_invoice_packing.invoice_num'); //$this->db->group_by('madeups_invoice_packing.p_category'); $query=$this->db->get(); $madeups_record = $query->result(); $data['madeups'] = $madeups_record; $data['year'] = $year; $this->load->view('g_report/rex_report',$data); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function gst_report() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; // $RT = substr($uri, strpos($uri, "/") + 12); $RT = substr($uri, strpos($uri, "/") + 12,20); $m = substr($uri, strpos($uri, "/") + 33,4); // // echo $RT; // echo $m; // die(); if($RT == 'g_reports/gst_report') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { $this->db->select('*'); $this->db->from('select_year'); $this->db->where('id','1'); $query=$this->db->get(); $year_record = $query->result(); $year = ''; foreach ($year_record as $row) { $year = $row->year; } $this->db->select('packing_list_data.*,invoice_packing.unitprice,country_table.rex,invoice_packing.contarct_type,sum(invoice_packing.stock_qty) as sum_qty,sum(invoice_packing.values_es) as sum_values_es,sum(invoice_packing.stock_wt) as sum_wt,invoice_packing.hsn_code,product_category.product_category'); $this->db->from('packing_list_data'); $this->db->join('country_table', 'packing_list_data.country = country_table.country_name','left'); $this->db->join('invoice_packing', 'packing_list_data.invoice_num = invoice_packing.invoice_num','left'); $this->db->join('product_category', 'invoice_packing.p_category = product_category.id'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); if($m != 'all' && $m != ''){ $this->db->like('packing_list_data.e_way_date','-'.$m.'-'); } $this->db->order_by('packing_list_data.invoice_date', "desc"); $this->db->group_by('invoice_packing.p_category'); $this->db->group_by('invoice_packing.invoice_num'); $this->db->group_by('invoice_packing.unitprice'); $query=$this->db->get(); $p_record = $query->result(); $data['fabric'] = $p_record; $this->db->select('madeups_list_data.*,madeups_invoice_packing.unitprice,country_table.rex,madeups_invoice_packing.contarct_type,sum(madeups_invoice_packing.stock_qty) as sum_qty,sum(madeups_invoice_packing.values_es) as sum_values_es,sum(madeups_invoice_packing.stock_wt) as sum_wt,madeups_invoice_packing.hsn_code,product_category.product_category'); $this->db->from('madeups_list_data'); $this->db->join('country_table', 'madeups_list_data.country = country_table.country_name','left'); $this->db->join('madeups_invoice_packing', 'madeups_list_data.invoice = madeups_invoice_packing.invoice','left'); $this->db->join('product_category', 'madeups_invoice_packing.p_category = product_category.id'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); if($m != 'all' && $m != ''){ $this->db->like('madeups_list_data.e_way_date','-'.$m.'-'); } $this->db->order_by('madeups_list_data.invoice_date', "desc"); $this->db->group_by('madeups_invoice_packing.p_category'); $this->db->group_by('madeups_invoice_packing.invoice_num'); $this->db->group_by('madeups_invoice_packing.unitprice'); //$this->db->group_by('madeups_invoice_packing.p_category'); $query=$this->db->get(); $madeups_record = $query->result(); $data['madeups'] = $madeups_record; $data['year'] = $year; $this->load->view('g_report/gst_report',$data); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function gst_summery_reports() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; $RT = substr($uri, strpos($uri, "/") + 12); if($RT == 'g_reports/gst_summery_reports') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { $this->db->select('*'); $this->db->from('select_year'); $this->db->where('id','1'); $query=$this->db->get(); $year_record = $query->result(); $year = ''; foreach ($year_record as $row) { $year = $row->year; } $this->db->select('invoice_packing.p_category,product_category.product_category,product_category.hs_code'); $this->db->from('packing_list_data'); $this->db->join('invoice_packing', 'packing_list_data.invoice_num = invoice_packing.invoice_num','left'); $this->db->join('product_category', 'invoice_packing.p_category = product_category.id'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); $this->db->order_by('packing_list_data.e_way_date', "desc"); $this->db->group_by('invoice_packing.p_category'); $query=$this->db->get(); $p_record = $query->result(); $a = array(); $hsn = array(); foreach ($p_record as $row) { $p_id = $row->p_category; array_push($a,$row->product_category); array_push($hsn,$row->hs_code); $this->db->select('sum(invoice_packing.stock_wt) as sum,packing_list_data.*,sum(invoice_packing.values_es) as sum_values_es,invoice_packing.unitprice'); $this->db->from('packing_list_data'); $this->db->join('invoice_packing', 'packing_list_data.invoice_num = invoice_packing.invoice_num','left'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('invoice_packing.p_category',$p_id); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); $this->db->order_by('packing_list_data.e_way_date', "desc"); $this->db->group_by('invoice_packing.invoice_num'); $this->db->group_by('invoice_packing.unitprice'); $query=$this->db->get(); $sum_record = $query->result(); //print_r($this->db->last_query()); //die(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $products = []; $b = array(); foreach ($sum_record as $row1) { $e_way_date = $row1->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $total5 = ($row1->total_value + $row1->discount); $discount = ($row1->discount/$total5)*100; $discount1 = ((($row1->sum_values_es * $discount)/100)); $total = (($row1->sum * $row1->unitprice) - $discount1) * ($row1->shipping_customs_ex_rate); $total1 = (($total) * (($row1->igst_rate)/100)); $value = $total1; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } array_push($b,$april); array_push($b,$may); array_push($b,$june); array_push($b,$july); array_push($b,$aug); array_push($b,$sept); array_push($b,$oct); array_push($b,$nov); array_push($b,$dec); array_push($b,$jan); array_push($b,$feb); array_push($b,$march); $fabric[$row->product_category] = $b; } $data['category'] = $a; $data['hsn'] = $hsn; // $data['products'] = $fabric; $this->db->select('sum(invoice_packing.stock_wt) as sum,sum(invoice_packing.values_es) as sum_values_es,packing_list_data.*,invoice_packing.unitprice'); $this->db->from('packing_list_data'); $this->db->join('invoice_packing', 'packing_list_data.invoice_num = invoice_packing.invoice_num','left'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); $this->db->order_by('packing_list_data.e_way_date', "desc"); $this->db->group_by('invoice_packing.invoice_num'); $this->db->group_by('invoice_packing.unitprice'); $this->db->where('packing_list_data.p_category !=',''); $query=$this->db->get(); $total_record = $query->result(); //print_r($this->db->last_query()); // die(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $products = []; $total_array = array(); foreach ($total_record as $row1) { $e_way_date = $row1->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $total5 = ($row1->total_value + $row1->discount); $discount = ($row1->discount/$total5)*100; $discount1 = ((($row1->sum_values_es * $discount)/100)); $total = (($row1->sum * $row1->unitprice) - $discount1) * ($row1->shipping_customs_ex_rate); $total1 = (($total) * (($row1->igst_rate)/100)); $value = $total1; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } array_push($total_array,$april); array_push($total_array,$may); array_push($total_array,$june); array_push($total_array,$july); array_push($total_array,$aug); array_push($total_array,$sept); array_push($total_array,$oct); array_push($total_array,$nov); array_push($total_array,$dec); array_push($total_array,$jan); array_push($total_array,$feb); array_push($total_array,$march); $data['total_array'] = $total_array; $this->db->select('madeups_invoice_packing.p_category,product_category.product_category,product_category.hs_code'); $this->db->from('madeups_list_data'); $this->db->join('madeups_invoice_packing', 'madeups_list_data.invoice_num = madeups_invoice_packing.invoice_num','left'); $this->db->join('product_category', 'madeups_invoice_packing.p_category = product_category.id'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); $this->db->order_by('madeups_list_data.e_way_date', "desc"); $this->db->group_by('madeups_invoice_packing.p_category'); $query=$this->db->get(); $p_record = $query->result(); $a_madeups = array(); $hsn_madeups = array(); foreach ($p_record as $row) { $p_id = $row->p_category; array_push($a_madeups,$row->product_category); array_push($hsn_madeups,$row->hs_code); $this->db->select('sum(madeups_invoice_packing.stock_qty) as sum,sum(madeups_invoice_packing.values_es) as sum_values_es,madeups_list_data.*,madeups_invoice_packing.unitprice'); $this->db->from('madeups_list_data'); $this->db->join('madeups_invoice_packing', 'madeups_list_data.invoice = madeups_invoice_packing.invoice','left'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_invoice_packing.p_category',$p_id); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); $this->db->order_by('madeups_list_data.e_way_date', "desc"); $this->db->group_by('madeups_invoice_packing.invoice'); $this->db->group_by('madeups_invoice_packing.unitprice'); $query=$this->db->get(); $sum_record = $query->result(); //print_r($this->db->last_query()); //die(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $products_madeups = []; $b_madeups = array(); foreach ($sum_record as $row1) { $e_way_date = $row1->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $total5 = ($row1->total_value + $row1->discount); $discount = ($row1->discount/$total5)*100; $discount1 = ((($row1->sum_values_es * $discount)/100)); $total = (($row1->sum * $row1->unitprice) - $discount1) * ($row1->shipping_customs_ex_rate); $total1 = (($total) * (($row1->igst_rate)/100)); $value = $total1; if($month == '04'){ $april += $value; } else if($month == '05'){ // echo $value; // die(); $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } array_push($b_madeups,$april); array_push($b_madeups,$may); array_push($b_madeups,$june); array_push($b_madeups,$july); array_push($b_madeups,$aug); array_push($b_madeups,$sept); array_push($b_madeups,$oct); array_push($b_madeups,$nov); array_push($b_madeups,$dec); array_push($b_madeups,$jan); array_push($b_madeups,$feb); array_push($b_madeups,$march); $madeups[$row->product_category] = $b_madeups; } $data['category_madeups'] = $a_madeups; $data['hsn_madeups'] = $hsn_madeups; $data['products_madeups'] = $madeups; $this->db->select('sum(madeups_invoice_packing.stock_qty) as sum,sum(madeups_invoice_packing.values_es) as sum_values_es,madeups_list_data.*,madeups_invoice_packing.unitprice'); $this->db->from('madeups_list_data'); $this->db->join('madeups_invoice_packing', 'madeups_list_data.invoice = madeups_invoice_packing.invoice','left'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); $this->db->where('madeups_list_data.p_category !=',''); $this->db->order_by('madeups_list_data.e_way_date', "desc"); $this->db->group_by('madeups_invoice_packing.invoice'); $this->db->group_by('madeups_invoice_packing.unitprice'); $query=$this->db->get(); $total_record_madeups = $query->result(); // print_r($this->db->last_query()); // die(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $products = []; // echo'<pre>'; // print_r($total_record_madeups); // echo'</pre>'; $total_array_madeups = array(); foreach ($total_record_madeups as $row1) { $e_way_date = $row1->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $total5 = ($row1->total_value + $row1->discount); $discount = ($row1->discount/$total5)*100; $discount1 = ((($row1->sum_values_es * $discount)/100)); $total = (($row1->sum * $row1->unitprice) - $discount1) * ($row1->shipping_customs_ex_rate); $total1 = (($total) * (($row1->igst_rate)/100)); $value = $total1; if($month == '04'){ //echo $value; // echo '---'; $april += $value; } else if($month == '05'){ // echo $value; // echo '---'; $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } // die(); array_push($total_array_madeups,$april); array_push($total_array_madeups,$may); array_push($total_array_madeups,$june); array_push($total_array_madeups,$july); array_push($total_array_madeups,$aug); array_push($total_array_madeups,$sept); array_push($total_array_madeups,$oct); array_push($total_array_madeups,$nov); array_push($total_array_madeups,$dec); array_push($total_array_madeups,$jan); array_push($total_array_madeups,$feb); array_push($total_array_madeups,$march); $data['total_array_madeups'] = $total_array_madeups; $data['year'] = $year; // echo'<pre>'; // print_r($total_array_madeups); // echo'</pre>'; // die(); $data['total'] = '10'; //$this->load->view('templates/header_inside',$data); $this->load->view('g_report/gst_summery',$data); //$this->load->view('templates/footer_inside'); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function hscode_summery_reports() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; $RT = substr($uri, strpos($uri, "/") + 12); if($RT == 'g_reports/hscode_summery_reports') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { // $this->db->select('packing_list_data.p_category,product_category.product_category'); // $this->db->from('packing_list_data'); // $this->db->join('product_category', 'packing_list_data.p_category = product_category.id'); // $this->db->where('packing_list_data.financ_year',$year); // $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); // $this->db->order_by('packing_list_data.e_way_date', "desc"); // $this->db->group_by('packing_list_data.p_category'); $this->db->select('*'); $this->db->from('select_year'); $this->db->where('id','1'); $query=$this->db->get(); $year_record = $query->result(); $year = ''; foreach ($year_record as $row) { $year = $row->year; } $this->db->select('invoice_packing.p_category,product_category.product_category,product_category.hs_code'); $this->db->from('packing_list_data'); $this->db->join('invoice_packing', 'packing_list_data.invoice_num = invoice_packing.invoice_num','left'); $this->db->join('product_category', 'invoice_packing.p_category = product_category.id'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); $this->db->order_by('packing_list_data.e_way_date', "desc"); $this->db->group_by('invoice_packing.p_category'); $query=$this->db->get(); $p_record = $query->result(); $a = array(); $hsn = array(); foreach ($p_record as $row) { $p_id = $row->p_category; array_push($a,$row->product_category); array_push($hsn,$row->hs_code); $this->db->select('sum(invoice_packing.stock_wt) as sum,packing_list_data.*,invoice_packing.unitprice'); $this->db->from('packing_list_data'); $this->db->join('invoice_packing', 'packing_list_data.invoice_num = invoice_packing.invoice_num','left'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('invoice_packing.p_category',$p_id); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); $this->db->order_by('packing_list_data.e_way_date', "desc"); $this->db->group_by('invoice_packing.invoice_num'); $this->db->group_by('invoice_packing.unitprice'); $query=$this->db->get(); $sum_record = $query->result(); // print_r($sum_record); // die(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $products = []; $b = array(); foreach ($sum_record as $row1) { $e_way_date = $row1->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $total = ($row1->sum * $row1->unitprice) * ($row1->shipping_customs_ex_rate); $value = $total; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } array_push($b,$april); array_push($b,$may); array_push($b,$june); array_push($b,$july); array_push($b,$aug); array_push($b,$sept); array_push($b,$oct); array_push($b,$nov); array_push($b,$dec); array_push($b,$jan); array_push($b,$feb); array_push($b,$march); $fabric[$row->product_category] = $b; } // print_r($data['category'] ); // die(); $data['category'] = $a; $data['hsn'] = $hsn; // $data['products'] = $fabric; $this->db->select('sum(invoice_packing.stock_wt) as sum,packing_list_data.*,invoice_packing.unitprice'); $this->db->from('packing_list_data'); $this->db->join('invoice_packing', 'packing_list_data.invoice_num = invoice_packing.invoice_num','left'); $this->db->where('packing_list_data.financ_year',$year); $this->db->where('packing_list_data.confirm','Yes'); $this->db->where('packing_list_data.shipped','Yes'); $this->db->order_by('packing_list_data.e_way_date', "desc"); $this->db->group_by('invoice_packing.invoice_num'); $this->db->group_by('invoice_packing.unitprice'); $this->db->where('packing_list_data.p_category !=',''); $query=$this->db->get(); $total_record = $query->result(); // print_r($this->db->last_query()); // die(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $products = []; $total_array = array(); foreach ($total_record as $row1) { $e_way_date = $row1->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $total = ($row1->sum * $row1->unitprice) * ($row1->shipping_customs_ex_rate); $value = $total; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } array_push($total_array,$april); array_push($total_array,$may); array_push($total_array,$june); array_push($total_array,$july); array_push($total_array,$aug); array_push($total_array,$sept); array_push($total_array,$oct); array_push($total_array,$nov); array_push($total_array,$dec); array_push($total_array,$jan); array_push($total_array,$feb); array_push($total_array,$march); $data['total_array'] = $total_array; $this->db->select('madeups_invoice_packing.p_category,product_category.product_category,product_category.hs_code'); $this->db->from('madeups_list_data'); $this->db->join('madeups_invoice_packing', 'madeups_list_data.invoice_num = madeups_invoice_packing.invoice_num','left'); $this->db->join('product_category', 'madeups_invoice_packing.p_category = product_category.id'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); $this->db->order_by('madeups_list_data.e_way_date', "desc"); $this->db->group_by('madeups_invoice_packing.p_category'); $query=$this->db->get(); $p_record = $query->result(); $a_madeups = array(); $hsn_madeups = array(); foreach ($p_record as $row) { $p_id = $row->p_category; array_push($a_madeups,$row->product_category); array_push($hsn_madeups,$row->hs_code); $this->db->select('sum(madeups_invoice_packing.stock_qty) as sum,madeups_list_data.*,madeups_invoice_packing.unitprice'); $this->db->from('madeups_list_data'); $this->db->join('madeups_invoice_packing', 'madeups_list_data.invoice = madeups_invoice_packing.invoice','left'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_invoice_packing.p_category',$p_id); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); $this->db->order_by('madeups_list_data.e_way_date', "desc"); $this->db->group_by('madeups_invoice_packing.invoice'); $this->db->group_by('madeups_invoice_packing.unitprice'); $query=$this->db->get(); $sum_record = $query->result(); //print_r($this->db->last_query()); //die(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $products_madeups = []; $b_madeups = array(); foreach ($sum_record as $row1) { $e_way_date = $row1->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $total = ($row1->sum * $row1->unitprice) * ($row1->shipping_customs_ex_rate); $value = $total; if($month == '04'){ $april += $value; } else if($month == '05'){ // echo $value; // die(); $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } array_push($b_madeups,$april); array_push($b_madeups,$may); array_push($b_madeups,$june); array_push($b_madeups,$july); array_push($b_madeups,$aug); array_push($b_madeups,$sept); array_push($b_madeups,$oct); array_push($b_madeups,$nov); array_push($b_madeups,$dec); array_push($b_madeups,$jan); array_push($b_madeups,$feb); array_push($b_madeups,$march); $madeups[$row->product_category] = $b_madeups; } $data['category_madeups'] = $a_madeups; $data['hsn_madeups'] = $hsn_madeups; $data['products_madeups'] = $madeups; $this->db->select('sum(madeups_invoice_packing.stock_qty) as sum,madeups_list_data.*,madeups_invoice_packing.unitprice'); $this->db->from('madeups_list_data'); $this->db->join('madeups_invoice_packing', 'madeups_list_data.invoice = madeups_invoice_packing.invoice','left'); $this->db->where('madeups_list_data.financ_year',$year); $this->db->where('madeups_list_data.confirm','Yes'); $this->db->where('madeups_list_data.shipped','Yes'); $this->db->where('madeups_list_data.p_category !=',''); $this->db->order_by('madeups_list_data.e_way_date', "desc"); $this->db->group_by('madeups_invoice_packing.invoice'); $this->db->group_by('madeups_invoice_packing.unitprice'); $query=$this->db->get(); $total_record_madeups = $query->result(); // print_r($this->db->last_query()); // die(); $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; $products = []; // echo'<pre>'; // print_r($total_record_madeups); // echo'</pre>'; $total_array_madeups = array(); foreach ($total_record_madeups as $row1) { $e_way_date = $row1->e_way_date; $month = date("m",strtotime($e_way_date)); if($e_way_date != ''){ $value = 0; $total = ($row1->sum * $row1->unitprice) * ($row1->shipping_customs_ex_rate); $value = $total; if($month == '04'){ //echo $value; // echo '---'; $april += $value; } else if($month == '05'){ // echo $value; // echo '---'; $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } // die(); array_push($total_array_madeups,$april); array_push($total_array_madeups,$may); array_push($total_array_madeups,$june); array_push($total_array_madeups,$july); array_push($total_array_madeups,$aug); array_push($total_array_madeups,$sept); array_push($total_array_madeups,$oct); array_push($total_array_madeups,$nov); array_push($total_array_madeups,$dec); array_push($total_array_madeups,$jan); array_push($total_array_madeups,$feb); array_push($total_array_madeups,$march); $data['total_array_madeups'] = $total_array_madeups; $data['year'] = $year; // echo'<pre>'; // print_r($total_array_madeups); // echo'</pre>'; // die(); $data['total'] = '10'; //$this->load->view('templates/header_inside',$data); $this->load->view('g_report/hscode_summery',$data); //$this->load->view('templates/footer_inside'); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function summery_report_marketing() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; // $RT = substr($uri, strpos($uri, "/") + 12); $RT = substr($uri, strpos($uri, "/") + 12,34); $m = substr($uri, strpos($uri, "/") + 47,4); if($RT == 'g_reports/summery_report_marketing') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { $this->db->select('*'); $this->db->from('select_year'); $this->db->where('id','1'); $query=$this->db->get(); $year_record = $query->result(); $year = ''; foreach ($year_record as $row) { $year = $row->year; } $start_year =''; $end_year = ''; if($year == '24-25'){ $start_year = '2024-04-01'; $end_year = '2025-03-31'; } else if($year == '25-26'){ $start_year = '2025-04-01'; $end_year = '2026-03-31'; } else if($year == '23-24'){ $start_year = '2023-04-01'; $end_year = '2024-03-31'; } else if($year == '17-18'){ $start_year = '2017-04-01'; $end_year = '2018-03-31'; } else if($year == '18-19'){ $start_year = '2018-04-01'; $end_year = '2019-03-31'; } else if($year == '19-20'){ $start_year = '2019-04-01'; $end_year = '2020-03-31'; } else if($year == '20-21'){ $start_year = '2020-04-01'; $end_year = '2021-03-31'; } else if($year == '21-22'){ $start_year = '2021-04-01'; $end_year = '2022-03-31'; } else if($year == '22-23'){ $start_year = '2022-04-01'; $end_year = '2023-03-31'; } $this->db->select('o.*,sos.planned_by,sos.planningStatus,so.totalValue,so.orders_Type,adv.adv_pay_stat'); $this->db->from('orders o'); ///$this->db->where('so.orderConfirm', 'Yes'); $this->db->where('o.status',0); //$this->db->where('so.article_type', 'outsource'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->join('advance_payment_details adv', 'adv.orderid = o.id','left'); $this->db->order_by("id", "desc"); $this->db->group_by('o.oslNo'); if($m != 'all' && $m != ''){ $this->db->like('o.deliveryDate','-'.$m.'-'); } $this->db->where('o.deliveryDate >', $start_year); $this->db->where('o.deliveryDate <', $end_year); $this->db->where('o.confirm_status', 'CONFIRMED'); $this->db->where('sos.planningStatus', 'planned'); $this->db->where('o.orderType','DTL'); $query = $this->db->get(); $result=$query->result(); $array = array(); $f_order_value = 0; $f_shipped_value = 0; $m_order_value = 0; $m_shipped_value = 0; foreach($result as $value) { $data['id'] = $value->id; $data['oslNo'] = $value->oslNo; $data['fileNo'] = $value->fileNo; $data['orderMode'] = $value->orderMode; $data['orderNo'] = $value->orderNo; $data['deliveryDate'] = $value->deliveryDate; $this->db->select('SUM(sub_orders.totalValue) as value,SUM(sub_orders.totalQuantity) as qnty,SUM(sub_orders.indianValue) as indian'); $this->db->from('sub_orders'); $this->db->where('sub_orders.orderID',$value->id); $query= $this->db->get(); $sumvalues= $query->row(); if($value->orders_Type == 'MADEUPS'){ $this->db->select('sum(madeups_invoice_packing.values_es) as total,madeups_list_data.shipping_customs_ex_rate,madeups_list_data.discount,madeups_list_data.total_value,madeups_list_data.currency'); $this->db->from('madeups_invoice_packing'); $this->db->join('madeups_list_data', 'madeups_invoice_packing.invoice = madeups_list_data.invoice'); $this->db->where('madeups_invoice_packing.osl_no', $value->oslNo); $query3=$this->db->get(); $total3=$query3->row(); $total6 = 0; $total6 = ($total3->total_value + $total3->discount); if($total6 == 0){ $data['discount'] = 0; $sh_val = 0; $data['sh_val'] = $sh_val; $data['sh_val_rate'] = 0; } else{ $discount = ($total3->discount/$total6)*100; $discount1 = ((($total3->total * $discount)/100)); $data['discount'] = number_format((float)$discount1, 2, '.', ''); $sh_val = ($total3->total - number_format((float)$discount1, 2, '.', '')); $data['sh_val'] = $sh_val; $data['sh_val_rate'] = $total3->shipping_customs_ex_rate; } $data['currency'] = $total3->currency; $m_order_value += round($sumvalues->indian,2); $m_shipped_value += (($sh_val * $total3->shipping_customs_ex_rate)); //print_r($this->db->last_query()); // die(); } else{ $this->db->select('sum(invoice_packing.values_es) as total,packing_list_data.shipping_customs_ex_rate,packing_list_data.discount,packing_list_data.total_value,packing_list_data.currency'); $this->db->from('invoice_packing'); $this->db->join('packing_list_data', 'invoice_packing.invoice_num = packing_list_data.invoice_num'); $this->db->where('invoice_packing.po_no', $value->oslNo); $query3=$this->db->get(); $total3=$query3->row(); $total6 = 0; $total6 = ($total3->total_value + $total3->discount); if($total6 == 0){ $data['discount'] = 0; $sh_val = 0; $data['sh_val'] = $sh_val; $data['sh_val_rate'] = 0; } else{ $discount = ($total3->discount/$total6)*100; $discount1 = ((($total3->total * $discount)/100)); $data['discount'] = number_format((float)$discount1, 2, '.', ''); $sh_val = ($total3->total - number_format((float)$discount1, 2, '.', '')); $data['sh_val'] = $sh_val; $data['sh_val_rate'] = $total3->shipping_customs_ex_rate; } $data['currency'] = $total3->currency; $f_order_value += round($sumvalues->indian,2); $f_shipped_value += (($sh_val * $total3->shipping_customs_ex_rate)); } $this->db->select('sum(totalValue) as totalValue'); $this->db->from('sub_orders'); $this->db->where('orderID',$value->id); $query=$this->db->get(); $total=$query->row(); $pro=$value->shipped_fun; if($pro==0){ $data['shipped_fun']='Pending'; }else{ $data['shipped_fun']='Completed'; } $data['indian']=round($sumvalues->indian,2); $data['invoice_no']=$value->invoice_no; $data['totalValue'] = ROUND($total->totalValue,2); $data['currency'] = $value->currency; $data['orders_Type']=$value->orders_Type; $data['confirm_status'] = $value->confirm_status; $data['planningStatus'] = $value->planningStatus; $data['adv_pay_stat'] = $value->adv_pay_stat; array_push($array, $data); } $data['res'] = $array; $data['f_order_value'] = $f_order_value; $data['f_shipped_value'] = $f_shipped_value; $data['m_order_value'] = $m_order_value; $data['m_shipped_value'] = $m_shipped_value; $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; foreach ($array as $row) { $deliveryDate = $row['deliveryDate']; $month = date("m",strtotime($deliveryDate)); if($deliveryDate != ''){ $value = $row['indian']; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } //die(); $products[] = array( 'day' => 'Apr', 'sell' => $april ); $products[] = array( 'day' => 'May', 'sell' => $may ); $products[] = array( 'day' => 'Jun', 'sell' => $june ); $products[] = array( 'day' => 'Jul', 'sell' => $july ); $products[] = array( 'day' => 'Aug', 'sell' => $aug ); $products[] = array( 'day' => 'Sep', 'sell' => $sept ); $products[] = array( 'day' => 'Oct', 'sell' => $oct ); $products[] = array( 'day' => 'Nov', 'sell' => $nov ); $products[] = array( 'day' => 'Dec', 'sell' => $dec ); $products[] = array( 'day' => 'Jan', 'sell' => $jan ); $products[] = array( 'day' => 'Feb', 'sell' => $feb ); $products[] = array( 'day' => 'Mar', 'sell' => $march ); $data['products'] = $products; $this->db->select('o.*,sos.planningStatus,co.customerName'); $this->db->from('orders o'); ///$this->db->where('so.orderConfirm', 'Yes'); $this->db->where('o.status',0); //$this->db->where('so.article_type', 'outsource'); $this->db->join('sub_orders so', 'so.orderID = o.id','left'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id','left'); $this->db->join('customer_master co', 'o.fileNo = co.customerID','left'); $this->db->order_by("id", "desc"); $this->db->group_by('o.oslNo'); $this->db->group_by('co.customerName'); if($m != 'all' && $m != ''){ $this->db->like('o.deliveryDate','-'.$m.'-'); } $this->db->where('o.deliveryDate >', $start_year); $this->db->where('o.deliveryDate <', $end_year); $this->db->where('o.confirm_status', 'CONFIRMED'); $this->db->where('sos.planningStatus', 'planned'); $this->db->where('o.orderType','DTL'); $query = $this->db->get(); $result10=$query->result(); //print_r($this->db->last_query()); // die(); $array1 = array(); foreach($result10 as $value) { $array5 = array(); $this->db->select('SUM(sub_orders.totalValue) as value,SUM(sub_orders.totalQuantity) as qnty,SUM(sub_orders.indianValue) as indian'); $this->db->from('sub_orders'); $this->db->where('sub_orders.orderID',$value->id); $query= $this->db->get(); $sumvalues= $query->row(); $array5['customerName'] = $value->customerName; $array5['indian'] = round($sumvalues->indian,2); array_push($array1, $array5); } $a = array(); // echo '<pre>'; // print_r($array1); // echo '</pre>'; // die(); foreach ($array1 as $row) { if(in_array($row['customerName'],$a)){ $index = array_search($row['customerName'],$a); $cust = $a[$index]; $inr_val = $a[$index+1]; $total_c_val = $inr_val + $row['indian']; $a[$index+1] = $total_c_val; } else { array_push($a,$row['customerName'],$row['indian']); } } //print_r($a); // die(); // $a = arsort($a); $i = 0; $tot = 0; for($i = 0; $i <count($a); $i=$i+2){ $customer[] = array( 'day' => $a[$i], 'sell' => $a[$i+1] ); $tot += $a[$i+1]; } $data['customer'] = $customer; $data['year'] = $year; $data['total'] = '10'; //$this->load->view('templates/header_inside',$data); $this->load->view('g_report/summery_report_marketing',$data); //$this->load->view('templates/footer_inside'); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function summery_report_order_date() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; // $RT = substr($uri, strpos($uri, "/") + 12); $RT = substr($uri, strpos($uri, "/") + 12,35); $m = substr($uri, strpos($uri, "/") + 48,4); // echo $RT; // echo '---'; // echo $m; // die(); if($RT == 'g_reports/summery_report_order_date') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { $this->db->select('*'); $this->db->from('select_year'); $this->db->where('id','1'); $query=$this->db->get(); $year_record = $query->result(); $year = ''; foreach ($year_record as $row) { $year = $row->year; } $start_year =''; $end_year = ''; if($year == '24-25'){ $start_year = '2024-04-01'; $end_year = '2025-03-31'; } else if($year == '25-26'){ $start_year = '2025-04-01'; $end_year = '2026-03-31'; } else if($year == '23-24'){ $start_year = '2023-04-01'; $end_year = '2024-03-31'; } else if($year == '17-18'){ $start_year = '2017-04-01'; $end_year = '2018-03-31'; } else if($year == '18-19'){ $start_year = '2018-04-01'; $end_year = '2019-03-31'; } else if($year == '19-20'){ $start_year = '2019-04-01'; $end_year = '2020-03-31'; } else if($year == '20-21'){ $start_year = '2020-04-01'; $end_year = '2021-03-31'; } else if($year == '21-22'){ $start_year = '2021-04-01'; $end_year = '2022-03-31'; } else if($year == '22-23'){ $start_year = '2022-04-01'; $end_year = '2023-03-31'; } $this->db->select('o.*,sos.planned_by,sos.planningStatus,so.totalValue,so.orders_Type,adv.adv_pay_stat'); $this->db->from('orders o'); ///$this->db->where('so.orderConfirm', 'Yes'); $this->db->where('o.status',0); //$this->db->where('so.article_type', 'outsource'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->join('advance_payment_details adv', 'adv.orderid = o.id','left'); $this->db->order_by("id", "desc"); $this->db->group_by('o.oslNo'); if($m != 'all' && $m != ''){ $this->db->like('o.orderDate','-'.$m.'-'); } $this->db->where('o.orderDate >', $start_year); $this->db->where('o.orderDate <', $end_year); $this->db->where('o.confirm_status', 'CONFIRMED'); $this->db->where('sos.planningStatus', 'planned'); $this->db->where('o.orderType','DTL'); $query = $this->db->get(); $result=$query->result(); $array = array(); $f_order_value = 0; $f_shipped_value = 0; $m_order_value = 0; $m_shipped_value = 0; foreach($result as $value) { $data['id'] = $value->id; $data['oslNo'] = $value->oslNo; $data['fileNo'] = $value->fileNo; $data['orderMode'] = $value->orderMode; $data['orderNo'] = $value->orderNo; $data['deliveryDate'] = $value->deliveryDate; $data['orderDate'] = $value->orderDate; $this->db->select('SUM(sub_orders.totalValue) as value,SUM(sub_orders.totalQuantity) as qnty,SUM(sub_orders.indianValue) as indian'); $this->db->from('sub_orders'); $this->db->where('sub_orders.orderID',$value->id); $query= $this->db->get(); $sumvalues= $query->row(); if($value->orders_Type == 'MADEUPS'){ $this->db->select('sum(madeups_invoice_packing.values_es) as total,madeups_list_data.shipping_customs_ex_rate,madeups_list_data.discount,madeups_list_data.total_value,madeups_list_data.currency'); $this->db->from('madeups_invoice_packing'); $this->db->join('madeups_list_data', 'madeups_invoice_packing.invoice = madeups_list_data.invoice'); $this->db->where('madeups_invoice_packing.osl_no', $value->oslNo); $query3=$this->db->get(); $total3=$query3->row(); $total6 = 0; $total6 = ($total3->total_value + $total3->discount); if($total6 == 0){ $data['discount'] = 0; $sh_val = 0; $data['sh_val'] = $sh_val; $data['sh_val_rate'] = 0; } else{ $discount = ($total3->discount/$total6)*100; $discount1 = ((($total3->total * $discount)/100)); $data['discount'] = number_format((float)$discount1, 2, '.', ''); $sh_val = ($total3->total - number_format((float)$discount1, 2, '.', '')); $data['sh_val'] = $sh_val; $data['sh_val_rate'] = $total3->shipping_customs_ex_rate; } $data['currency'] = $total3->currency; $m_order_value += round($sumvalues->indian,2); $m_shipped_value += (($sh_val * $total3->shipping_customs_ex_rate)); //print_r($this->db->last_query()); // die(); } else{ $this->db->select('sum(invoice_packing.values_es) as total,packing_list_data.shipping_customs_ex_rate,packing_list_data.discount,packing_list_data.total_value,packing_list_data.currency'); $this->db->from('invoice_packing'); $this->db->join('packing_list_data', 'invoice_packing.invoice_num = packing_list_data.invoice_num'); $this->db->where('invoice_packing.po_no', $value->oslNo); $query3=$this->db->get(); $total3=$query3->row(); $total6 = 0; $total6 = ($total3->total_value + $total3->discount); if($total6 == 0){ $data['discount'] = 0; $sh_val = 0; $data['sh_val'] = $sh_val; $data['sh_val_rate'] = 0; } else{ $discount = ($total3->discount/$total6)*100; $discount1 = ((($total3->total * $discount)/100)); $data['discount'] = number_format((float)$discount1, 2, '.', ''); $sh_val = ($total3->total - number_format((float)$discount1, 2, '.', '')); $data['sh_val'] = $sh_val; $data['sh_val_rate'] = $total3->shipping_customs_ex_rate; } $data['currency'] = $total3->currency; $f_order_value += round($sumvalues->indian,2); $f_shipped_value += (($sh_val * $total3->shipping_customs_ex_rate)); } $this->db->select('sum(totalValue) as totalValue'); $this->db->from('sub_orders'); $this->db->where('orderID',$value->id); $query=$this->db->get(); $total=$query->row(); $pro=$value->shipped_fun; if($pro==0){ $data['shipped_fun']='Pending'; }else{ $data['shipped_fun']='Completed'; } $data['indian']=round($sumvalues->indian,2); $data['invoice_no']=$value->invoice_no; $data['totalValue'] = ROUND($total->totalValue,2); $data['currency'] = $value->currency; $data['orders_Type']=$value->orders_Type; $data['confirm_status'] = $value->confirm_status; $data['planningStatus'] = $value->planningStatus; $data['adv_pay_stat'] = $value->adv_pay_stat; array_push($array, $data); } $data['res'] = $array; $data['f_order_value'] = $f_order_value; $data['f_shipped_value'] = $f_shipped_value; $data['m_order_value'] = $m_order_value; $data['m_shipped_value'] = $m_shipped_value; $april = 0; $may = 0; $june = 0; $july = 0; $aug = 0; $sept = 0; $oct = 0; $nov = 0; $dec = 0; $jan = 0; $feb = 0; $march = 0; foreach ($array as $row) { $orderDate = $row['orderDate']; $month = date("m",strtotime($orderDate)); if($orderDate != ''){ $value = $row['indian']; if($month == '04'){ $april += $value; } else if($month == '05'){ $may += $value; } else if($month == '06'){ $june += $value; } else if($month == '07'){ $july += $value; } else if($month == '08'){ $aug += $value; } else if($month == '09'){ $sept += $value; } else if($month == '10'){ $oct += $value; } else if($month == '11'){ $nov += $value; } else if($month == '12'){ $dec += $value; } else if($month == '01'){ $jan += $value; } else if($month == '02'){ $feb += $value; } else if($month == '03'){ $march += $value; } } } //die(); $products[] = array( 'day' => 'Apr', 'sell' => $april ); $products[] = array( 'day' => 'May', 'sell' => $may ); $products[] = array( 'day' => 'Jun', 'sell' => $june ); $products[] = array( 'day' => 'Jul', 'sell' => $july ); $products[] = array( 'day' => 'Aug', 'sell' => $aug ); $products[] = array( 'day' => 'Sep', 'sell' => $sept ); $products[] = array( 'day' => 'Oct', 'sell' => $oct ); $products[] = array( 'day' => 'Nov', 'sell' => $nov ); $products[] = array( 'day' => 'Dec', 'sell' => $dec ); $products[] = array( 'day' => 'Jan', 'sell' => $jan ); $products[] = array( 'day' => 'Feb', 'sell' => $feb ); $products[] = array( 'day' => 'Mar', 'sell' => $march ); $data['products'] = $products; $this->db->select('o.*,sos.planningStatus,co.customerName'); $this->db->from('orders o'); ///$this->db->where('so.orderConfirm', 'Yes'); $this->db->where('o.status',0); //$this->db->where('so.article_type', 'outsource'); $this->db->join('sub_orders so', 'so.orderID = o.id','left'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id','left'); $this->db->join('customer_master co', 'o.fileNo = co.customerID','left'); $this->db->order_by("id", "desc"); $this->db->group_by('o.oslNo'); $this->db->group_by('co.customerName'); if($m != 'all' && $m != ''){ $this->db->like('o.orderDate','-'.$m.'-'); } $this->db->where('o.orderDate >', $start_year); $this->db->where('o.orderDate <', $end_year); $this->db->where('o.confirm_status', 'CONFIRMED'); $this->db->where('sos.planningStatus', 'planned'); $this->db->where('o.orderType','DTL'); $query = $this->db->get(); $result10=$query->result(); //print_r($this->db->last_query()); // die(); $array1 = array(); foreach($result10 as $value) { $array5 = array(); $this->db->select('SUM(sub_orders.totalValue) as value,SUM(sub_orders.totalQuantity) as qnty,SUM(sub_orders.indianValue) as indian'); $this->db->from('sub_orders'); $this->db->where('sub_orders.orderID',$value->id); $query= $this->db->get(); $sumvalues= $query->row(); $array5['customerName'] = $value->customerName; $array5['indian'] = round($sumvalues->indian,2); array_push($array1, $array5); } $a = array(); // echo '<pre>'; // print_r($array1); // echo '</pre>'; // die(); foreach ($array1 as $row) { if(in_array($row['customerName'],$a)){ $index = array_search($row['customerName'],$a); $cust = $a[$index]; $inr_val = $a[$index+1]; $total_c_val = $inr_val + $row['indian']; $a[$index+1] = $total_c_val; } else { array_push($a,$row['customerName'],$row['indian']); } } //print_r($a); // die(); // $a = arsort($a); $i = 0; $tot = 0; for($i = 0; $i <count($a); $i=$i+2){ $customer[] = array( 'day' => $a[$i], 'sell' => $a[$i+1] ); $tot += $a[$i+1]; } $data['customer'] = $customer; $data['year'] = $year; $data['total'] = '10'; //$this->load->view('templates/header_inside',$data); $this->load->view('g_report/summery_order_date',$data); //$this->load->view('templates/footer_inside'); } else{ $this->session->sess_destroy(); redirect(base_url()); } } public function po_reports() { $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='employee_details'; $where=array('id'=>$emp_row); $data['emp_details']=$this->vendor_model->get_customerdata($table,$where); $uri = $_SERVER["REQUEST_URI"]; $RT = substr($uri, strpos($uri, "/") + 12); if($RT == 'g_reports/po_reports') { $data['url_val']='1'; $data['val']='g_reports'; $data['ref']='indent'; } $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; //<!----add from-------------> $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $approved_id=$id['userid']; $table='employee_details'; $where=array('id'=>$approved_id); $dept_id_row=$this->vendor_model->get_where_row($table,$where); $user_type_id_row=$dept_id_row->user_type_id; //----------tiill-------------------- $data['userdetails'] = $this->session_data_pass(); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $check=""; foreach($m_id as $menu_id) { $table='swansilk_menu'; $where=array('delete_status'=>'ACTIVE','menu_id'=>$menu_id); $result= $this->marketing_model->fetch_main_data($table,$where); if(!empty($result->reference_url)){ if($result->reference_url == $data['val']) { $check=$data['val']; } } } if($check != "") { $this->db->select('*'); $this->db->from('select_year'); $this->db->where('id','1'); $query=$this->db->get(); $year_record = $query->result(); $year = ''; foreach ($year_record as $row) { $year = $row->year; } $year = str_replace("-","/",$year); $this->db->select('product_type'); $this->db->from('indent_po'); $this->db->where('financ_year',$year); $this->db->where('product_type !=',''); $this->db->where('confirm','Yes'); $this->db->group_by('product_type'); $query1 = $this->db->get(); $product_type = $query1->result(); $this->db->select('currency'); $this->db->from('indent_po'); $this->db->where('financ_year',$year); $this->db->where('product_type !=',''); $this->db->where('confirm','Yes'); $this->db->group_by('currency'); $query2 = $this->db->get(); $currency = $query2->result(); $data['currency'] = $currency; $data['product_type'] = $product_type; $this->db->select('sum(totalvalue) as sum,product_type,currency'); $this->db->from('indent_po'); $this->db->where('financ_year',$year); $this->db->where('product_type !=',''); $this->db->where('confirm','Yes'); $this->db->group_by('product_type'); $this->db->group_by('currency'); $query=$this->db->get(); $p_record = $query->result(); //print_r($this->db->last_query()); //die(); $p_array = array(); foreach ($p_record as $row) { $p_array[$row->product_type][$row->currency] = $row->sum; } $data['p_array'] = $p_array; // echo '<pre>'; // print_r($p_array); // echo '</pre>'; //die(); $data['p_record'] = $p_record; $data['year'] = $year; $data['total'] = '10'; //$this->load->view('templates/header_inside',$data); $this->load->view('g_report/po_report',$data); //$this->load->view('templates/footer_inside'); } else{ $this->session->sess_destroy(); redirect(base_url()); } } }