Files
aportil/objectx/obj_data/data_priceinfo.php

394 lines
28 KiB
PHP

<?php
class DATA_PRICEINFO extends DATA
{
public function data_priceinfo_javainit()
{
}
public function fn_priceinfo_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_priceinfo();
break;
case $task:
$task="fn_".$task;
if(method_exists($this,$task)){$this->$task();}
break;
default:
$this->fn_default_priceinfo();
break;
}
}
public function fn_default_priceinfo()
{
echo $this->FN_CREATEHEADER();
echo "<style>
.besidebtnsave {margin-left:110px;margin-top:-6px;position:absolute;}
.besidebtnupdate {margin-left:214px;margin-top:-6px;position:absolute;}
.besidebtnsubmit {margin-left:292px;margin-top:-6px;position:absolute;}
.besidebtndelete {margin-left:310px;margin-top:-6px;position:absolute;}
.besidelabel {margin-left:340px;margin-top:-6px;position:absolute;}
</style>";
echo "<script>
var myForm,myFormsearch,dgpriceinfo;
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"=>"combo","name"=>"cbo_idroutestart","label"=>"From","required"=>"true","info"=>"true","inputWidth"=>"150","value"=>"",
"tooltip"=>"Pilih From terlebih dahulu. TERIMA KASIH","validate"=>"NotEmpty","maxLength"=>"11","className"=>"txtleft"),
array("type"=>"combo","name"=>"cbo_idrouteend","label"=>"To","required"=>"true","info"=>"true","inputWidth"=>"150","value"=>"",
"tooltip"=>"Pilih To terlebih dahulu. TERIMA KASIH","validate"=>"NotEmpty","maxLength"=>"11","className"=>"txtleft"),
array("type"=>"input","name"=>"txt_prices","label"=>"Price","required"=>"true","info"=>"true","inputWidth"=>"150","value"=>"0",
"tooltip"=>"Masukkan Price terlebih dahulu. TERIMA KASIH","validate"=>"NotEmpty","maxLength"=>"","className"=>"txtright",
"numberFormat"=>"0,000.00"),
array("type"=>"label","name"=>"lblmeter","label"=>"\$","className"=>"besidelabel"),
array("type"=>"input","name"=>"txt_years","label"=>"Years","required"=>"true","info"=>"true","inputWidth"=>"110","value"=>date("Y"),
"tooltip"=>"Masukkan Years terlebih dahulu. TERIMA KASIH","validate"=>"NotEmpty","maxLength"=>"11","className"=>"txtcenter"),
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","divpriceinfonew",$formdata);
$urlcbo="fn_dhtmlxloadobject('".$this->enc("obj_controller")."','obj=".$this->enc("-")."&task=".$this->enc("dhtmlxcbofilter")."&tableobj=tbl_route_information|id,routename')";
$this->FN_COMBOVALIDATIONVALUENEW("myForm","cbo_idroutestart","tbl_route_information","$urlcbo","");
$urlcbo="fn_dhtmlxloadobject('".$this->enc("obj_controller")."','obj=".$this->enc("-")."&task=".$this->enc("dhtmlxcbofilter")."&tableobj=tbl_route_information|id,routename')";
$this->FN_COMBOVALIDATIONVALUENEW("myForm","cbo_idrouteend","tbl_route_information","$urlcbo","");
$arrerror=array("cbo_idroutestart"=>"Error Found : Harap Isikan <b>From</b> terlebih dahulu.TERIMA KASIH",
"cbo_idrouteend"=>"Error Found : Harap Isikan <b>To</b> terlebih dahulu.TERIMA KASIH",
"txt_prices"=>"Error Found : Harap Isikan <b>Price</b> terlebih dahulu.TERIMA KASIH",
"txt_years"=>"Error Found : Harap Isikan <b>Years</b> terlebih dahulu.TERIMA KASIH"
);
$this->FN_DHTMLXFORMVALIDATIONERROR("myForm",$arrerror);
$arrayControls=array("txt_id"=>"",
"cbo_idroutestart"=>"",
"cbo_idrouteend"=>"",
"txt_prices"=>0,
"txt_years"=>date("Y")
);
// === 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())
{
if(myForm.getItemValue('txt_prices')<=0){
fn_dhtmlxmessage('error','Please insert price!');
myForm.setItemFocus('txt_prices');
return false;
}
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_priceinfo")."&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('cbo_idroutestart')+'</b> has been saved');";
$onformsenddata.=$this->FN_DHTMLXFORMCLEAR2("myForm",$arrayControls,"cbo_idroutestart");
$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_priceinfo")."&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('cbo_idroutestart')+'</b> has been update');";
$onformsenddata.=$this->FN_DHTMLXFORMCLEAR2("myForm",$arrayControls,"cbo_idroutestart");
$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,"cbo_idroutestart");
$eventafterdeleted.="myForm.enableItem('btnsave');";
$eventafterdeleted.="myForm.disableItem('btnupdate');";
$eventafterdeleted.="myForm.disableItem('btndelete');";
$eventafterdeleted.="fn_grid_loaddata();";
$onbuttonclickbtndeleted=$this->FN_DHTMLXREMARKFORDELETED2("obj_data","data_priceinfo","myForm.getItemValue('txt_id')","myForm.getItemValue('cbo_idroutestart')",$eventafterdeleted);
$onbuttonclickbtncancel=$this->FN_DHTMLXFORMCLEAR2("myForm",$arrayControls);
$onbuttonclickbtncancel.="myForm.enableItem('btnsave');";
$onbuttonclickbtncancel.="myForm.disableItem('btnupdate');";
$onbuttonclickbtncancel.="myForm.disableItem('btndelete');";
$onbuttonclickbtncancel.="myForm.setItemFocus('cbo_idroutestart');";
$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_years"=>"$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","divpriceinfosearch",$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"=>"dgpriceinfo","divtarget"=>"div_dgpriceinfo","divpaging"=>"div_dgpriceinfopaging","paginglimit"=>PAGE_LIMIT,
"showloader"=>"true");
$gridproperties=array("id"=>"right,ro,96,right,int,false,true",
"No.&nbsp;"=>"right,ro,35,center,int,false",
"From"=>"left,ro,112,left,str,false",
"To"=>"left,ro,112,left,str,false",
"Price&nbsp;"=>"right,ro,120,right,int,false",
"Years"=>"center,ro,120,center,int,false");
$this->FN_DHTMLXGRIDVIEW($grdinit,$gridproperties,"bricks","","fn_grid_loaddata()");
$arrfields=array("txt_id"=>"","cbo_idroutestart"=>"idroutestart|routenamestart","cbo_idrouteend"=>"idrouteend|routenameend","txt_prices"=>"","txt_years"=>"");
$otherevent="";
$this->FN_DHTMLXGRIDVIEWTOFORMNEW("dgpriceinfo","myForm","tbl_price_information",0,$arrfields,"");
echo " }
function fn_grid_loaddata()
{
var keyword=myFormsearch.getItemValue('txtsearch');
url=fn_dhtmlxloadobject('".$this->enc("obj_data")."','obj=".$this->enc("data_priceinfo")."&task=".$this->enc("grdrecord")."&keyword='+keyword);
//alert(url);
dgpriceinfo.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='passengerprice_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>PRICE INFORMATION</b>"=>"$url|id='a_newticket'","$urlmanualbook"=>"|id='a_manualbook'");
echo $this->MULTIPLE_LINK($myuri);
echo " </td>
</tr>
<tr>
<td>
<div id=\"divpriceinfocontent\" style=\"margin-left:0px;\">
<table width=\"98%\" border=\"0\">
<tr>
<td width=\"45%\" valign=\"top\">
<div id=\"divpriceinfonew\" style=\"\"></div>
</td>
<td valign=\"top\">
<table width=\"98%\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td valign=\"top\">
<div id=\"divpriceinfosearch\" style=\"width:560px;margin-top:-6px;\"></div>
</td>
</tr>
<tr>
<td>
<div id=\"div_dgpriceinfo\" style=\"height:380px;width:580px;overflow:hidden\"></div>
</td>
</tr>
<tr>
<td>
<div id=\"div_dgpriceinfopaging\" 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,idroutestart,routenamestart,idrouteend,routenameend,prices,years
from ".DB_APORTIL.".tbl_price_information
where idroutestart 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["routenamestart"]."]]></cell>");
print("<cell><![CDATA[".$row["routenameend"]."]]></cell>");
print("<cell><![CDATA[".number_format($row["prices"],2,".","00")." \$]]></cell>");
print("<cell><![CDATA[".$row["years"]."]]></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'];}
$idroutestart=$_REQUEST['cbo_idroutestart'];
$routenamestart=$this->fn_get_fieldvalue("routename","select routename from ".DB_APORTIL.".tbl_route_information where id='".$idroutestart."'");
$idrouteend=$_REQUEST['cbo_idrouteend'];
$routenameend=$this->fn_get_fieldvalue("routename","select routename from ".DB_APORTIL.".tbl_route_information where id='".$idrouteend."'");
$prices=$_REQUEST['txt_prices'];
$years=$_REQUEST['txt_years'];
// === Check Validation Route Price Information
$qry="select id from ".DB_APORTIL.".tbl_price_information
where idroutestart='$idroutestart' and idrouteend='$idrouteend' and years='$years' and isdeleted='0'
order by id desc limit 1";
if($this->fn_row_isexists($qry)&&!$isupdate){
echo "failed|Price is already exists, for editing please click your Table";return false;
}
// =============================================
$qry="insert into ".DB_APORTIL.".tbl_price_information
set idroutestart='$idroutestart',routenamestart='$routenamestart',idrouteend='$idrouteend',routenameend='$routenameend',
prices='$prices',years='$years',iby='".$_SESSION['nik']."',idt=now()";
if($isupdate)
{
$qry="update ".DB_APORTIL.".tbl_price_information
set idroutestart='$idroutestart',routenamestart='$routenamestart',idrouteend='$idrouteend',routenameend='$routenameend',
prices='$prices',years='$years',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_price_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();
}
}
}
?>