<?php

function UpdateDataLast() {
 global $objAxpDB;
 $strSQL=array();
 $objAxpDB->Allow_update(true);

 switch($_REQUEST[mode]) {
 case "update":

 // $ambil = mysql_query("SELECT fnurut, `ftmenu_category`, ftmenu_name FROM tlmenu
 //          where ftmenu_category='{$_REQUEST['ftmenu_category']}'
 //          and ftmenu_type = '{$_REQUEST['ftmenu_type']}'
 //          AND ftmenu_code = '{$_REQUEST['ftmenu_code']}'");


 $ambil = mysql_query("SELECT `fnOrder`, `ftreport_group` FROM tlreport
          WHERE ftreport_group = '{$_REQUEST['ftreport_group']}'
          AND ftreport_code = '{$_REQUEST['ftreport_code']}'");

 $hasil  = mysql_fetch_assoc($ambil);

  $srint1 ="UPDATE tlreport
  SET fnOrder = '{$hasil['fnOrder']}'
  WHERE ftreport_group = '{$_REQUEST['ftreport_group']}'
  AND fnOrder = '{$_REQUEST['fnOrder']}'";

  mysql_query($srint1);

  $srint2 ="UPDATE tlreport
  SET fnOrder = '{$_REQUEST['fnOrder']}'
  WHERE ftreport_group = '{$_REQUEST['ftreport_group']}'
  AND ftreport_code = '{$_REQUEST['ftreport_code']}'";

  mysql_query($srint2);

         break;
  }

  return $strSQL;
}

function SaveData() {
    global $objAxpDB;
    $strSQL=array();
    $objAxpDB->Allow_Save(true);
    switch($_REQUEST[mode]) {

  case "simpan":

  $ambil = mysql_query("SELECT `fnOrder`, `ftreport_group` FROM tlreport
           WHERE ftreport_group = '{$_REQUEST['ftreport_group']}'
           AND fnOrder = '{$_REQUEST['fnOrder']}'");

  if($hasil = mysql_fetch_assoc($ambil)){

  $ssql1="SELECT MAX(fnOrder)
          FROM tlreport
          WHERE ftreport_group='{$_REQUEST['ftreport_group']}'";

  $no=RetRstField($ssql1);

  $plus = $no+1;

  $srint ="UPDATE tlreport
  SET fnOrder = '{$plus}'
  WHERE ftreport_group = '{$_REQUEST['ftreport_group']}'
  AND fnOrder = '{$_REQUEST['fnOrder']}'";

  mysql_query($srint);

}
break;

}

// echo "<pre>";
// print_r($strSQL);
// echo "</pre>";
// die;
   return $strSQL;
}

?>
