<?php
function ValCheckLocation() {

    for($j=1; $j<count($_REQUEST['fnindexD0']); $j++) {
        if ((CCur($_REQUEST['fnqty_baseD0'][$j]) > 0) && (CCur($_REQUEST['ftlocation_codeD0'][$j])=="")) {
            echo "<script>
                    alert('Lokasi harus diisi. ');
                    window.history.back();
                  </script>";
            die("");
        }
    }
}

function ValBatal() {

    if (($_REQUEST['ftcategory_code'] == 0) || ($_REQUEST['ftcategory_code'] == 4)) {
        echo "<script>
                alert('Kategori Stock Keluar ini harus dibatalkan dari dokumen sumber nya. ');
                window.history.back();
              </script>";
        die("");
    }
}

  function SaveData() {         
        $strSQL=array();
        ValCheckLocation();

        switch($_REQUEST[mode]) {
        case "simpan":
            for($j=1; $j<count($_REQUEST['ftitem_codeD0']); $j++) {
                 $m=SaveStock_bahan_baku('-',$_REQUEST['ftitem_codeD0'][$j],'',$_REQUEST['ftwarehouse_codeD0'][$j],$_REQUEST['ftlocation_codeD0'][$j],$_REQUEST['fdexp_dateD0'][$j],CCur($_REQUEST['fnqtyD0'][$j]),CCur($_REQUEST['fnqtyD0'][$j]));
                 $strSQL=array_merge_recursive($strSQL,$m);
            }
            break;
        }
       # pr($strSQL);die("mm");
     return $strSQL;
  }
  
  function CancelData() {
        ValBatal();
        
        global $objAxpDB;
//        $objAxpDB->Allow_Cancel(false);  
        $strSQL=array();
        switch($_REQUEST[mode]) {
          case "batal":
             if($_REQUEST['fnstatus']=='1') {
                 for($j=1; $j<count($_REQUEST['ftitem_codeD0']); $j++) {
                     $m=SaveStock_bahan_baku('+',$_REQUEST['ftitem_codeD0'][$j],'',$_REQUEST['ftwarehouse_codeD0'][$j],$_REQUEST['ftlocation_codeD0'][$j],$_REQUEST['fdexp_dateD0'][$j],CCur($_REQUEST['fnqtyD0'][$j]),CCur($_REQUEST['fnqtyD0'][$j]));
                     $strSQL=array_merge_recursive($strSQL,$m);
                }
             }            
        }
        return $strSQL;
  }



?>