<?php
switch($_REQUEST[mode]) {
    case "hapus":
        if(RetRstField("SELECT fnid FROM txpurchase_order_hdr WHERE ftsupplier_code='{$_REQUEST['ftsupplier_code']}'")) {
            echo "<script>
                  alert('data tidak dapat di delete karena sudah digunakan dalam transaksi ...');
                  window.history.back();
                  </script>";   
            die("");            
        }

        break;    
}
   

function SaveData() {
    global $objAxpDB;
    $strSQL=array();
    $objAxpDB->Allow_Save(true);
    switch($_REQUEST[mode]) {
        case "simpan":
            if ($_REQUEST['ftsupplier_code'] == "") {
                // auto generate number when save
                if ($_REQUEST['fnsupplier_type'] == 0) {
                    $str_code = "L";
                } else if ($_REQUEST['fnsupplier_type'] == 1) {
                    $str_code = "I";
                } 
                $str_code = $str_code . substr($_REQUEST['ftsupplier_name'],0,1);
                $ftsupplier_code=getAutoNumber($_SESSION['strbranch'],'pu007','tlsupplier','ftsupplier_code',$str_code);
                $_REQUEST['ftsupplier_code'] = $ftsupplier_code;    
            }
            
            break;
    }
    return $strSQL;
}

?>
