EVOLUTION-NINJA
Edit File: Packing_list_billing.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Packing_list_billing extends CI_Controller { public function __construct() { parent::__construct(); ini_set('max_execution_time', 30000); $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('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_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 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 madeups_generate_weight_note_new() { if (date('m') <= 3) { $financial_year = (date('y')-1) . '-' . date('y'); } else { $financial_year = date('y') . '-' . (date('y') + 1); } $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"]; $val = substr($uri, strpos($uri, "=") + 1); $data=array('invoice_description'=>''); $table='madeups_packing_new'; $where=array('invoice_description !='=>''); $this->vendor_model->update_data($where,$table,$data); $table='madeups_list_data_new'; $where=array('id'=>$val); $data['fetch']=$this->vendor_model->get_customerdata($table,$where); $data1=$data['fetch']->invoice; $financ_year=$data['fetch']->financ_year; $where1=array('invoice'=>$data1,'financ_year'=>$financ_year); $table1='madeups_packing_new'; $data_inv_dess_pack_des=$this->vendor_model->list_invoice_sum_of_mktrs1($table1,$where1); foreach($data_inv_dess_pack_des as $d) { $table='madeups_packing_new'; $where=array('id'=>$d->id); $in_dess=$this->vendor_model->fetch_where_subgrid_data($table,$where); $table='madeups_invoice_packing_new'; $where=array('invoice'=>$in_dess->invoice,'buyershade'=>$in_dess->shades,'design'=>$in_dess->design,'width'=>$in_dess->size,'article'=>$in_dess->article); $data=array('pack_des_id'=>$d->id); $this->vendor_model->update_data($where,$table,$data); $table='madeups_invoice_packing_new'; $where=array('pack_des_id'=>$d->id); $in=$this->vendor_model->fetch_where_subgrid_data($table,$where); $table='madeups_invoice_packing_new'; $where=array('invoice'=>$in_dess->invoice,'buyershade'=>$in_dess->shades,'design'=>$in_dess->design,'width'=>$in_dess->size,'article'=>$in_dess->article); $data=array('pack_des_id'=>$d->id); $this->vendor_model->update_data($where,$table,$data); $table='madeups_invoice_packing_new'; $where=array('pack_des_id'=>$d->id); $in=$this->vendor_model->fetch_where_subgrid_data($table,$where); //print_r($this->db->last_query()); if(empty($in)) { } else { if($in->description == '') { $table='madeups_packing_new'; $where=array('id'=>$d->id); $in_des=$this->vendor_model->fetch_where_subgrid_data($table,$where); $data=array('invoice_description'=>$in_des->description); $table='madeups_packing_new'; $where=array('id'=>$d->id); $this->vendor_model->update_data($where,$table,$data); } else { $data=array('invoice_description'=>$in->description); $table='madeups_packing_new'; $where=array('id'=>$d->id); $this->vendor_model->update_data($where,$table,$data); } } } $where=array('id'=>$val); $table='madeups_list_data_new'; $data['fetchh']=$this->vendor_model->get_customerdata($table,$where); $table='madeups_list_data_new'; $where=array('id'=>$val); $data['fetch']=$this->vendor_model->get_customerdata($table,$where); $data1=$data['fetch']->invoice; $osl_number=$data['fetch']->osl_no; $data['osl']=$this->vendor_model->get_contract_type_customerdata($osl_number); $where = array('invoice'=>$data1,'status'=>'0','financ_year'=>$financ_year); $table='madeups_invoice_packing_new'; $data['fetch_invoice']=$this->vendor_model->get_where_dataa($table,$where); $data_fetch_invoice=$this->vendor_model->get_where_dataa($table,$where); $mark=array(); foreach($data_fetch_invoice as $f) { $design=$f->design; $width=$f->width; $shade=$f->buyershade; $article=$f->article; $po_no=$f->osl_no; $buyershade=$f->buyershade; $d_fetch=$this->vendor_model->order_sub_order_data($design,$width,$shade,$article,$po_no,$buyershade); array_push($mark,$d_fetch); } $data['marketing']=$mark; $where = array('invoice'=>$data1,'status'=>'0','financ_year'=>$financ_year); $table='madeups_invoice_packing_new'; $data['fetch_sum_pcs_invoice']=$this->vendor_model->sum_get_customerdata($table,$where); $where = array('invoice'=>$data1,'status'=>'0','financ_year'=>$financ_year); $table='madeups_invoice_packing_new'; $data['fetch_invoice_cureency']=$this->vendor_model->get_customerdata($table,$where); $where1 = array('invoice'=>$data1,'status'=>'0','financ_year'=>$financ_year); $table1='madeups_invoice_packing_new'; $data['fetch_sum_amt_invoice']=$this->vendor_model->sum_amount_get_customerdata($table,$where); $where1=array('invoice'=>$data1,'financ_year'=>$financ_year); $table1='madeups_box_packing_new'; $data['fetch_count_amt_invoice']=$this->vendor_model->count_amount_get_customerdata($table,$where); $where1=array('invoice'=>$data1,'financ_year'=>$financ_year); $table1='madeups_box_packing_new'; $data['fetch_sum_gross_net_invoice1']=$this->vendor_model->sum_get_fetch_sum_gross_invoice($table1,$where1); $where1=array('invoice'=>$data1,'financ_year'=>$financ_year); $table1='madeups_box_packing_new'; $data['fetch_sum_gross_net_invoice2']=$this->vendor_model->sum_get_fetch_sum_net_invoice($table1,$where1); $where=array('id'=>$val); $table='madeups_list_data_new'; $data['customer_number']=$this->vendor_model->get_customerdata($table,$where); $where1=array('invoice'=>$data1,'financ_year'=>$financ_year); $table1='madeups_packing_new'; $data['sku_number']=$this->vendor_model->get_customerdata($table1,$where1); $data['user_type_id'] = $this->access_id(); $data['total_indent_notifications'] = 0; // $this->indent_page_notifications();notifications']; $data['access'] = $this->access_details(); $data['userdetails'] = $this->session_data_pass(); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='box_packing'; $data['box_fetch_invoice']=$this->vendor_model->get_where_dataa($table,$where); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['package_fetch_invoice1']=$this->vendor_model->get_where_dataa($table,$where); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['package_fetch_invoice2']=$this->vendor_model->get_where_dataa($table,$where); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['package_fetch_invoice3']=$this->vendor_model->get_where_dataa($table,$where); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['package_fetch_invoice4']=$this->vendor_model->get_where_dataa($table,$where); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['package_fetch_invoice5']=$this->vendor_model->get_where_dataa($table,$where); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['package_fetch_invoice6']=$this->vendor_model->get_where_dataa($table,$where); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['package_fetch_invoice7']=$this->vendor_model->sum_of_mktrs($table,$where); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['package_fetch_invoice8']=$this->vendor_model->sum_of_mktrs1($table,$where); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['group_package_fetch_invoice']=$this->vendor_model->marketing_box_master_confirm_get_details_new($data1); $data['dist_order_no'] = $this->vendor_model->get_distict_where_data($table,$where); $data['dist_osl_no'] = $this->vendor_model->get_distict_dtl_where_data($table,$where); $data['group_package_ttl_gross']=$this->vendor_model->marketing_toatl_box_master_confirm_get_details_new($data1); $data_group_package_fetch_invoice=$this->vendor_model->group_get_where_dataa($table,$where); $boxes=array(); foreach($data_group_package_fetch_invoice as $d) { $where=array('unique_no'=>$d->box_id); $table='madeups_box_master'; $data_box=$this->vendor_model->issue_fabric_exported_stock($table,$where); if(empty($data_box)) { array_push($boxes,''); } else { array_push($boxes,$data_box); } } $data['box']=$boxes; $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['count_package_fetch_invoice']=$this->vendor_model->count_of_mktrs1($table,$where); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['count_package_fetch_invoice1']=$this->vendor_model->count_of_pcs($table,$where); $where=array('invoice'=>$data1,'box_dimension !='=>'','financ_year'=>$financ_year); $table='madeups_box_packing_new'; $data['box_summary']=$this->vendor_model->marketing_toatl_box_master_summary_confirm_get_details_new($data1); $data_box_summaryy=$this->vendor_model->marketing_toatl_box_master_summary_confirm_get_details_new($data1); $data_box_summary=$this->vendor_model->get_box_data_sl_fetch($table,$where); $boxess=array(); foreach($data_box_summaryy as $b) { // $where=array('box_dimension'=>$b->box_dimension,'invoice'=>$data1,'financ_year'=>$financ_year); $where=array('box_dimension'=>$b->box_dimension,'invoice'=>$data1); $table='madeups_box_packing_new'; $data_box=$this->vendor_model->count_amount_get_customerdata($table,$where); array_push($boxess,$data_box); } $data['box_s']=$boxess; $data_box_s=$boxess; $box=array(); $t=0; foreach($data_box_summaryy as $key=>$s) { $v=0; $v=$data_box_s[$key] * $s->total_cmb; $t = $t + $v; //array_push($box,$v); } $data['total_cbms']=$t; $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['package_fetch_invoice9']=$this->vendor_model->sum_of_mktrs_exp_qty($table,$where); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['package_fetch_invoice10']=$this->vendor_model->sum_of_mktrs_exp_wt($table,$where); $data['package_fetch_generte_invoice']=$this->vendor_model->max_select_generate_invoice_no(); $where=array('id'=>$val); $table='madeups_list_data_new'; $data['fetchh']=$this->vendor_model->get_customerdata($table,$where); // print_r($data['count_package_fetch_invoice']); //die(); $data['access'] = $this->access_details(); $data['userdetails'] = $this->session_data_pass(); $data['indent_p']='indent_preview'; $data['val']='packing_list/madeups_list_data_new?prop_id=1'; $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; $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']; } } } $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $data1=array(); foreach($m_id as $menu_id) { $table='access_action_rights'; $where=array('menu_id'=>$menu_id,'department_id'=>$user_type_id_row); $arr=$this->vendor_model->get_where_row($table,$where); if(empty($arr)) { } else { //print_r($arr); $menu_id=$arr->menu_id; $table='swansilk_menu'; $where=array('menu_id'=>$menu_id); $url=$this->vendor_model->get_where_row($table,$where); if(!empty($url->reference_url)){ if($url->reference_url == $data['val']) { $data['access_row']=$arr; } } } } $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); $table='employee_details'; $data['user_list']=$this->vendor_model->fetch_where_data($table); $id=$this->session->userdata('logged_in'); $where=array('id'=>$id); $data['approved_by']=$id['username']; $emp_row=$id['userid']; $table='chat_message'; $where=array('unread'=>'0','to_id'=>$emp_row); $data['chatting_count']=$this->vendor_model->count_amount_work_order_delivery_yarn_po_get_customerdata($table,$where); $data['indent_p']='indent_preview'; // $this->load->view('templates/header_inside',$data); $this->load->view('packing_list/madeups_list_weight_note',$data); //$this->load->view('templates/footer_inside'); /// } public function madeups_buyer_generate_invoice_new() { if (date('m') <= 3) { $financial_year = (date('y')-1) . '-' . date('y'); } else { $financial_year = date('y') . '-' . (date('y') + 1); } $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"]; $val = substr($uri, strpos($uri, "=") + 1); $where=array('id'=>$val); $table='madeups_list_data_new'; $data['fetchh']=$this->vendor_model->get_customerdata($table,$where); $data1=$data['fetchh']->invoice; $financ_year=$data['fetchh']->financ_year; $where = array('invoice'=>$data1,'status'=>'0','financ_year'=>$financ_year); $table = 'madeups_invoice_packing_new'; $total_dis_pkg_data = $this->outsource_model->invoice_sum_fetch_where_quantity_total($table,$where); $rr=$total_dis_pkg_data ->values_es; $table='madeups_list_data_new'; $where=array('id'=>$val); $data['fetch']=$this->vendor_model->get_customerdata($table,$where); $data1=$data['fetch']->invoice; $osl_number=$data['fetch']->osl_no; $data['osl']=$this->vendor_model->get_contract_type_customerdata($osl_number); $where=array('invoice'=>$data1,'status'=>'0','financ_year'=>$financ_year); $table='madeups_invoice_packing_new'; $data['fetch_invoice']=$this->vendor_model->get_where_dataa($table,$where); $data_fetch_invoice=$this->vendor_model->get_where_dataa($table,$where); // print_r($data_fetch_invoice); // die(); $data_fetch_invoice1=$this->vendor_model->get_where_dataa($table,$where); $mark1=array(); foreach($data_fetch_invoice as $f) { $where=array('oslNo'=>$f->osl_no); $table='orders'; $data_order_no=$this->vendor_model->get_where_row($table,$where); if(empty($data_order_no)) { array_push($mark1,''); } else { array_push($mark1,$data_order_no); } } $data['oder_numbers']=$mark1; $mark=array(); foreach($data_fetch_invoice as $f) { $design=$f->design; $width=$f->width; $shade=$f->buyershade; $article=$f->article; $po_no=$f->osl_no; $buyershade=$f->buyershade; $d_fetch=$this->vendor_model->order_sub_order_data($design,$width,$shade,$article,$po_no,$buyershade); array_push($mark,$d_fetch); } $data['marketing']=$mark; if(empty($mark)) { $data['units_val']='MTRs'; } else { foreach($mark as $m) { if(empty($m)) { $u='MTRs'; } else { $u=$m->unit; } } if($u == '') { $data['units_val']='MTRs'; } else { $data['units_val']=$u; } } $where=array('invoice'=>$data1); $table='madeups_invoice_packing_new'; $data['fetch_sum_pcs_invoice']=$this->vendor_model->sum_get_qty_customerdata($table,$where); $where=array('invoice'=>$data1); $table='madeups_invoice_packing_new'; $data['fetch_invoice_cureency']=$this->vendor_model->get_customerdata($table,$where); $where1=array('invoice'=>$data1); $table1='madeups_invoice_packing_new'; $data['fetch_sum_amt_invoice']=$this->vendor_model->sum_amount_get_customerdata($table,$where); /////////////////////////////// $where1=array('invoice'=>$data1); $table1='madeups_box_packing_new'; $data['fetch_count_amt_invoice']=$this->vendor_model->count_amount_get_customerdata($table,$where); $where1=array('pack_id'=>$val); $table1='madeups_box_packing_new'; $data['fetch_sum_gross_net_invoice1']=$this->vendor_model->sum_get_fetch_sum_gross_invoice($table1,$where1); /*$where1=array('pack_id'=>$val); $table1='madeups_box_packing_new'; $data['fetch_sum_gross_net_invoice2']=$this->vendor_model->sum_get_fetch_sum_net_invoice($table1,$where1);*/ $where=array('madeups_id'=>$val); $table='madeups_packing_new'; $data['fetch_sum_gross_net_invoice2']=$this->vendor_model->sum_of_mktrs_exp_wt($table,$where); $data1=$data['fetchh']->invoice; $where = array('invoice'=>$data1,'status'=>'0','financ_year'=>$financ_year); $table = 'madeups_invoice_packing_new'; $data['contarct_type'] = $this->outsource_model->get_customerdata($table,$where); $where=array('id'=>$val); $table='madeups_list_data_new'; $data['customer_number']=$this->vendor_model->get_customerdata($table,$where); $data1=$data['fetchh']->invoice; $where = array('invoice'=>$data1,'status'=>'0','financ_year'=>$financ_year); $table = 'madeups_invoice_packing_new'; $data['contract_type'] = $this->outsource_model->get_customerdata($table,$where); $where=array('invoice'=>$data1,'financ_year'=>$financ_year); $table='madeups_packing_new'; $data['count_package_fetch_invoice']=$this->vendor_model->count_of_mktrs1($table,$where); $where1=array('madeups_id'=>$val); $table1='madeups_packing_new'; $data['sku_number']=$this->vendor_model->get_modal_g_madeups_sku_customerdata($table1,$where1); /* print_r($data['sku_number']); die();*/ $data['access'] = $this->access_details(); $data['userdetails'] = $this->session_data_pass(); $data['indent_p']='indent_preview'; $data['val']='packing_list/madeups_list_data?prop_id=1'; $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; $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']; } } } $access_menu_id=$this->access_details_id(); $m_id=unserialize($access_menu_id->menu_id); $data1=array(); foreach($m_id as $menu_id) { $table='access_action_rights'; $where=array('menu_id'=>$menu_id,'department_id'=>$user_type_id_row); $arr=$this->vendor_model->get_where_row($table,$where); if(empty($arr)) { } else { //print_r($arr); $menu_id=$arr->menu_id; $table='swansilk_menu'; $where=array('menu_id'=>$menu_id); $url=$this->vendor_model->get_where_row($table,$where); if(!empty($url->reference_url)){ if($url->reference_url == $data['val']) { $data['access_row']=$arr; } } } } $table='countries'; $data['countries']=$this->vendor_model->get_data_customer($table); // $where1=array('pack_id'=>$val); // $table1='madeups_packing_new'; // $data['sku_number']=$this->vendor_model->get_customerdata($table1,$where1); $data['indent_p']='indent_preview'; $this->load->view('packing_list/madeups_buyer_invoice_generate',$data); //print_r($data['customer_number']); //die(); } public function get_new_invoice() { $val = $this->input->post('as'); $this->marketing_model->update_data($where,$table,$data); } public function move_new_invoice() { $val = $this->input->post('as'); $table = 'madeups_list_data_new'; $where = array('id'=>$val); $dept = $this->vendor_model->get_where_row($table,$where); $invoice = $dept->invoice; if(date('m') <= 3) { $financial_year = (date('y')-1) . '-' . date('y'); } else { $financial_year = date('y') . '-' . (date('y') + 1); } $max_invoice = $this->marketing_model->fetch_max_invoice_billing(); $invoice_new = $max_invoice->invoice_num + 1; $inv = "DT/".$invoice_new."/".$financial_year; $id=$this->session->userdata('logged_in'); $approved_by=$id['username']; $created_At=date('d/m/Y'); $return_id = 0; $where=array('invoice'=>$invoice); $table='madeups_list_data_new'; $details = $this->marketing_model->fetch_where_data($table,$where); foreach($details as $p) { if($return_id == 0){ $table = 'customer_master'; $where = array('customerID'=>$p->customer_name); $customer = $this->vendor_model->get_where_row($table,$where); $data=array( 'invoice_num' =>$invoice_new, 'invoice' => $inv, 'sys_date' => date('d-m-Y'), 'customer_name' => $customer->customerName, 'order_date' => date('d-m-Y'), 'invoice_date' => date('d-m-Y'), 'created_by'=>$approved_by, 'created_at'=>$created_At, 'financ_year'=>$financial_year, 'units_pcs'=>$p->units_pcs, 'generate_invoice_num'=>$p->generate_invoice_num, ); $table='madeups_list_data'; $this->db->insert($table,$data); $return_id = $this->db->insert_id(); } } $where=array('invoice'=>$invoice); $table='madeups_packing_new'; $details1 = $this->marketing_model->fetch_where_data($table,$where); foreach($details1 as $p1) { $data=array('madeups_id'=>$return_id, 'invoice'=>$inv, 'invoice_num'=>$invoice_new, 'ref_id'=>$p1->ref_id, 'osl_no'=>$p1->osl_no, 'orderNo'=>$p1->orderNo, 'shades'=>$p1->shades, 'ssl_shade'=>$p1->ssl_shade, 'design'=>$p1->design, 'batch_no'=>$p1->batch_no, 'size'=>$p1->size, 'financ_year'=>$p1->financ_year, 'article'=>$p1->article, 'received_qty'=>$p1->received_qty, 'exp_qty'=>$p1->exp_qty, 'exp_wt'=>$p1->exp_wt, 'bal_qty'=>$p1->bal_qty, 'order_type'=>$p1->order_type, 'skuno'=>$p1->skuno, 'box_id'=>$p1->box_id, 'description'=>$p1->description, 'unit_price' =>$p1->unit_price ); $table='madeups_packing'; $id = $this->db->insert($table,$data); } $where=array('invoice'=>$invoice); $table='madeups_box_packing_new'; $details2 = $this->marketing_model->fetch_where_data($table,$where); foreach($details2 as $p2) { $data=array('pack_id'=>$return_id, 'financ_year'=>$financial_year, 'invoice'=>$inv, 'box_id'=>$p2->box_id, 'total_pcs'=>$p2->total_pcs, 'net_wt'=>$p2->net_wt, 'gross_wt'=>$p2->gross_wt, 'tare_wt'=>($p2->net_wt - $p2->gross_wt), 'box_dimension'=>$p2->box_dimension, ); $table='madeups_box_packing'; $this->db->insert($table,$data); } $where=array('invoice'=>$invoice); $table='madeups_invoice_packing_new'; $details3 = $this->marketing_model->fetch_where_data($table,$where); foreach($details3 as $val) { $data=array('pack_id'=>$return_id, 'invoice'=>$inv, 'invoice_num'=>$invoice_new, 'osl_no'=>$val->osl_no, 'article'=>$val->article, 'width'=>$val->width, 'design'=>$val->design, 'batch_no'=>$val->batch_no, 'ssl_shades'=>$val->ssl_shades, 'buyershade'=>$val->buyershade, 'stock_qty'=>$val->stock_qty, 'stock_wt'=>$val->stock_wt, 'financ_year'=>$val->financ_year, 'unitprice'=>$val->unitprice, 'ordertype'=>$val->ordertype, 'values_es'=>($val->stock_qty*$val->unitprice), 'description'=>$val->description, 'currency'=>'USD', 'contarct_type'=>'FAQ', ); $table1 = 'madeups_invoice_packing'; $this->db->insert($table1,$data); } print_r($details); } public function add_invoice_preview_buyer_data() { $invoic_no=$this->input->post('invoice_numbers'); $data=array('exporter_ref_preview' =>$this->input->post('exp_ref'), 'other_reference_preview'=>$this->input->post('other_ref'), 'consignee'=>$this->input->post('consignee'), 'buyer_consignee_preview'=>$this->input->post('buyer_consignee'), 'pre_carriage'=>$this->input->post('pre_carriage'), 'country' =>$this->input->post('country'), 'receipt_carriage' =>$this->input->post('receipt'), 'vehicle_flight'=>$this->input->post('Vehicle'), 'port_loading'=>$this->input->post('Port'), 'delivery_payment_preview'=>$this->input->post('payment'), 'port_discharge'=>$this->input->post('discharge'), 'buyer_card_board'=>$this->input->post('card_board_select'), 'final_destination' =>$this->input->post('destination'), 'buyer_card_board_box'=>$this->input->post('card_board_box'), 'sq_mtrs'=>$this->input->post('sq_mtrs'), 'buyer_net_wt_val'=>$this->input->post('net_wt'), 'order_numbner_date'=>$this->input->post('order_myInput1'), 'submitted'=>1 ); $where=array('invoice_num'=>$invoic_no); $table='madeups_list_data_new'; $this->marketing_model->update_data($where,$table,$data); } }