<?php
  function ValSaldoAwalStock() {
       for($j=1; $j<count($_REQUEST['ftitem_codeD0']); $j++) {
             $ssql="select b.ftitem_code
                    from txinnitial_stock_hdr_bahan_baku a,txinnitial_stock_det_bahan_baku b
                    where a.ftstock_in_no=b.ftstock_in_no and a.fnstatus<>9 and
                            b.ftitem_code='{$_REQUEST['ftitem_codeD0'][$j]}'";

             if(RetRstField($ssql)) {
                    echo "<script>
                          alert('Kode Barang {$_REQUEST['ftitem_codeD0'][$j]} sudah pernah di input disaldo awal stock ...');
                          window.history.back();
                     </script>";
                    die("Kode Barang {$_REQUEST['ftitem_codeD0'][$j]} sudah pernah di input disaldo awal stock ...");
             }

            
        }
  }
         
     
switch($_REQUEST[mode]) {
case "batal":
    
break;    
}

 function SaveData() {
    global $objAxpDB;   
    $strSQL=array();
    ValSaldoAwalStock();
    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],CCur($_REQUEST['fnqtyD0'][$j]),CCur($_REQUEST['fnqtyD0'][$j]));
             $strSQL=array_merge_recursive($strSQL,$m);
        }*/
        
       break;
      
    }
   
    return $strSQL;
 }
 function CancelData() {    
    global $objAxpDB;
//    $objAxpDB->Allow_Cancel(false);
    $strSQL=array();
    
    switch($_REQUEST[mode]) {
    case "batal":
      /*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],CCur($_REQUEST['fnqtyD0'][$j]),CCur($_REQUEST['fnqtyD0'][$j]));
             $strSQL=array_merge_recursive($strSQL,$m);
        }*/
//            $ssql1="SELECT IFNULL(MAX(ftstock_in_no),'')  AS M
//                      FROM txinnitial_stock__hdr
//                      WHERE ftstock_in_no LIKE '{$_REQUEST['ftstock_in_no']}-%'";
//            $no=RetRstField($ssql1);
//            if($no!="") {
//                $no=$no+1;
//                $str1="-{$no}";
//            }
//            else {
//                $str1="-1";
//            }
//
//             $ftstock_in_no_new="{$_REQUEST['ftstock_in_no']}{$str1}";
//
//             $strSQL["batal"][]="update txinnitial_stock__hdr
//                                set fnstatus=9,ftstock_in_no='{$ftstock_in_no_new}'
//                                where ftstock_in_no='{$_REQUEST['ftstock_in_no']}'";
//
//             $strSQL["batal"][]="update txinnitial_stock__det
//                                set ftstock_in_no='{$ftstock_in_no_new}'
//                                where ftstock_in_no='{$_REQUEST['ftstock_in_no']}'";

        break;
    }
   
     return $strSQL;
 }


 function UpdateData() {
    global $objAxpDB;
    $objAxpDB->Allow_Update(false);
    $strSQL=array();
    switch($_REQUEST[mode]) {
    case "update":
        for($j=1; $j<count($_REQUEST['fnindexD0']); $j++) {
            $strSQL["update harga hpp"][]="
                        update txinnitial_stock_det_bahan_baku
                        set fcprice= '".CCur($_REQUEST['fcpriceD0'][$j])."'
                        where ftstock_in_no ='".$_REQUEST['ftstock_in_no']."'
                                AND fnindex ='".$_REQUEST['fnindexD0'][$j]."'  ";
        }

        break;

    }

    return $strSQL;
 }


?>