Files
aportil/objectx/obj_data/data_shipinfo.php

453 lines
35 KiB
PHP

<?php
class DATA_SHIPINFO extends DATA
{
public function data_shipinfo_javainit()
{
}
public function fn_shipinfo_init()
{
if(isset($_REQUEST['task'])){$task=trim(strtolower($_REQUEST['task']));}
if(isset($_POST['task'])){$task=trim(strtolower($_POST['task']));}
if($_REQUEST||$_POST){if($_REQUEST['sec']||$_POST['sec']){$task=$this->dec($task);}}
switch($task)
{
case "default":
$this->fn_default_shipinfo();
break;
case $task:
$task="fn_".$task;
if(method_exists($this,$task)){$this->$task();}
break;
default:
$this->fn_default_shipinfo();
break;
}
}
public function fn_default_shipinfo()
{
echo $this->FN_CREATEHEADER();
echo "<style>
.besidebtnsave {margin-left:110px;margin-top:-6px;position:absolute;}
.besidebtnupdate {margin-left:213px;margin-top:-6px;position:absolute;}
.besidebtnsubmit {margin-left:322px;margin-top:-6px;position:absolute;}
.besidebtndelete {margin-left:310px;margin-top:-6px;position:absolute;}
.besidelabel {margin-left:280px;margin-top:-5px;position:absolute;}
</style>";
echo "<script>
var myForm,myFormsearch,dgshipinfo;
function initObject()
{";
$formdata=array(
array("type"=>"settings","position"=>"label-left","labelWidth"=>"180","inputWidth"=>"120"),
array("type"=>"block","width"=>"500",
"list"=>array(
array("type"=>"hidden","name"=>"txt_id"),
array("type"=>"input","name"=>"txt_shipnumber","label"=>"Voy Number","required"=>"true","info"=>"true","inputWidth"=>"180","value"=>"",
"tooltip"=>"Masukkan Voy Number first. Obrigado","validate"=>"NotEmpty","maxLength"=>"100","className"=>"txtcenter"),
array("type"=>"input","name"=>"txt_shipname","label"=>"Ship Name","required"=>"true","info"=>"true","inputWidth"=>"180","value"=>"",
"tooltip"=>"Masukkan Ship Name first. Obrigado","validate"=>"NotEmpty","maxLength"=>"100","className"=>"txtleft"),
array("type"=>"calendar","name"=>"txt_datecreated","label"=>"Created Date","required"=>"true","info"=>"true","inputWidth"=>"90","readonly"=>"true","value"=>date("Y-m-d"),
"tooltip"=>"Masukkan Created Date first. Obrigado","validate"=>"NotEmpty","maxLength"=>"","className"=>"txtcenter","dateFormat"=>"%Y-%m-%d"),
array("type"=>"input","name"=>"txt_width","label"=>"Width","required"=>"true","info"=>"true","inputWidth"=>"90","value"=>"0",
"tooltip"=>"Masukkan Width first. Obrigado","validate"=>"NotEmpty,ValidNumeric","maxLength"=>"","className"=>"txtright"),
array("type"=>"label","name"=>"lblmeter","label"=>"Meter","className"=>"besidelabel"),
array("type"=>"input","name"=>"txt_shiplength","label"=>"Length","required"=>"true","info"=>"true","inputWidth"=>"90","value"=>"0",
"tooltip"=>"Masukkan Length first. Obrigado","validate"=>"NotEmpty,ValidNumeric","maxLength"=>"","className"=>"txtright"),
array("type"=>"label","name"=>"lbllength","label"=>"Meter","className"=>"besidelabel"),
array("type"=>"input","name"=>"txt_height","label"=>"Height","required"=>"true","info"=>"true","inputWidth"=>"90","value"=>"0",
"tooltip"=>"Masukkan Height first. Obrigado","validate"=>"NotEmpty,ValidNumeric","maxLength"=>"","className"=>"txtright"),
array("type"=>"label","name"=>"lblheight","label"=>"Meter","className"=>"besidelabel"),
array("type"=>"input","name"=>"txt_totalseat","label"=>"Total Seat","required"=>"true","info"=>"true","inputWidth"=>"90","value"=>"0",
"tooltip"=>"Masukkan Total Seat first. Obrigado","validate"=>"NotEmpty,ValidNumeric","maxLength"=>"","className"=>"txtright"),
array("type"=>"input","name"=>"txt_maxton","label"=>"Maximal Tonase","required"=>"true","info"=>"true","inputWidth"=>"90","value"=>"0",
"tooltip"=>"Masukkan Maximal Tonase first. Obrigado","validate"=>"NotEmpty,ValidNumeric","maxLength"=>"","className"=>"txtright"),
array("type"=>"label","name"=>"lblheight","label"=>"Kg","className"=>"besidelabel"),
array("type"=>"input","name"=>"txt_thresholdton","label"=>"Threshold Tonase","required"=>"true","info"=>"true","inputWidth"=>"90","value"=>"0",
"tooltip"=>"Masukkan Threshold Tonase first. Obrigado","validate"=>"NotEmpty,ValidNumeric","maxLength"=>"","className"=>"txtright"),
array("type"=>"input","name"=>"txt_totalsekoci","label"=>"Total Lifeboat","required"=>"true","info"=>"true","inputWidth"=>"90","value"=>"0",
"tooltip"=>"Masukkan Total Lifeboat first. Obrigado","validate"=>"NotEmpty,ValidNumeric","maxLength"=>"","className"=>"txtright"),
array("type"=>"input","name"=>"txt_totalrestroom","label"=>"Total RestRoom","required"=>"true","info"=>"true","inputWidth"=>"90","value"=>"0",
"tooltip"=>"Masukkan Total RestRoom first. Obrigado","validate"=>"NotEmpty,ValidNumeric","maxLength"=>"","className"=>"txtright"),
array("type"=>"input","name"=>"txt_fuel","label"=>"Fuel","required"=>"true","info"=>"true","inputWidth"=>"90","value"=>"Solar",
"tooltip"=>"Masukkan Fuel first. Obrigado","validate"=>"NotEmpty","maxLength"=>"20","className"=>"txtleft"),
array("type"=>"input","name"=>"txt_capacityfuel","label"=>"Max Capacity","required"=>"true","info"=>"true","inputWidth"=>"90","value"=>"0",
"tooltip"=>"Masukkan Max Capacity first. Obrigado","validate"=>"NotEmpty,ValidNumeric","maxLength"=>"","className"=>"txtright"),
array("type"=>"label","name"=>"lblcapacityfuel","label"=>"Ltr","className"=>"besidelabel"),
array("type"=>"button","name"=>"btnsave","value"=>"Save","className"=>"button_update","offsetLeft"=>"20","offsetTop"=>"15"),
array("type"=>"button","name"=>"btnupdate","value"=>"Update","className"=>"button_saveas besidebtnsave","offsetLeft"=>"0","disabled"=>"1"),
//array("type"=>"button","name"=>"btnsubmit","value"=>"Submit","className"=>"button_submit besidebtnupdate","offsetLeft"=>"0","disabled"=>"1"),
array("type"=>"button","name"=>"btndelete","value"=>"Delete","className"=>"button_delete besidebtnupdate","offsetLeft"=>"0","disabled"=>"1"),
array("type"=>"button","name"=>"btncancel","value"=>"Cancel","className"=>"button_cancel besidebtndelete","offsetLeft"=>"0","disabled"=>"0")
)
)
);
$this->FN_DHTMLXFORM("myForm","divshipinfonew",$formdata);
$arrerror=array("txt_shipnumber"=>"Error Found : Please Insert <b>Voy Number</b> First.Obrigado",
"txt_shipname"=>"Error Found : Please Insert <b>Ship Name</b> first.Obrigado",
"txt_datecreated"=>"Error Found : Please Insert <b>Created Date</b> first.Obrigado",
"txt_width"=>"Error Found : Insert <b>Width</b> Information First with numeric.Obrigado",
"txt_shiplength"=>"Error Found : Insert <b>Length</b> Information First with numeric.Obrigado",
"txt_height"=>"Error Found : Please Insert <b>Height</b> first.Obrigado",
"txt_totalseat"=>"Error Found : Please Insert <b>Total Seat</b> first.Obrigado",
"txt_maxton"=>"Error Found : Please Insert <b>Maximal Tonase</b> first.Obrigado",
"txt_thresholdton"=>"Error Found : Please Insert <b>Threshold Tonase</b> first.Obrigado",
"txt_totalsekoci"=>"Error Found : Please Insert <b>Total Lifeboat</b> first.Obrigado",
"txt_totalrestroom"=>"Error Found : Please Insert <b>Total RestRoom</b> first.Obrigado",
"txt_fuel"=>"Error Found : Please Insert <b>Fuel</b> first.Obrigado",
"txt_capacityfuel"=>"Error Found : Please Insert <b>Max Capacity</b> first.Obrigado"
);
$this->FN_DHTMLXFORMVALIDATIONERROR("myForm",$arrerror);
$arrayControls=array("txt_id"=>"",
"txt_shipnumber"=>"",
"txt_shipname"=>"",
"txt_datecreated"=>"",
"txt_width"=>"",
"txt_shiplength"=>"",
"txt_height"=>"",
"txt_totalseat"=>"",
"txt_maxton"=>"",
"txt_thresholdton"=>"",
"txt_totalsekoci"=>"",
"txt_totalrestroom"=>"",
"txt_fuel"=>"",
"txt_capacityfuel"=>""
);
// === Form Event
$onobjkeydown="if(ev.keyCode==13){ev.stopPropagation();ev.preventDefault();if(myForm.isItemEnabled('btnupdate')){myForm.setItemFocus('btnupdate');dhtmlXclickButton('btnupdate');}else{myForm.setItemFocus('btnsave');}return false;}";
$onbuttonclickbtnsave="if(myForm.validate())
{
dhtmlx.confirm({
title:'Confirmation',text:'Are you will be saved and data is correctly?',type:'confirm',
callback:function(result){
if(result)
{";
$params="'obj=".$this->enc("data_shipinfo")."&task=".$this->enc("saverecord")."'";
$onformsenddata="url=fn_dhtmlxsenddata('".$this->enc("obj_data")."',$params);
myForm.send(url,\"get\",function(loader, response){";
$onformsenddata.=$this->FN_DHTMLXWINDOWSHIDEPROGRESS();
$onformsenddata.="var sp=trim(response).split('|');
//alert(response);
if(sp[0]=='ok')
{
fn_dhtmlxmessage('','Data <b>'+myForm.getItemValue('txt_shipnumber')+'</b> has been saved');";
$onformsenddata.=$this->FN_DHTMLXFORMCLEAR2("myForm",$arrayControls,"txt_shipnumber");
$onformsenddata.="fn_grid_loaddata();
}
else if(sp[0]=='failed')
{fn_dhtmlxmessage('error','Error Found : '+sp[1]);}
else
{fn_dhtmlxmessage('error','Error Found : '+response);}
});";
$onbuttonclickbtnsave.=$this->FN_DHTMLXWINDOWSHOWPROGESS($onformsenddata);
$onbuttonclickbtnsave.=" }
}
});
}";
$onbuttonclickbtnupdt="if(myForm.validate())
{
dhtmlx.confirm({
title:'Confirmation',text:'Are you will be updated and data is correctly?',type:'confirm',
callback:function(result){
if(result)
{";
$params="'obj=".$this->enc("data_shipinfo")."&task=".$this->enc("updrecord")."'";
$onformsenddata="url=fn_dhtmlxsenddata('".$this->enc("obj_data")."',$params);
myForm.send(url,\"get\",function(loader, response){";
$onformsenddata.=$this->FN_DHTMLXWINDOWSHIDEPROGRESS();
$onformsenddata.="var sp=trim(response).split('|');
//alert(response);
if(sp[0]=='ok')
{
fn_dhtmlxmessage('','Data <b>'+myForm.getItemValue('txt_shipnumber')+'</b> has been update');";
$onformsenddata.=$this->FN_DHTMLXFORMCLEAR2("myForm",$arrayControls,"txt_shipnumber");
$onformsenddata.="myForm.enableItem('btnsave');";
$onformsenddata.="myForm.disableItem('btnupdate');";
$onformsenddata.="myForm.disableItem('btndelete');";
$onformsenddata.="fn_grid_loaddata();
}
else if(sp[0]=='failed')
{fn_dhtmlxmessage('error','Error Found : '+sp[1]);}
else
{fn_dhtmlxmessage('error','Error Found : '+response);}
});";
$onbuttonclickbtnupdt.=$this->FN_DHTMLXWINDOWSHOWPROGESS($onformsenddata);
$onbuttonclickbtnupdt.=" }
}
});
}";
$eventafterdeleted=$this->FN_DHTMLXFORMCLEAR2("myForm",$arrayControls,"txt_shipnumber");
$eventafterdeleted.="myForm.enableItem('btnsave');";
$eventafterdeleted.="myForm.disableItem('btnupdate');";
$eventafterdeleted.="myForm.disableItem('btndelete');";
$eventafterdeleted.="fn_grid_loaddata();";
$onbuttonclickbtndeleted=$this->FN_DHTMLXREMARKFORDELETED2("obj_data","data_shipinfo","myForm.getItemValue('txt_id')","myForm.getItemValue('txt_shipnumber')",$eventafterdeleted);
$onbuttonclickbtncancel=$this->FN_DHTMLXFORMCLEAR2("myForm",$arrayControls);
$onbuttonclickbtncancel.="myForm.enableItem('btnsave');";
$onbuttonclickbtncancel.="myForm.disableItem('btnupdate');";
$onbuttonclickbtncancel.="myForm.disableItem('btndelete');";
$onbuttonclickbtncancel.="myForm.setItemFocus('txt_shipnumber');";
$onbuttonclickbtncancel.="fn_grid_loaddata();";
$arrevent=array(
array("eventname"=>"onbuttonclick","eventparam"=>"id,val",
"switch"=>array(
"btnsave"=>"$onbuttonclickbtnsave",
"btnupdate"=>"$onbuttonclickbtnupdt",
"btndelete"=>"$onbuttonclickbtndeleted",
"btncancel"=>"$onbuttonclickbtncancel"
)
),
array("eventname"=>"onkeydown","eventparam"=>"inp,ev,id,val",
"switch"=>array(
"txt_capacityfuel"=>"$onobjkeydown"
)
)
);
$this->FN_DHTMLXFORMEVENT("myForm",$arrevent);
// === FORM SEARCH AND GRID
$formdata=array(
array("type"=>"settings","position"=>"label-left","labelWidth"=>"180","inputWidth"=>"120"),
array("type"=>"fieldset","width"=>"580","label"=>"Search",
"list"=>array(
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"),
array("type"=>"button","name"=>"btnfind","value"=>"","className"=>"button_find","offsetLeft"=>"10","offsetTop"=>"5")
)
)
);
$this->FN_DHTMLXFORM("myFormsearch","divshipinfosearch",$formdata,true);
$ontxtsearchkeydown="if(ev.keyCode==13){ev.stopPropagation();ev.preventDefault();myFormsearch.setItemFocus('btnfind');}";
$arrevent=array(
array("eventname"=>"onbuttonclick","eventparam"=>"id,val",
"switch"=>array(
"btnfind"=>"fn_grid_loaddata()"
)
),
array("eventname"=>"onkeydown","eventparam"=>"inp,ev,id,val",
"switch"=>array(
"txtsearch"=>"$ontxtsearchkeydown"
)
)
);
$this->FN_DHTMLXFORMEVENT("myFormsearch",$arrevent);
$grdinit=array("gridname"=>"dgshipinfo","divtarget"=>"div_dgshipinfo","divpaging"=>"div_dgshipinfopaging","paginglimit"=>PAGE_LIMIT,
"showloader"=>"true");
$gridproperties=array("id"=>"right,ro,96,right,int,false,true",
"No.&nbsp;"=>"right,ro,35,center,int,false",
"Voy Number"=>"center,ro,110,center,str,false",
"Ship Name"=>"left,ro,180,left,str,false",
"Created Date"=>"center,ro,90,center,date,false",
"Width&nbsp;"=>"right,ro,90,right,int,false",
"Length&nbsp;"=>"right,ro,90,right,int,false",
"Height&nbsp;"=>"right,ro,90,right,int,false",
"Total Seat&nbsp;"=>"right,ro,110,right,int,false",
"Maximal Tonase(Kg)&nbsp;"=>"right,ro,140,right,int,false",
"Threshold Tonase(Kg)&nbsp;"=>"right,ro,140,right,int,false",
"Total Lifeboat&nbsp;"=>"right,ro,110,right,int,false",
"Total RestRoom&nbsp;"=>"right,ro,110,right,int,false",
"Fuel"=>"left,ro,102,left,str,false",
"Max Capacity&nbsp;"=>"right,ro,110,right,int,false");
$this->FN_DHTMLXGRIDVIEW($grdinit,$gridproperties,"bricks","","fn_grid_loaddata()");
$arrfields=array("txt_id"=>"","txt_shipnumber"=>"","txt_shipname"=>"","txt_datecreated"=>"","txt_width"=>"","txt_shiplength"=>"","txt_height"=>"","txt_totalseat"=>"","txt_maxton"=>"","txt_thresholdton"=>"","txt_totalsekoci"=>"","txt_totalrestroom"=>"","txt_fuel"=>"","txt_capacityfuel"=>"");
$otherevent="";
$this->FN_DHTMLXGRIDVIEWTOFORMNEW("dgshipinfo","myForm","tbl_ship_information",0,$arrfields,"");
echo " }
function fn_grid_loaddata()
{
var keyword=myFormsearch.getItemValue('txtsearch');
url=fn_dhtmlxloadobject('".$this->enc("obj_data")."','obj=".$this->enc("data_shipinfo")."&task=".$this->enc("grdrecord")."&keyword='+keyword);
//alert(url);
dgshipinfo.clearAndLoad(url);";
echo " }
</script>";
echo $this->FN_CLOSEHEADER();
echo $this->FN_CREATEBODY("e8f1ff");
echo "<table width=\"98%\" border=\"0\">
<tr>
<td>";
$qry="select filepdf from ".DB_APORTIL.".tbl_manualbook where isdeleted=0 and filepdf='ships_information.pdf'";
$filepdf=$this->fn_get_fieldvalue("filepdf",$qry);
$urlmanualbook="<a href='".UPLOAD_DIR."/manualbook/$filepdf"."' target='_blank'><img src='".PATH_THEME."/images/pdf.png' />&nbsp;<b>MANUAL BOOK</b></a>";
$url="location.reload();";
$myuri=array("<b>SHIP INFORMATION</b>"=>"$url|id='a_newticket'","$urlmanualbook"=>"|id='a_manualbook'");
echo $this->MULTIPLE_LINK($myuri);
echo " </td>
</tr>
<tr>
<td>
<div id=\"divshipinfocontent\" style=\"margin-left:0px;\">
<table width=\"98%\" border=\"0\">
<tr>
<td width=\"45%\" valign=\"top\">
<div id=\"divshipinfonew\" style=\"\"></div>
</td>
<td valign=\"top\">
<table width=\"98%\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td valign=\"top\">
<div id=\"divshipinfosearch\" style=\"width:560px;margin-top:-6px;\"></div>
</td>
</tr>
<tr>
<td>
<div id=\"div_dgshipinfo\" style=\"height:380px;width:580px;overflow:hidden\"></div>
</td>
</tr>
<tr>
<td>
<div id=\"div_dgshipinfopaging\" style=\"width:598px;margin-top:1px\"></div>
</td>
</tr>
<tr><td valign=\"top\"><div id=\"loadergrid\" style=\"z-index:100;position:absolute;margin-top:-220px;margin-left:287px;display:visibility;\">".$this->CREATE_IMAGE("loadergrid.gif")."</div></td></tr>
<tr>
<td valign=\"top\">
<table>
<tr>
<td style='color:red;font-weight:bold;'>Notes</td>
<td>:</td>
<td>- Click Row For Edit</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>";
echo $this->FN_CREATEFOOTER();
}
public function fn_grdrecord()
{
$keyword=$_REQUEST["keyword"];
header("Content-type: text/xml");
echo('<?xml version="1.0" encoding="utf-8"?>');
echo "<rows id='0'>";
$qry="select id,shipnumber,shipname,datecreated,width,shiplength,height,totalseat,maxton,thresholdton,totalsekoci,totalrestroom,fuel,capacityfuel
from ".DB_APORTIL.".tbl_ship_information
where shipnumber like '%$keyword%' and isdeleted=0
order by id asc limit ".TBL_PAGE_LIMIT;
$rs=$this->selectquery($qry);
if($rs)
{
$i=1;
while($row=$this->data_row_array($rs))
{
echo ("<row id='".$row["id"]."'>");
print("<cell><![CDATA[".$row["id"]."]]></cell>");
print("<cell><![CDATA[".$i."]]></cell>");
print("<cell><![CDATA[".$row["shipnumber"]."]]></cell>");
print("<cell><![CDATA[".$row["shipname"]."]]></cell>");
print("<cell><![CDATA[".date("Y-m-d",strtotime($row["datecreated"]))."]]></cell>");
print("<cell><![CDATA[".$row["width"]."]]></cell>");
print("<cell><![CDATA[".$row["shiplength"]."]]></cell>");
print("<cell><![CDATA[".$row["height"]."]]></cell>");
print("<cell><![CDATA[".$row["totalseat"]."]]></cell>");
print("<cell><![CDATA[".$row["maxton"]."]]></cell>");
print("<cell><![CDATA[".$row["thresholdton"]."]]></cell>");
print("<cell><![CDATA[".$row["totalsekoci"]."]]></cell>");
print("<cell><![CDATA[".$row["totalrestroom"]."]]></cell>");
print("<cell><![CDATA[".$row["fuel"]."]]></cell>");
print("<cell><![CDATA[".$row["capacityfuel"]."]]></cell>");
echo ("</row>");
$i+=1;
}
}
else
{
echo mysql_errno().": ".mysql_error()." at ".__LINE__." line in ".__FILE__." file<br>";
}
echo "</rows>";
}
public function fn_saverecord($isupdate=null)
{
if($isupdate){$id=$_REQUEST['txt_id'];}
$shipnumber=$_REQUEST['txt_shipnumber'];
$shipname=$_REQUEST['txt_shipname'];
$datecreated=$_REQUEST['txt_datecreated'];
$width=$_REQUEST['txt_width'];
$shiplength=$_REQUEST['txt_shiplength'];
$height=$_REQUEST['txt_height'];
$totalseat=$_REQUEST['txt_totalseat'];
$maxton=$_REQUEST['txt_maxton'];
$thresholdton=$_REQUEST['txt_thresholdton'];
$totalsekoci=$_REQUEST['txt_totalsekoci'];
$totalrestroom=$_REQUEST['txt_totalrestroom'];
$fuel=$_REQUEST['txt_fuel'];
$capacityfuel=$_REQUEST['txt_capacityfuel'];
$qry="insert into ".DB_APORTIL.".tbl_ship_information
set shipnumber='$shipnumber',shipname='$shipname',datecreated='$datecreated',width='$width',shiplength='$shiplength',height='$height',
totalseat='$totalseat',maxton='$maxton',thresholdton='$thresholdton',totalsekoci='$totalsekoci',totalrestroom='$totalrestroom',fuel='$fuel',
capacityfuel='$capacityfuel',iby='".$_SESSION['nik']."',idt=now()";
if($isupdate)
{
$qry="update ".DB_APORTIL.".tbl_ship_information
set shipnumber='$shipnumber',shipname='$shipname',datecreated='$datecreated',width='$width',shiplength='$shiplength',height='$height',
totalseat='$totalseat',maxton='$maxton',thresholdton='$thresholdton',totalsekoci='$totalsekoci',totalrestroom='$totalrestroom',fuel='$fuel',
capacityfuel='$capacityfuel',uby='".$_SESSION['nik']."',udt=now()
where id='$id'";
}
if($this->executequery($qry)){echo "ok|";return true;}
}
public function fn_updrecord(){$this->fn_saverecord(true);}
public function fn_delrecord()
{
$id=$_REQUEST['txt_id'];
$remark=$_REQUEST['txtremark'];
$qry="update ".DB_APORTIL.".tbl_ship_information
set isdeleted=1,remark='$remark',dby='".$_SESSION['nik']."',ddt=now()
where id='$id'";
if($this->executequery($qry)){echo "ok|";return true;}
else
{
echo "failed|".$this->getErrorQuery();
}
}
}
?>