From 6f0921ca2c3ad55e58c9e5c6a525e6e5ae13cd60 Mon Sep 17 00:00:00 2001 From: asansal Date: Thu, 29 May 2025 06:31:31 +0700 Subject: [PATCH] Add duration field and validation for ticket cancellation --- controller/libconfig.php | 2 +- objectx/obj_tra/tra_cancelcrg.php | 29 +++++++++++++++++++++++++--- objectx/obj_tra/tra_canceltic.php | 32 +++++++++++++++++++++++++++---- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/controller/libconfig.php b/controller/libconfig.php index 9cf82e6..20525df 100644 --- a/controller/libconfig.php +++ b/controller/libconfig.php @@ -925,7 +925,7 @@ public function NewDateDiff($time1, $time2, $precision = 6) { // If not numeric then convert texts to unix timestamps if (!is_int($time1)){$time1 = strtotime($time1);} - if (!is_int($time2)){$time2 = strtotime($time2);} + if (!is_int($time2)){$time2 = strtotime($time2);} // If time1 is bigger than time2 // Then swap time1 and time2 diff --git a/objectx/obj_tra/tra_cancelcrg.php b/objectx/obj_tra/tra_cancelcrg.php index bb223a8..e7ca1b5 100644 --- a/objectx/obj_tra/tra_cancelcrg.php +++ b/objectx/obj_tra/tra_cancelcrg.php @@ -48,6 +48,7 @@ array("type"=>"fieldset","width"=>"1080","label"=>"Search", "list"=>array( array("type"=>"hidden","name"=>"txt_idcargo"), + array("type"=>"hidden","name"=>"txt_duration"), array("type"=>"input","name"=>"txtsearch","label"=>"Insert Your Keyword","info"=>"true","inputWidth"=>"240", "tooltip"=>"Insert Your Keyword","maxLength"=>"","className"=>"txtleft","labelWidth"=>"210"), array("type"=>"newcolumn"), @@ -94,13 +95,18 @@ "Price "=>"right,ro,120,right,int,false", "Quantity "=>"right,ro,144,right,int,false", "Weight "=>"right,ro,144,right,int,false", - "Total "=>"right,ro,120,right,int,false"); + "Total "=>"right,ro,120,right,int,false", + "Insert Date "=>"center,ro,170,center,str,false", + "Duration ( Hours ) "=>"center,ro,120,center,str,false" + ); $this->FN_DHTMLXGRIDVIEW($grdinit,$gridproperties,"bricks","","fn_grid_loaddata()"); $oneditcell="if(colid==1&&stage==1)"; $oneditcell.="{"; $oneditcell.=" var status=dgresult.cells(rowid,4).getValue();"; $oneditcell.=" var idcargo=dgresult.cells(rowid,0).getValue();"; + $oneditcell.=" var duration=dgresult.cells(rowid,18).getValue();"; + $oneditcell.=" myFormsearch.setItemValue('txt_duration',duration);"; $oneditcell.=" var tiketnumber=dgresult.cells(rowid,7).getValue();"; $oneditcell.=" if(status!=0){fn_dhtmlxmessage('error','I\'m sorry you can\'t cancel this Tiket number!!');return false;}"; $oneditcell.=" myFormsearch.setItemValue('txt_idcargo',idcargo+'|'+tiketnumber);"; @@ -122,7 +128,13 @@ function fn_cancelcrg() - {"; + { + var duration=myFormsearch.getItemValue('txt_duration'); + if(duration>6) + { + fn_dhtmlxmessage('error','I\'m sorry you can\'t cancel this Tiket number, because the duration is more than 6 hours!!'); + return false; + }"; //var idcargo=myFormsearch.getItemValue('txt_idcargo'); //var url='?ajax=1&sec=1&option=".$this->enc("obj_ss")."&obj=".$this->enc("ss_necheck")."&task=".$this->enc("viewchecklist")."&idchecklist='+idchecklist+'&checklistnumber='+checklistnumber+'&category='+category;"; $rtn="var idcargo=myFormsearch.getItemValue('txt_idcargo');"; @@ -281,7 +293,7 @@ $qry="select id,0 ischecklist,idship,shipname,tiketnumber,tiketnumberpassenger,voynumber,inctiket,idcategory,cargodescription,passengername, idcardtype,cardtype,cardnumber,dates,idroutestart,routenamestart,idrouteend, - routenameend,price,quantity,weight,totalprice,units,modifcount,status + routenameend,price,quantity,weight,totalprice,units,modifcount,status,iby,idt from ".DB_APORTIL.".tbl_cargo_tiket where (tiketnumber like '%$keyword%' or voynumber like '%$keyword%' or passengername like '%$keyword%') and isdeleted=0 and status=0 order by id desc limit ".TBL_PAGE_LIMIT; @@ -313,6 +325,17 @@ print("".$row["quantity"].""."]]>"); print("".$row["weight"].""."]]>"); print("".$row["totalprice"]." \$"."]]>"); + print(""); + $now=date("Y-m-d H:i:s"); + $idt=date("Y-m-d H:i:s",strtotime($row["idt"])); + $df=$this->NewDateDiff($idt,$now); + $durationinhours=0; + if(count($df)>0) + { + $durationindays=$df['day']*24; + $durationinhours=$df['hour']+$durationindays; + } + print(""); echo (""); $i+=1; } diff --git a/objectx/obj_tra/tra_canceltic.php b/objectx/obj_tra/tra_canceltic.php index b0d307f..2e4b4e4 100644 --- a/objectx/obj_tra/tra_canceltic.php +++ b/objectx/obj_tra/tra_canceltic.php @@ -48,6 +48,7 @@ array("type"=>"fieldset","width"=>"1080","label"=>"Search", "list"=>array( array("type"=>"hidden","name"=>"txt_idticketing"), + array("type"=>"hidden","name"=>"txt_duration"), array("type"=>"input","name"=>"txtsearch","label"=>"Insert Your Keyword","info"=>"true","inputWidth"=>"240", "tooltip"=>"Insert Your Keyword","maxLength"=>"","className"=>"txtleft","labelWidth"=>"210"), array("type"=>"newcolumn"), @@ -77,7 +78,7 @@ $footerevent.=""; $grdinit=array("gridname"=>"dgresult","divtarget"=>"div_dgresult","divpaging"=>"div_dgresultpaging","paginglimit"=>PAGE_LIMIT, - "showloader"=>"true","enableMultiline"=>"true","footer"=>"$footerevent","footerspan"=>"16"); + "showloader"=>"true","enableMultiline"=>"true","footer"=>"$footerevent","footerspan"=>"21"); $gridproperties=array("id"=>"right,ro,96,right,int,false,true", "C  "=>"center,ra,30,center,int,false", "No. "=>"right,ro,35,center,int,false", @@ -97,12 +98,17 @@ "Quantity "=>"right,ro,110,right,int,false", "Price "=>"right,ro,120,right,int,false", "Baggage "=>"right,ro,136,right,int,false", - "Price "=>"right,ro,120,right,int,false"); + "Price baggage "=>"right,ro,120,right,int,false", + "Insert Date "=>"center,ro,170,center,str,false", + "Duration ( Hours ) "=>"center,ro,120,center,str,false" + ); $this->FN_DHTMLXGRIDVIEW($grdinit,$gridproperties,"bricks","","fn_grid_loaddata()"); $oneditcell="if(colid==1&&stage==1)"; $oneditcell.="{"; $oneditcell.=" var status=dgresult.cells(rowid,4).getValue();"; + $oneditcell.=" var duration=dgresult.cells(rowid,21).getValue();"; + $oneditcell.=" myFormsearch.setItemValue('txt_duration',duration);"; $oneditcell.=" var idticketing=dgresult.cells(rowid,0).getValue();"; $oneditcell.=" var tiketnumber=dgresult.cells(rowid,7).getValue();"; $oneditcell.=" if(status!=0){fn_dhtmlxmessage('error','I\'m sorry you can\'t cancel this Tiket number!!');return false;}"; @@ -125,7 +131,13 @@ function fn_cancelticketing() - {"; + { + var duration=myFormsearch.getItemValue('txt_duration'); + if(duration>6) + { + fn_dhtmlxmessage('error','I\'m sorry you can\'t cancel this Tiket number, because the duration is more than 6 hours!!'); + return false; + }"; //var idticketing=myFormsearch.getItemValue('txt_idticketing'); //var url='?ajax=1&sec=1&option=".$this->enc("obj_ss")."&obj=".$this->enc("ss_necheck")."&task=".$this->enc("viewchecklist")."&idchecklist='+idchecklist+'&checklistnumber='+checklistnumber+'&category='+category;"; $rtn="var idticketing=myFormsearch.getItemValue('txt_idticketing');"; @@ -283,7 +295,8 @@ echo ""; $qry="select id,0 ischecklist,idship,tiketnumber,inctiket,shipname,shipnumber,passengername,picdata,dates,idroutestart, - routenamestart,idrouteend,routenameend,seatnumber,quantity,price,baggageinkg,pricebaggage,modifcount,status + routenamestart,idrouteend,routenameend,seatnumber,quantity,price,baggageinkg,pricebaggage,modifcount,status, + idt from ".DB_APORTIL.".tbl_passenger_tiket where (tiketnumber like '%$keyword%' or passengername like '%$keyword%') and isdeleted=0 and status=0 order by id desc limit ".TBL_PAGE_LIMIT; @@ -318,6 +331,17 @@ print(""."\$".$row["price"].""."]]>"); print("".$row["baggageinkg"].""."]]>"); print(""."\$".$row["pricebaggage"].""."]]>"); + print(""); + $now=date("Y-m-d H:i:s"); + $idt=date("Y-m-d H:i:s",strtotime($row["idt"])); + $df=$this->NewDateDiff($idt,$now); + $durationinhours=0; + if(count($df)>0) + { + $durationindays=$df['day']*24; + $durationinhours=$df['hour']+$durationindays; + } + print(""); echo (""); $i+=1; }