<?php
function SaveData() {
        global $objAxpDB;
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "simpan":

		break;
    }
    return $strSQL;

   }
    
function UpdateData() {
        global $objAxpDB;
        $objAxpDB->Allow_Update(false);
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "update":
                $strSQL['a'][]="DELETE
                                FROM tlbom_detail
                                WHERE ftitem_code='{$_REQUEST['ftitem_code']}'";

                $strSQL['a'][]="UPDATE tlbom_header
                                SET
									ftbom_type='{$_REQUEST['ftbom_type']}',
                                    ftitem_name='{$_REQUEST['ftitem_name']}',
                                    ftuom_code='{$_REQUEST['ftuom_code']}',
									ftdepartment_code='{$_REQUEST['ftdepartment_code']}',
                                    ftdescription='{$_REQUEST['ftdescription']}',
                                    fnstatus='{$_REQUEST['fnstatus']}',
									ffnetto='{$_REQUEST['ffnetto']}',
									ffbruto='{$_REQUEST['ffbruto']}'
                                WHERE ftitem_code='{$_REQUEST['ftitem_code']}'";
                for($j=1; $j<count($_REQUEST['fnindexD0']); $j++) {
                       $strSQL['a'][]="INSERT INTO tlbom_detail
                                            (ftitem_type,ftitem_code, fnindex, ftitemdetail_code,ftitemdetail_name,ftoumdetail_code,fnqty,ftuomdetail_multi_code)
                                        SELECT '{$_REQUEST['ftitem_typeD0'][$j]}' as ftitem_type,'{$_REQUEST['ftitem_code']}' as ftitem_code ,'{$_REQUEST['fnindexD0'][$j]}' AS fnindex,'{$_REQUEST['ftitemdetail_codeD0'][$j]}' AS ftitemdetail_code,
                                               '{$_REQUEST['ftitemdetail_nameD0'][$j]}' AS ftitemdetail_name,'{$_REQUEST['ftoumdetail_codeD0'][$j]}'  AS ftoumdetail_code, '".CCur($_REQUEST['fnqtyD0'][$j])."'  AS fnqty,'{$_REQUEST['ftuomdetail_multi_codeD0'][$j]}'  AS ftuomdetail_multi_code
                                            ";
                    }
          break;
    }
    return $strSQL;

   }

  function DeleteData() {
        global $objAxpDB;
        $objAxpDB->Allow_Delete(false);
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "hapus":
                $strSQL['DELETE a'][]="DELETE FROM tlbom_detail WHERE ftitem_code='".$_REQUEST['ftitem_code']."'";
                $strSQL['DELETE a'][]="DELETE FROM tlbom_header WHERE ftitem_code='".$_REQUEST['ftitem_code']."'";
				$strSQL['a'][]="UPDATE tlbom_header
                                SET
                                    fnstatus='{0}'  
                                WHERE ftitem_code='{$_REQUEST['ftitem_code']}'";
            break;
		 }
    return $strSQL;

   }


?>
