Compare commits

...

2 Commits

Author SHA1 Message Date
f6d5663ef7 Merge branch 'dev_1.2' into prod_v1.2 2025-05-29 06:31:44 +07:00
6f0921ca2c Add duration field and validation for ticket cancellation 2025-05-29 06:31:31 +07:00
3 changed files with 55 additions and 8 deletions

View File

@ -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

View File

@ -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 <b>more than 6 hours</b>!!');
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("<cell><![CDATA["."<span style='color:$color'>".$row["quantity"]."</span>"."]]></cell>");
print("<cell><![CDATA["."<span style='color:$color'>".$row["weight"]."</span>"."]]></cell>");
print("<cell><![CDATA["."<span style='color:$color'>".$row["totalprice"]." \$</span>"."]]></cell>");
print("<cell><![CDATA[".date("Y-m-d H:i:s",strtotime($row["idt"]))."]]></cell>");
$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("<cell><![CDATA[".$durationinhours."]]></cell>");
echo ("</row>");
$i+=1;
}

View File

@ -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.="</div>";
$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",
"<font color='green'><b>C&nbsp;&nbsp;</b></font>"=>"center,ra,30,center,int,false",
"No.&nbsp;"=>"right,ro,35,center,int,false",
@ -97,12 +98,17 @@
"Quantity&nbsp;"=>"right,ro,110,right,int,false",
"Price&nbsp;"=>"right,ro,120,right,int,false",
"Baggage&nbsp;"=>"right,ro,136,right,int,false",
"Price&nbsp;"=>"right,ro,120,right,int,false");
"Price baggage&nbsp;"=>"right,ro,120,right,int,false",
"Insert Date&nbsp;"=>"center,ro,170,center,str,false",
"Duration ( Hours )&nbsp;"=>"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 <b>more than 6 hours</b>!!');
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 "<rows id='0'>";
$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("<cell><![CDATA["."<span style='color:black'>"."\$".$row["price"]."</span>"."]]></cell>");
print("<cell><![CDATA["."<span style='color:black'>".$row["baggageinkg"]."</span>"."]]></cell>");
print("<cell><![CDATA["."<span style='color:black'>"."\$".$row["pricebaggage"]."</span>"."]]></cell>");
print("<cell><![CDATA[".date("Y-m-d H:i:s",strtotime($row["idt"]))."]]></cell>");
$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("<cell><![CDATA[".$durationinhours."]]></cell>");
echo ("</row>");
$i+=1;
}