diff --git a/application/controllers/Admin.php b/application/controllers/Admin.php index 287f5ea..48562ab 100644 --- a/application/controllers/Admin.php +++ b/application/controllers/Admin.php @@ -198,6 +198,8 @@ class Admin extends CI_Controller { $resi->refrole = ucfirst($resi->u_role); if($resi->u_role == 'corporate') $resi->refrole = $resi->c_name; + else if($resi->u_role == 'tmc') + $resi->refrole = $resi->c_name."/".$resi->refrole; $fary['data'][] = $resi; } } diff --git a/application/controllers/Corporate.php b/application/controllers/Corporate.php index e494b1e..6df30a7 100644 --- a/application/controllers/Corporate.php +++ b/application/controllers/Corporate.php @@ -938,18 +938,25 @@ class Corporate extends CI_Controller { } else if($col == 6){ if($cc != ''){ + // print_r($cc); + // $cc = date('d/M/Y', strtotime($cc)); + // print_r($cc); 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.'",'; + // print_r($values);die(); } 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){ + // print_r($dary);die(); + if($dary[0]>31 || $dary[1]>12 || $dary[2]<1900 || $dary[2]>date("Y")){ // if(!isset($ferror['Invoice Date'])) // $ferror['Invoice Date'] = $row.'-Invoice Date'; $ferror[$row]['column'][] = 'Invoice Date'; @@ -970,7 +977,7 @@ class Corporate extends CI_Controller { } } else if($col == 7 || $col == 10 || $col == 11 || $col == 12 || $col == 13 || $col == 14 || $col == 15){ - if(!preg_match("@^[0-9]+$@",$cc)){ + if(!preg_match("@^[0-9\.]+$@",$cc)){ $seterror = 1; $ferror[$row]['row'] = $row; } @@ -1146,9 +1153,9 @@ class Corporate extends CI_Controller { public function gstr2a() { $this->checksess(); - + $data['gstinfo'] = $this->corp->get_gstno(null,1); - + // print_r($this->session->userdata['recon_sess_i']['u_corporateid']);die(); $monthAllAryLabel = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); $yearAry = array(); $monthAry = array(); $m = date('m',time()); @@ -1162,7 +1169,6 @@ class Corporate extends CI_Controller { $data['month'] = $monthAry; $data['allmonth'] = $monthAllAryLabel; $data['curYear'] = date('Y',time()); - $this->load->view('corporate/gstr2a',$data); } @@ -2810,6 +2816,7 @@ class Corporate extends CI_Controller { 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; @@ -4633,7 +4640,9 @@ class Corporate extends CI_Controller { if($dat->f_max_date != '') $dat->f_max_date_ref = date('d-m-Y',strtotime($dat->f_max_date)); $refm = $dat->f_month - 1; - $dat->inv_ref = $monthAry[$refm]."' ".substr($dat->f_year,2,2); + if (isset($monthAry[$refm])) { + $dat->inv_ref = $monthAry[$refm]."' ".substr($dat->f_year,2,2); + } $dat->u_name = ucfirst(strtolower($dat->u_name)); $dat->f_uploadedat_ref = date('d-m-Y H:i',strtotime($dat->f_uploadedat)); $fary['data'][] = $dat; diff --git a/application/controllers/Tmc.php b/application/controllers/Tmc.php new file mode 100644 index 0000000..8e3ffeb --- /dev/null +++ b/application/controllers/Tmc.php @@ -0,0 +1,398 @@ + + * @see https://codeigniter.com/user_guide/general/urls.html + */ + + function __construct() + { + parent::__construct(); + $this->load->model('Tmc_model','tmc'); + //force_ssl(); + } + + public function index(){ + redirect('tmc/tmc'); + } + + 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 + 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++){ + $monthAry[] = $monthAllAryLabel[$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(){ + $this->checksess(); + // $data['gstno_list'] = $this->intl->get_gstno(); + // $data['gstno_list'] = array(); + $this->load->view('tmc/tmc_recon'); + } + + public function gen_tmc_recon(){ + $this->checksess(); + $fromdate = $this->input->post('fromdate'); + $todate = $this->input->post('todate'); +// 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 == '') + $res1->d_remarks = 'Invoice not received'; + else{ + $payremarks = ($res1->s_amt * 100) / $res1->td_tkt_fare; + 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)); + $fres['data'][] = $res1; + } + echo json_encode($fres); + } + + public function upload_tmc(){ + // print_r("aaaaa"); + $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()); + + $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){ + 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); + $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]>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.'",'; + } + //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.'",'; + } + //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){ + $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;$cdb->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;$cdb->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); + } + } + } + +} \ No newline at end of file diff --git a/application/models/Tmc_model.php b/application/models/Tmc_model.php new file mode 100644 index 0000000..0d70aba --- /dev/null +++ b/application/models/Tmc_model.php @@ -0,0 +1,22 @@ +db->where($con); + return $this->db->get('users'); + } + + function get_corp($con=null,$c_id = null,$is_active = null){ + if($c_id) + $con['c_id'] = $c_id; + if($is_active) + $con['c_isactive'] = 1; + return $this->db->get_where('corporates',$con); + } +} \ No newline at end of file diff --git a/application/views/admin/users.php b/application/views/admin/users.php index f6a8609..d6b953e 100644 --- a/application/views/admin/users.php +++ b/application/views/admin/users.php @@ -160,6 +160,7 @@ + @@ -240,6 +241,7 @@ + @@ -318,6 +320,7 @@ } } var form = $(this); + console.log('322',form); $.ajax({ type: "POST", url: '', @@ -350,6 +353,7 @@ return false; } var form = $(this); + console.log('355',form); $.ajax({ type: "POST", url: '', @@ -391,7 +395,7 @@ $('#e_u_corporateid').val(pd[0].u_corporateid); $('#e_u_role').val(pd[0].u_role); - if($('#e_u_role').val() == 'corporate') + if($('#e_u_role').val() == 'corporate' || $('#e_u_role').val() == 'tmc') { $('#e_corp_div').show(); $("#e_u_corporateid").prop('required',true); @@ -488,7 +492,7 @@ $('#e_u_role').on('change',function(){ var utype = this.value; - if(utype == 'corporate'){ + if(utype == 'corporate' || utype == 'tmc'){ $('#e_u_corporateid').prop('disabled',false); $('#e_corp_div').show(); } @@ -502,7 +506,7 @@ var utype = this.value; var htmlData = ''; // var htmlData = '', type:'POST', diff --git a/application/views/corporate/gstr2a.php b/application/views/corporate/gstr2a.php index 7a9f769..b906a05 100644 --- a/application/views/corporate/gstr2a.php +++ b/application/views/corporate/gstr2a.php @@ -650,6 +650,7 @@ url: url, success: function(data) { + console.log("111"); oTable.clear(); var jsonData = JSON.parse(data); var jd = jsonData.data; diff --git a/application/views/corporate/tmc.php b/application/views/corporate/tmc.php index 2157bda..68f6249 100644 --- a/application/views/corporate/tmc.php +++ b/application/views/corporate/tmc.php @@ -655,6 +655,7 @@ type: "POST", url: url, success: function(data) { + console.log(data); if(data.length > 2){ oTable.clear(); var jsonData = JSON.parse(data); diff --git a/application/views/tmc/includes/footer.php b/application/views/tmc/includes/footer.php new file mode 100644 index 0000000..b2d2339 --- /dev/null +++ b/application/views/tmc/includes/footer.php @@ -0,0 +1,20 @@ + +
+
+
+
+ © TravelSpends +
+ +
+
+
+ \ No newline at end of file diff --git a/application/views/tmc/includes/top_nav.php b/application/views/tmc/includes/top_nav.php new file mode 100644 index 0000000..ef30525 --- /dev/null +++ b/application/views/tmc/includes/top_nav.php @@ -0,0 +1,102 @@ + + + + +
+
+ +
+
\ No newline at end of file diff --git a/application/views/tmc/tmc.php b/application/views/tmc/tmc.php new file mode 100644 index 0000000..da75f25 --- /dev/null +++ b/application/views/tmc/tmc.php @@ -0,0 +1,690 @@ + + + + + + TMC File Listing + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+ + +
+ + +
+
+
+

TMC File Listing

+
+ +
+
+
+
+ + +
+
+
+
+
+
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + +
AgentFor MonthFromToUploaded ByEmailUploaded OnAction
+ +
+
+
+
+ + +
+ +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/views/tmc/tmc_recon.php b/application/views/tmc/tmc_recon.php new file mode 100644 index 0000000..1c09991 --- /dev/null +++ b/application/views/tmc/tmc_recon.php @@ -0,0 +1,591 @@ + + + + + TMC Recon + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+ + +
+ + +
+
+
+

TMC

+
+ +
+
+
+
+ + +
+
+
+
+ +
+
+
+ +
+ + +
+
+ + +
+
+ + +
+
+
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
SEGMENTINV DATEGST INVOICE NOREF NODOC TYPEBILLING ENTITYPASSENGER NAMEAIRLINE CODETICKET NOSECTORCABINCLASSTOTAL TKT FAREREMARKSAction
+ +
+
+
+
+ + +
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file