ok
Direktori : /home2/selectio/www/mm-tailor-billing/app/controllers/ |
Current File : /home2/selectio/www/mm-tailor-billing/app/controllers/Sales-Copy-1.php |
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } class Sales extends MY_Controller { public function __construct() { parent::__construct(); if (!$this->loggedIn) { redirect('login'); } if (!$this->session->userdata('store_id')) { $this->session->set_flashdata('warning', lang('please_select_store')); redirect('stores'); } $this->load->library('form_validation'); $this->load->model('sales_model'); $this->digital_file_types = 'zip|pdf|doc|docx|xls|xlsx|jpg|png|gif'; } public function add_payment($id = null, $cid = null) { $this->load->helper('security'); if ($this->input->get('id')) { $id = $this->input->get('id'); } $this->form_validation->set_rules('amount-paid', lang('amount'), 'required'); $this->form_validation->set_rules('paid_by', lang('paid_by'), 'required'); $this->form_validation->set_rules('userfile', lang('attachment'), 'xss_clean'); if ($this->form_validation->run() == true) { if ($this->Admin) { $date = $this->input->post('date'); } else { $date = date('Y-m-d H:i:s'); } $payment = [ 'date' => $date, 'sale_id' => $id, 'customer_id' => $cid, 'reference' => $this->input->post('reference'), 'amount' => $this->input->post('amount-paid'), 'paid_by' => $this->input->post('paid_by'), 'cheque_no' => $this->input->post('cheque_no'), 'gc_no' => $this->input->post('gift_card_no'), 'cc_no' => $this->input->post('pcc_no'), 'cc_holder' => $this->input->post('pcc_holder'), 'cc_month' => $this->input->post('pcc_month'), 'cc_year' => $this->input->post('pcc_year'), 'cc_type' => $this->input->post('pcc_type'), 'note' => $this->input->post('note'), 'created_by' => $this->session->userdata('user_id'), 'store_id' => $this->session->userdata('store_id'), ]; $status = $this->input->post('paid'); if ($_FILES['userfile']['size'] > 0) { $this->load->library('upload'); $config['upload_path'] = 'files/'; $config['allowed_types'] = $this->digital_file_types; $config['max_size'] = 2048; $config['overwrite'] = false; $config['encrypt_name'] = true; $this->upload->initialize($config); if (!$this->upload->do_upload()) { $error = $this->upload->display_errors(); $this->session->set_flashdata('error', $error); redirect($_SERVER['HTTP_REFERER']); } $photo = $this->upload->file_name; $payment['attachment'] = $photo; } // $this->tec->print_arrays($payment); } elseif ($this->input->post('add_payment')) { $this->session->set_flashdata('error', validation_errors()); $this->tec->dd(); } if ($this->form_validation->run() == true && $this->sales_model->addPayment($payment)) { $this->sales_model->addPaymentStatus($status,$id); $this->session->set_flashdata('message', lang('payment_added')); redirect($_SERVER['HTTP_REFERER']); } else { $this->data['error'] = (validation_errors() ? validation_errors() : $this->session->flashdata('error')); $sale = $this->sales_model->getSaleByID($id); $this->data['inv'] = $sale; $this->load->view($this->theme . 'sales/add_payment', $this->data); } } public function delete($id = null) { if (DEMO) { $this->session->set_flashdata('error', lang('disabled_in_demo')); redirect($_SERVER['HTTP_REFERER'] ?? 'welcome'); } if ($this->input->get('id')) { $id = $this->input->get('id'); } if (!$this->Admin) { $this->session->set_flashdata('error', lang('access_denied')); redirect('sales'); } if ($this->sales_model->deleteInvoice($id)) { $this->session->set_flashdata('message', lang('invoice_deleted')); redirect('sales'); } } public function delete_holded($id = null) { if ($this->input->get('id')) { $id = $this->input->get('id'); } if (!$this->Admin) { $this->session->set_flashdata('error', lang('access_denied')); redirect('sales/opened'); } if ($this->sales_model->deleteOpenedSale($id)) { $this->session->set_flashdata('message', lang('opened_bill_deleted')); redirect('sales/opened'); } } public function delete_payment($id = null) { if ($this->input->get('id')) { $id = $this->input->get('id'); } if (!$this->Admin) { $this->session->set_flashdata('error', lang('access_denied')); redirect($_SERVER['HTTP_REFERER']); } if ($this->sales_model->deletePayment($id)) { $this->session->set_flashdata('message', lang('payment_deleted')); redirect('sales'); } } // New Function Starst Here function customerInfo() { $customer_id = $this->input->get('sale_id'); $customer_details = $this->sales_model->getSaleByCusID($customer_id); echo json_encode($customer_details); } function saleItemsInfo() { $sales_id = $this->input->get('sale_id'); $sale_items_details = $this->sales_model->getSaleIemsBySaleID($sales_id); echo json_encode($sale_items_details); } // New Function Ends Here public function edit_payment($id = null, $sid = null) { if (!$this->Admin) { $this->session->set_flashdata('error', lang('access_denied')); redirect($_SERVER['HTTP_REFERER']); } $this->load->helper('security'); if ($this->input->get('id')) { $id = $this->input->get('id'); } $this->form_validation->set_rules('amount-paid', lang('amount'), 'required'); $this->form_validation->set_rules('paid_by', lang('paid_by'), 'required'); $this->form_validation->set_rules('userfile', lang('attachment'), 'xss_clean'); if ($this->form_validation->run() == true) { $payment = [ 'sale_id' => $sid, 'reference' => $this->input->post('reference'), 'amount' => $this->input->post('amount-paid'), 'paid_by' => $this->input->post('paid_by'), 'cheque_no' => $this->input->post('cheque_no'), 'gc_no' => $this->input->post('gift_card_no'), 'cc_no' => $this->input->post('pcc_no'), 'cc_holder' => $this->input->post('pcc_holder'), 'cc_month' => $this->input->post('pcc_month'), 'cc_year' => $this->input->post('pcc_year'), 'cc_type' => $this->input->post('pcc_type'), 'note' => $this->input->post('note'), 'updated_by' => $this->session->userdata('user_id'), 'updated_at' => date('Y-m-d H:i:s'), ]; if ($this->Admin) { $payment['date'] = $this->input->post('date'); } if ($_FILES['userfile']['size'] > 0) { $this->load->library('upload'); $config['upload_path'] = 'files/'; $config['allowed_types'] = $this->digital_file_types; $config['max_size'] = 2048; $config['overwrite'] = false; $config['encrypt_name'] = true; $this->upload->initialize($config); if (!$this->upload->do_upload()) { $error = $this->upload->display_errors(); $this->session->set_flashdata('error', $error); redirect($_SERVER['HTTP_REFERER']); } $photo = $this->upload->file_name; $payment['attachment'] = $photo; } //$this->tec->print_arrays($payment); } elseif ($this->input->post('edit_payment')) { $this->session->set_flashdata('error', validation_errors()); $this->tec->dd(); } if ($this->form_validation->run() == true && $this->sales_model->updatePayment($id, $payment)) { $this->session->set_flashdata('message', lang('payment_updated')); redirect('sales'); } else { $this->data['error'] = (validation_errors() ? validation_errors() : $this->session->flashdata('error')); $payment = $this->sales_model->getPaymentByID($id); if ($payment->paid_by != 'cash') { $this->session->set_flashdata('error', lang('only_cash_can_be_edited')); $this->tec->dd(); } $this->data['payment'] = $payment; $this->load->view($this->theme . 'sales/edit_payment', $this->data); } } public function get_opened_list() { $this->load->library('datatables'); if ($this->db->dbdriver == 'sqlite3') { $this->datatables->select("id, date, customer_name, hold_ref, (total_items || ' (' || total_quantity || ')') as items, grand_total", false); } else { $this->datatables->select("id, date, customer_name, hold_ref, CONCAT(total_items, ' (', total_quantity, ')') as items, grand_total", false); } $this->datatables->from('suspended_sales'); if (!$this->Admin) { $user_id = $this->session->userdata('user_id'); $this->datatables->where('created_by', $user_id); } $this->datatables->where('store_id', $this->session->userdata('store_id')); $this->datatables->add_column( 'Actions', "<div class='text-center'><div class='btn-group'><a href='" . site_url('pos/?hold=$1') . "' title='" . lang('click_to_add') . "' class='tip btn btn-info btn-xs'><i class='fa fa-th-large'></i></a> <a href='" . site_url('sales/delete_holded/$1') . "' onClick=\"return confirm('" . lang('alert_x_holded') . "')\" title='" . lang('delete_sale') . "' class='tip btn btn-danger btn-xs'><i class='fa fa-trash-o'></i></a></div></div>", 'id' ) ->unset_column('id'); echo $this->datatables->generate(); } public function get_sales() { $customer = $this->input->get('customer') ? $this->input->get('customer') : NULL; $start_date = $this->input->get('start_date') ? $this->input->get('start_date') : NULL; $end_date = $this->input->get('end_date') ? $this->input->get('end_date') : NULL; $user = $this->input->get('user') ? $this->input->get('user') : NULL; //$hold_ref=array(); $hold_ref = $this->input->get('hold_ref') ? $this->input->get('hold_ref') : NULL; // multiple dc numbers //$hold_ref = implode(",", $this->input->post('hold_ref')) ? $this->input->get('hold_ref') : NULL; //error_log("DC Number:".$hold_ref); $status = $this->input->get('process_status') ? $this->input->get('process_status') : NULL; $payment = $this->input->get('payment') ? $this->input->get('payment') : NULL; $this->load->library('datatables'); if ($this->db->dbdriver == 'sqlite3') { $this->datatables->select("tec_sales.id, strftime('%Y-%m-%d %H:%M', date) as date, customer_name, customer_phone_no, hold_ref, total, total_tax, total_discount, grand_total, paid, status, cutting_unit_user, stitching_unit_user, unit_process_status, cutting_unit_com_date, stitching_unit_com_date, DATE_FORMAT(deliver_date, '%d-%m-%Y') as deliver_date, DATE_FORMAT(due_date, '%d-%m-%Y') as due_date, total_items,(SELECT FORMAT((SUM(tec_sale_items.quantity)),0) from tec_sale_items where tec_sale_items.sale_id=tec_sales.id and tec_sale_items.product_id=1) as pant_count,(SELECT FORMAT((SUM(tec_sale_items.quantity)),0) from tec_sale_items where tec_sale_items.sale_id=tec_sales.id and tec_sale_items.product_id=2 or tec_sale_items.sale_id=tec_sales.id and tec_sale_items.product_id=3) as shirt_count,IF(sells='1','Sales',IF(sells='2','Trails',IF(sells='3','Trail Completed','Undefined'))) as sale_type_name"); } else { $this->datatables->select("tec_sales.id, DATE_FORMAT(date, '%Y-%m-%d %H:%i') as date, customer_name, customer_phone_no, hold_ref, total, total_tax, total_discount, grand_total, paid, status, cutting_unit_user, stitching_unit_user, unit_process_status, cutting_unit_com_date, stitching_unit_com_date, DATE_FORMAT(deliver_date, '%d-%m-%Y') as deliver_date, DATE_FORMAT(due_date, '%d-%m-%Y') as due_date, total_items,(SELECT FORMAT((SUM(tec_sale_items.quantity)),0) from tec_sale_items where tec_sale_items.sale_id=tec_sales.id and tec_sale_items.product_id=1) as pant_count,(SELECT FORMAT((SUM(tec_sale_items.quantity)),0) from tec_sale_items where tec_sale_items.sale_id=tec_sales.id and tec_sale_items.product_id=2 or tec_sale_items.sale_id=tec_sales.id and tec_sale_items.product_id=3) as shirt_count,IF(sells='1','Sales',IF(sells='2','Trails',IF(sells='3','Trail Completed','Undefined'))) as sale_type_name"); } $this->datatables->from('sales'); if (!$this->Admin && !$this->session->userdata('view_right')) { $this->datatables->where('created_by', $this->session->userdata('user_id')); /*$this->datatables->where('sells', '1');*/ } $this->datatables->where('store_id', $this->session->userdata('store_id')); /*$this->datatables->where('sells', '1');*/ //$this->datatables->join('tec_sale_items', 'tec_sales.id = tec_sale_items.sale_id','inner'); $this->datatables->add_column('Clone', "<div class='text-center'><a href='" . site_url('pos/?clone=$1') . "' title='" . lang('view_invoice') . "' target='_blank' class='tip btn btn-success btn-xs'>Clone <i class='fa fa-copy'></i></a> </div>", 'id'); $this->datatables->add_column('Actions', "<div class='text-center'><div class='btn-group'><a href='" . site_url('pos/view/$1/1') . "' title='" . lang('view_invoice') . "' class='tip btn btn-primary btn-xs' data-toggle='ajax-modal'><i class='fa fa-list'></i></a> <a href='" . site_url('sales/payments/$1') . "' title='" . lang('view_payments') . "' class='tip btn btn-primary btn-xs' data-toggle='ajax'><i class='fa fa-money'></i></a> <a href='" . site_url('sales/add_payment/$1') . "' title='" . lang('add_payment') . "' class='tip btn btn-primary btn-xs' data-toggle='ajax'><i class='fa fa-briefcase'></i></a> <a href='" . site_url('pos/?edit=$1') . "' title='" . lang('edit_invoice') . "' class='tip btn btn-warning btn-xs'><i class='fa fa-edit'></i></a> <a href='" . site_url('sales/delete/$1') . "' onClick=\"return confirm('" . lang('alert_x_sale') . "')\" title='" . lang('delete_sale') . "' class='tip btn btn-danger btn-xs'><i class='fa fa-trash-o'></i></a></div></div>", 'id'); $this->datatables->edit_column('sale_type_name', "<div class='text-center'><b style='color: black;'><b>$1</div>",'sale_type_name'); if($customer) { $this->datatables->where('customer_id', $customer); } if($user) { $this->datatables->where('created_by', $user); } if($start_date) { $this->datatables->where('date >=', $start_date); } if($end_date) { $this->datatables->where('date <=', $end_date); } //if($hold_ref) { $this->datatables->where('hold_ref', $hold_ref); } //$hold_ref=array(); if($hold_ref) { error_log('Ganesh Anna DC Number: '.$hold_ref); $this->datatables->where_in('hold_ref', [$hold_ref]); // where_in('id', ['20','15','22','42','86']); // $this->datatables->where_in('hold_ref', [780,7865]); //$this->datatables->where_in('hold_ref', ['780','7865']); } if($status) { $this->datatables->where('unit_process_status', $status); } if($payment) { $this->datatables->where('status', $payment); } echo $this->datatables->generate(); } public function index() { // Filter Starts Here if ($this->input->post('customer')) { $start_date = $this->input->post('start_date') ? $this->input->post('start_date') : NULL; $end_date = $this->input->post('end_date') ? $this->input->post('end_date') : NULL; $user = $this->input->post('user') ? $this->input->post('user') : NULL; $hold_ref = $this->input->post('hold_ref') ? $this->input->post('hold_ref') : NULL; $status = $this->input->post('process_status') ? $this->input->post('process_status') : NULL; $payment = $this->input->post('payment') ? $this->input->post('payment') : NULL; $this->data['total_sales'] = $this->sales_model->getTotalCustomerSales($this->input->post('customer'), $user, $start_date, $end_date, $hold_ref, $status, $payment); } // Filter Ends Here $this->data['error'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('error'); $this->data['customers'] = $this->sales_model->getAllCustomers(); $this->data['users'] = $this->sales_model->getAllStaff(); $this->data['sale_items'] = $this->sales_model->getAllSaleItems(id); $this->data['dc_number'] = $this->sales_model->getAllSaleDC(); $this->data['page_title'] = lang('sales'); $bc = [['link' => '#', 'page' => lang('sales')]]; $meta = ['page_title' => lang('sales'), 'bc' => $bc]; $this->page_construct('sales/index', $this->data, $meta); } // Trails Section Starts Here public function trail_sales() { // Filter Starts Here if ($this->input->post('customer')) { $start_date = $this->input->post('start_date') ? $this->input->post('start_date') : NULL; $end_date = $this->input->post('end_date') ? $this->input->post('end_date') : NULL; $user = $this->input->post('user') ? $this->input->post('user') : NULL; $hold_ref = $this->input->post('hold_ref') ? $this->input->post('hold_ref') : NULL; $status = $this->input->post('process_status') ? $this->input->post('process_status') : NULL; $payment = $this->input->post('payment') ? $this->input->post('payment') : NULL; $this->data['total_sales'] = $this->sales_model->getTotalCustomerSales($this->input->post('customer'), $user, $start_date, $end_date, $hold_ref, $status, $payment); } // Filter Ends Here $this->data['error'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('error'); $this->data['customers'] = $this->sales_model->getAllCustomers(); $this->data['users'] = $this->sales_model->getAllStaff(); $this->data['sale_items'] = $this->sales_model->getAllSaleItems(id); $this->data['page_title'] = lang('trail_sales'); $bc = [['link' => '#', 'page' => lang('trail_sales')]]; $meta = ['page_title' => lang('trail_sales'), 'bc' => $bc]; $this->page_construct('sales/trail_sales', $this->data, $meta); } public function get_trail_sales() { $customer = $this->input->get('customer') ? $this->input->get('customer') : NULL; $start_date = $this->input->get('start_date') ? $this->input->get('start_date') : NULL; $end_date = $this->input->get('end_date') ? $this->input->get('end_date') : NULL; $user = $this->input->get('user') ? $this->input->get('user') : NULL; $hold_ref = $this->input->get('hold_ref') ? $this->input->get('hold_ref') : NULL; $status = $this->input->get('process_status') ? $this->input->get('process_status') : NULL; $payment = $this->input->get('payment') ? $this->input->get('payment') : NULL; $this->load->library('datatables'); if ($this->db->dbdriver == 'sqlite3') { $this->datatables->select("id, strftime('%Y-%m-%d %H:%M', date) as date, customer_name, customer_phone_no, hold_ref, total, total_tax, total_discount, grand_total, paid, status, cutting_unit_user, stitching_unit_user, unit_process_status, cutting_unit_com_date, stitching_unit_com_date, deliver_date, DATE_FORMAT(deliver_date, '%d-%m-%Y') as deliver_date, DATE_FORMAT(due_date, '%d-%m-%Y') as due_date, total_items"); } else { $this->datatables->select("id, DATE_FORMAT(date, '%Y-%m-%d %H:%i') as date, customer_name, customer_phone_no, hold_ref, total, total_tax, total_discount, grand_total, paid, status, cutting_unit_user, stitching_unit_user, unit_process_status, cutting_unit_com_date, stitching_unit_com_date, deliver_date, DATE_FORMAT(deliver_date, '%d-%m-%Y') as deliver_date, DATE_FORMAT(due_date, '%d-%m-%Y') as due_date, total_items"); } $this->datatables->from('sales'); if (!$this->Admin && !$this->session->userdata('view_right')) { $this->datatables->where('sells', $this->session->userdata('user_id')); $this->datatables->where('sells', '2'); } $this->datatables->where('store_id', $this->session->userdata('store_id')); $this->datatables->where('sells', '2'); $this->datatables->add_column('Clone', "<div class='text-center'><a href='" . site_url('pos/?clone=$1') . "' title='" . lang('view_invoice') . "' target='_blank' class='tip btn btn-success btn-xs'>Clone <i class='fa fa-copy'></i></a> </div>", 'id'); $this->datatables->add_column('Actions', "<div class='text-center'><div class='btn-group'><a href='" . site_url('pos/view/$1/1') . "' title='" . lang('view_invoice') . "' class='tip btn btn-primary btn-xs' data-toggle='ajax-modal'><i class='fa fa-list'></i></a> <a href='" . site_url('sales/payments/$1') . "' title='" . lang('view_payments') . "' class='tip btn btn-primary btn-xs' data-toggle='ajax'><i class='fa fa-money'></i></a> <a href='" . site_url('sales/add_payment/$1') . "' title='" . lang('add_payment') . "' class='tip btn btn-primary btn-xs' data-toggle='ajax'><i class='fa fa-briefcase'></i></a> <a href='" . site_url('pos/?edit=$1') . "' title='" . lang('edit_invoice') . "' class='tip btn btn-warning btn-xs'><i class='fa fa-edit'></i></a> <a href='" . site_url('sales/delete/$1') . "' onClick=\"return confirm('" . lang('alert_x_sale') . "')\" title='" . lang('delete_sale') . "' class='tip btn btn-danger btn-xs'><i class='fa fa-trash-o'></i></a></div></div>", 'id'); if($customer) { $this->datatables->where('customer_id', $customer); } if($user) { $this->datatables->where('created_by', $user); } if($start_date) { $this->datatables->where('date >=', $start_date); } if($end_date) { $this->datatables->where('date <=', $end_date); } if($hold_ref) { $this->datatables->where('hold_ref', $hold_ref); } if($status) { $this->datatables->where('unit_process_status', $status); } if($payment) { $this->datatables->where('status', $payment); } echo $this->datatables->generate(); } // Trails Section Ends Here public function opened() { $this->data['error'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('error'); $this->data['page_title'] = lang('opened_bills'); $bc = [['link' => '#', 'page' => lang('opened_bills')]]; $meta = ['page_title' => lang('opened_bills'), 'bc' => $bc]; $this->page_construct('sales/opened', $this->data, $meta); } public function payment_note($id = null) { $payment = $this->sales_model->getPaymentByID($id); $inv = $this->sales_model->getSaleByID($payment->sale_id); $this->data['customer'] = $this->site->getCompanyByID($inv->customer_id); $this->data['inv'] = $inv; $this->data['payment'] = $payment; $this->data['page_title'] = $this->lang->line('payment_note'); $this->load->view($this->theme . 'sales/payment_note', $this->data); } /* -------------------------------------------------------------------------------- */ public function payments($id = null) { $this->data['payments'] = $this->sales_model->getSalePayments($id); $this->load->view($this->theme . 'sales/payments', $this->data); } public function status() { if (!$this->Admin) { $this->session->set_flashdata('warning', lang('access_denied')); redirect('sales'); } $this->form_validation->set_rules('sale_id', lang('sale_id'), 'required'); $this->form_validation->set_rules('status', lang('status'), 'required'); if ($this->form_validation->run() == true) { $this->sales_model->updateStatus($this->input->post('sale_id', true), $this->input->post('status', true)); $this->session->set_flashdata('message', lang('status_updated')); redirect('sales'); } else { $this->session->set_flashdata('error', validation_errors()); redirect('sales'); } } public function up_status() { if (!$this->Admin) { $this->session->set_flashdata('warning', lang('access_denied')); redirect('sales'); } $this->form_validation->set_rules('sale_id1', lang('sale_id'), 'required'); $this->form_validation->set_rules('upstatus', lang('upstatus'), 'required'); if ($this->form_validation->run() == true) { $cutting_products =array(); $cutting_username=array(); $cutting_assign_date=array(); $stitching_products =array(); $stitching_username=array(); $stitching_assign_date=array(); $id=array(); $ready_products=array(); $items_delivery_date=array(); $sell_id = $this->input->post('multi_sell_id', true); $status = $this->input->post('upstatus', true); $cutting_products = $this->input->post('products'); $cutting_username = $this->input->post('user_name'); $cutting_assign_date = $this->input->post('assign_date'); $id = $this->input->post('tec_works_id'); $stitching_products = $this->input->post('s_products'); $stitching_username = $this->input->post('s_user_name'); $stitching_assign_date = $this->input->post('s_assign_date'); $ready_products = $this->input->post('ready_not_ready'); $delivery_date = $this->input->post('delivery_date'); $items_delivery_date = $this->input->post('items_delivery_date'); $bbid = $this->input->post('bbid'); $this->sales_model->updateupStatusNew($id, $sell_id, $status, $cutting_products, $cutting_username,$cutting_assign_date,$stitching_products,$stitching_username,$stitching_assign_date,$ready_products,$delivery_date,$items_delivery_date); $this->sales_model->newww($bbid); $this->session->set_flashdata('message', 'Unit Process Status Updated...'); redirect('sales'); } else { $this->session->set_flashdata('error', validation_errors()); redirect('sales'); } } // New Method Update Measurement Starts Here public function up_status_new() { if (!$this->Admin) { $this->session->set_flashdata('warning', lang('access_denied')); redirect('sales'); } $this->form_validation->set_rules('cutting_sale_id', lang('cutting_sale_id'), 'required'); if ($this->form_validation->run() == true) { // New Starts $cutting_sale_id = $this->input->post('cutting_sale_id', true); $cutting_products =array(); $cutting_username=array(); $cutting_assign_date=array(); $cutting_quantity=array(); $cutting_total_quantity=array(); $cutting_products_name=array(); $ready_or_not_ready=array(); $delivery_date=array(); $cutting_products = $this->input->post('cutting_products'); $cutting_products_name = $this->input->post('cutting_products_name'); $cutting_username = $this->input->post('cutting_user_name'); $cutting_assign_date = $this->input->post('cutting_assign_date'); $cutting_quantity = $this->input->post('cutting_quantity'); $cutting_total_quantity = $this->input->post('cutting_total_quantity'); $cutting_status = $this->input->post('cutting_status'); $ready_or_not_ready = $this->input->post('ready_or_not_ready'); $delivery_date = $this->input->post('delivery_date'); $overall_d_date = $this->input->post('overall_products_delivery_date'); // New Ends // $this->sales_model->updateupStatusNew($id, $sell_id, $status, $cutting_products, $cutting_username,$cutting_assign_date,$stitching_products,$stitching_username,$stitching_assign_date,$ready_products,$delivery_date,$items_delivery_date); $this->sales_model->cuttingUnitStatus($cutting_sale_id, $cutting_products, $cutting_products_name, $cutting_username, $cutting_assign_date, $cutting_quantity, $cutting_total_quantity, $cutting_status,$ready_or_not_ready,$delivery_date,$overall_d_date); $this->session->set_flashdata('message', 'Update Successfully...'); redirect('sales'); } else { $this->session->set_flashdata('error', validation_errors()); redirect('sales'); } } // New Method Update Measurement Endss Here // New Cutting Starts // New Method Sale Items Table Cutting Starts Here public function get_all_sale_cutting_items() { $sales_id = $this->input->get('sale_id'); $user = $this->input->get('user'); $date = $this->input->get('date'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $sale_works_data=$this->sales_model->getSaleIemsBySaleIDWithWorksTable($sales_id); $user_data = $this->sales_model->getAllStaff(); $content='<div class="row"> <div class="col-md-3"> <label for="products">Products</label> </div> <div class="col-md-3"> <label for="products">Users</label> </div> <div class="col-md-2"> <label for="products">Qty</label> </div> <div class="col-md-3"> <label for="products">Assign Date</label> </div> <div class="col-md-1"> <label for="products">Actions</label> </div> </div>'; if($data){ $i=1; $ec=1; $hec=1; $esi=1; $a=1; $b=1; $c=1; $u=1; $f=1; $e=1; $g=1; $h=1; $content.=''; foreach($data as $d){ $user_content='<option value="0">Select User</option>'; if($user_data){ foreach($user_data as $user){ $user_content.='<option value="'.$user->id.'" '.(($d->cutting_user_id==$user->id)?'selected="selected"':"").'>'.$user->first_name. "" . $user->last_name.'</option>'; } }else{ $user_content.='<option value="">No Data Available</option>'; } $content.='<div class="row" style="padding: 6px 0px 6px 0px; border: 1px dashed gray; border-radius: 5px; margin-top: 15px;background: #f1eded;">'; $content.='<div class="col-md-3">'; $content.='<select id="products" name="cutting_products[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<input type="hidden" name="cutting_products_name[]" value="'.$d->product_name.'" class="form-control tip" style="width:100%;">'; $content.='<div class="col-md-3">'; $content.='<select id="user_name_'.$d->id.'" name="cutting_user_name[]" class="form-control tip" style="width:100%;">'; $content.=''.$user_content.''; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-2">'; $content.='<input type="number" id="qty_'.$d->id.'" name="cutting_quantity[]" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip qqty_'.$d->id.' quantity" style="width:100%;" /> <input type="hidden" id="bal_'.$d->id.'" value="" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /> <input type="hidden" id="tot_'.$d->id.'" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /> <input type="hidden" id="total" name="cutting_total_quantity[]" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" />'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" id="date_'.$d->id.'" value="'.$d->cutting_assign_date.'" name="cutting_assign_date[]" style="padding: 8px;" class="form-control tip today_date">'; $content.='</div>'; $content.='<div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;">'; $content.='<span id="expand_sale_items_'.$d->product_id.'" class="btn btn-primary btn-xs expand_sale_items"><i class="fa fa-plus"></i> Add</span>'; $content.='<input type="hidden" id="work_sale_id" value="'.$d->sale_id.'" name="work_sale_id[]" class="form-control work_sale_id" style="width:100%;">'; $content.='<input type="hidden" id="work_product_id" value="'.$d->product_id.'" name="work_product_id[]" class="form-control work_product_id" style="width:100%;">'; $content.='</div>'; $content.='<div id="expand_conteent_'.$d->product_id.'" style="padding: 0px 0px 0px 0px;"></div> <div class="row"> <div class="col-md-6" style="padding-left: 50px;"> <b>Total Quantity: <span id="total_qty_'.$d->product_id.'"></span></b> </div> <div class="col-md-6" style="padding-left: 50px;"> <b id="bal_total_qty_'.$d->product_id.'">Remaining Quantity: <span id="balance_qty_'.$d->product_id.'"></span></b> </div> </div>'; $content.='</div>'; $new_one = '<div class="row"> <div class="col-md-3"> <select id="products" name="products[]" class="form-control tip" style="width:100%;"> <option value="'.$d->product_id.'">'.$d->product_name.'</option> </select> </div> <div class="col-md-3"> <select id="user_name_'.$d->id.'" name="user_name[]" class="form-control tip" style="width:100%;"> '.$user_content.' </select> </div> <div class="col-md-2"> <input type="number" id="qty_'.$d->id.'" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /> </div> <div class="col-md-3"> <input type="date" id="date_'.$d->id.'" value="'.$d->cutting_assign_date.'" name="assign_date[]" style="padding: 8px;" class="form-control tip today_date"> </div> <div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;"> </div> </div>'; $content.='<script> $(document).on("click", ".expand_remove_'.$d->product_id.'", function() { $(this).closest(".rows").remove(); }); $("#expand_sale_items_'.$d->product_id.'").on("click", function() { html=`<div class="rows"><div class="col-md-3"><select id="products" name="cutting_products[]" class="form-control tip" style="width:100%;"><option value="'.$d->product_id.'">'.$d->product_name.'</option> </select><input type="hidden" name="cutting_products_name[]" value="'.$d->product_name.'" class="form-control tip" style="width:100%;"></div><div class="col-md-3"><select id="user_name_'.$d->id.'" name="cutting_user_name[]" class="form-control tip" style="width:100%;">'.$user_content.'</select></div><div class="col-md-2"><input type="number" name="cutting_quantity[]" id="qty_'.$d->id.'" value="" min="1" max="'.number_format("$d->quantity").'" class="form-control tip qqty_'.$d->id.' quantity" style="width:100%;" /><input type="hidden" id="total" name="cutting_total_quantity[]" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /></div><div class="col-md-3"><input type="date" id="date_'.$d->id.'" value="'.$d->cutting_assign_date.'" name="cutting_assign_date[]" style="padding: 8px;" class="form-control tip today_date"></div><div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;"><span id="expand_remove_'.$d->product_id.'" class="btn btn-danger btn-xs expand_remove_'.$d->product_id.'"><i class="fa fa-close"></i></span></div></div>`; $("#expand_conteent_'.$d->product_id.'").append(html); }); </script>'; $content.='<script> $(document).ready(function(){ $("#total_qty_'.$d->product_id.'").text('.number_format("$d->quantity").'); }); $(function() { $("#user_name_'.$d->id.'").change(function() { /*alert( $("option:selected", this).text() );*/ var user_name = $("#user_name_'.$d->id.'").val(); console.log(user_name); $(".user_'.$work->product_id.'").val(user_name); }); $("#date_'.$d->id.'").change(function() { var date = $("#date_'.$d->id.'").val(); console.log(date); $(".date_'.$work->product_id.'").val(date); }); $("#qty_'.$d->id.'").keyup(function() { var qty = $("#qty_'.$d->id.'").val(); console.log(qty); // Total and Balance var total = $("#tot_'.$d->id.'").val(); var balance = $("#bal_'.$d->id.'").val(); var output=total-qty; console.log("Output:"+output); $("#bal_'.$d->id.'").val(total-qty); $("#total_qty_'.$d->product_id.'").text('.number_format("$d->quantity").'); //$("#balance_qty_'.$d->product_id.'").text(total-qty); }); $("body").on("keyup",".qqty_'.$d->id.'",function(){ var quantity=Number($(this).val()); var tot=0; $(".qqty_'.$d->id.'").each(function(){ tot+=Number($(this).val()); var total = $("#tot_'.$d->id.'").val(); console.log("Total:"+tot); grand_balance=total-tot; $("#balance_qty_'.$d->product_id.'").text(grand_balance); if($("#balance_qty_'.$d->product_id.'").text() < 0){ $("#bal_total_qty_'.$d->product_id.'").css({"color":"#FF0000"}); $("#cutting_submit").prop("disabled", true); }else{ $("#bal_total_qty_'.$d->product_id.'").css({"color":"black"}); $("#cutting_submit").prop("disabled", false); } }); }); }); </script><style> .redBackground { background-color: red; } </style>'; } $content.='<div style="float: right; padding-top: 30px;"><input type="submit" id="cutting_submit" class="btn btn-success" value="Submit"></div>'; }else{ $content.='No Data Available'; } echo $content; } // New Method Sale Items Table Cutting Ends Here // New Cutting Ends // New Stitching Starts // New Method Sale Items Table Stitching Starts Here public function get_all_sale_stitching_items() { $sales_id = $this->input->get('sale_id'); $user = $this->input->get('user'); $date = $this->input->get('date'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $sale_works_data=$this->sales_model->getSaleIemsBySaleIDWithWorksTable($sales_id); $user_data = $this->sales_model->getAllStaff(); $content='<div class="row"> <div class="col-md-3"> <label for="products">Products</label> </div> <div class="col-md-3"> <label for="products">Users</label> </div> <div class="col-md-2"> <label for="products">Qty</label> </div> <div class="col-md-3"> <label for="products">Assign Date</label> </div> <div class="col-md-1"> <label for="products">Actions</label> </div> </div>'; if($data){ $i=1; $ec=1; $hec=1; $esi=1; $a=1; $b=1; $c=1; $u=1; $f=1; $e=1; $g=1; $h=1; $content.=''; foreach($data as $d){ $user_content='<option value="0">Select User</option>'; if($user_data){ foreach($user_data as $user){ $user_content.='<option value="'.$user->id.'" '.(($d->cutting_user_id==$user->id)?'selected="selected"':"").'>'.$user->first_name. "" . $user->last_name.'</option>'; } }else{ $user_content.='<option value="">No Data Available</option>'; } $content.='<div class="row" style="padding: 6px 0px 6px 0px; border: 1px dashed gray; border-radius: 5px; margin-top: 15px;background: #f1eded;">'; $content.='<div class="col-md-3">'; $content.='<select id="products" name="cutting_products[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<input type="hidden" name="cutting_products_name[]" value="'.$d->product_name.'" class="form-control tip" style="width:100%;">'; $content.='<div class="col-md-3">'; $content.='<select id="user_name_'.$d->id.'" name="cutting_user_name[]" class="form-control tip" style="width:100%;">'; $content.=''.$user_content.''; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-2">'; $content.='<input type="number" id="s_qty_'.$d->id.'" name="cutting_quantity[]" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip s_qqty_'.$d->id.' quantity" style="width:100%;" /> <input type="hidden" id="s_bal_'.$d->id.'" value="" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /> <input type="hidden" id="s_tot_'.$d->id.'" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /> <input type="hidden" id="total" name="cutting_total_quantity[]" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" />'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" id="date_'.$d->id.'" value="'.$d->cutting_assign_date.'" name="cutting_assign_date[]" style="padding: 8px;" class="form-control tip today_date">'; $content.='</div>'; $content.='<div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;">'; $content.='<span id="s_expand_sale_items_'.$d->product_id.'" class="btn btn-primary btn-xs expand_sale_items"><i class="fa fa-plus"></i> Add</span>'; $content.='</div>'; $content.='<div id="s_expand_conteent_'.$d->product_id.'" style="padding: 0px 0px 0px 0px;"></div> <div class="row"> <div class="col-md-6" style="padding-left: 50px;"> <b>Total Quantity: <span id="s_total_qty_'.$d->product_id.'"></span></b> </div> <div class="col-md-6" style="padding-left: 50px;"> <b id="s_bal_total_qty_'.$d->product_id.'">Remaining Quantity: <span id="s_balance_qty_'.$d->product_id.'"></span></b> </div> </div>'; $content.='</div>'; $content.='<script> $(document).on("click", ".s_expand_remove_'.$d->product_id.'", function() { $(this).closest(".rows").remove(); }); $("#s_expand_sale_items_'.$d->product_id.'").on("click", function() { html=`<div class="rows"><div class="col-md-3"><select id="products" name="cutting_products[]" class="form-control tip" style="width:100%;"><option value="'.$d->product_id.'">'.$d->product_name.'</option> </select><input type="hidden" name="cutting_products_name[]" value="'.$d->product_name.'" class="form-control tip" style="width:100%;"></div><div class="col-md-3"><select id="user_name_'.$d->id.'" name="cutting_user_name[]" class="form-control tip" style="width:100%;">'.$user_content.'</select></div><div class="col-md-2"><input type="number" name="cutting_quantity[]" id="qty_'.$d->id.'" value="" min="1" max="'.number_format("$d->quantity").'" class="form-control tip s_qqty_'.$d->id.' quantity" style="width:100%;" /><input type="hidden" id="total" name="cutting_total_quantity[]" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /></div><div class="col-md-3"><input type="date" id="date_'.$d->id.'" value="'.$d->cutting_assign_date.'" name="cutting_assign_date[]" style="padding: 8px;" class="form-control tip today_date"></div><div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;"><span id="vexpand_remove_'.$d->product_id.'" class="btn btn-danger btn-xs s_expand_remove_'.$d->product_id.'"><i class="fa fa-close"></i></span></div></div>`; $("#s_expand_conteent_'.$d->product_id.'").append(html); }); </script>'; $content.='<script> $(document).ready(function(){ $("#s_total_qty_'.$d->product_id.'").text('.number_format("$d->quantity").'); }); $(function() { $("#s_qty_'.$d->id.'").keyup(function() { var qty = $("#s_qty_'.$d->id.'").val(); var total = $("#s_tot_'.$d->id.'").val(); var balance = $("#s_bal_'.$d->id.'").val(); var output=total-qty; $("#s_bal_'.$d->id.'").val(total-qty); $("#s_total_qty_'.$d->product_id.'").text('.number_format("$d->quantity").'); $("#s_balance_qty_'.$d->product_id.'").text(total-qty); }); $("body").on("keyup",".s_qqty_'.$d->id.'",function(){ var quantity=Number($(this).val()); var tot=0; $(".s_qqty_'.$d->id.'").each(function(){ tot+=Number($(this).val()); var total = $("#s_tot_'.$d->id.'").val(); console.log("Total:"+tot); grand_balance=total-tot; $("#s_balance_qty_'.$d->product_id.'").text(grand_balance); if($("#s_balance_qty_'.$d->product_id.'").text() < 0){ $("#s_bal_total_qty_'.$d->product_id.'").css({"color":"#FF0000"}); $("#stitching_submit").prop("disabled", true); }else{ $("#s_bal_total_qty_'.$d->product_id.'").css({"color":"black"}); $("#stitching_submit").prop("disabled", false); } }); }); }); </script>'; } $content.='<div style="float: right; padding-top: 30px;"><input type="submit" id="stitching_submit" class="btn btn-success" value="Submit"></div>'; }else{ $content.='No Data Available'; } echo $content; } // New Stitching Ends // New Method Sale Items Table Stitching Ends Here // New Ready to Delivery Itmes // New Method Sale Items Table Ready to Delivery Itmes Starts Here public function get_all_ready_items() { $sales_id = $this->input->get('sale_id'); $user = $this->input->get('user'); $date = $this->input->get('date'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $sale_works_data=$this->sales_model->getSaleIemsBySaleIDWithWorksTable($sales_id); $user_data = $this->sales_model->getAllStaff(); $content='<div class="row"> <div class="col-md-4"> <label for="products">Products</label> </div> <div class="col-md-3"> <label for="products">Qty</label> </div> <div class="col-md-4"> <label for="products">Status</label> </div> <div class="col-md-1"> <label for="products">Actions</label> </div> </div>'; if($data){ $i=1; $ec=1; $hec=1; $esi=1; $a=1; $b=1; $c=1; $u=1; $f=1; $e=1; $g=1; $h=1; $content.=''; foreach($data as $d){ $content.='<div class="row" style="padding: 6px 0px 6px 0px; border: 1px dashed gray; border-radius: 5px; margin-top: 15px;background: #f1eded;">'; $content.='<div class="col-md-4">'; $content.='<select id="products" name="cutting_products[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<input type="hidden" name="cutting_products_name[]" value="'.$d->product_name.'" class="form-control tip" style="width:100%;">'; $content.='<div class="col-md-3">'; $content.='<input type="number" id="r_qty_'.$d->id.'" name="cutting_quantity[]" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip r_qqty_'.$d->id.' quantity" style="width:100%;" /> <input type="hidden" id="r_bal_'.$d->id.'" value="" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /> <input type="hidden" id="r_tot_'.$d->id.'" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /> <input type="hidden" id="total" name="cutting_total_quantity[]" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" />'; $content.='</div>'; $content.='<div class="col-md-4">'; $content.='<select id="ready_not_ready" name="ready_not_ready[]" class="form-control tip" style="width:100%;"> <option value="ready" '.(($d->ready_or_not_ready=="ready")?'selected="selected"':"").'>Ready</option> <option value="not_ready" '.(($d->ready_or_not_ready=="not_ready")?'selected="selected"':"").'>Not Ready</option> </select>'; $content.='</div>'; $content.='<div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;">'; $content.='<span id="r_expand_sale_items_'.$d->product_id.'" class="btn btn-primary btn-xs expand_sale_items"><i class="fa fa-plus"></i> Add</span>'; $content.='</div>'; $content.='<div id="r_expand_conteent_'.$d->product_id.'" style="padding: 0px 0px 0px 0px;"></div> <div class="row"> <div class="col-md-6" style="padding-left: 50px;"> <b>Total Quantity: <span id="r_total_qty_'.$d->product_id.'"></span></b> </div> <div class="col-md-6" style="padding-left: 50px;"> <b id="r_bal_total_qty_'.$d->product_id.'">Remaining Quantity: <span id="r_balance_qty_'.$d->product_id.'"></span></b> </div> </div>'; $content.='</div>'; $content.='<script> $(document).on("click", ".r_expand_remove_'.$d->product_id.'", function() { $(this).closest(".rows").remove(); }); $("#r_expand_sale_items_'.$d->product_id.'").on("click", function() { html=`<div class="rows"><div class="col-md-4"><select id="products" name="cutting_products[]" class="form-control tip" style="width:100%;"><option value="'.$d->product_id.'">'.$d->product_name.'</option></select></div><input type="hidden" name="cutting_products_name[]" value="'.$d->product_name.'" class="form-control tip" style="width:100%;"><div class="col-md-3"><input type="number" id="r_qty_'.$d->id.'" name="cutting_quantity[]" value="" min="1" max="'.number_format("$d->quantity").'" class="form-control tip r_qqty_'.$d->id.' quantity" style="width:100%;" /><input type="hidden" id="total" name="cutting_total_quantity[]" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /></div><div class="col-md-4"><select id="ready_not_ready" name="ready_not_ready[]" class="form-control tip" style="width:100%;"><option value="ready" '.(($d->ready_or_not_ready=="ready")?'selected="selected"':"").'>Ready</option><option value="not_ready" '.(($d->ready_or_not_ready=="not_ready")?'selected="selected"':"").'>Not Ready</option></select></div><div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;"><span id="vexpand_remove_'.$d->product_id.'" class="btn btn-danger btn-xs s_expand_remove_'.$d->product_id.'"><i class="fa fa-close"></i></span></div></div>`; $("#r_expand_conteent_'.$d->product_id.'").append(html); }); </script>'; $content.='<script> $(document).ready(function(){ $("#r_total_qty_'.$d->product_id.'").text('.number_format("$d->quantity").'); }); $(function() { $("#r_qty_'.$d->id.'").keyup(function() { var qty = $("#r_qty_'.$d->id.'").val(); var total = $("#r_tot_'.$d->id.'").val(); var balance = $("#r_bal_'.$d->id.'").val(); var output=total-qty; $("#r_bal_'.$d->id.'").val(total-qty); $("#r_total_qty_'.$d->product_id.'").text('.number_format("$d->quantity").'); $("#r_balance_qty_'.$d->product_id.'").text(total-qty); }); $("body").on("keyup",".r_qqty_'.$d->id.'",function(){ var quantity=Number($(this).val()); var tot=0; $(".r_qqty_'.$d->id.'").each(function(){ tot+=Number($(this).val()); var total = $("#r_tot_'.$d->id.'").val(); console.log("Total:"+tot); grand_balance=total-tot; $("#r_balance_qty_'.$d->product_id.'").text(grand_balance); if($("#r_balance_qty_'.$d->product_id.'").text() < 0){ $("#r_bal_total_qty_'.$d->product_id.'").css({"color":"#FF0000"}); $("#ready_to_delivery_submit").prop("disabled", true); }else{ $("#r_bal_total_qty_'.$d->product_id.'").css({"color":"black"}); $("#ready_to_delivery_submit").prop("disabled", false); } }); }); }); </script>'; } $content.='<div style="float: right; padding-top: 30px;"><input type="submit" id="ready_to_delivery_submit" class="btn btn-success" value="Submit"></div>'; }else{ $content.='No Data Available'; } echo $content; } // New Ready to Delivery Itmes // New Method Sale Items Table Ready to Delivery Itmes Ends Here // New Ready to Delivery Itmes // New Method Sale Items Table Ready to Delivery Itmes Starts Here public function get_all_delivery_items() { $sales_id = $this->input->get('sale_id'); $user = $this->input->get('user'); $date = $this->input->get('date'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $sale_works_data=$this->sales_model->getSaleIemsBySaleIDWithWorksTable($sales_id); $user_data = $this->sales_model->getAllStaff(); $content='<div class="row"> <div class="col-md-4"> <label for="products">Products</label> </div> <div class="col-md-3"> <label for="products">Qty</label> </div> <div class="col-md-4"> <label for="products">Delivery Date</label> </div> <div class="col-md-1"> <label for="products">Actions</label> </div> </div>'; if($data){ $i=1; $ec=1; $hec=1; $content.=''; foreach($data as $d){ $content.='<div class="row" style="padding: 6px 0px 6px 0px; border: 1px dashed gray; border-radius: 5px; margin-top: 15px;background: #f1eded;">'; $content.='<div class="col-md-4">'; $content.='<select id="products" name="cutting_products[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<input type="hidden" name="cutting_products_name[]" value="'.$d->product_name.'" class="form-control tip" style="width:100%;">'; $content.='<div class="col-md-3">'; $content.='<input type="number" id="d_qty_'.$d->id.'" name="cutting_quantity[]" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip d_qqty_'.$d->id.' quantity" style="width:100%;" /> <input type="hidden" id="d_tot_'.$d->id.'" name="cutting_total_quantity[]" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" />'; $content.='</div>'; $content.='<div class="col-md-4"> <input type="date" id="d_qty_'.$d->id.'" name="delivery_date[]" value="" class="form-control tip" style="width:100%;" /> </div>'; $content.='<div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;">'; $content.='<span id="d_expand_sale_items_'.$d->product_id.'" class="btn btn-primary btn-xs expand_sale_items"><i class="fa fa-plus"></i> Add</span>'; $content.='</div>'; $content.='<div id="d_expand_conteent_'.$d->product_id.'" style="padding: 0px 0px 0px 0px;"></div> <div class="row"> <div class="col-md-6" style="padding-left: 50px;"> <b>Total Quantity: <span id="d_total_qty_'.$d->product_id.'"></span></b> </div> <div class="col-md-6" style="padding-left: 50px;"> <b id="d_bal_total_qty_'.$d->product_id.'">Remaining Quantity: <span id="d_balance_qty_'.$d->product_id.'"></span></b> </div> </div>'; $content.='</div>'; $content.='<script> </script>'; $content.='<script> $(document).ready(function(){ $("#d_total_qty_'.$d->product_id.'").text('.number_format("$d->quantity").'); }); $("#d_expand_sale_items_'.$d->product_id.'").on("click", function() { html=`<div class="rows"><div class="col-md-4"><select id="products" name="cutting_products[]" class="form-control tip" style="width:100%;"><option value="'.$d->product_id.'">'.$d->product_name.'</option></select></div><input type="hidden" name="cutting_products_name[]" value="'.$d->product_name.'" class="form-control tip" style="width:100%;"><div class="col-md-3"><input type="number" id="d_qty_'.$d->id.'" name="cutting_quantity[]" value="" min="1" max="'.number_format("$d->quantity").'" class="form-control tip d_qqty_'.$d->id.' quantity" style="width:100%;" /><input type="hidden" id="total" name="cutting_total_quantity[]" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /></div><div class="col-md-4"><input type="date" id="d_qty_'.$d->id.'" name="delivery_date[]" value="" class="form-control tip" style="width:100%;" /></div><div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;"><span id="d_expand_remove_'.$d->product_id.'" class="btn btn-danger btn-xs d_expand_remove_'.$d->product_id.'"><i class="fa fa-close"></i></span></div></div>`; $("#d_expand_conteent_'.$d->product_id.'").append(html); }); $(function() { $(document).on("click", ".d_expand_remove_'.$d->product_id.'", function() { $(this).closest(".rows").remove(); grand_total(); }); $("body").on("keyup",".d_qqty_'.$d->id.'",function(){ var quantity=Number($(this).val()); grand_total(); }); function grand_total(){ var tot=0; $(".d_qqty_'.$d->id.'").each(function(){ tot+=Number($(this).val()); var total = $("#d_tot_'.$d->id.'").val(); console.log("Total:"+tot); grand_balance=total-tot; $("#d_balance_qty_'.$d->product_id.'").text(grand_balance); if($("#d_balance_qty_'.$d->product_id.'").text() < 0){ $("#d_bal_total_qty_'.$d->product_id.'").css({"color":"#FF0000"}); $("#delivery_partial_date_submit").prop("disabled", true); }else{ $("#d_bal_total_qty_'.$d->product_id.'").css({"color":"black"}); $("#delivery_partial_date_submit").prop("disabled", false); } }); } }); </script>'; } $content.='<div style="float: right; padding-top: 30px;"><input type="submit" id="delivery_partial_date_submit" class="btn btn-success" value="Submit"></div>'; }else{ $content.='No Data Available'; } echo $content; } // New Ready to Delivery Itmes // New Method Sale Items Table Ready to Delivery Itmes Ends Here /* ------------- New Method Cutting & Stitching & Delivery Ends Now ------------------*/ // New Method Sale Items Table Cutting Starts Here public function get_all_sale_cuttingg_items() { $sales_id = $this->input->get('sale_id'); $user = $this->input->get('user'); $date = $this->input->get('date'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $sale_works_data=$this->sales_model->getSaleIemsBySaleIDWithWorksTable($sales_id); $user_data = $this->sales_model->getAllStaff(); $content='<div class="row"> <div class="col-md-3"> <label for="products">Products</label> </div> <div class="col-md-3"> <label for="products">Users</label> </div> <div class="col-md-2"> <label for="products">Qty</label> </div> <div class="col-md-3"> <label for="products">Assign Date</label> </div> <div class="col-md-1"> <label for="products">Actions</label> </div> </div>'; if($data){ $i=1; $ec=1; $hec=1; $esi=1; $a=1; $b=1; $c=1; $u=1; $f=1; $e=1; $g=1; $h=1; foreach($data as $d){ $user_content='<option value="0">Select User</option>'; if($user_data){ foreach($user_data as $user){ $user_content.='<option value="'.$user->id.'" '.(($d->cutting_user_id==$user->id)?'selected="selected"':"").'>'.$user->first_name. "" . $user->last_name.'</option>'; } }else{ $user_content.='<option value="">No Data Available</option>'; } $content.='<div class="row">'; $content.='<div class="col-md-3">'; $content.='<select id="products" name="products[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<input type="hidden" id="tec_works_id" value="'.$d->id.'" name="tec_works_id[]" class="form-control tip" style="width:100%;">'; $content.='<div class="col-md-3">'; $content.='<select id="user_name_'.$d->id.'" name="user_name[]" class="form-control tip" style="width:100%;">'; $content.=''.$user_content.''; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-2">'; $content.='<input type="number" id="qty_'.$d->id.'" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /> <input type="number" id="bal_'.$d->id.'" value="" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" /> <input type="number" id="tot_'.$d->id.'" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" />'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" id="date_'.$d->id.'" value="'.$d->cutting_assign_date.'" name="assign_date[]" style="padding: 8px;" class="form-control tip today_date">'; $content.='</div>'; $content.='<div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;">'; $content.='<div class="quantity"> <a href="#" class="quantity__minus"><span>-</span></a> <input name="quantity" type="text" class="quantity__input" value="1"> <a href="#" class="quantity__plus"><span>+</span></a> </div>'; $content.='<span id="expand_sale_items_'.$d->product_id.'" class="btn btn-primary btn-xs expand_sale_items">Expand</span>'; $content.='<span id="expand_clear_'.$d->product_id.'" class="btn btn-primary btn-xs expand_sale_items">Clear</span>'; $content.='<input type="hidden" id="work_sale_id" value="'.$d->sale_id.'" name="work_sale_id[]" class="form-control work_sale_id" style="width:100%;">'; $content.='<input type="hidden" id="work_product_id" value="'.$d->product_id.'" name="work_product_id[]" class="form-control work_product_id" style="width:100%;">'; $content.='</div>'; $content.='</div>'; $content.='<div id="expand_conteent_'.$d->product_id.'"></div>'; $content.='<div id="expand_content_'.$ec++.'" style="padding: 10px 15px 10px 15px; border: 1px dashed gray; border-radius: 5px; margin: 16px;background: #f1eded;">'; foreach($sale_works_data as $work){ if($work->sale_id==$d->sale_id && $work->product_id==$d->product_id){ $content.='<div class="row"> <div class="col-md-3"> <select id="products" name="products[]" class="form-control tip" style="width:100%;"> <option value="'.$work->product_id.'">'.$work->product_name.'</option> </select> </div> <div class="col-md-3"> <select id="user_name_'.$work->id.'" name="user_name[]" class="form-control tip user_'.$work->product_id.'" style="width:100%;"> '.$user_content.' </select> </div> <div class="col-md-2"> <input type="hidden" id="tec_works_id" value="'.$work->id.'" name="tec_works_id[]" class="form-control tip" style="width:100%;"> <input type="number" value="1" class="form-control tip" style="width:100%;" readonly /> </div> <div class="col-md-3"> <input type="date" id="cutting_unit_com_date" value="'.$work->cutting_assign_date.'" name="assign_date[]" style="padding: 8px;" class="form-control tip today_date date_'.$work->product_id.'"> </div> <div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;"> </div> </div>'; } } $content.='</div>'; $content.='<script> $(document).ready(function(){ }); $(function() { $("#user_name_'.$d->id.'").change(function() { alert( $("option:selected", this).text() ); var user_name = $("#user_name_'.$d->id.'").val(); console.log(user_name); $(".user_'.$work->product_id.'").val(user_name); }); $("#date_'.$d->id.'").change(function() { alert( $("option:selected", this).text() ); var date = $("#date_'.$d->id.'").val(); console.log(date); $(".date_'.$work->product_id.'").val(date); }); $("#qty_'.$d->id.'").keyup(function() { var qty = $("#qty_'.$d->id.'").val(); console.log(qty); // Total and Balance var total = $("#tot_'.$d->id.'").val(); var balance = $("#bal_'.$d->id.'").val(); var output=total-qty; console.log("Output:"+output); $("#bal_'.$d->id.'").val(total-qty); }); }); </script>'; $content.='<script> $(document).ready(function(){ $("#expand_sale_items_'.$d->product_id.'").one("click",function() { console.log("Its Working"); var balance = $("#bal_'.$d->id.'").val(); var row=`<input type="number" id="tot_'.$d->id.'" value="'.number_format("$d->quantity").'" min="1" max="'.number_format("$d->quantity").'" class="form-control tip" style="width:100%;" />`; $("#expand_conteent_'.$d->product_id.'").append(row); $("#expand_sale_items_'.$d->product_id.'").one("click",function() { $("#expand_conteent_'.$d->product_id.'").empty(); }); }); $("#expand_clear_'.$d->product_id.'").click(function() { $("#expand_conteent_'.$d->product_id.'").empty(); }); }); </script>'; } }else{ $content.='No Data Available'; } echo $content; } // New Method Sale Items Table Cutting Ends Here /* ----- New Working Cutting Unit Assign Section Starts Here ----- */ public function get_all_sale_cuttting_items() { $sales_id = $this->input->get('sale_id'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $sale_works_data=$this->sales_model->getSaleIemsBySaleIDWithWorksTable($sales_id); $user_data = $this->sales_model->getAllStaff(); $content='<div class="row"> <div class="col-md-3"> <label for="products">Products</label> </div> <div class="col-md-3"> <label for="products">Users</label> </div> <div class="col-md-2"> <label for="products">Qty</label> </div> <div class="col-md-3"> <label for="products">Assign Date</label> </div> <div class="col-md-1"> <label for="products">Actions</label> </div> </div>'; if($sale_works_data){ $i=1; foreach($sale_works_data as $d){ $user_content='<option value="0">Select User</option>'; if($user_data){ foreach($user_data as $user){ $user_content.='<option value="'.$user->id.'" '.(($d->cutting_user_id==$user->id)?'selected="selected"':"").'>'.$user->first_name. "" . $user->last_name.'</option>'; } }else{ $user_content.='<option value="">No Data Available</option>'; } $content.='<div class="row">'; $content.='<div class="col-md-3">'; $content.='<select id="products" name="products[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<select id="user_name" name="user_name[]" class="form-control tip" style="width:100%;">'; $content.=''.$user_content.''; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-2">'; $content.='<input type="hidden" id="tec_works_id" value="'.$d->id.'" name="tec_works_id[]" class="form-control tip" style="width:100%;">'; $content.='<input type="number" value="'.$d->quantity.'" class="form-control tip" style="width:100%;" readonly />'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" id="cutting_unit_com_date" value="'.$d->cutting_assign_date.'" name="assign_date[]" style="padding: 8px;" class="form-control tip today_date">'; $content.='</div>'; $content.='<div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;">'; $content.='<span id="expand_sale_items" class="btn btn-primary btn-xs expand_sale_items">Expand</span>'; $content.='</div>'; $content.='</div>'; $content.='<div id="expand_content_'.$i++.'" style="padding: 3px 0px 3px 0px;"></div>'; } }else{ $content.='No Data Available'; } echo $content; } /* ----- New Working Cutting Unit Assign Section Endss Here ----- */ /* ----- New Working Stithcing Unit Assign Section Starts Here ----- */ public function get_all_sale_stitching_itemss() { $sales_id = $this->input->get('sale_id'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $sale_works_data=$this->sales_model->getSaleIemsBySaleIDWithWorksTable($sales_id); $user_data = $this->sales_model->getAllStaff(); $content='<div class="row"> <div class="col-md-4"> <label for="products">Products</label> </div> <div class="col-md-3"> <label for="products">Users</label> </div> <div class="col-md-2"> <label for="products">Qty</label> </div> <div class="col-md-3"> <label for="products">Assign Date</label> </div> </div>'; if($sale_works_data){ $i=1; foreach($sale_works_data as $d){ $user_content='<option value="0">Select User</option>'; if($user_data){ foreach($user_data as $user){ $user_content.='<option value="'.$user->id.'" '.(($d->stitching_user_id==$user->id)?'selected="selected"':"").'>'.$user->first_name. "" . $user->last_name.'</option>'; } }else{ $user_content.='<option value="">No Data Available</option>'; } $content.='<div class="row">'; $content.='<div class="col-md-4">'; $content.='<select id="s_products" name="s_products[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<select id="s_user_name" name="s_user_name[]" class="form-control tip" style="width:100%;">'; $content.='echo "'.$user_content.'"'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-2">'; $content.='<input type="hidden" id="s_tec_works_id" value="'.$d->id.'" name="s_tec_works_id[]" class="form-control tip" style="width:100%;">'; $content.='<input type="number" value="1" class="form-control tip" style="width:100%;" readonly />'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" id="s_assign_date" value="'.$d->stitching_assign_date.'" name="s_assign_date[]" style="padding: 8px;" class="form-control tip today_date">'; $content.='</div>'; $content.='</div>'; $content.='<div id="expand_content_'.$i++.'" style="padding: 3px 0px 3px 0px;"></div>'; } }else{ $content.='No Data Available'; } echo $content; } /* ----- New Working Stithcing Unit Assign Section Endss Here ----- */ /* ----- Ready to Delivery Section Starts Here ----- */ public function get_all_ready_itemss() { $sales_id = $this->input->get('sale_id'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $sale_works_data=$this->sales_model->getSaleIemsBySaleIDWithWorksTable($sales_id); $user_data = $this->sales_model->getAllStaff(); $content='<div class="row"> <div class="col-md-4" style="text-align: center;"> <label for="products">Products</label> </div> <div class="col-md-2" style="text-align: center;"> <label for="products">Qty</label> </div> <div class="col-md-6" style="text-align: center;"> <label for="products">Status</label> </div> </div>'; if($sale_works_data){ $i=1; foreach($sale_works_data as $d){ /*if($d->stitching_status==1){ $ready_content='<div class="text-center"><span class="upsale_status label label-warning"></span></div>'; }*/ $user_content='<option value="0">Select User</option>'; if($user_data){ foreach($user_data as $user){ $user_content.='<option value="'.$user->id.'" '.(($d->cutting_user_id==$user->id)?'selected="selected"':"").'>'.$user->first_name. "" . $user->last_name.'</option>'; } }else{ $user_content.='<option value="">No Data Available</option>'; } $content.='<div class="row">'; $content.='<input type="hidden" id="r_tec_works_id" value="'.$d->id.'" name="r_tec_works_id[]" class="form-control tip" style="width:100%;">'; $content.='<div class="col-md-4">'; $content.='<select id="ready_products" name="ready_products[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-2">'; $content.='<input type="number" value="1" class="form-control tip" style="width:100%;" readonly />'; $content.='</div>'; $content.='<div class="col-md-6">'; $content.='<select id="ready_not_ready" name="ready_not_ready[]" class="form-control tip" style="width:100%;"> <option value="ready" '.(($d->ready_or_not_ready=="ready")?'selected="selected"':"").'>Ready</option> <option value="not_ready" '.(($d->ready_or_not_ready=="not_ready")?'selected="selected"':"").'>Not Ready</option> </select>'; $content.='</div>'; $content.='</div>'; } }else{ $content.='No Data Available'; } echo $content; } /* ----- Ready to Delivery Section Ends Here ----- */ /* ----- Delivery Items Section Starts Here ----- */ public function get_all_delivery_itemss() { $sales_id = $this->input->get('sale_id'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $sale_works_data=$this->sales_model->getSaleIemsBySaleIDWithWorksTable($sales_id); $user_data = $this->sales_model->getAllStaff(); $content='<div class="row"> <div class="col-md-4" style="text-align: center;"> <label for="products">Products</label> </div> <div class="col-md-2" style="text-align: center;"> <label for="products">Qty</label> </div> <div class="col-md-3" style="text-align: center;"> <label for="products">Status</label> </div> <div class="col-md-3" style="text-align: center;"> <label for="products">Delivery Date</label> </div> </div>'; if($sale_works_data){ $i=1; foreach($sale_works_data as $d){ if($d->ready_or_not_ready=="ready"){ $content.='<div class="row">'; $content.='<input type="hidden" id="d_tec_works_id" value="'.$d->id.'" name="r_tec_works_id[]" class="form-control tip" style="width:100%;">'; $content.='<div class="col-md-4">'; $content.='<select id="d_products" name="d_products[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-2">'; $content.='<input type="number" value="1" class="form-control tip" style="width:100%;" readonly />'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<select id="ready_product" name="ready_product[]" class="form-control tip" style="width:100%;"> <option value="ready" '.(($d->ready_or_not_ready=="ready")?'selected="selected"':"").'>Ready</option> <option value="not_ready" '.(($d->ready_or_not_ready=="not_ready")?'selected="selected"':"").'>Not Ready</option> </select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" name="items_delivery_date[]" class="form-control tip" value="'.$d->delivery_date.'" style="padding: 8px; width:100%;" />'; $content.='</div>'; $content.='</div>'; }else{ $content.=''; } } }else{ $content.='No Data Available'; } echo $content; } /* ----- Delivery Items Section Ends Here ----- */ // Append API Starts Here /*2 = Cutting Unit Assigned 3 = Cutting Unit Complete 4 = Stitching Unit Assigned 5 = Stitching Unit Complete*/ // Expand Cutting Function Starts Here /*public function get_expand_cutting_all_sale_items() { $user_data = $this->sales_model->getAllStaff(); $user_content=''; if($user_data){ foreach($user_data as $user){ $user_content.='<option value="'.$user->id.'">'.$user->first_name. "" . $user->last_name.'</option>'; } }else{ $user_content.='<option value="">No Data Available</option>'; } $sales_id = $this->input->get('sale_id'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $content='<div style="border: 1px dashed gray; border-radius: 10px; padding: 10px 0px 10px 10px;background-color: #f1ecec;"><a><i class="fa fa-close remove_expand" style="float: right; margin: 8px 38px 0px 0px; background: red; padding: 5px; border-radius: 7px; color: white; cursor: pointer;"></i></a>'; if($data){ foreach($data as $d){ $content.='<div class="row">'; $content.='<div class="col-md-3" style="width: 23%;">'; $content.='<select id="products" name="products[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<select id="user_name" name="user_name[]" class="form-control tip" style="width:100%;">'; $content.='echo "'.$user_content.'"'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-1" style="width: 12.666667%">'; $content.='<input type="number" value="'.number_format("$d->quantity").'" id="user_name" name="user_name[]" class="form-control tip" style="width:100%;"/>'; $content.='</div>'; $content.='<div class="col-md-3" style="width: 23%;">'; $content.='<input type="date" id="cutting_unit_com_date" value="'.$d->cutting_start_date.'" name="assign_date[]" class="form-control tip cutting">'; $content.='</div>'; //$content.='<div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 0px;">'; //$content.=''; //$content.='</div>'; $content.='</div>'; $content.='<div id="expand_content_'.$ec++.'" style="padding: 10px 15px 10px 15px; border: 1px dashed gray; border-radius: 5px; margin: 16px;background: #f1eded;">'; foreach($sale_works_data as $work){ if($work->sale_id==$d->sale_id && $work->product_id==$d->product_id){ $content.='<div class="row"> <div class="col-md-3"> <select id="products" name="products[]" class="form-control tip" style="width:100%;"> <option value="'.$work->product_id.'">'.$work->product_name.'</option> </select> </div> <div class="col-md-3"> <select id="user_name_'.$work->id.'" name="user_name[]" class="form-control tip user_'.$work->product_id.'" style="width:100%;"> '.$user_content.' </select> </div> <div class="col-md-2"> <input type="hidden" id="tec_works_id" value="'.$work->id.'" name="tec_works_id[]" class="form-control tip" style="width:100%;"> <input type="number" value="1" class="form-control tip" style="width:100%;" readonly /> </div> <div class="col-md-3"> <input type="date" id="cutting_unit_com_date" value="'.$work->cutting_assign_date.'" name="assign_date[]" style="padding: 8px;" class="form-control tip today_date date_'.$work->product_id.'"> </div> <div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;"> </div> </div>'; } } $content.='</div>'; $content.='<style> .form-control { width: 100%; height: 34px; padding: 2px 7px; background-color: #fff; background-image: none; border: 1px solid #ccc; -webkit-box-shadow: inset 0 1px 1px rgb(0 0 0 / 8%); -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s; -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; } </style>'; } $content.="</div>"; }else{ $content.='No Data Available'; } echo $content; }*/ // Expand Cutting Function Ends Here // New Popup Append Function Starts Here public function get_new_cutting_measurements() { $sales_id = $this->input->get('sale_id'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $content='<div class="row"> <div class="col-md-3"> <label for="products">Products</label> </div> <div class="col-md-3"> <label for="products">Cutting Users</label> </div> <div class="col-md-3"> <label for="products">Start Date</label> </div> <div class="col-md-3"> <label for="products">Complete Date</label> </div> </div>'; if($data){ foreach($data as $d){ $content.='<div class="row">'; $content.='<div class="col-md-3">'; $content.='<select id="products" name="products" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<select id="products" name="users" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->cutting_user.'">'.$d->user_fname.' '.$d->user_lname.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" id="cutting_start_date" value="'.$d->cutting_start_date.'" name="cutting_start_date" class="form-control tip" style="width:100%;">'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" id="cutting_unit_com_date" name="cutting_complete_date" value="'.$d->cutting_complete_date.'" class="form-control tip cutting">'; $content.='</div>'; $content.='</div>'; } }else{ $content.='No Data Available'; } echo $content; } // New Popup Append Function Ends Here /*<div class="col-md-1" style="width: 12.666667%"> <label for="products">Qty</label> </div><div class="col-md-y" style=""> <label for="products">Actions</label> </div>*/ /*if($data){ $i=1; foreach($data as $d){ $qty=1; for($qty=1;$qty<=$d->quantity;$qty++){ $content.='<div class="row">'; $content.='<div class="col-md-4">'; $content.='<select id="products" name="products[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<select id="user_name" name="user_name[]" class="form-control tip" style="width:100%;">'; $content.='echo "'.$user_content.'"'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-2">'; $content.='<input type="number" value="1" id="user_name" name="user_name[]" class="form-control tip" style="width:100%;" readonly />'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" id="cutting_unit_com_date" value="'.$d->cutting_start_date.'" name="assign_date[]" class="form-control tip cutting">'; $content.='</div>'; /*$content.='<div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;">'; $content.='<span id="expand_sale_items" name="assign_date[]" class="btn btn-primary btn-xs expand_sale_items">Expand</span>'; $content.='</div>';*/ /*$content.='</div>'; $content.='<div id="expand_content_'.$i++.'" style="padding: 3px 0px 3px 0px;"></div>'; $content.='<div id="expand_content_'.$ec++.'" style="padding: 10px 15px 10px 15px; border: 1px dashed gray; border-radius: 5px; margin: 16px;background: #f1eded;">'; foreach($sale_works_data as $work){ if($work->sale_id==$d->sale_id && $work->product_id==$d->product_id){ $content.='<div class="row"> <div class="col-md-3"> <select id="products" name="products[]" class="form-control tip" style="width:100%;"> <option value="'.$work->product_id.'">'.$work->product_name.'</option> </select> </div> <div class="col-md-3"> <select id="user_name_'.$work->id.'" name="user_name[]" class="form-control tip user_'.$work->product_id.'" style="width:100%;"> '.$user_content.' </select> </div> <div class="col-md-2"> <input type="hidden" id="tec_works_id" value="'.$work->id.'" name="tec_works_id[]" class="form-control tip" style="width:100%;"> <input type="number" value="1" class="form-control tip" style="width:100%;" readonly /> </div> <div class="col-md-3"> <input type="date" id="cutting_unit_com_date" value="'.$work->cutting_assign_date.'" name="assign_date[]" style="padding: 8px;" class="form-control tip today_date date_'.$work->product_id.'"> </div> <div class="col-md-1" style="text-align: center; padding: 5px 0px 0px 5px;"> </div> </div>'; } } $content.='</div>'; $content.='<script> $(document).ready(function(){ $("#expand_content_'.$hec++.'").hide(); $("#expand_sale_items_'.$a++.'").click(function(){ console.log("Expand Working"); $("#expand_content_'.$esi++.'").slideToggle(); return false; }); }); $(function() { $("#user_name_'.$d->id.'").change(function() { alert( $("option:selected", this).text() ); var user_name = $("#user_name_'.$d->id.'").val(); console.log(user_name); $(".user_'.$work->product_id.'").val(user_name); }); $("#date_'.$d->id.'").change(function() { alert( $("option:selected", this).text() ); var date = $("#date_'.$d->id.'").val(); console.log(date); $(".date_'.$work->product_id.'").val(date); }); }); </script>'; } $content.='<style> .form-control { width: 100%; height: 34px; padding: 2px 7px; background-color: #fff; background-image: none; border: 1px solid #ccc; -webkit-box-shadow: inset 0 1px 1px rgb(0 0 0 / 8%); -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s; -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; } </style>'; } }*/ //Cutting Unit Complete Date Section Here public function get_all_sale_items_cutting_date() { $sales_id = $this->input->get('sale_id'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $content='<div class="row"> <div class="col-md-4"> <label for="products">Products</label> </div> <div class="col-md-4"> <label for="products"> Cutting Start Date</label> </div> <div class="col-md-4"> <label for="products"> Cutting Complete Date</label> </div> </div>'; if($data){ foreach($data as $d){ $content.='<div class="row">'; $content.='<div class="col-md-4">'; $content.='<select id="products" name="productsss[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-4">'; $content.='<input type="date" id="cutting_start_date" value="'.$d->cutting_start_date.'" name="cutting_start_date[]" class="form-control tip" style="width:100%;">'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-4">'; $content.='<input type="date" id="cutting_unit_com_date" name="cutting_complete_date[]" class="form-control tip cutting">'; $content.='</div>'; $content.='</div>'; } }else{ $content.='No Data Available'; } echo $content; } //Stitching Unit Assign Section Here public function get_all_sale_items_stitching_date() { $sales_id = $this->input->get('sale_id'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $content='<div class="row"> <div class="col-md-4"> <label for="products">Products</label> </div> <div class="col-md-4"> <label for="products"> Stitching Start Date</label> </div> <div class="col-md-4"> <label for="products"> Stitching Complete Date</label> </div> </div>'; if($data){ foreach($data as $d){ $content.='<div class="row">'; $content.='<div class="col-md-4">'; $content.='<select id="products" name="productss[]" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-4">'; $content.='<input type="date" id="stitching_start_date" value="'.$d->stitching_start_date.'" name="stitching_start_date[]" class="form-control tip" style="width:100%;">'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-4">'; $content.='<input type="date" id="stitching_unit_com_date" name="stitching_complete_date[]" class="form-control tip cutting">'; $content.='</div>'; $content.='</div>'; } }else{ $content.='No Data Available'; } echo $content; } // Append API Ends Here // Append Cutting Report Starts Here public function get_report_cutting_part() { $sales_id = $this->input->get('sale_id'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $content='<div class="row"> <div class="col-md-3"> <label for="products">Products</label> </div> <div class="col-md-3"> <label for="products">Cutting Users</label> </div> <div class="col-md-3"> <label for="products">Start Date</label> </div> <div class="col-md-3"> <label for="products">Complete Date</label> </div> </div>'; if($data){ foreach($data as $d){ $content.='<div class="row">'; $content.='<div class="col-md-3">'; $content.='<select id="products" name="products" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<select id="products" name="users" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->cutting_user.'">'.$d->user_fname.' '.$d->user_lname.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" id="cutting_start_date" value="'.$d->cutting_start_date.'" name="cutting_start_date" class="form-control tip" style="width:100%;">'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" id="cutting_unit_com_date" name="cutting_complete_date" value="'.$d->cutting_complete_date.'" class="form-control tip cutting">'; $content.='</div>'; $content.='</div>'; } }else{ $content.='No Data Available'; } echo $content; } // Append Cutting Report Ends Here //Append Stithcing Report Starts Here public function get_report_stitching_part() { $sales_id = $this->input->get('sale_id'); $data=$this->sales_model->getSaleIemsBySaleID($sales_id); $content='<div class="row"> <div class="col-md-3"> <label for="products">Products</label> </div> <div class="col-md-3"> <label for="products">Stitching Users</label> </div> <div class="col-md-3"> <label for="products">Start Date</label> </div> <div class="col-md-3"> <label for="products">Complete Date</label> </div> </div>'; if($data){ foreach($data as $d){ $content.='<div class="row">'; $content.='<div class="col-md-3">'; $content.='<select id="products" name="products" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->product_id.'">'.$d->product_name.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<select id="products" name="users" class="form-control tip" style="width:100%;">'; $content.='<option value="'.$d->stitching_user.'">'.$d->user_fname.' '.$d->user_lname.'</option>'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" id="cutting_start_date" value="'.$d->stitching_start_date.'" name="cutting_start_date" class="form-control tip" style="width:100%;">'; $content.='</select>'; $content.='</div>'; $content.='<div class="col-md-3">'; $content.='<input type="date" id="cutting_unit_com_date" name="cutting_complete_date" value="'.$d->stitching_complete_date.'" class="form-control tip cutting">'; $content.='</div>'; $content.='</div>'; } }else{ $content.='No Data Available'; } echo $content; } //Append Stithcing Report Ends here }