<?php

switch($_REQUEST[mode]) {
case "batal":
    $ssql="select a.ftar_no,b.ftsales_invoice_no
            from txar_hdr a,
                    txar_det b
            where a.ftar_no=b.ftar_no and
                     a.fnstatus<>9
              and b.ftsales_invoice_no='{$_REQUEST['ftsales_invoice_no']}'";

    $rs=mysql_query($ssql);
    $str="No. Transaksi Penerimaan piutang ini harus dibatal kan dahulu :";
    while($r=mysql_fetch_assoc($rs)) {
        $str.=$r['ftar_no'];
    }
//   die($str);
     if(RetRstField($ssql)) {
           echo "<script>
                alert('$str');
                window.history.back();
            </script>";
            die("");
     }

      break;

}

 function CancelData() {
    
    global $objAxpDB;  
//    $objAxpDB->Allow_Cancel(false);
     $strSQL=array();
    switch($_REQUEST[mode]) {
    case "batal":
         //-----------------------------------------------------
         // batal -%
//         $ssql1="SELECT IFNULL(MAX(ftsales_invoice_no),'')  AS M
//                      FROM txsales_invoice_hdr
//                      WHERE ftsales_invoice_no LIKE '{$_REQUEST['ftsales_invoice_no']}-%'";
//            $no=RetRstField($ssql1);
//            if($no!="") {
//                $no=$no+1;
//                $str1="-{$no}";
//            }
//            else {
//                $str1="-1";
//            }
//
//             $ftftsales_invoice_no_new="{$_REQUEST['ftsales_invoice_no']}{$str1}";
//
//             $strSQL["batal"][]="update txsales_invoice_hdr
//                                set fnstatus=9,ftsales_invoice_no='{$ftsales_invoice_no_new}'
//                                where ftsales_invoice_no='{$_REQUEST['ftsales_invoice_no']}'";
//
//
//             $strSQL['Batal txar_det'][]="UPDATE txar_det
//                                                SET ftsales_invoice_no='{$ftsales_invoice_no_new}'
//                                                WHERE ftsales_invoice_no='{$_REQUEST['ftsales_invoice_no']}'";

        break;
    }
   
     return $strSQL;
 }    