<?php



 $searchdisabled    ='';

 $adddisabled       ='';

 $editdisabled      ='';

 $savedisabled      ='';

 $deletedisabled    ='';

 $printdisabled     ='';

 $canceldisabled    ='';

 $pdisabled         ='';

 $ndisabled         ='';

 

if (isset($_GET["mode"])) {

    $mode = $_GET["mode"];

    if ($mode == "true") {

        $addflag = 1;

        $gen1 = mysql_query("SELECT MAX(code) AS maxcode FROM `$maindb` LIMIT 0,1 ") or die(mysql_error());

        if (mysql_num_rows($gen1) > 0) {

            $vvouch = mysql_fetch_assoc($gen1);

            $qvouch = $vvouch["maxcode"] + 1;

        } else {

            $qvouch = '1';

        }

        $gen2 = mysql_query("SELECT MAX(code) AS maxcode FROM `$maindb_d` LIMIT 0,1 ") or die(mysql_error());

        if (mysql_num_rows($gen2) > 0) {

            $cvvouch = mysql_fetch_assoc($gen2);

            $dvouch = $cvvouch["maxcode"] + 1;

        } else {

            $dvouch = '1';

        }

        $flag = "Add";

        /*Disabling buttons*/        

        $searchdisabled ='disabled';

        $adddisabled ='disabled';

        $editdisabled ='disabled';

        $deletedisabled ='disabled';

        $printdisabled ='disabled';

        $pdisabled ='disabled';

        $ndisabled ='disabled';

        /*End Disabling buttons*/        

    }elseif($mode === "last"){

        $addflag = 2;

        $mgetlastrec = mysql_query("SELECT * FROM `$maindb` ORDER BY `code` DESC LIMIT 0,1") or die(mysql_error());

        $mgetvouchno = mysql_fetch_array($mgetlastrec);

        $tgetlastrec = mysql_query("SELECT * FROM `$trandb` ORDER BY `code` DESC LIMIT 0,1") or die(mysql_error());

        $lgetvouchno = mysql_fetch_array($tgetlastrec);

        $getvouch   = $lgetvouchno["code"];

        $qvouch     = $mgetvouchno["code"];

        $getvouch_d = $lgetvouchno["code_d"];



        /*Disabling buttons*/

        $savedisabled = 'disabled';

        $canceldisabled = 'disabled';

        /*End Disabling buttons*/

        

    }elseif($mode === "edit"){

        $addflag = 0;

        $qvouch = $_GET["code"];

        $dvouch = $_GET["code_d"];

        $flag = "Edit";



        /*Disabling buttons*/

        $savedisabled = 'disabled';

        $canceldisabled = 'disabled';

        $pdisabled ='disabled';

        $ndisabled ='disabled';

        /*End Disabling buttons*/

    }

}

?>



