Add child passenger handling and delete functionality in new ticket process

This commit is contained in:
2025-04-03 13:16:28 +07:00
parent 663c28a2ea
commit ec0c5ba0f7
2 changed files with 130 additions and 17 deletions

View File

@ -95,7 +95,7 @@
array("type"=>"input","name"=>"txt_passengername","label"=>"Name","required"=>"true","info"=>"true","inputWidth"=>"280","value"=>"",
"tooltip"=>"Insert Nama first. Thank You","validate"=>"NotEmpty","maxLength"=>"100","className"=>"txtleft"),
array("type"=>"label","name"=>"lbllookuphist","label"=>"<a href='javascript:void(0)' onClick='fn_showchildren()'><span id='spchild'>0</span> Children</a>","className"=>"underpassengername","offsetLeft"=>"0","offsetTop"=>"15"),
array("type"=>"label","name"=>"lbllookuphist","label"=>"<a id='achilds' href='javascript:void(0)' onClick='fn_showchildren()'><span id='spchild'>0</span> Children</a>","className"=>"underpassengername","offsetLeft"=>"0","offsetTop"=>"15"),
array("type"=>"combo","name"=>"cbo_idgender","label"=>"Gender","required"=>"true","info"=>"true","inputWidth"=>"140","value"=>"0",
"tooltip"=>"Please Choice gender first. Thank You","validate"=>"NotEmpty","maxLength"=>"11","className"=>"txtleft","note"=>array("text"=>"Ex : Female or Male")),
array("type"=>"calendar","name"=>"txt_bod","label"=>"Birth Of Dates","required"=>"false","info"=>"true","inputWidth"=>"90","readonly"=>"true","value"=>"",
@ -267,7 +267,7 @@
$arrayControls=array("txt_id"=>"","cbo_idship"=>"","txt_tiketnumber"=>"","txt_voynumber"=>"",
"txt_passengername"=>"","cbo_idgender"=>"","txt_bod"=>"","txt_bodyears"=>"",
"cbo_idcardtype"=>"","txt_nationality"=>"Timor Leste",
"cbo_idcardtype"=>"","txt_nationality"=>"Timor Leste","txt_childspassenger"=>"",
"txt_cardnumber"=>"","txt_picdata"=>"aportildefault.png","txt_dates"=>date("Y-m-d"),"txt_price"=>0,
"txt_timeschedule"=>"00:00:00","txt_baggageinkg"=>0,"txt_limitbaggage"=>80,"txt_overlimitbaggage"=>0,
"txt_priceoverinkg"=>0,"txt_pricebaggage"=>0,"txt_totalprice"=>0,"cbo_idroutestart"=>"","cbo_idrouteend"=>""
@ -334,6 +334,7 @@
{
fn_dhtmlxmessage('','Ticket Number <b>'+myForm.getItemValue('txt_tiketnumber')+'</b> has been saved');";
//$onformsenddata.="document.getElementById('imgtiket').src='';";
$onformsenddata.="fn_childspassengerdefault();";
$onformsenddata.="fn_grid_loaddata();myForm.setItemFocus('cbo_idship');";
$onformsenddata.="myForm.setItemValue('cbo_bodmonth','');myForm.setItemValue('cbo_bodday','');";
$onformsenddata.=$this->FN_DHTMLXFORMCLEAR2("myForm",$arrayControls,"cbo_idship")."
@ -365,6 +366,7 @@
if(sp[0]=='ok')
{
fn_dhtmlxmessage('','Ticket Number <b>'+myForm.getItemValue('txt_tiketnumber')+'</b> has been update');";
$onformsenddata.="fn_childspassengerdefault();";
$onformsenddata.="myForm.enableItem('btnsave');";
//$onformsenddata.="document.getElementById('imgtiket').src='';";
$onformsenddata.="myForm.disableItem('btndelete');";
@ -394,7 +396,7 @@
$eventafterdeleted.="myForm.enableItem('btnsave');";
$eventafterdeleted.="myForm.disableItem('btnupdate');";
$eventafterdeleted.="myForm.disableItem('btndelete');";
$eventafterdeleted.="fn_grid_loaddata();";
$eventafterdeleted.="fn_grid_loaddata();fn_childspassengerdefault();";
$onbuttonclickbtndeleted=$this->FN_DHTMLXREMARKFORDELETED2("obj_tra","tra_newticket","myForm.getItemValue('txt_id')","myForm.getItemValue('txt_tiketnumber')",$eventafterdeleted);
//$onbuttonclickbtncancel="document.getElementById('imgtiket').src='';";
@ -404,7 +406,7 @@
$onbuttonclickbtncancel.="myForm.enableItem('txt_tiketnumber');";
$onbuttonclickbtncancel.="myForm.disableItem('btndelete');";
$onbuttonclickbtncancel.="myForm.setItemFocus('cbo_idship');";
$onbuttonclickbtncancel.="fn_grid_loaddata();";
$onbuttonclickbtncancel.="fn_grid_loaddata();fn_childspassengerdefault();";
$onbuttonclickbtncancel.=$this->FN_DHTMLXFORMCLEAR2("myForm",$arrayControls);
$onbuttonclickbtncancel.="myForm.setItemValue('cbo_bodmonth','');myForm.setItemValue('cbo_bodday','');";
@ -491,6 +493,8 @@
"Baggage&nbsp;"=>"right,ro,136,right,int,false",
"Price&nbsp;"=>"right,ro,120,right,int,false");
$this->FN_DHTMLXGRIDVIEW($grdinit,$gridproperties,"bricks","","fn_grid_loaddata()");
echo "dgnewticket.setStyle('font-size:14px','font-size:14px','');";
$arrfields=array("txt_id"=>"","cbo_idship"=>"idship|shipname","txt_tiketnumber"=>"","txt_inctiket"=>"","txt_shipnumber"=>"",
"txt_passengername"=>"","cbo_idgender"=>"","txt_bod"=>"","cbo_idcardtype"=>"idcardtype|cardtype","txt_cardnumber"=>"",
"txt_nationality"=>"","txt_voynumber"=>"","txt_picdata"=>"","txt_dates"=>"","cbo_idroutestart"=>"idroutestart|routenamestart",
@ -511,17 +515,24 @@
$otherevent.="myForm.disableItem('cbo_idship');";
$otherevent.="myForm.disableItem('txt_tiketnumber');";
$otherevent.="myForm.setItemFocus('txt_voynumber');";
$otherevent.="var childspassenger=ajaxuridhtmlx('".$this->enc("obj_tra")."','obj=".$this->enc("tra_newticket")."&task=".$this->enc("getchilds")."&idtiketpassenger='+spres[0]);";
$otherevent.="if(trim(childspassenger)!=''){";
$otherevent.=" myForm.setItemValue('txt_childspassenger',childspassenger);fn_recalchilds();";
$otherevent.="}";
//$otherevent.="document.getElementById('imgtiket').src='uploads/temps/'+spres[11];";
$this->FN_DHTMLXGRIDVIEWTOFORMNEW("dgnewticket","myForm","tbl_passenger_tiket",0,$arrfields,"",$otherevent);
echo " }
function fn_showchildren(){
// fn_dhtmlxmessage('error','Your module still underconstruction');return false;
var tiketnumber=myForm.getItemValue('txt_tiketnumber');
var childspassenger=myForm.getItemValue('txt_childspassenger');
if(!tiketnumber){
fn_dhtmlxmessage('error','Please Insert passenger first!');return false;
}
var url='?ajax=1&sec=1&option=".$this->enc("obj_tra")."&obj=".$this->enc("tra_newticketc")."&task=".$this->enc("default")."&tiketnumber='+tiketnumber;
var url='?ajax=1&sec=1&option=".$this->enc("obj_tra")."&obj=".$this->enc("tra_newticketc")."&task=".$this->enc("default")."&tiketnumber='+tiketnumber+'&childspassenger='+childspassenger;
dwins=new dhtmlXWindows();
dwins.createWindow(\"winchild\",0,0,screen.width-500,screen.height-350);
dwins.window('winchild').progressOn();
@ -540,7 +551,10 @@
function fn_recalchilds(){
var datachilds=myForm.getItemValue('txt_childspassenger');
var sp=datachilds.split(';');
document.getElementbyId('spchild').html = sp.length;
var labelchilds='<a id=\'achilds\' href=\'javascript:void(0)\' onClick=\'fn_showchildren()\'><span id=\'spchild\'>'+sp.length+'</span> Children</a>';
myForm.setItemLabel('lbllookuphist',labelchilds);
// console.log(document.getElementbyId('spchild'));
// document.getElementbyId('spchild').innerHTML = sp.length;
}
function fn_printtraold(tiketnumber,idtransaction){
@ -619,7 +633,11 @@
myForm.setItemFocus('txt_dates');
dwins.unload();
document.getElementById('imgtiket').src='uploads/temps/'+filename;
}
function fn_childspassengerdefault(){
var datachilds='<a id=\'achilds\' href=\'javascript:void(0)\' onClick=\'fn_showchildren()\'><span id=\'spchild\'>0</span> Children</a>';
myForm.setItemLabel('lbllookuphist', datachilds);
}
function fn_showBookingSeat()
@ -905,11 +923,11 @@
$qryins="insert into ".DB_APORTIL.".tbl_passenger_childs
set idtiketpassenger='$id',tiketnumber='$tiketnumber',names='$names',birthofdate='$birthofdate',
ages='$ages',notes='$notes',iby='".$_SESSION['nik']."',idt=now()";
if($this->fn_row_isexists("select id from ".DB_APORTIL.".tbl_passenger_childs where idtiketpassenger='$id' and isdeleted=0 order by id asc limit 1")){
if($this->fn_row_isexists("select id from ".DB_APORTIL.".tbl_passenger_childs where id='$idchilds' order by id asc limit 1")){
$qryins="update ".DB_APORTIL.".tbl_passenger_childs
set names='$names',birthofdate='$birthofdate',ages='$ages',notes='$notes',
uby='".$_SESSION['nik']."',udt=now()
where idtiketpassenger='$id' and names='$names' and birthofdate='$birthofdate'";
where id='$idchilds'";
}
$this->executequery($qryins);
}
@ -950,6 +968,31 @@
}
}
public function fn_getchilds(){
$idtiketpassenger=$_REQUEST['idtiketpassenger'];
$qry="select * from ".DB_APORTIL.".tbl_passenger_childs where idtiketpassenger='$idtiketpassenger' and isdeleted=0 order by id asc";
$rs=$this->selectquery($qry);
if($rs)
{
$i=1;$data="";
while($row=$this->data_row_array($rs))
{
$id=$row['id'];
$names=$row['names'];
$birthofdate=$row['birthofdate'];
$ages=$row['ages'];
$notes=$row['notes'];
$data.=$id."|".$names."|".$birthofdate."|".$ages."|".$notes.";";
$i+=1;
}
if($data){
$data=substr($data,0,strlen($data)-1);
}
echo $data;
}
}
public function fn_printtra($idtransaction=''){
date_default_timezone_set("Asia/Bangkok");
include("lib/mpdf/mpdf.php");

View File

@ -33,6 +33,7 @@
{
echo $this->FN_CREATEHEADER();
$tiketnumber=$_REQUEST['tiketnumber'];
$childspassenger=$_REQUEST['childspassenger'];
$idtiketpassenger=$this->fn_get_fieldvalue("id","select id from ".DB_APORTIL.".tbl_passenger_tiket where tiketnumber='$tiketnumber'");
echo "<style>
.besidebtnsave {margin-left:104px;margin-top:-6px;position:absolute;}
@ -89,7 +90,7 @@
echo "dgchild.setStyle('font-size:14px','font-size:14px','');";
echo "dgchild.setDateFormat('%Y-%m-%d', '%Y-%m-%d');";
$eventrowselect="rowid=(dgchild.cells(rId,0).getValue());";
$eventrowselect="rowid=(dgchild.cells(rId,1).getValue());";
// $eventxle="rwcount=dgtrasoap.getRowsNum();";
// $eventxle.="var isvitanam=0;";
// $eventxle.="if(rwcount>0){isvitanam=1;}";
@ -116,10 +117,16 @@
);
$this->FN_DHTMLXGRIDVIEWEVENT("dgchild",$arrevent);
echo " }
// if($childspassenger){
// echo "fn_grid_default();";
// }
echo " }
function fn_grid_new(){
var idx=rowid;
var childspassenger='".$childspassenger."';
var rowcount=dgchild.getRowsNum()+1;
var idtiketpassenger=myForm.getItemValue('txt_idtiketpassenger');
var gridid=dgchild.uid();";
@ -127,6 +134,56 @@
}
function fn_grid_delrow(){
dhtmlx.confirm({
title:'Confirmation',text:'Are you sure for delete this row?',type:'confirm',
callback:function(result){
if(result)
{
dgchild.deleteSelectedRows();
if(rowid==0){
dgchild.deleteSelectedRows();
}
else{
var delchild=ajaxuridhtmlx('".$this->enc("obj_tra")."','obj=".$this->enc("tra_newticketc")."&task=".$this->enc("delchilds")."&id='+rowid).split('|');
if(delchild[0]=='ok'){
fn_dhtmlxmessage('','Data has been deleted. Thank you');
// fn_grid_loaddata();
}
else{
fn_dhtmlxmessage('error',delchild[1]);
}
}
}
}
});
}
function fn_grid_default(){
var idx=rowid;
var childspassenger='".$childspassenger."';
var rowcount=dgchild.getRowsNum()+1;
var idtiketpassenger=myForm.getItemValue('txt_idtiketpassenger');
if(childspassenger){
var sp=childspassenger.split(';');
for(i=0;i<sp.length;i++)
{
var gridid=dgchild.uid();
var spchild=sp[i].split('|');
var idchild=spchild[0];
var names=spchild[1];
var birthofdate=spchild[2];
var ages=spchild[3];
var notes=spchild[4];
var idtiketpassenger=spchild[5];
dgchild.addRow((i+1),[gridid,idchild,names,birthofdate,ages,notes,idtiketpassenger]);
}
}
}
function fn_setchild(){
var rowcount=dgchild.getRowsNum();
// alert(rowcount);
@ -208,10 +265,9 @@
echo('<?xml version="1.0" encoding="utf-8"?>');
echo "<rows id='0'>";
$qry="select *
from ".DB_APORTIL.".tbl_passenger_childs
$qry="select * from ".DB_APORTIL.".tbl_passenger_childs
where idtiketpassenger='$idtiketpassenger' and isdeleted=0
order by id desc limit ".TBL_PAGE_LIMIT;
order by id asc limit ".TBL_PAGE_LIMIT;
$rs=$this->selectquery($qry);
if($rs)
@ -219,7 +275,8 @@
$i=1;
while($row=$this->data_row_array($rs))
{
echo ("<row id='".$i."'>");
echo ("<row id='".$row["id"]."'>");
print("<cell><![CDATA[".$i."]]></cell>");
print("<cell><![CDATA[".$row["id"]."]]></cell>");
print("<cell><![CDATA[".$row["names"]."</span>"."]]></cell>");
print("<cell><![CDATA[".date("Y-m-d H:i:s",strtotime($row["birthofdate"]))."]]></cell>");
@ -239,5 +296,18 @@
}
public function fn_delchilds(){
$id=$_REQUEST['id'];
$qry="update ".DB_APORTIL.".tbl_passenger_childs set isdeleted=1,remarkdeleted='Cancel by user ',dby='".$_SESSION['nik']."',ddt=now()
where id='$id'";
if($this->executequery($qry)){
echo "ok|";
}
else{
echo "failed|Failed remove child";
}
}
}
?>