<?php
ob_start();
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');

$maindb = "salemain";
$trandb = "saletran";
$formname = "Sale Print";
$file = "sale_print.php";

$vouch = $_GET["vouchno"];


$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);


$getpmain = mysqli_query($conn, "SELECT *,Date_Format(`vouchdt`,'%d-%m-%y')as mydt  FROM `$maindb` where `vouchno`= '$vouch'  ")or die(mysqli_error($conn));
$main = mysqli_fetch_array($getpmain)or die(mysqli_error($conn));

//$dvouch = $main[vouchno] . '/NA/' . $main[callno];

$getroot = mysqli_query($conn, "SELECT * FROM `cepheisy_msp_root`.`company`")or die(mysqli_error($conn));
$root = mysqli_fetch_array($getroot);

include("includes/linkshead.php");
?>
<link href="MyStyle/rep_format.css" rel="stylesheet">

</head>
<body>
    <div class="container">
        <div class="col-lg-1">
            <a  class="btn btn-primary goback"  onclick="window.close()">Go Back</a>
        </div>
    </div>
    <div class="page">
        <div class="subpage" style="margin-top: 1px; margin-left: 25px; margin-right: 25px;">
            <div class="row">
                <div class="col-lg-12 text-center" >
                    <?php
                    Echo "<b><h2>$root[name]</h2><b>";
                    ?>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12 text-center" >
                    <?php
                    $add1 = "";
                    if($root[add1] != ""){
                        $add1 = $root[add1] .",";
                    }
                    $add2 = "";
                    if($root[add2] != ""){
                        $add2 = $root[add2]." , ";
                    }
                    $add3 = "";
                    if($root[add3] != ""){
                        $add3 = $root[add3]; 
                    }
                    echo "<b>$add1 $add2  $add3</b>";
                    ?>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12 text-center" >
                    <?php
                    $station = "";
                    if($root[station] != ""){
                        $station = $root[station] .",";
                    }
                    $city = "";
                    if($root[city] != ""){
                        $city = $root[city]." - ";
                    }
                    $pin = "";
                    if($root[pin] != ""){
                        $pin = $root[pin] .",";
                    }
                    $country = "";
                    if($root[country] != ""){
                        $country = $root[country];
                    }
                    Echo "<b>$station $city $pin $country</b>";
                    ?>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12 text-center" >
                    <?php
                    $fax = "";
                    if($root[fax] != ""){
                        $fax = $root[country];
                    }
                    Echo "<b>$fax</b>";
                    ?>
                </div>
            </div>
            <div class="col-lg-12 text-center" >
                <?php
                $mobile = "";
                    if($root[mobile] != ""){
                        $mobile = $root[mobile] . ",";
                    }
                    $tel = "";
                    if($root[tel] != ""){
                        $tel = $root[tel];
                    }
                Echo "<b>$mobile $tel</b> "; 
                ?>
            </div>
            <table width="100%">
                <tr>
                    <td  style="text-align: center;padding-top: 8px;" ><b>QUOTATION</b></td>
                </tr>
            </table>
            <div class="row bd">
                <table width="100%" style="margin-top:5px;">
                    <tr>
                        <td> <b>TO,</b></td>
                    </tr>
                    <tr> 
                        <td><?php echo "<b>$main[name]</b>"; ?> </td>
                    </tr>
                    <tr>
                        <td> <?php echo "<b>$main[add1]</b>"; ?></td>
                        <td><b>Ref.No : <?php echo "<b>$dvouch</b>"; ?></b></td>
                    </tr>        
                    <tr>
                        <td>
                            <?php echo "<b>$main[add2]</b>"; ?>
                        </td>
                        <td><b>Date : <?php echo "<b>$main[mydt]</b>"; ?></b></td>
                    </tr>        
                    <tr>
                        <td>
                            <?php echo "<b>$main[add3]</b>"; ?>
                        </td>
                        <td>
                            <b>Valid Upto :  &nbsp;  /&nbsp;   /&nbsp;  </b>
                        </td>
                    </tr>        
                    <tr>
                        <td style="padding-left:30px;">
                            <b>Subject:</b>    
                        </td>
                        <td>
                            <?php echo "<b>$main[subject]<b>"; ?>
                        <td>
                    </tr>
                    <tr>
                        <td>
                            <b>Dear Sir,</b>    
                        </td>
                    </tr>
                </table>
                <table width="100%">
                    <tr>
                        <td style="padding-left:30px; width: 100%">
                            <b>We hereby give below reasonable and competitive estimate for repairs/supply to the following items</b>
                        </td>
                    </tr>
                </table>
            </div> 
            <table  width="100%" class="bd" style="margin-top:15px;">
                <thead class="bd">
                    <tr>
                        <th class="bd">Sr.</th>
                        <th class="bd">Description</th>
                        <th class="bd" style="text-align: right">Qty.</th>
                        <th class="bd" style="text-align: right">Rate</th>
                        <th class="bd" style="text-align: right">Amount</th>
                    </tr>
                </thead>
                <?php
                $ctab = 0;
                $totamt = 0; 
                $getdetail = mysqli_query($conn, "SELECT * FROM `$trandb` where `vouchno`= '$main[vouchno]'") or die(mysqli_error($conn));
                while ($detail = mysqli_fetch_array($getdetail)) {
                    ?>
                    <tbody class="bd">
                        <tr style="height: 25px;">
                            <td class="bd"><?php echo $detail[srno]; ?></td>
                            <td class="bd"><?php echo $detail[descrip]; ?></td>
                            <td class="bd" style="text-align: right"><?php echo $detail[qty]; ?></td>
                            <td class="bd" style="text-align: right"><?php echo $detail[rate]; ?></td>
                            <td class="bd" style="text-align: right"><?php echo $detail[amount]; ?></td>
                        </tr>

                    </tbody>
                    <?php
                    $totamt = $totamt + $detail[amount];
                }
                $ctab = $ctab + 1;
                if ($ctab < 15) {
                    for ($i = $ctab; $i <= 15; $i++) {
                        
                        ?>
                        <tr style="height: 25px;">
                            <td class="bd"></td> 
                            <td class="bd"></td>
                            <td class="bd"></td>
                            <td class="bd"></td>
                            <td class="bd"></td>
                        </tr>      
                        <?php
                    }
                }
                ?>
                </table>
