diff --git a/application/controllers/Corporate.php b/application/controllers/Corporate.php index e26d0ee..4f38ec3 100644 --- a/application/controllers/Corporate.php +++ b/application/controllers/Corporate.php @@ -257,7 +257,8 @@ class Corporate extends CI_Controller { // echo 1; // } - public function get_td_gst_tkts(){ + +public function get_td_gst_tkts(){ $gdid = $this->input->post('gdid'); $fdatas['frec'] = 0; $fdatas['drec'] = 0; @@ -983,6 +984,10 @@ class Corporate extends CI_Controller { $highestColumn = $worksheet->getHighestColumn(); $seterror = 0;$ferror=array(); $pcols = 17;$ttlrows=0; + $remarksColumn = 'R'; // Define the column where you want to add the 'Remarks' + + // Add 'Remarks' as a header in the specified column + $worksheet->setCellValue($remarksColumn . '1', 'Remarks'); for ($row = 1; $row <= $highestRow; $row++) { $gd_inv_type=''; @@ -1134,6 +1139,7 @@ class Corporate extends CI_Controller { // $chk = $this->db->query('select * from gstr2a_data where gd_inv_no = "'.$gd_inv_no.'" and gd_doc_type = "'.$gd_doc_type.'" and gd_inv_type = "'.$gd_inv_type.'"'); if($chk->num_rows()>0){ + $worksheet->setCellValue($remarksColumn . $row, 'Duplicate found'); $inserror++; } @@ -1143,6 +1149,22 @@ class Corporate extends CI_Controller { } } } + // echo $ttlrows; + // echo "="; + // echo $inserror; + // die; + $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); + + $objWriter->save('./uploads/' . $this->session->userdata['recon_sess_i']['u_corporateid'] . '/gstr2a/' . $filename); + + if ($ttlrows == $inserror) { + + + $rdata['status'] = 31; + echo json_encode($rdata); + exit; // Exit the function + } + $ferror = array_values($ferror); @@ -1316,6 +1338,7 @@ class Corporate extends CI_Controller { function p_c1_valid_download($td_tfid){ + // valid download function for bta cta file// $this->load->library('excel'); $this->load->helper('download'); $this->excel->setActiveSheetIndex(0); @@ -1387,10 +1410,12 @@ class Corporate extends CI_Controller { $this->db->join('p_files f','tmc.pc1_pc1fid=f.pf_id','left'); $this->db->where('pc1_pc1fid',$td_tfid); $rec = $this->db->get(); + // print_r($rec);die; $i=1; foreach($rec->result() as $recr){ if($i == 1) $f_name = $recr->pf_file; + // print_r($recr);die; $this->excel->getActiveSheet()->setCellValue('A' . ++$i, $recr->pc1_stmt_date); $this->excel->getActiveSheet()->setCellValue('B' . $i, $recr->pc1_stmt_ref_no); $this->excel->getActiveSheet()->setCellValue('C' . $i, $recr->pc1_customer_ref); @@ -1414,21 +1439,71 @@ class Corporate extends CI_Controller { } $f_name = str_replace('.','-valid.',$f_name); header('Content-Type: application/vnd.ms-excel'); //mime type - header('Content-Disposition: attachment;filename="'.$f_name.'"'); //tell browser what's the file name + header('Content-Disposition: attachment;filename="'.$f_name.'.xls"'); //tell browser what's the file name header('Cache-Control: max-age=0'); //no cache $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5'); ob_end_clean(); ob_start(); $objWriter->save('php://output'); // echo ""; -// exit; - } + // exit; + // } + } + function p_c2_valid_download($td_tfid){ + $this->load->library('excel'); + $this->load->helper('download'); + $this->excel->setActiveSheetIndex(0); + + $this->excel->getActiveSheet()->setTitle('Sheet 1'); + $this->excel->getActiveSheet()->setCellValue('A1', 'STMT REF NO'); + $this->excel->getActiveSheet()->setCellValue('B1', 'INVOICE CRN'); + $this->excel->getActiveSheet()->setCellValue('C1', 'GST INV REF'); + $this->excel->getActiveSheet()->setCellValue('D1', 'UNPAID AMOUNT'); + + + $this->excel->getActiveSheet()->getStyle('A1')->getFont()->setSize(12); + $this->excel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); + $this->excel->getActiveSheet()->getStyle('B1')->getFont()->setSize(12); + $this->excel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true); + $this->excel->getActiveSheet()->getStyle('C1')->getFont()->setSize(12); + $this->excel->getActiveSheet()->getStyle('C1')->getFont()->setBold(true); + $this->excel->getActiveSheet()->getStyle('D1')->getFont()->setSize(12); + $this->excel->getActiveSheet()->getStyle('D1')->getFont()->setBold(true); + + $this->db->from('p_client_upload_2 tmc'); + $this->db->join('p_files f','tmc.pc2_pc2fid=f.pf_id','left'); + $this->db->where('pc2_pc2fid',$td_tfid); + $rec = $this->db->get(); + // print_r($rec);die; + $i=1; + foreach($rec->result() as $recr){ + if($i == 1) + $f_name = $recr->pf_file; + // print_r($recr);die; + $this->excel->getActiveSheet()->setCellValue('A' . ++$i, $recr->pc2_stmt_ref_no); + $this->excel->getActiveSheet()->setCellValue('B' . $i, $recr->pc2_inv_crn); + $this->excel->getActiveSheet()->setCellValue('C' . $i, $recr->pc2_inv_crn_ref_no); + $this->excel->getActiveSheet()->setCellValue('D' . $i, $recr->pc2_unpaid_amt); + } + $f_name = str_replace('.','-valid.',$f_name); + header('Content-Type: application/vnd.ms-excel'); //mime type + header('Content-Disposition: attachment;filename="'.$f_name.'.xls"'); //tell browser what's the file name + header('Cache-Control: max-age=0'); //no cache + $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5'); + ob_end_clean(); + ob_start(); + $objWriter->save('php://output'); +// echo ""; + // exit; + // } + } + function p_tmc_valid_download($td_tfid){ $this->load->library('excel'); $this->load->helper('download'); $this->excel->setActiveSheetIndex(0); - +// print_r($td_tfid);die; $this->excel->getActiveSheet()->setTitle('Sheet 1'); $this->excel->getActiveSheet()->setCellValue('A1', 'TMC NAME'); $this->excel->getActiveSheet()->setCellValue('B1', 'TMC GSTIN NO'); @@ -1483,6 +1558,8 @@ class Corporate extends CI_Controller { $this->excel->getActiveSheet()->setCellValue('AY1', 'GDS PNR'); $this->excel->getActiveSheet()->setCellValue('AZ1', 'TICKETED ON CORP OR RETAIL'); $this->excel->getActiveSheet()->setCellValue('BA1', 'APPROVER NAME/CODE'); + $this->excel->getActiveSheet()->setCellValue('BB1', 'REMARKS'); + $this->excel->getActiveSheet()->getStyle('A1')->getFont()->setSize(12); $this->excel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); @@ -1590,15 +1667,25 @@ class Corporate extends CI_Controller { $this->excel->getActiveSheet()->getStyle('AZ1')->getFont()->setBold(true); $this->excel->getActiveSheet()->getStyle('BA1')->getFont()->setSize(12); $this->excel->getActiveSheet()->getStyle('BA1')->getFont()->setBold(true); + $this->excel->getActiveSheet()->getStyle('BB1')->getFont()->setSize(12); + $this->excel->getActiveSheet()->getStyle('BB1')->getFont()->setBold(true); + $this->db->from('p_tmc_data tmc'); $this->db->join('p_files f','tmc.ptd_id=f.pf_id','left'); $this->db->where('ptd_ptfid',$td_tfid); $rec = $this->db->get(); + // print_r($rec->result()); + // print_r($this->db->last_query()); + // die; $i=1; foreach($rec->result() as $recr){ + + // print_r($recr);die; if($i == 1) $f_name = $recr->pf_file; + + $this->excel->getActiveSheet()->setCellValue('A' . ++$i, $recr->ptd_tmc_name); $this->excel->getActiveSheet()->setCellValue('B' . $i, $recr->ptd_tmc_gstin_no); // $this->excel->getActiveSheet()->setCellValue('B' . $i, date('d-m-Y',strtotime($recr->td_inv_date))); @@ -1653,8 +1740,10 @@ class Corporate extends CI_Controller { $this->excel->getActiveSheet()->setCellValue('AY' . $i, $recr->ptd_gst_pnr); $this->excel->getActiveSheet()->setCellValue('AZ' . $i, $recr->ptd_corp_retail); $this->excel->getActiveSheet()->setCellValue('BA' . $i, $recr->ptd_approver); + $this->excel->getActiveSheet()->setCellValue('BB' . $i, $recr->remarks); } $f_name = str_replace('.','-valid.',$f_name); + header('Content-Type: application/vnd.ms-excel'); //mime type header('Content-Disposition: attachment;filename="'.$f_name.'"'); //tell browser what's the file name header('Cache-Control: max-age=0'); //no cache @@ -1973,6 +2062,7 @@ class Corporate extends CI_Controller { } public function p_d_record_c1(){ + // download option for bta cta valid or raws $data = $this->input->post('id'); $ftype = $this->input->post('type'); @@ -1985,6 +2075,19 @@ class Corporate extends CI_Controller { $this->p_c1_valid_download($data); } } + public function p_d_record_c2(){ + $data = $this->input->post('id'); + $ftype = $this->input->post('type'); + + if($ftype == 'Raw') + { + $this->p_c2_file_download($data); + } + else if($ftype == 'Validated') + { + $this->p_c2_valid_download($data); + } + } public function p_d_record_tmc(){ $data = $this->input->post('id'); @@ -2068,6 +2171,7 @@ class Corporate extends CI_Controller { } public function p_c1_file_download($fid){ + // used for download raw file bta cta// $this->checksess(); $this->load->helper('download'); $fname = $this->corp->get_p_tmc_file($fid); @@ -2078,11 +2182,24 @@ class Corporate extends CI_Controller { else echo 'Invalid request'; } + public function p_c2_file_download($fid){ + $this->checksess(); + $this->load->helper('download'); + $fname = $this->corp->get_p_c2_file($fid); + // print_r($fname);die; + if(file_exists(dirname( dirname( dirname(__FILE__) ) ).'/uploads/'.$this->session->userdata['recon_sess_i']['u_corporateid'].'/p_c2/'.$fname)){ + $pth = file_get_contents(dirname( dirname( dirname(__FILE__) ) ).'/uploads/'.$this->session->userdata['recon_sess_i']['u_corporateid'].'/p_c2/'.$fname); + force_download($fname, $pth); + } + else + echo 'Invalid request'; + } public function p_tmc_file_download($fid){ $this->checksess(); $this->load->helper('download'); - $fname = $this->corp->get_tmc_file($fid); + $fname = $this->corp->get_p_tmc_file_tmc($fid); + // print_r($fname);die; if(file_exists(dirname( dirname( dirname(__FILE__) ) ).'/uploads/'.$this->session->userdata['recon_sess_i']['u_corporateid'].'/p_tmc/'.$fname)){ $pth = file_get_contents(dirname( dirname( dirname(__FILE__) ) ).'/uploads/'.$this->session->userdata['recon_sess_i']['u_corporateid'].'/p_tmc/'.$fname); force_download($fname, $pth); @@ -2369,8 +2486,45 @@ class Corporate extends CI_Controller { $highestColumn = $worksheet->getHighestColumn(); $seterror = 0;$ferror=array(); $pcols = 21;$ttlrows=0; + $encounteredTickets = array(); for ($row = 1; $row <= $highestRow; $row++) { + // Assuming the ticket number is in column index 9 (adjust if needed) + $tktCell = $worksheet->getCellByColumnAndRow(9, $row)->getValue(); + $tktCell = strtoupper(trim($tktCell)); + + + + if (!empty($tktCell)) { + if (in_array($tktCell, $encounteredTickets)) { + // If encountered, get the statement reference number from the first occurrence + $firstOccurrenceRow = array_search($tktCell, $encounteredTickets); + $statement = $worksheet->getCellByColumnAndRow(1, $firstOccurrenceRow)->getValue(); + + // Update the current row in the Excel sheet with the statement reference number + $worksheet->setCellValueByColumnAndRow(20, $row, 'dupe found/' . $statement); + $worksheet->setCellValueByColumnAndRow(15, $row, 'POTENTIAL DUPE/'); + } else { + // If not encountered, add the ticket number to the encountered tickets array + $encounteredTickets[$row] = $tktCell; + } + } + $checkDuplicateQuery = $this->db->query('SELECT * FROM p_client_upload_1 WHERE pc1_ticket_no = "'.$tktCell.'"'); + // print_r($checkDuplicateQuery); + if ($checkDuplicateQuery->num_rows() > 0) { + $duplicateRecords = $checkDuplicateQuery->result(); + // print_r($duplicateRecords); + $statement=$duplicateRecords[0]->pc1_stmt_ref_no; + // print_r($statement); + $worksheet->setCellValueByColumnAndRow(20, $row, 'dupe found/'.$statement.''); + $worksheet->setCellValueByColumnAndRow(15, $row, 'POTENTIAL DUPE'); // Adjust the column index accordingly + } else { + + } + + // Check for duplicate ticket numbers within the file + + if($row == 1){ for($col = 0; $col < $pcols; $col++){ $cell = $worksheet->getCellByColumnAndRow($col, $row); @@ -2400,6 +2554,16 @@ class Corporate extends CI_Controller { $cc = strval($cell); $cc = trim($cc); if($cell != ''){ + // $tktCheck = $this->db->query('SELECT * FROM p_client_upload_1 WHERE pc1_ticket_no = "'.$cell.'"'); + + // if ($tktCheck->num_rows() > 0) { + // // pc1_tkt number exists in the database + // // Update pc1_remarks field instead of inserting a new record + // $updateQuery = 'UPDATE p_client_upload_1 SET pc1_remarks = "Duplicate entry" WHERE pc1_ticket_no = "'.$cell.'"'; + // $this->db->query($updateQuery); + // } else { + + // } $keys .= $labelAry[$col].','; if($col == 1){ $cc = preg_replace('/\s+/', ' ',trim($cc)); @@ -2567,9 +2731,9 @@ class Corporate extends CI_Controller { { $data = array('upload_data' => $this->upload->data()); - $fieldAry = array("TMC NAME","TMC GSTIN NO","SEGMENT","INV DATE","GST INV/CRN NO","GST INV/CRN REF NO","DOCUMENT TYPE","BILLING ENTITYNAME","CUSTOMER GSTIN NO","BILLABLE","BUSINESS UNIT","TRIP CODE","COST CENTRE","BUDGET CODE","P.O NO","LOCATION","DEPARTMENT","EMP ID","BOOKING RCVD FROM","PASSENGER NAME","PASSENGER TYPE","AIRLINE CODE","AIRLINE NAME","TICKET NO","FLIGHTNO","SECTOR","DEP START DATE","ARRVL END DATE","CABINCLASS","FARECLASS","BASIC FARE","K3","IGST","CGST","SGST","MEAL","SEAT","OTHER CHARGES","TKT FARE","SERVICE CHARGES","DISCOUNT","TMC CAN CHARGES","PANALTY","CARD CHARGES","IGST ON SER CHARGES","CGST ON SER CHARGES","SGST ON SER CHARGES","NETPAYABLE","SERVICE TYPE","AIRLINE PNR","GDS PNR"," TICKETED ON CORP OR RETAIL","APPROVER NAME/CODE"); + $fieldAry = array("TMC NAME","TMC GSTIN NO","SEGMENT","INV DATE","GST INV/CRN NO","GST INV/CRN REF NO","DOCUMENT TYPE","BILLING ENTITYNAME","CUSTOMER GSTIN NO","BILLABLE","BUSINESS UNIT","TRIP CODE","COST CENTRE","BUDGET CODE","P.O NO","LOCATION","DEPARTMENT","EMP ID","BOOKING RCVD FROM","PASSENGER NAME","PASSENGER TYPE","AIRLINE CODE","AIRLINE NAME","TICKET NO","FLIGHTNO","SECTOR","DEP START DATE","ARRVL END DATE","CABINCLASS","FARECLASS","BASIC FARE","K3","IGST","CGST","SGST","MEAL","SEAT","OTHER CHARGES","TKT FARE","SERVICE CHARGES","DISCOUNT","TMC CAN CHARGES","PANALTY","CARD CHARGES","IGST ON SER CHARGES","CGST ON SER CHARGES","SGST ON SER CHARGES","NETPAYABLE","SERVICE TYPE","AIRLINE PNR","GDS PNR"," TICKETED ON CORP OR RETAIL","APPROVER NAME/CODE","REMARKS"); - $labelAry = array("ptd_tmc_name","ptd_tmc_gstin_no","ptd_segment","ptd_inv_date","ptd_gst_inv_crn_no","ptd_gst_inv_crn_ref_no","ptd_doc_type","ptd_billing_entity","ptd_customer_gstin_no","ptd_billable","ptd_business_unit","ptd_trip_code","ptd_cost_centre","ptd_budget_code","ptd_po_no","ptd_location","ptd_department","ptd_emp_id","ptd_booking_rcvd_from","ptd_pax_name","ptd_pax_type","ptd_airline_code","ptd_airline_name","ptd_tkt_no","ptd_flight_no","ptd_sector","ptd_dep_start_date","ptd_arr_end_date","ptd_cabinclass","ptd_fareclass","ptd_basic_fare","ptd_k3","ptd_igst","ptd_cgst","ptd_sgst","ptd_meal","ptd_seat","ptd_others","ptd_tkt_fare","ptd_service_charge","ptd_discount","ptd_tmc_can_charge","ptd_penalty","ptd_card_charge","ptd_igst_service_charge","pgd_cgst_service_charge","ptd_sgst_service_charge","ptd_netpayable","ptd_servicetype","ptd_airline_pnr","ptd_gst_pnr","ptd_corp_retail","ptd_approver"); + $labelAry = array("ptd_tmc_name","ptd_tmc_gstin_no","ptd_segment","ptd_inv_date","ptd_gst_inv_crn_no","ptd_gst_inv_crn_ref_no","ptd_doc_type","ptd_billing_entity","ptd_customer_gstin_no","ptd_billable","ptd_business_unit","ptd_trip_code","ptd_cost_centre","ptd_budget_code","ptd_po_no","ptd_location","ptd_department","ptd_emp_id","ptd_booking_rcvd_from","ptd_pax_name","ptd_pax_type","ptd_airline_code","ptd_airline_name","ptd_tkt_no","ptd_flight_no","ptd_sector","ptd_dep_start_date","ptd_arr_end_date","ptd_cabinclass","ptd_fareclass","ptd_basic_fare","ptd_k3","ptd_igst","ptd_cgst","ptd_sgst","ptd_meal","ptd_seat","ptd_others","ptd_tkt_fare","ptd_service_charge","ptd_discount","ptd_tmc_can_charge","ptd_penalty","ptd_card_charge","ptd_igst_service_charge","pgd_cgst_service_charge","ptd_sgst_service_charge","ptd_netpayable","ptd_servicetype","ptd_airline_pnr","ptd_gst_pnr","ptd_corp_retail","ptd_approver","remarks"); $inserror = 0; $this->load->library('excel'); @@ -2581,9 +2745,38 @@ class Corporate extends CI_Controller { $highestRow = (int)$worksheet->getHighestRow(); $highestColumn = $worksheet->getHighestColumn(); $seterror = 0;$ferror=array(); - $pcols = 53;$ttlrows=0; - for ($row = 1; $row <= $highestRow; $row++) - { + $pcols = 54;$ttlrows=0; + // for ($row = 1; $row <= $highestRow; $row++) + // { + $encounteredTickets = array(); +// ................................this for dupe chk.........................../// + for ($row = 1; $row <= $highestRow; $row++) { + $tktCell = $worksheet->getCellByColumnAndRow(23, $row)->getValue(); + $passengerName = $worksheet->getCellByColumnAndRow(19, $row)->getValue(); + + if (!empty($tktCell) && !empty($passengerName)) { + $key = $tktCell . '|' . $passengerName; // Creating a unique key with ticket number and passenger name + + if (in_array($key, $encounteredTickets)) { + $firstOccurrenceRow = array_search($key, $encounteredTickets); + $statement = $worksheet->getCellByColumnAndRow(4, $firstOccurrenceRow)->getValue(); + $worksheet->setCellValueByColumnAndRow(53, $row, 'dupe found/' . $statement); + } else { + $encounteredTickets[$row] = $key; + } + } + + $checkDuplicateQuery = $this->db->query('SELECT * FROM p_tmc_data WHERE ptd_tkt_no = "' . $tktCell . '" AND ptd_pax_name = "'.$passengerName.'"'); + + if ($checkDuplicateQuery->num_rows() > 0) { + $duplicateRecords = $checkDuplicateQuery->result(); + // print_r($duplicateRecords); + $statement = $duplicateRecords[0]->ptd_gst_inv_crn_no; + $worksheet->setCellValueByColumnAndRow(53, $row, 'dupe found/' . $statement); + } + + + if($row == 1){ for($col = 0; $col < $pcols; $col++){ $cell = $worksheet->getCellByColumnAndRow($col, $row); @@ -2823,7 +3016,7 @@ class Corporate extends CI_Controller { if($chk->num_rows()>0){ $inserror++; } - + // store the query/// $insArym[] = 'insert into p_tmc_data_dump ('.substr($keys,0,-1).',ptd_ptfid) values ('.substr($values,0,-1); $insAry[] = 'insert ignore into p_tmc_data ('.substr($keys,0,-1).',ptd_ptfid) values ('.substr($values,0,-1); } @@ -2838,7 +3031,7 @@ class Corporate extends CI_Controller { // $rdata['error'] = $ferror; // echo json_encode($rdata); // exit; - + // insertion in p_filr////// $insdata['pf_corporateid'] = $this->session->userdata['recon_sess_i']['u_corporateid']; $insdata['pf_file'] = $filename; $insdata['pf_type'] = 'tmc'; @@ -2848,16 +3041,17 @@ class Corporate extends CI_Controller { $this->db->insert('p_files',$insdata); $td_tfid = $this->db->insert_id(); $rdata['insref'] = $td_tfid; - + // dummy tmc insertion directly using query(assigned variable) for($c=0;$cdb->query($insArym[$c].',"'.$td_tfid.'")'); + // echo $insArym[$c].',"'.$td_tfid.'")'; // } // catch(Exception $e){ // continue; // } } - +// after checkness if(!empty($ferror)){ $rdata['duprecords'] = 0; @@ -2875,7 +3069,7 @@ class Corporate extends CI_Controller { $reccnt = $highestRow; $inscnt = 0; - +// data insert in main table ater iflktering the duplication for($c=0;$cdb->query($insAry[$c].',"'.$td_tfid.'")'); @@ -3314,7 +3508,7 @@ public function upload_tmc(){ } //change else if($col == 3){ - // print_r($cc); + // print_r($ccinvalidrowsstat); if($cc != "CRN" && $cc != "INV" && $cc != "REISSUE"){ $seterror = 1; $ferror[$row]['column'][] = 'DOC TYPE'; @@ -3395,6 +3589,7 @@ public function upload_tmc(){ } $chk = $this->db->query('select * from tmc_data where td_gst_inv = "'.$td_gst_inv.'"'); + // print_r($chk);die; if($chk->num_rows()>0){ $inserror++; @@ -3408,11 +3603,12 @@ public function upload_tmc(){ } $ferror = array_values($ferror); + $this->log->write_log($ferror); // print_r($ferror); // $rdata['status'] = 0; // $rdata['error'] = $ferror; -// echo json_encode($rdata); -// exit; + echo json_encode($rdata); + exit; $insdata['f_corporateid'] = $this->session->userdata['recon_sess_i']['u_corporateid']; $insdata['f_file'] = $filename; @@ -4048,12 +4244,13 @@ public function upload_tmc(){ } public function drecords($refid){ + //................. this function for addition matched data download/////////////// $this->load->library('excel'); $this->load->helper('download'); $this->excel->setActiveSheetIndex(0); $headers = array("STMT REF NO","UNPAIDAMT","REMARK FOR RECON","PRIMERY REMARK","SECONDARY REMARK","TMC NAME","SEGMENT","INV DATE","GST INV/CRN NO","GST INV/CRN REF NO","DOCUMENT TYPE","BILLING ENTITYNAME","PASSENGER NAME","AIRLINE NAME","TICKET NO","FLIGHTNO","SECTOR","DEP START DATE","NETPAYABLE","TMC GSTIN NO","CUSTOMER GSTIN NO","BILLABLE / NON BILLABLE","BUSINESS UNIT","TRIP CODE","COST CENTRE","BUDGET CODE","P.O NO","LOCATION","DEPARTMENT","EMP ID","BOOKING RCVD FROM","PASSENGER TYPE","AIRLINE CODE","ARRVL END DATE","CABINCLASS","FARECLASS","BASIC FARE","IGST","CGST","SGST","MEAL","SEAT","OTHER CHARGES","TKT FARE","SERVICE CHARGES","DISCOUNT","TMC CAN CHARGES","PANALTY","CARD CHARGES","IGST ON SER CHARGES","CGST ON SER CHARGES","SGST ON SER CHARGES","SERVICE TYPE","AIRLINE PNR","GDS PNR"," TICKETED ON CORP OR RETAIL","APPROVER NAME"); - + // print_r($refid);die; $k=-1; $l=1; $this->excel->getActiveSheet()->setTitle('Sheet 1'); @@ -4233,10 +4430,13 @@ public function upload_tmc(){ $rec = $this->db->query('select * from p_client_upload_1 pc1 inner join p_client_upload_2 pc2 on pc1.pc1_stmt_ref_no=pc2.pc2_inv_crn inner join p_tmc_data ptd on ptd.ptd_gst_inv_crn_no=pc2.pc2_inv_crn where pc2_pc2fid = "'.$refid.'"'); // $rec = $this->db->query('select * from p_client_upload_1 pc1 inner join p_client_upload_2 pc2 on pc1.pc1_stmt_ref_no=pc2.pc2_inv_crn inner join p_tmc_data ptd on ptd.ptd_gst_inv_crn_no=pc2.pc2_inv_crn where ptd_inv_date between "'.$this->input->post('from').'" and "'.$this->input->post('to').'"'); // $this->db->get(); +// print_r($rec->result());die; $i=1; foreach($rec->result() as $recr){ + if($i == 1) $f_name = $recr->pf_file; + $this->excel->getActiveSheet()->setCellValue('A' . ++$i, $recr->pc1_stmt_ref_no); $this->excel->getActiveSheet()->setCellValue('B' . $i, $recr->pc1_unpaid_amt); $this->excel->getActiveSheet()->setCellValue('C' . $i, ''); @@ -4298,13 +4498,16 @@ public function upload_tmc(){ // $f_name = str_replace('.','-valid.',$f_name); $f_name = 'Client download format.xlsx'; header('Content-Type: application/vnd.ms-excel'); //mime type - header('Content-Disposition: attachment;filename="'.$f_name.'"'); //tell browser what's the file name + header('Content-Disposition: attachment;filename="'.$f_name.'.xls"'); //tell browser what's the file name header('Cache-Control: max-age=0'); //no cache $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5'); ob_end_clean(); ob_start(); $objWriter->save('php://output'); - } +// echo ""; + // exit; + // } + } public function proceedinsert_pc1(){ $filerefid = $this->input->post('fileref'); @@ -4475,6 +4678,9 @@ public function upload_tmc(){ $cc = strval($cell); $cc = trim($cc); if($cell != ''){ + + + $keys .= $labelAry[$col].','; if($col == 0){ $cc = preg_replace('/\s+/', ' ',trim($cc)); diff --git a/application/controllers/Tmc.php b/application/controllers/Tmc.php index a104442..9078824 100644 --- a/application/controllers/Tmc.php +++ b/application/controllers/Tmc.php @@ -1,29 +1,30 @@ - * @see https://codeigniter.com/user_guide/general/urls.html - */ + /** + * Index Page for this controller. + * + * Maps to the following URL + * http://example.com/index.php/welcome + * - or - + * http://example.com/index.php/welcome/index + * - or - + * Since this controller is set as the default controller in + * config/routes.php, it's displayed at http://example.com/ + * + * So any other public methods not prefixed with an underscore will + * map to /index.php/welcome/ + * @see https://codeigniter.com/user_guide/general/urls.html + */ function __construct() - { - parent::__construct(); - $this->load->model('Tmc_model','tmc'); - //force_ssl(); + { + parent::__construct(); + $this->load->model('Tmc_model', 'tmc'); + //force_ssl(); $total = $this->tmc->get_tmc_inv_count(); $received = $this->tmc->get_tmc_inv_received_count(); $not_received = $this->tmc->get_tmc_inv_not_received_count(); @@ -33,75 +34,80 @@ class Tmc extends CI_Controller { $this->session->set_flashdata('received', $received); $this->session->set_flashdata('not_received', $not_received); $this->session->set_flashdata('par_received', $par_received); - } - - public function index(){ + } + + public function index() + { redirect('tmc/dashboard'); } - public function dashboard(){ + public function dashboard() + { $this->checksess(); $this->load->view('tmc/dashboard'); } - public function checksess(){ - if(isset($this->session->userdata['recon_sess_i']['u_role'])){ - if($this->session->userdata['recon_sess_i']['u_role'] == 'admin') + public function checksess() + { + if (isset($this->session->userdata['recon_sess_i']['u_role'])) { + if ($this->session->userdata['recon_sess_i']['u_role'] == 'admin') redirect('admin'); - } - else + } else redirect('login'); } public function tmc() - { + { $this->checksess(); - $monthAllAryLabel = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); - $yearAry = array(); $monthAry = array(); - $m = date('m',time()); - for($i=0;$i<$m;$i++){ + $monthAllAryLabel = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); + $yearAry = array(); + $monthAry = array(); + $m = date('m', time()); + for ($i = 0; $i < $m; $i++) { $monthAry[] = $monthAllAryLabel[$i]; } - for($i=0;$i<4;$i++){ - $yearAry[] = date('Y',time()) - $i; + for ($i = 0; $i < 4; $i++) { + $yearAry[] = date('Y', time()) - $i; } $data['years'] = $yearAry; $data['month'] = $monthAry; $data['allmonth'] = $monthAllAryLabel; - $data['curYear'] = date('Y',time()); - - $this->load->view('tmc/tmc',$data); - } - public function tmc_recon(){ + $data['curYear'] = date('Y', time()); + + $this->load->view('tmc/tmc', $data); + } + public function tmc_recon() + { $this->checksess(); // $data['gstno_list'] = $this->intl->get_gstno(); // $data['gstno_list'] = array(); $this->load->view('tmc/tmc_recon'); } - public function gen_tmc_recon(){ + public function gen_tmc_recon() + { $this->checksess(); $fromdate = $this->input->post('from'); - + $todate = $this->input->post('to'); -// if($gid) -// $res = $this->db->query('select *,am_code as supplier_code from gstr2a_data gd left join (select *,group_concat(td_gst_inv) g_td_gst_inv,sum(td_net) td_net_ref from tmc_data where td_show_status = 1 group by td_tkt) td on gd.gd_id=td.td_gstr2a_match_id left join airline_master am on am.am_name=gd.gd_supplier_type where gd_id = "'.$gid.'"'); -// else - $res = $this->db->query('select * from tmc_data td left join (select *,sum(ti_amount) s_amt from airline_invoice group by ti_tdid) ti on ti.ti_tdid = td.td_id where td_inv_date between "'.$fromdate.'" and "'.$todate.'" order by td_id desc'); + // if($gid) + // $res = $this->db->query('select *,am_code as supplier_code from gstr2a_data gd left join (select *,group_concat(td_gst_inv) g_td_gst_inv,sum(td_net) td_net_ref from tmc_data where td_show_status = 1 group by td_tkt) td on gd.gd_id=td.td_gstr2a_match_id left join airline_master am on am.am_name=gd.gd_supplier_type where gd_id = "'.$gid.'"'); + // else + $res = $this->db->query('select * from tmc_data td left join (select *,sum(ti_amount) s_amt from airline_invoice group by ti_tdid) ti on ti.ti_tdid = td.td_id where td_inv_date between "' . $fromdate . '" and "' . $todate . '" order by td_id desc'); $fres['data'] = array(); $res2 = new stdClass(); - foreach($res->result() as $res1){ - if($res1->ti_tdid == '') + foreach ($res->result() as $res1) { + if ($res1->ti_tdid == '') $res1->d_remarks = 'Invoice not received'; - else{ + else { $payremarks = ($res1->s_amt * 100) / $res1->td_tkt_fare; - if($payremarks > 70) + if ($payremarks > 70) $res1->d_remarks = 'Invoice Received'; else $res1->d_remarks = 'Parital Invoice Received'; } $res1->tkt_like = $res1->td_tkt; - $res1->td_inv_date = date('d-m-Y',strtotime($res1->td_inv_date)); + $res1->td_inv_date = date('d-m-Y', strtotime($res1->td_inv_date)); $fres['data'][] = $res1; } echo json_encode($fres); @@ -113,283 +119,305 @@ class Tmc extends CI_Controller { - - public function upload_tmc(){ + public function upload_tmc() + { $this->checksess(); - - $monthAllAryLabel = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); - + + $monthAllAryLabel = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); + $insdata = $this->input->post('usr'); $ext = pathinfo($_FILES['tmc_file']['name'], PATHINFO_EXTENSION); - $filename = 'TMC-'.str_replace(' ','_',$insdata['f_agent']).'-'.$monthAllAryLabel[$insdata['f_month']-1].'-'.$insdata['f_year'].'-'.time().'.'.$ext; - + $filename = 'TMC-' . str_replace(' ', '_', $insdata['f_agent']) . '-' . $monthAllAryLabel[$insdata['f_month'] - 1] . '-' . $insdata['f_year'] . '-' . time() . '.' . $ext; + $conchk['f_month'] = $insdata['f_month']; $conchk['f_year'] = $insdata['f_year']; $conchk['f_agent'] = $insdata['f_agent']; $conchk['f_corporateid'] = $this->session->userdata['recon_sess_i']['u_corporateid']; -// $entryres = $this->db->get_where('files',$conchk); -// if($entryres->num_rows()>0){ -// $rdata['status'] = 31; echo json_encode($rdata); exit; -// } - - if(!is_dir(dirname( dirname( dirname(__FILE__) ) ).'/uploads/'.$this->session->userdata['recon_sess_i']['u_corporateid'])) { - mkdir(dirname( dirname( dirname(__FILE__) ) ).'/uploads/'.$this->session->userdata['recon_sess_i']['u_corporateid']); - mkdir(dirname( dirname( dirname(__FILE__) ) ).'/uploads/'.$this->session->userdata['recon_sess_i']['u_corporateid'].'/gstr2a'); - mkdir(dirname( dirname( dirname(__FILE__) ) ).'/uploads/'.$this->session->userdata['recon_sess_i']['u_corporateid'].'/tmc'); + // $entryres = $this->db->get_where('files',$conchk); + // if($entryres->num_rows()>0){ + // $rdata['status'] = 31; echo json_encode($rdata); exit; + // }cc + + if (!is_dir(dirname(dirname(dirname(__FILE__))) . '/uploads/' . $this->session->userdata['recon_sess_i']['u_corporateid'])) { + mkdir(dirname(dirname(dirname(__FILE__))) . '/uploads/' . $this->session->userdata['recon_sess_i']['u_corporateid']); + mkdir(dirname(dirname(dirname(__FILE__))) . '/uploads/' . $this->session->userdata['recon_sess_i']['u_corporateid'] . '/gstr2a'); + mkdir(dirname(dirname(dirname(__FILE__))) . '/uploads/' . $this->session->userdata['recon_sess_i']['u_corporateid'] . '/tmc'); } - + $config['file_name'] = $filename; - $config['upload_path'] = './uploads/'.$this->session->userdata['recon_sess_i']['u_corporateid'].'/tmc/'; + $config['upload_path'] = './uploads/' . $this->session->userdata['recon_sess_i']['u_corporateid'] . '/tmc/'; $config['allowed_types'] = '*'; $config['max_size'] = 3000; $this->load->library('upload', $config); - - if(!$this->upload->do_upload('tmc_file')) - { + + if (!$this->upload->do_upload('tmc_file')) { $error = array('error' => $this->upload->display_errors()); echo $error['error']; - } - else - { + } else { $data = array('upload_data' => $this->upload->data()); - - $fieldAry = array("SEGMENT","INV DATE ","GST INVOICE NO","DOC TYPE","BILLING ENTITY","EMP ID","PASSENGER NAME","CARRIER NAME","TICKET NO","FLIGHTNO","SECTOR","DEPDATE &TIME","CABINCLASS","TOTAL TKT FARE","NETPAYABLE","AIR TAX DESCRIPTION","AIRLINE PNR","GDS PNR"); - - $labelAry = array('td_segment','td_inv_date','td_gst_inv','td_doc_type','td_billing_entity','td_empid','td_pax','td_carrier','td_tkt','td_flight','td_sector','td_departure','td_cabin_class','td_tkt_fare','td_net','td_air_tax','td_airline_pnr','td_pnr'); - + + $fieldAry = array("SEGMENT", "INV DATE ", "GST INVOICE NO", "DOC TYPE", "BILLING ENTITY", "EMP ID", "PASSENGER NAME", "CARRIER NAME", "TICKET NO", "FLIGHTNO", "SECTOR", "DEPDATE &TIME", "CABINCLASS", "TOTAL TKT FARE", "NETPAYABLE", "AIR TAX DESCRIPTION", "AIRLINE PNR", "GDS PNR"); + + $labelAry = array('td_segment', 'td_inv_date', 'td_gst_inv', 'td_doc_type', 'td_billing_entity', 'td_empid', 'td_pax', 'td_carrier', 'td_tkt', 'td_flight', 'td_sector', 'td_departure', 'td_cabin_class', 'td_tkt_fare', 'td_net', 'td_air_tax', 'td_airline_pnr', 'td_pnr'); + $inserror = 0; $this->load->library('excel'); //read file from path - $filepath = './uploads/'.$this->session->userdata['recon_sess_i']['u_corporateid'].'/tmc/'.$filename; + $filepath = './uploads/' . $this->session->userdata['recon_sess_i']['u_corporateid'] . '/tmc/' . $filename; $objPHPExcel = PHPExcel_IOFactory::load($filepath); $worksheet = $objPHPExcel->getActiveSheet(); $highestRow = (int)$worksheet->getHighestRow(); $highestColumn = $worksheet->getHighestColumn(); - $seterror = 0;$ferror=array(); - $pcols = 18;$ttlrows=0; - for ($row = 1; $row <= $highestRow; $row++) - { - if($row == 1){ - for($col = 0; $col < $pcols; $col++){ + // echo $highestColumn; + // echo $highestRow; + // die; + $seterror = 0; + $ferror = array(); + $pcols = 18; + $ttlrows = 0; + $validRows = 0; + // $no_of_records=0; + $inserror = 0; + $remarksColumn = 'S'; // Define the column where you want to add the 'Remarks' + +// Add 'Remarks' as a header in the specified column +$worksheet->setCellValue($remarksColumn . '1', 'Remarks'); + + for ($row = 1; $row <= $highestRow; $row++) { + if ($row == 1) { + for ($col = 0; $col < $pcols; $col++) { $cell = $worksheet->getCellByColumnAndRow($col, $row); $cellref = $cell; $headingary[] = strval($cell); } - } - else{ - if($fieldAry != $headingary){ -// print_r($fieldAry); -// echo ''; -// print_r($headingary); + } else { + $ttlrows++; + if ($fieldAry != $headingary) { + // print_r($fieldAry); + // echo ''; + // print_r($headingary); $rdata['status'] = 13; $ferror['column'] = 'Column mismatch.'; $rdata['error'] = $ferror; - echo json_encode($rdata); exit; - } - else{ - $ttlrows++; + echo json_encode($rdata); + exit; + } else { + $chkcell = $worksheet->getCellByColumnAndRow(1, $row); - if($chkcell != ''){ - $keys='';$values=''; - for($col = 0; $col < $pcols; $col++) - { + if ($chkcell != '') { + $keys = ''; + $values = ''; + for ($col = 0; $col < $pcols; $col++) { + $cell = $worksheet->getCellByColumnAndRow($col, $row); $cell = strtoupper($cell); $cc = strval($cell); $cc = trim($cc); - if($cell != ''){ - $keys .= $labelAry[$col].','; - if($col == 0){ - $cc = preg_replace('/\s+/', '',trim($cc)); - if($cc != 'DOMESTIC' && $cc != 'INTERNATIONAL' && $cc != 'HOTEL' && $cc != 'MISC'){ - $seterror = 1; -// $ferror[$row]['column'][] = 'GST INVOICE NO'; - $ferror[$row]['column'][] = 0; - $ferror[$row]['row'] = $row; - } - $values .= '"'.$cc.'",'; - } - else if($col == 1){ - if(is_numeric($cc)){ - $unix_date = ($cc - 25569) * 86400; - $excel_date = 25569 + ($unix_date / 86400); - $unix_date = ($excel_date - 25569) * 86400; - $fdate = gmdate("Y-m-d", $unix_date); - $values .= '"'.$fdate.'",'; - } - else{ - $cc = str_replace('.',"-",$cc); - $cc = str_replace('/',"-",$cc); - $dary = explode('-',$cc); - if($dary[0]>31 || $dary[1]>12 || $dary[2]<1900 || $dary[2]>2021){ -// if(!isset($ferror['INV DATE'])) -// $ferror['INV DATE'] = $row.'-INV DATE'; -// $ferror[$row]['column'][] = 'INV DATE'; - $ferror[$row]['column'][] = 1; + + if ($cell != '') { + $keys .= $labelAry[$col] . ','; + + if ($col == 0) { + $cc = preg_replace('/\s+/', '', trim($cc)); + if ($cc != 'DOMESTIC' && $cc != 'INTERNATIONAL' && $cc != 'HOTEL' && $cc != 'MISC') { + $seterror = 1; + // $ferror[$row]['column'][] = 'GST INVOICE NO'; + $ferror[$row]['column'][] = 0; $ferror[$row]['row'] = $row; - $values .= '"'.$cc.'",'; } - else{ - $ffdate = $dary[2].'-'.$dary[1].'-'.$dary[0]; - $cc = $ffdate; - $values .= '"'.$cc.'",'; + $values .= '"' . $cc . '",'; + } else if ($col == 1) { + if (is_numeric($cc)) { + $unix_date = ($cc - 25569) * 86400; + $excel_date = 25569 + ($unix_date / 86400); + $unix_date = ($excel_date - 25569) * 86400; + $fdate = gmdate("Y-m-d", $unix_date); + $values .= '"' . $fdate . '",'; + } else { + $cc = str_replace('.', "-", $cc); + $cc = str_replace('/', "-", $cc); + $dary = explode('-', $cc); + if ($dary[0] > 31 || $dary[1] > 12 || $dary[2] < 1900 || $dary[2] > 2021) { + // if(!isset($ferror['INV DATE'])) + // $ferror['INV DATE'] = $row.'-INV DATE'; + // $ferror[$row]['column'][] = 'INV DATE'; + $ferror[$row]['column'][] = 1; + $ferror[$row]['row'] = $row; + $values .= '"' . $cc . '",'; + } else { + $ffdate = $dary[2] . '-' . $dary[1] . '-' . $dary[0]; + $cc = $ffdate; + $values .= '"' . $cc . '",'; + } } + } else if ($col == 2) { + $cc = preg_replace('/\s+/', '', trim($cc)); + if (!preg_match("@^[a-zA-Z0-9\-\s/.]+$@", $cc)) { + $seterror = 1; + $ferror[$row]['column'][] = 'GST INVOICE NO'; + $ferror[$row]['row'] = $row; + } + // else + $td_gst_inv = $cc; + $values .= '"' . $cc . '",'; } - } - else if($col == 2){ - $cc = preg_replace('/\s+/', '',trim($cc)); - if(!preg_match("@^[a-zA-Z0-9\-\s/.]+$@",$cc)){ - $seterror = 1; - $ferror[$row]['column'][] = 'GST INVOICE NO'; - $ferror[$row]['row'] = $row; + //change + else if ($col == 3) { + // print_r($cc); + if ($cc != "CRN" && $cc != "INV" && $cc != "REISSUE") { + $seterror = 1; + $ferror[$row]['column'][] = 'DOC TYPE'; + $ferror[$row]['row'] = $row; + } + $values .= '"' . $cc . '",'; + } else if ($col == 6) { + if (!preg_match("@^[a-zA-Z\s.]+$@", $cc)) { + $seterror = 1; + $ferror[$row]['column'][] = '6-7'; + $ferror[$row]['row'] = $row; + } + $values .= '"' . $cc . '",'; } -// else - $td_gst_inv = $cc; - $values .= '"'.$cc.'",'; - } - //change - else if($col == 3){ - // print_r($cc); - if($cc != "CRN" && $cc != "INV" && $cc != "REISSUE"){ - $seterror = 1; - $ferror[$row]['column'][] = 'DOC TYPE'; - $ferror[$row]['row'] = $row; + //CHANGE + else if ($col == 7) { + if (!preg_match("@^[a-zA-Z\s0-9.]+$@", $cc)) { + $seterror = 1; + $ferror[$row]['column'][] = '6-7'; + $ferror[$row]['row'] = $row; + } + $values .= '"' . $cc . '",'; + } else if ($col == 12) { + if (!preg_match("@^[a-zA-Z]+$@", $cc)) { + $seterror = 1; + $ferror[$row]['column'][] = '12'; + $ferror[$row]['row'] = $row; + } + $values .= '"' . $cc . '",'; + } else if ($col == 16 || $col == 17) { + if (!preg_match("@^[a-zA-Z0-9]+$@", $cc)) { + $seterror = 1; + $ferror[$row]['column'][] = '16-17'; + $ferror[$row]['row'] = $row; + } + $values .= '"' . $cc . '",'; + } else if ($col == 8) { + if (!preg_match("/[a-zA-Z0-9 ]/", $cc)) { + $seterror = 1; + $ferror[$row]['column'][] = '16-17'; + $ferror[$row]['row'] = $row; + } + $values .= '"' . $cc . '",'; + } else if ($col == 13 /* || $col == 14 */) { + if (!preg_match("@^[0-9\-]+$@", $cc)) { + $seterror = 1; + $ferror[$row]['column'][] = '13-14'; + $ferror[$row]['row'] = $row; + } + $values .= '"' . $cc . '",'; } - $values .= '"'.$cc.'",'; - } - else if($col == 6){ - if(!preg_match("@^[a-zA-Z\s]+$@",$cc)){ - $seterror = 1; - $ferror[$row]['column'][] = '6-7'; - $ferror[$row]['row'] = $row; + //change + else if ($col == 14) { + if (!preg_match("@^[0-9\.-]+$@", $cc)) { + $seterror = 1; + $ferror[$row]['column'][] = '13-14'; + $ferror[$row]['row'] = $row; + } + $values .= '"' . $cc . '",'; + } else if ($col == 11) { + if (!preg_match("@^[0-9\-/:\s]+$@", $cc)) { + $seterror = 1; + $ferror[$row]['column'][] = '11'; + $ferror[$row]['row'] = $row; + } + $values .= '"' . $cc . '",'; + } else { + $values .= '"' . $cell . '",'; } - $values .= '"'.$cc.'",'; - } - //CHANGE - else if($col == 7){ - if(!preg_match("@^[a-zA-Z\s0-9]+$@",$cc)){ - $seterror = 1; - $ferror[$row]['column'][] = '6-7'; - $ferror[$row]['row'] = $row; - } - $values .= '"'.$cc.'",'; - } - else if($col == 12){ - if(!preg_match("@^[a-zA-Z]+$@",$cc)){ - $seterror = 1; - $ferror[$row]['column'][] = '12'; - $ferror[$row]['row'] = $row; - } - $values .= '"'.$cc.'",'; - } - else if($col == 16 || $col == 17){ - if(!preg_match("@^[a-zA-Z0-9]+$@",$cc)){ - $seterror = 1; - $ferror[$row]['column'][] = '16-17'; - $ferror[$row]['row'] = $row; - } - $values .= '"'.$cc.'",'; - } - else if($col == 8){ - if(!preg_match("/[a-zA-Z0-9 ]/",$cc)){ - $seterror = 1; - $ferror[$row]['column'][] = '16-17'; - $ferror[$row]['row'] = $row; - } - $values .= '"'.$cc.'",'; - } - else if($col == 13 /* || $col == 14 */){ - if(!preg_match("@^[0-9\-]+$@",$cc)){ - $seterror = 1; - $ferror[$row]['column'][] = '13-14'; - $ferror[$row]['row'] = $row; - } - $values .= '"'.$cc.'",'; - } - //change - else if($col == 14){ - if(!preg_match("@^[0-9\.-]+$@",$cc)){ - $seterror = 1; - $ferror[$row]['column'][] = '13-14'; - $ferror[$row]['row'] = $row; - } - $values .= '"'.$cc.'",'; - } - else if($col == 11){ - if(!preg_match("@^[0-9\-/:\s]+$@",$cc)){ - $seterror = 1; - $ferror[$row]['column'][] = '11'; - $ferror[$row]['row'] = $row; - } - $values .= '"'.$cc.'",'; - } - else{ - $values .= '"'.$cell.'",'; } } - } - - $chk = $this->db->query('select * from tmc_data where td_gst_inv = "'.$td_gst_inv.'"'); - - if($chk->num_rows()>0){ + + $chk = $this->db->query('select * from tmc_data where td_gst_inv = "' . $td_gst_inv . '"'); + + if ($chk->num_rows() > 0) { + $worksheet->setCellValue($remarksColumn . $row, 'Duplicate found'); // Assuming 'Z' is an empty column for remarks $inserror++; } -// print_r($ferror); - $insArym[] = 'insert into tmc_data_dump ('.substr($keys,0,-1).',td_tfid) values ('.substr($values,0,-1); - $insAry[] = 'insert ignore into tmc_data ('.substr($keys,0,-1).',td_tfid) values ('.substr($values,0,-1); + + + // print_r($ferror); + $insArym[] = 'insert into tmc_data_dump (' . substr($keys, 0, -1) . ',td_tfid) values (' . substr($values, 0, -1); + $insAry[] = 'insert ignore into tmc_data (' . substr($keys, 0, -1) . ',td_tfid) values (' . substr($values, 0, -1); } } } } - + $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); +$objWriter->save('./uploads/' . $this->session->userdata['recon_sess_i']['u_corporateid'] . '/tmc/' . $filename); + // echo $ttlrows; + // echo"breAK"; + // echo $inserror; + // die; + // $tt + if ($ttlrows == $inserror) { + + + $rdata['status'] = 31; + echo json_encode($rdata); + exit; // Exit the function + } + + + + + $ferror = array_values($ferror); -// print_r($ferror); -// $rdata['status'] = 0; -// $rdata['error'] = $ferror; -// echo json_encode($rdata); -// exit; - + // print_r($ferror); + // $rdata['status'] = 0; + // $rdata['error'] = $ferror; + // echo json_encode($rdata); + // exit; + $insdata['f_corporateid'] = $this->session->userdata['recon_sess_i']['u_corporateid']; $insdata['f_file'] = $filename; $insdata['f_type'] = 'tmc'; $insdata['f_status'] = 'Initiated'; $insdata['f_uploadedby'] = $this->session->userdata['recon_sess_i']['u_id']; - $insdata['f_uploadedat'] = date('Y-m-d H:i:s',time()); + $insdata['f_uploadedat'] = date('Y-m-d H:i:s', time()); if (!$this->input->post('condition_check')) { - $this->db->insert('files',$insdata); + $this->db->insert('files', $insdata); $td_tfid = $this->db->insert_id(); $rdata['insref'] = $td_tfid; - } - else{ + } else { // $this->db->insert('files',$insdata); // $td_tfid = $this->db->insert_id(); $td_tfid = $this->input->post('td_tfid'); $rdata['insref'] = $this->input->post('td_tfid'); } - - for($c=0;$cdb->query($insArym[$c].',"'.$td_tfid.'")'); -// } -// catch(Exception $e){ -// continue; -// } + + for ($c = 0; $c < count($insArym); $c++) { + // try{ + $this->db->query($insArym[$c] . ',"' . $td_tfid . '")'); + // } + // catch(Exception $e){ + // continue; + // } } - if(!empty($ferror)){ - + if (!empty($ferror)) { + $rdata['duprecords'] = 0; $rdata['status'] = 0; -// $rdata['error'] = $ferror; - - if($inserror != 0) + // $rdata['error'] = $ferror; + + if ($inserror != 0) $rdata['duprecords'] = $inserror; $rdata['ttlrows'] = $ttlrows; -// $rdata['error'] = $ferror; + // $rdata['error'] = $ferror; $rdata['invalidrows'] = count($ferror); // if (!$this->input->post('condition_check')) { - echo json_encode($rdata); exit; + echo json_encode($rdata); + exit; // } // else{ // $message = "Invalid Records"; @@ -398,38 +426,36 @@ class Tmc extends CI_Controller { // window.open("", "_self").close(); // '; // } - } - else{ - + } else { + $reccnt = $highestRow; $inscnt = 0; - for($c=0;$cdb->query($insAry[$c].',"'.$td_tfid.'")'); - if($this->db->affected_rows()) + $this->db->query($insAry[$c] . ',"' . $td_tfid . '")'); + if ($this->db->affected_rows()) $inscnt++; - } - catch(Exception $e){ + } catch (Exception $e) { continue; } } - $datequery = $this->db->query('select min(td_inv_date) mindate, max(td_inv_date) maxdate from tmc_data where td_tfid = '.$td_tfid); + $datequery = $this->db->query('select min(td_inv_date) mindate, max(td_inv_date) maxdate from tmc_data where td_tfid = ' . $td_tfid); $dateAry = array(); - foreach($datequery->result() as $dateq){ + foreach ($datequery->result() as $dateq) { $dateCon['f_id'] = $td_tfid; $dateAry['f_min_date'] = $dateq->mindate; $dateAry['f_max_date'] = $dateq->maxdate; } $this->db->where($dateCon); - $this->db->update('files',$dateAry); + $this->db->update('files', $dateAry); $rdata['status'] = 1; $rdata['added_records'] = $inscnt; // if (!$this->input->post('condition_check')) { - echo json_encode($rdata); + echo json_encode($rdata); // } // else{ // $message = "Data Uploaded"; @@ -442,7 +468,8 @@ class Tmc extends CI_Controller { } } - public function gen_tmc_datewise_data(){ + public function gen_tmc_datewise_data() + { $this->checksess(); $date = $this->input->post('date'); $arr = array(); @@ -455,27 +482,32 @@ class Tmc extends CI_Controller { foreach ($date as $key => $value) { if ($key < count($date) - 1) { $inc = $key + 1; - $total = $this->tmc->total_count($date[$key] , $date[$inc]); - $received = $this->tmc->get_inv_rec_1($date[$key] , $date[$inc]); - $par_received = $this->tmc->get_inv_rec_2($date[$key] , $date[$inc]); - $not_received = $this->tmc->not_received_count($date[$key] , $date[$inc]); - array_push($arr , $received);array_push($arr1 , $par_received); - array_push($arr2 , $total);array_push($arr3 , $not_received); - } + $total = $this->tmc->total_count($date[$key], $date[$inc]); + $received = $this->tmc->get_inv_rec_1($date[$key], $date[$inc]); + $par_received = $this->tmc->get_inv_rec_2($date[$key], $date[$inc]); + $not_received = $this->tmc->not_received_count($date[$key], $date[$inc]); + array_push($arr, $received); + array_push($arr1, $par_received); + array_push($arr2, $total); + array_push($arr3, $not_received); + } } - array_push($c , array_sum($arr));array_push($c1 , array_sum($arr3)); - $data = array('received' => $arr , 'par_received' => $arr1 , 'total' => $arr2 , 'not_received' => $arr3 , 'c' => $c , 'c1' => $c1); - + array_push($c, array_sum($arr)); + array_push($c1, array_sum($arr3)); + $data = array('received' => $arr, 'par_received' => $arr1, 'total' => $arr2, 'not_received' => $arr3, 'c' => $c, 'c1' => $c1); + echo json_encode($data); } - public function delete_tmc(){ + + public function delete_tmc() + { $update_data['is_active'] = 0; $this->db->where('f_id', $this->input->post('id')); - $data = $this->db->update('files',$update_data); + $data = $this->db->update('files', $update_data); if ($data) { $this->db->where('td_tfid', $this->input->post('id')); - $data1 = $this->db->update('tmc_data',$update_data); + $data1 = $this->db->update('tmc_data', $update_data); if ($data1) { echo 1; } else { @@ -484,28 +516,29 @@ class Tmc extends CI_Controller { } else { echo 0; } - } - public function delete_tmc_recon(){ + public function delete_tmc_recon() + { $update_data['is_active'] = 0; $this->db->where('td_id', $this->input->post('id')); - $data = $this->db->update('tmc_data',$update_data); + $data = $this->db->update('tmc_data', $update_data); if ($data) { echo 1; } else { echo 0; } - } - public function delete_gst2ra(){ + public function delete_gst2ra() + { $update_data['is_active'] = 0; $this->db->where('f_id', $this->input->post('id')); - $data = $this->db->update('files',$update_data); + $data = $this->db->update('files', $update_data); if ($data) { $this->db->where('gd_gid', $this->input->post('id')); - $data1 = $this->db->update('gstr2a_data',$update_data); + $data1 = $this->db->update('gstr2a_data', $update_data); + if ($data1) { echo 1; } else { @@ -514,19 +547,20 @@ class Tmc extends CI_Controller { } else { echo 0; } - } - public function delete_gst2ra_recon(){ + public function delete_gst2ra_recon() + { $update_data['is_active'] = 0; + $this->db->where('gd_id', $this->input->post('id')); - $data = $this->db->update('gstr2a_data',$update_data); + $id= $this->input->post('id'); + $data = $this->db->update('gstr2a_data', $update_data); + if ($data) { echo 1; } else { echo 0; } - } } - diff --git a/application/controllers/recon.code-workspace b/application/controllers/recon.code-workspace index 407c760..926492b 100644 --- a/application/controllers/recon.code-workspace +++ b/application/controllers/recon.code-workspace @@ -2,6 +2,9 @@ "folders": [ { "path": "../.." + }, + { + "path": "../../../../../xamp1/htdocs/Minton_v5.0.0" } ], "settings": {} diff --git a/application/models/Corporate_model.php b/application/models/Corporate_model.php index 9430eac..75269d3 100644 --- a/application/models/Corporate_model.php +++ b/application/models/Corporate_model.php @@ -80,11 +80,27 @@ class Corporate_model extends CI_Model { } function get_p_tmc_file($fid){ + // used to get the file id of BTA/CTA// $con['pf_type'] = 'c1'; $con['pf_corporateid'] = $this->session->userdata['recon_sess_i']['u_corporateid']; $con['pf_id'] = $fid; return $this->db->get_where('p_files',$con)->row('pf_file'); } + function get_p_tmc_file_tmc($fid){ + // used to get the file id of PTmc// + $con['pf_type'] = 'tmc'; + $con['pf_corporateid'] = $this->session->userdata['recon_sess_i']['u_corporateid']; + $con['pf_id'] = $fid; + return $this->db->get_where('p_files',$con)->row('pf_file'); + } + function get_p_c2_file($fid){ + // used to get the file id of corporate (p_c2)// + $con['pf_type'] = 'c2'; + $con['pf_corporateid'] = $this->session->userdata['recon_sess_i']['u_corporateid']; + $con['pf_id'] = $fid; + return $this->db->get_where('p_files',$con)->row('pf_file'); + } + function get_gstno($gn_id = null,$isactive = null){ if($gn_id) diff --git a/application/views/corporate/airlineinvoice.php b/application/views/corporate/airlineinvoice.php index f682c1d..c112fdc 100644 --- a/application/views/corporate/airlineinvoice.php +++ b/application/views/corporate/airlineinvoice.php @@ -1,43 +1,30 @@ - - - AIRLINE INVOICE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + /* Style the container for the table with a fixed header */ + /* Style the container for the table with a fixed header */ - - - - - - - - - + + + + + - - - - - - - - - AIRLINE INVOICE - - - Files - AIRLINE INVOICE - - - - - - - - - - - - - - - - + + + + + + AIRLINE INVOICE + + + + Files + + AIRLINE INVOICE + + + + + + + + + + + + AIRLINE INVOICE + + - - - - - - - - - - - - S.NO - INVOICE id + + + + + + + Select Column to Display + + × + + + + Select Column: + + PAX NAME PNR + TICKET NO VENDOR - VENDOR GST - RECIPIENT - RECIPIENT GST - INVOICE NUMBER - INVOICE DATE - HSN - TAXABLE VALUE - CGST VALUE - CGST RATE (₹) - SGST VALUE (₹) - SGST RATE(₹) - IGST VALUE - IGST RATE - TOTAL INVOICE VALUE - TOTAL VALUE - STATUS - TICKET TYPE - AIRLINE FILE NAME - EXTRACTION DATE - BATCH ID - - + VENDOR GST + RECIPIENT + RECIPIENT GST + INVOICE NUMBER + INVOICE DATE + HSN + TAXABLE VALUE + CGST VALUE + CGST RATE + SGST VALUE + SGST RATE + IGST VALUE + IGST RATE + TOTAL INVOICE VALUE + TOTAL VALUE + STATUS + TICKET TYPE + AIRLINE FILE NAME + EXTRACTION DATE + + - - - - - - - - - - - S.NO - INVOICE ID - PAX NAME - PNR - TICKET NO - VENDOR - VENDOR GST - RECIPIENT - RECIPIENT GST - INVOICE NUMBER - INVOICE DATE - HSN - TAXABLE VALUE - CGST VALUE - CGST RATE - SGST VALUE - SGST RATE - IGST VALUE - IGST RATE - TOTAL INVOICE VALUE - TOTAL VALUE - STATUS - TICKET TYPE - AIRLINE FILE NAME - EXTRACTION DATE - BATCH ID - - - - - - - - - - sno;?> - sl; ?> - pax_name; ?> - pnr; ?> - ticket_no; ?> - vendor; ?> - vendor_gst; ?> - recepient; ?> - recepient_gst; ?> - invoice_no?> - invoice_dt; ?> - hsn; ?> - taxable_value; ?> - cgst_value;?> - cgst_rate; ?> - sgst_value; ?> - sgst_rate; ?> - igst_value; ?> - igst_rate; ?> - total_inv_value; ?> - total_values; ?> - status; ?> - ticket_type; ?> - airline_file_name; ?> - extraction_date; ?> - batch_id; ?> - - - - - - - - - - - - - - - - + + + + + + @@ -345,6 +415,8 @@ //// } // ], scrollX: !0, + "paging": true, + "pageLength": 50, language: { paginate: { previous: "", @@ -383,6 +455,42 @@ $('#column_name').change(function(){ }); + \ No newline at end of file diff --git a/application/views/corporate/bacjyop gst redcon.html b/application/views/corporate/bacjyop gst redcon.html new file mode 100644 index 0000000..5cecdca --- /dev/null +++ b/application/views/corporate/bacjyop gst redcon.html @@ -0,0 +1,291 @@ + + + + + GSTR2A Recon + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gstr2a + + + Reconciliation + Gstr2a + + + + + + + + + + + + + + + FROM + + + TO + + + + + + + + Submit + + + + + + + + + + Select Column to Display + + × + + + + Select Column: + GSTR@A + CORPORATE NAME + CORPORATE GSTIN + TRADE/LEGAL NAME OF THE SUPPLIER + SUPPLIER TYPE + INVOICE NUMBER + + DOCUMENT TYPE + INVOICE DATE + INVOICE AMT (₹) + TICKET NUM + TKT AMT + Variance + GST REMARKS (₹) + INV FILE (₹) + TAX AMT(₹) + CGST + + + SGST + IGST + RATE + + + + DELETE + Icon for Select Option + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/views/corporate/dashboard.php b/application/views/corporate/dashboard.php index 68f3eb7..0386f08 100644 --- a/application/views/corporate/dashboard.php +++ b/application/views/corporate/dashboard.php @@ -91,7 +91,7 @@ FROM - TO + TO diff --git a/application/views/corporate/dashboard_tmc.php b/application/views/corporate/dashboard_tmc.php index 389de4a..165d73c 100644 --- a/application/views/corporate/dashboard_tmc.php +++ b/application/views/corporate/dashboard_tmc.php @@ -91,7 +91,7 @@ FROM - TO + TO diff --git a/application/views/corporate/gstr2a_recon.php b/application/views/corporate/gstr2a_recon.php index 9ac1f73..ffc679a 100644 --- a/application/views/corporate/gstr2a_recon.php +++ b/application/views/corporate/gstr2a_recon.php @@ -41,8 +41,8 @@ - + + + + + + @@ -163,6 +227,7 @@ --> + @@ -180,7 +245,11 @@ + + GSTR2A - - - FROM - - - TO - - - - - - - - Submit - - + + + FROM + + + TO + + + + Submit + + + - - - - - GSTR2A - - - - - - - + - + + + + - - - + CORPORATE NAME CORPORATE GSTIN Trade/Legal name of the Supplier @@ -284,14 +317,14 @@ Inv File Tax Amt + IGST(₹) CGST(₹) SGST(₹) - IGST (₹) Rate (%) TKT Amt Inv - IGST + RATE(%) @@ -315,10 +348,10 @@ × - - Select Column: + + Select Column: GSTR@A - CORPORATE NAME + CORPORATE NAME CORPORATE GSTIN TRADE/LEGAL NAME OF THE SUPPLIER SUPPLIER TYPE @@ -343,13 +376,13 @@ DELETE - Icon for Select Option + -
GSTR@A