suseendhiran
This commit is contained in:
parent
188c3a3257
commit
f5cff42b81
@ -2802,279 +2802,608 @@ class Corporate extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function upload_tmc(){
|
||||
$this->checksess();
|
||||
// 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;
|
||||
// $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;
|
||||
|
||||
$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'];
|
||||
// $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');
|
||||
// }
|
||||
|
||||
// $config['file_name'] = $filename;
|
||||
// $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'))
|
||||
// {
|
||||
// $error = array('error' => $this->upload->display_errors());
|
||||
// echo $error['error'];
|
||||
// }
|
||||
// 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');
|
||||
|
||||
// $inserror = 0;
|
||||
// $this->load->library('excel');
|
||||
// //read file from path
|
||||
// $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){
|
||||
// print_r("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 '<br/>';
|
||||
// // print_r($headingary);
|
||||
// $rdata['status'] = 13;
|
||||
// $ferror['column'] = 'Column mismatch.';
|
||||
// $rdata['error'] = $ferror;
|
||||
// echo json_encode($rdata); exit;
|
||||
// }
|
||||
// else{
|
||||
// $ttlrows++;
|
||||
// $chkcell = $worksheet->getCellByColumnAndRow(1, $row);
|
||||
// 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]>2023){
|
||||
// // 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 == 3){
|
||||
// $cc = preg_replace('/\s+/', '',trim($cc));
|
||||
// if($cc != "CRN" && $cc != "INV"){
|
||||
// $seterror = 1;
|
||||
// $ferror[$row]['column'][] = 'DOC TYPE';
|
||||
// $ferror[$row]['row'] = $row;
|
||||
// }
|
||||
// $values .= '"'.$cc.'",';
|
||||
// }
|
||||
// else if($col == 6 || $col == 7){
|
||||
// if(!preg_match("@^[a-zA-Z\s]+$@",$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 || $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.'",';
|
||||
// }
|
||||
// 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){
|
||||
// $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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// $ferror = array_values($ferror);
|
||||
// // 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());
|
||||
// $this->db->insert('files',$insdata);
|
||||
// $td_tfid = $this->db->insert_id();
|
||||
// $rdata['insref'] = $td_tfid;
|
||||
|
||||
// for($c=0;$c<count($insArym);$c++){
|
||||
// // try{
|
||||
// $this->db->query($insArym[$c].',"'.$td_tfid.'")');
|
||||
// // }
|
||||
// // catch(Exception $e){
|
||||
// // continue;
|
||||
// // }
|
||||
// }
|
||||
|
||||
// if(!empty($ferror)){
|
||||
|
||||
// $rdata['duprecords'] = 0;
|
||||
// $rdata['status'] = 0;
|
||||
// // $rdata['error'] = $ferror;
|
||||
|
||||
// if($inserror != 0)
|
||||
// $rdata['duprecords'] = $inserror;
|
||||
// $rdata['ttlrows'] = $ttlrows;
|
||||
// // $rdata['error'] = $ferror;
|
||||
// $rdata['invalidrows'] = count($ferror);
|
||||
// echo json_encode($rdata); exit;
|
||||
// }
|
||||
// else{
|
||||
|
||||
// $reccnt = $highestRow;
|
||||
// $inscnt = 0;
|
||||
|
||||
// for($c=0;$c<count($insAry);$c++){
|
||||
// try{
|
||||
// $this->db->query($insAry[$c].',"'.$td_tfid.'")');
|
||||
// if($this->db->affected_rows())
|
||||
// $inscnt++;
|
||||
// }
|
||||
// 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);
|
||||
// $dateAry = array();
|
||||
// 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);
|
||||
|
||||
// $rdata['status'] = 1;
|
||||
// $rdata['added_records'] = $inscnt;
|
||||
// echo json_encode($rdata);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public function upload_tmc(){
|
||||
$this->checksess();
|
||||
|
||||
$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;
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
$config['file_name'] = $filename;
|
||||
$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'))
|
||||
{
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
echo $error['error'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = array('upload_data' => $this->upload->data());
|
||||
|
||||
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');
|
||||
}
|
||||
$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");
|
||||
|
||||
$config['file_name'] = $filename;
|
||||
$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'))
|
||||
{
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
echo $error['error'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = array('upload_data' => $this->upload->data());
|
||||
$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;
|
||||
$objPHPExcel = PHPExcel_IOFactory::load($filepath);
|
||||
$inserror = 0;
|
||||
$this->load->library('excel');
|
||||
//read file from path
|
||||
$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){
|
||||
print_r("1");
|
||||
for($col = 0; $col < $pcols; $col++){
|
||||
$cell = $worksheet->getCellByColumnAndRow($col, $row);
|
||||
$cellref = $cell;
|
||||
$headingary[] = strval($cell);
|
||||
}
|
||||
$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++){
|
||||
$cell = $worksheet->getCellByColumnAndRow($col, $row);
|
||||
$cellref = $cell;
|
||||
$headingary[] = strval($cell);
|
||||
}
|
||||
else{
|
||||
if($fieldAry != $headingary){
|
||||
}
|
||||
else{
|
||||
if($fieldAry != $headingary){
|
||||
// print_r($fieldAry);
|
||||
// echo '<br/>';
|
||||
// print_r($headingary);
|
||||
$rdata['status'] = 13;
|
||||
$ferror['column'] = 'Column mismatch.';
|
||||
$rdata['error'] = $ferror;
|
||||
echo json_encode($rdata); exit;
|
||||
}
|
||||
else{
|
||||
$ttlrows++;
|
||||
$chkcell = $worksheet->getCellByColumnAndRow(1, $row);
|
||||
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;
|
||||
$rdata['status'] = 13;
|
||||
$ferror['column'] = 'Column mismatch.';
|
||||
$rdata['error'] = $ferror;
|
||||
echo json_encode($rdata); exit;
|
||||
}
|
||||
else{
|
||||
$ttlrows++;
|
||||
$chkcell = $worksheet->getCellByColumnAndRow(1, $row);
|
||||
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.'",';
|
||||
$ferror[$row]['column'][] = 0;
|
||||
$ferror[$row]['row'] = $row;
|
||||
}
|
||||
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){
|
||||
$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.'",';
|
||||
}
|
||||
$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 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 == 3){
|
||||
$cc = preg_replace('/\s+/', '',trim($cc));
|
||||
if($cc != "CRN" && $cc != "INV"){
|
||||
$seterror = 1;
|
||||
$ferror[$row]['column'][] = 'DOC TYPE';
|
||||
$ferror[$row]['row'] = $row;
|
||||
}
|
||||
$values .= '"'.$cc.'",';
|
||||
}
|
||||
else if($col == 6 || $col == 7){
|
||||
if(!preg_match("@^[a-zA-Z\s]+$@",$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 || $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.'",';
|
||||
}
|
||||
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.'",';
|
||||
}
|
||||
$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;
|
||||
}
|
||||
$values .= '"'.$cc.'",';
|
||||
}
|
||||
|
||||
$chk = $this->db->query('select * from tmc_data where td_gst_inv = "'.$td_gst_inv.'"');
|
||||
|
||||
if($chk->num_rows()>0){
|
||||
$inserror++;
|
||||
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.'",';
|
||||
}
|
||||
//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.'",';
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
$chk = $this->db->query('select * from tmc_data where td_gst_inv = "'.$td_gst_inv.'"');
|
||||
|
||||
if($chk->num_rows()>0){
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ferror = array_values($ferror);
|
||||
}
|
||||
|
||||
$ferror = array_values($ferror);
|
||||
// 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_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());
|
||||
if (!$this->input->post('condition_check')) {
|
||||
$this->db->insert('files',$insdata);
|
||||
$td_tfid = $this->db->insert_id();
|
||||
$rdata['insref'] = $td_tfid;
|
||||
|
||||
for($c=0;$c<count($insArym);$c++){
|
||||
}
|
||||
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;$c<count($insArym);$c++){
|
||||
// try{
|
||||
$this->db->query($insArym[$c].',"'.$td_tfid.'")');
|
||||
$this->db->query($insArym[$c].',"'.$td_tfid.'")');
|
||||
// }
|
||||
// catch(Exception $e){
|
||||
// continue;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($ferror)){
|
||||
|
||||
$rdata['duprecords'] = 0;
|
||||
$rdata['status'] = 0;
|
||||
if(!empty($ferror)){
|
||||
|
||||
$rdata['duprecords'] = 0;
|
||||
$rdata['status'] = 0;
|
||||
// $rdata['error'] = $ferror;
|
||||
|
||||
if($inserror != 0)
|
||||
$rdata['duprecords'] = $inserror;
|
||||
$rdata['ttlrows'] = $ttlrows;
|
||||
|
||||
if($inserror != 0)
|
||||
$rdata['duprecords'] = $inserror;
|
||||
$rdata['ttlrows'] = $ttlrows;
|
||||
// $rdata['error'] = $ferror;
|
||||
$rdata['invalidrows'] = count($ferror);
|
||||
$rdata['invalidrows'] = count($ferror);
|
||||
// if (!$this->input->post('condition_check')) {
|
||||
echo json_encode($rdata); exit;
|
||||
// }
|
||||
// else{
|
||||
// $message = "Invalid Records";
|
||||
// echo "<script type='text/javascript'>alert('$message');</script>";
|
||||
// echo '<script type="text/javascript">
|
||||
// window.open("", "_self").close();
|
||||
// </script>';
|
||||
// }
|
||||
}
|
||||
else{
|
||||
|
||||
$reccnt = $highestRow;
|
||||
$inscnt = 0;
|
||||
|
||||
for($c=0;$c<count($insAry);$c++){
|
||||
try{
|
||||
// print_r($td_tfid);
|
||||
// print_r($insAry[$c].',"'.$td_tfid.'")');die();
|
||||
$this->db->query($insAry[$c].',"'.$td_tfid.'")');
|
||||
if($this->db->affected_rows())
|
||||
$inscnt++;
|
||||
}
|
||||
catch(Exception $e){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$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){
|
||||
$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);
|
||||
|
||||
$reccnt = $highestRow;
|
||||
$inscnt = 0;
|
||||
|
||||
for($c=0;$c<count($insAry);$c++){
|
||||
try{
|
||||
$this->db->query($insAry[$c].',"'.$td_tfid.'")');
|
||||
if($this->db->affected_rows())
|
||||
$inscnt++;
|
||||
}
|
||||
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);
|
||||
$dateAry = array();
|
||||
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);
|
||||
|
||||
$rdata['status'] = 1;
|
||||
$rdata['added_records'] = $inscnt;
|
||||
$rdata['status'] = 1;
|
||||
$rdata['added_records'] = $inscnt;
|
||||
// if (!$this->input->post('condition_check')) {
|
||||
echo json_encode($rdata);
|
||||
}
|
||||
// }
|
||||
// else{
|
||||
// $message = "Data Uploaded";
|
||||
// echo "<script type='text/javascript'>alert('$message');</script>";
|
||||
// echo '<script type="text/javascript">
|
||||
// window.open("", "_self").close();
|
||||
// </script>';
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function proceedinsert_cts(){
|
||||
$filerefid = $this->input->post('fileref');
|
||||
|
||||
BIN
uploads/2/gstr2a/GSTR2A-ASAASA-Jan-2023-1681881706.xlsx
Normal file
BIN
uploads/2/gstr2a/GSTR2A-ASAASA-Jan-2023-1681881706.xlsx
Normal file
Binary file not shown.
BIN
uploads/2/tmc/TMC-TEST1-Jan-2020-1681881892.xlsx
Normal file
BIN
uploads/2/tmc/TMC-TEST1-Jan-2020-1681881892.xlsx
Normal file
Binary file not shown.
BIN
uploads/2/tmc/TMC-TEST1-Jan-2020-1681881910.xlsx
Normal file
BIN
uploads/2/tmc/TMC-TEST1-Jan-2020-1681881910.xlsx
Normal file
Binary file not shown.
BIN
uploads/2/tmc/TMC-TESTAGENT111-Jan-2020-1681882280.xlsx
Normal file
BIN
uploads/2/tmc/TMC-TESTAGENT111-Jan-2020-1681882280.xlsx
Normal file
Binary file not shown.
BIN
uploads/2/tmc/TMC-TESTAGENT121-Jan-2020-1681882218.xlsx
Normal file
BIN
uploads/2/tmc/TMC-TESTAGENT121-Jan-2020-1681882218.xlsx
Normal file
Binary file not shown.
BIN
uploads/2/tmc/TMC-TESTAGENT121-Jan-2020-1681882233.xlsx
Normal file
BIN
uploads/2/tmc/TMC-TESTAGENT121-Jan-2020-1681882233.xlsx
Normal file
Binary file not shown.
BIN
uploads/2/tmc/TMC-testagent-Feb-2020-1681883182.xlsx
Normal file
BIN
uploads/2/tmc/TMC-testagent-Feb-2020-1681883182.xlsx
Normal file
Binary file not shown.
BIN
uploads/2/tmc/TMC-testagent-Jan-2020-1681881522.xlsx
Normal file
BIN
uploads/2/tmc/TMC-testagent-Jan-2020-1681881522.xlsx
Normal file
Binary file not shown.
BIN
uploads/2/tmc/TMC-testagent-Jan-2020-1681881999.xlsx
Normal file
BIN
uploads/2/tmc/TMC-testagent-Jan-2020-1681881999.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user