<!--                <div style="width: 40%;height:80px;float: left; padding:20px;"class="bd">
                    <table style="width: 100%; ">
                        <tr>
                            <td>VAT TIN NO.</td>
                            <td>:275545454545</td>
                        </tr>
                        <tr>
                            <td>ST TIN NO.</td>
                            <td>:275545454545</td>
                        </tr>
                    </table>
                </div>-->
<!--                <div style="width: 60%;float: right;height:80px; padding:5px;"class="bd">
                    <table style="width: 100%;">
                        <tr>
                        <td style="width: 75%;"><b>subtotal</b></td>
                        <td style="width: 25%; text-align: rigth;"><b><?php echo $totamt;?></b></td>
                        </tr>
                    </table>
                    <table width="100%">
                        <tr>
                            <td style="width: 25%;"><b>V.A.T.@ </b></td>
                            <td style="width: 25%;"><b><?= $main[vatperc1]?></b></td>
                            <td style="width: 25%;"><b>ON</b></td>
                            <td style="width: 25%;"><b><?= $main[vaton1]?></b></td>
                        </tr>
                    </table>
                    <table width="100%">
                        <tr>
                            <td style="width: 25%;"><b>Service Tax </b></td>
                            <td style="width: 25%;"><b><?= $main[servperc]?></b></td>
                            <td style="width: 25%;"><b>ON</b></td>
                            <td style="width: 25%;"><b><?= $main[servon]?></b></td>
                        </tr>
                    </table>-->
<!--                    <table width="100%">
                        <tr>
                            <td style="width: 75%;">
                                <b>Total Amount</b>
                            </td>
                            <td style="width: 25%;text-align: rigth;">
                                <b>44444</b>
                            </td>
                        </tr>
                    </table>
                </div>
            <div class="bd" style="width: 100%;padding:5px;">
                <b>Amount in rupees</b>
            </div>
            
            <div  style="width:50%; padding:5px; float:left">
                <b>We hope to hear from you at the earliest.Thankyou.</b>
            </div>
            
            <div  style="width:50%; padding:10px; float:right; text-align:right">
                <b style="font-size:14px;">For&nbsp;&nbsp;<span style="font-size:20px;"><?php echo $root[name] ?></span>&nbsp;&nbsp;&nbsp;&nbsp;</b>
            </div>
            -->
<!--            <div style="width: 100%;float: left;">
                <table width="100%">
                <tr>
                    <td>   
                        <b style="font-size:13px;">Special Instructions:</b>
                    </td>
                </tr>
                <tr>
                    <td>   
                        <b>Service warranty is for ** months.</b>
                    </td>
                </tr>
                <tr>
                    <td>   
                        <b>100% Advance Payment.</b>
                    </td>
                </tr>
                <tr>
                    <td>   
                        <b>Civil, Capentry, panting, Electric, Core-Cutting</b>
                    </td>
                </tr>
                <tr>
                    <td>   
                        <b>Not In Our Scope</b>
                    </td>
                    <td style="text-align: right">   
                        <b>Authorized Signature</b>
                    </td>
                </tr>
                </table>
                 
            
            </div>-->
        </div>
    </div>

<?php include("includes/linksfoot.php"); ?>
</body>
</html>
