<?php
   function SaveData() {
    global $objAxpDB;
    $strSQL=array();
    $objAxpDB->Allow_Save(false);
    switch($_REQUEST[mode]) {
    case "simpan":
      $strSQL['Insert Project Category HDR'][]="
              INSERT INTO tlproject_category_hdr(
              ftcategory_code,ftproject_code,
              ftcreated_user, fdcreated_date
              ) SELECT
              '{$_REQUEST["ftcategory_code"]}' AS ftcategory_code,'{$_REQUEST["ftproject_code"]}' AS ftproject_code,
              '{$_SESSION['username']}' AS ftcreated_user, now() AS fdcreated_date";
			  
			  for($j=1; $j<count($_REQUEST['fnindexD0']); $j++) {
					   $strSQL['Insert Project Category'][]="
							   INSERT INTO tlproject_category
								  (fnindex,ftcategory_code, ftproject_code, ftproject_category_name, ftcreated_user, fdcreated_date, ftmodified_user, fdmodified_date)
								SELECT
								  '{$_REQUEST['fnindexD0'][$j]}', '{$_REQUEST['ftcategory_code']}','{$_REQUEST['ftproject_code']}', '{$_REQUEST['ftproject_category_nameD0'][$j]}','{$_SESSION['username']}',now(),'{$_SESSION['username']}',now()";

			  }

      break;
    }

    return $strSQL;
   }

   
  function UpdateData() {
       global $objAxpDB;
        $strSQL=array();
        $objAxpDB->Allow_Update(false);
		switch($_REQUEST[mode]) {
			case "update":
                $strSQL["DELETE project category hdr"][]="DELETE from tlproject_category_hdr where ftcategory_code='{$_REQUEST['ftcategory_code']}' ";
				
                $strSQL["DELETE project category det"][]="DELETE from tlproject_category where ftcategory_code='{$_REQUEST['ftcategory_code']}' ";
				
      $strSQL['Insert Project Category HDR'][]="
              INSERT INTO tlproject_category_hdr(
              ftcategory_code,
              ftcreated_user, fdcreated_date
              ) SELECT
              '{$_REQUEST["ftcategory_code"]}' AS ftcategory_code,
              '{$_SESSION['username']}' AS ftcreated_user, now() AS fdcreated_date";				
				
               for($j=1; $j<count($_REQUEST['fnindexD0']); $j++) {
					   $strSQL['Insert Project Category'][]="
							   INSERT INTO tlproject_category
								  (fnindex,ftcategory_code, ftproject_code, ftproject_category_name, ftcreated_user, fdcreated_date, ftmodified_user, fdmodified_date)
								SELECT
								  '{$_REQUEST['fnindexD0'][$j]}', '{$_REQUEST['ftcategory_code']}','{$_REQUEST['ftproject_code']}', '{$_REQUEST['ftproject_category_nameD0'][$j]}','{$_SESSION['username']}',now(),'{$_SESSION['username']}',now()";

			  }
            break;
        }
     return $strSQL;
  }



?>
