<?php
//require("includes/dbconnect.php");

$zdb = $_SESSION["zdbyear_" . $dbname];
//$zyear = right($zdb, 4);
//$mfrdate = getzdates($zyear, 'S');
//$mtodate = getzdates($zyear, 'E');

mysqli_select_db($conn, $zdb);

function delro($ifrom, $ito, $icode, $istrm) {
    $accdb = 'actran';
    global $conn;

    for ($i = $ifrom; $i < $ito; $i++) {
//        echo "$i";
//        echo "$istrm";

        $j1 = '9000' . $i;
        $j = right($j1, 2);
//        echo "$j";

        mysqli_query($conn, "DELETE FROM `$accdb` WHERE `vouchno` = '$icode' AND `source` = 'RO' and trnno = '$j' and $istrm ") or die(mysqli_error($conn));
        mysqli_query($conn, "DELETE FROM `$accdb` WHERE `vouchno` = '$icode' AND `source` = 'OC' and trnno = '$j' and $istrm ") or die(mysqli_error($conn));
        mysqli_query($conn, "DELETE FROM `$accdb` WHERE `vouchno` = '$icode' AND `source` = 'STOC' and trnno = '$j' and $istrm ") or die(mysqli_error($conn));
        mysqli_query($conn, "DELETE FROM `$accdb` WHERE `vouchno` = '$icode' AND `source` = 'AC' and trnno = '$j' and $istrm ") or die(mysqli_error($conn));
        mysqli_query($conn, "DELETE FROM `$accdb` WHERE `vouchno` = '$icode' AND `source` = 'TCS' and trnno = '$j' and $istrm ") or die(mysqli_error($conn));
        mysqli_query($conn, "DELETE FROM `$accdb` WHERE `vouchno` = '$icode' AND `source` = 'TDS' and trnno = '$j' and $istrm ") or die(mysqli_error($conn));
    }
}

function delinv($imon, $icode, $ihalf, $istrm) {
    $invdb = 'invoice';
    global $conn;
    
//    print "DELETE FROM `$invdb` WHERE `month` = '$imon' and `accode` = '$icode' and half = '$ihalf' $istrm ";
    
    mysqli_query($conn, "DELETE FROM `$invdb` WHERE `month` = '$imon' and `accode` = '$icode' and half = '$ihalf' $istrm ") or die(mysqli_error($conn));
    
}
//echo "pppp";
?>


