<?php
   if($_REQUEST['ajax']) {
        switch($_REQUEST['code']) {
            case "transno":
              if(RetRstField("SELECT fnid FROM tlproject_category WHERE ftcategory_code='{$_REQUEST['fttrans_no']}'")) {
                    ?>
                    alert('Kode project_category sudah dipakai...');
                    OnChangeDate_fdtrans_date();
                    <?php
              }
              else {
                    ?>
                    submitbutton('Simpan','','','','');
                    <?php
              }
            break;

        }
        die("");
    }

    Getsecurity('category_project');
   
    $objAxpDB->ViewName("Daftar Project Category");
    // $objAxpDB->ViewTable("vSAproject_category");
    $objAxpDB->ViewSQL("SELECT a.fnid, a.ftcategory_code, e.fttrans_status_name
                                FROM tlproject_category_hdr a LEFT JOIN tstransaction_status e ON a.fnstatus = e.fntrans_status_code AND e.fntrans_group_code = 73");
    $objAxpDB->ViewCaption("ID, Kode Category,  Status");

	
	
	
    $objAxpDB->FormName("Project Category");
    $objAxpDB->FormSQL("SELECT a.ftcategory_code, a.ftproject_code,a.fnstatus
                                FROM tlproject_category_hdr a");

    $objAxpDB->FormCaption("kode Kategory, Project, Status");
	

	if ($_REQUEST['id'] == 0) {
	$objAxpDB->Lookup("ftproject_code", 
	"SELECT a.ftproject_code,a.ftproject_name FROM tlproject a 
	WHERE a.ftproject_code NOT IN (SELECT ftproject_code FROM tlproject_category)
	ORDER BY ftproject_code ASC", 
	"ftproject_code", 
	"ftproject_name", -1,true);
	}
	else{	
	$objAxpDB->Lookup("ftproject_code", 
	"SELECT a.ftproject_code,a.ftproject_name FROM tlproject a ", 
	"ftproject_code", 
	"ftproject_name", -1,true);		
	}
	
	$objAxpDB->Lookup("fnstatus", 
	"SELECT fntrans_status_code,fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 73", 
	"fntrans_status_code", 
	"fttrans_status_name", 1,true);   
			
    $objAxpDB->SetStatus("id");
    $objAxpDB->FormPosition("TL,TL,TL");

    $ssql="SELECT ftcategory_code FROM tlproject_category_hdr WHERE fnid='{$_REQUEST['id']}'";
    $rs=mysql_query($ssql);
    $r=mysql_fetch_assoc($rs);

    $objAxpDB->GridName(0, "Category Detail");
    $objAxpDB->GridSQL(0, "SELECT fnindex,ftproject_category_name FROM tlproject_category WHERE ftcategory_code='{$r['ftcategory_code']}' #");
    $objAxpDB->GridCaption(0, "No. ,Nama Category , Kode User");
    $objAxpDB->GridLocked(0,'1,0');	

    $objAxpDB->GridAllowAddNew(0, TRUE);
    $objAxpDB->GridAllowDelete(0, TRUE);
    $objAxpDB->GridAutoAdd(0, TRUE);
	
	
    if ($objAxpDB->GetStatus("id") == "") {
            $objAxpDB->ButtonShow("baru, cetak_daftar, export_excel , tutup");

    }
    elseif ($objAxpDB->GetStatus("id") == 0) {
            $objAxpDB->ButtonShow("reset, simpan, tutup");

    }
    elseif ($objAxpDB->GetStatus("id") != 0) {
            $objAxpDB->ButtonShow("update, hapus, tutup");
            $objAxpDB->FormLocked("1");
    }
    $objAxpDB->Process();
    $objAxpDB->WriteHtmlTable();
?>
