<?php require "_header.php";
include "Numbers/Words.php"; ?>
<script language="javascript" type="text/javascript">
  //document.getElementById("main-content").style.display = 'none';
</script>

<div id="main-report" align="center">

  <?php
  $height = 300;
  $nw = new Numbers_Words();
  if ($_SESSION["cCompany_id"] != "" && isset($_SESSION["cCompany_id"])) {

    $agencyid = $_SESSION["cCompany_id"];


    $invoice_no = Escape($_REQUEST["invoice_no"]);
    $qry = " SELECT * FROM lms_customerbill
					where invoice_no = " . $invoice_no . "  ";

    //$ObjagencymasterMgmt = new agencymasterMgmt(); ".$_REQUEST['nro_no']. "
  
    $rs = dbQuery($qry);
    $rs1 = dbQuery($qry);
    $count = dbRows($rs);
    $j = 0;
    $custome_height = 240;
    ///extract($row);
    ob_start();

    $i = 0;
    $sno = 1;
    $net_amount = 0;
    if ($count > 0) {
      $row = dbArray($rs);


      ?>
      <div style="height:160px;">
        <img src="head.jpg" height="140" width="100%" />
      </div>
      <table width="100%" align="center" class="report"
        style="background-image:url(back.jpg);background-position:center; background-repeat:no-repeat;">
        <tr style="height:35px">
          <td colspan="2" style="vertical-align:middle;border:none; background-color:#CCC" align="center">
            <span style="font-size:18px; font-weight:bold">INVOICE</span>
          </td>
        </tr>
        <tr>
          <td align="left" width="35%" style="text-align:left">
            <b>Customer Name & Address :</b>
            <br /><?php echo $row['customer_name'] . "<br/>" . $row['address']; ?>
          </td>
          <td width="100%" style="text-align:left;border:none">
            <b>Invoice No :&nbsp;&nbsp;</b><?php echo $row['invoice_no'] ?><br />
            <b>Date :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b> <?php

            if (substr($billdate, -4) == '1900')
              echo '-';
            else
              echo $billdate;
            ?><br />
            <b>Sales By :&nbsp;&nbsp;</b><?php echo $row['salesby'] ?>
          </td>

        </tr>


        <tr>
          <th style="text-align:center; background-color:#CCC" colspan="2">Product Details</th>

        </tr>

        <tr>
          <td colspan="2">
            <table width="100%" align="center" class="report">

              <tr style="text-align:center; background-color:#CCC">
                <td style="text-align:center;" width="6%">
                  <b> Sr.</b>
                </td>
                <td style="text-align:center;" width="40%">
                  <b> Description </b>
                </td>
                <td style="text-align:center;" width="10%">
                  <b> Qty. </b>
                </td>
                <td style="text-align:center;" width="15%">
                  <b> Rate </b>
                </td>

                <td style="text-align:center;" width="7%">
                  <b> Vat(%) </b>
                </td>

                <td style="text-align:center;" width="22%">
                  <b> Amount(Rs) </b>
                </td>
              </tr>

              <?php
              $sno = 1;
              $net_amount = 0;
              while ($row1 = dbArray($rs1)) { ?>
                <tr>
                  <td style="text-align:center;" width="6%">
                    <?php echo $sno; ?>
                  </td>
                  <td style="text-align:left;" width="40%">
                    <?php echo $row1['product_name']; ?>
                  </td>
                  <td style="text-align:center;" width="10%">
                    <?php echo $row1['qty'] ?>
                  </td>
                  <td style="text-align:center;" width="15%">
                    <?php

                    $tamount = $row1['rate'] * $row1['discount'] / 100;
                    echo $tamount ?>
                  </td>


                  <td style="text-align:center;" width="7%">
                    <?php echo $row1['vat'] ?>
                  </td>

                  <td style="text-align:center;" width="22%">
                    <?php
                    echo $row1['tamount'] ?>
                  </td>


                </tr>
                <?php
                $height = $height - 25;
                $sno++;
                $net_amount = $net_amount + $row1['tamount'];
              }

              ?>
              <tr style="height:<?php echo $height . "px" ?>">
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table>

          </td>
        </tr>
        <tr style="height:35px;vertical-align:middle">

          <td align="left" width="71%">
            <b>Final Payable Amount in Words : </b><br />
            <?php echo strtoupper($nw->toWords($net_amount) . " Rupees Only"); ?>
          </td>
          <td align="left">
            <b>Final Payable :</b>
            <?php echo ' Rs. ' . number_format(round($net_amount), 2); ?>
          </td>
        </tr>

        <tr>
          <td colspan="2">
            <u> <b>Terms & Condition:</b> </u>
            <div width="100%" style="vertical-align:top;font-size:9px" align="left">



              01. 100% Payment against delivery by Cheque/Draft in favour of Aum Infosys,Ahmedabad.<br>
              02. Goods once sold will not be taken back or exchange in any case.<br>
              03. One Year Warranty.<br>
              04. Subject to Ahmedabad Jurisdiction.<br>

            </div>
            <br><br> <br><br />
            <b>Received the above goods in good condition</b>
            <span style="font-size:12px;float:right;margin-right:30px"><b>For, Aum Infosys</b> </span><br /> &nbsp;
            <br /><br />
            <span style="margin-left:50px; font-size:12px; float:left"><b>Receiver's Sign with Stamp</b></span><span
              style="font-size:12px; float:right; margin-right:20px"><b>Authorized Signatory</b> </span>

          </td>
        </tr>
      </table>
      <div style="height:60px;">
        <img src="foot.jpg" height="60" width="100%" />
      </div>

    <?php


    } else {
      ?>
      <div style="height:160px;">
        <img src="head.jpg" height="140" width="100%" />
      </div>
      <table width="100%" align="center" class="report"
        style="background-image:url(back.jpg);background-position:center; background-repeat:no-repeat;">
        <tr style="height:35px">
          <td colspan="2" style="vertical-align:middle;border:none; background-color:#CCC" align="center">
            <span style="font-size:18px; font-weight:bold">INVOICE</span>
          </td>
        </tr>
        <tr>
          <td align="left" width="35%" style="text-align:left">
            <b>Customer Name & Address :</b>
            <br />
          </td>
          <td width="100%" style="text-align:left;border:none">
            <b>Invoice No :&nbsp;&nbsp;</b><br />
            <b>Date :&nbsp;&nbsp;</b> <br />
            <b>Sales By :&nbsp;&nbsp;</b>
          </td>

        </tr>


        <tr>
          <th style="text-align:center; background-color:#CCC" colspan="2">Product Details</th>

        </tr>

        <tr>
          <td colspan="2">
            <table width="100%" align="center" class="report">

              <tr style="text-align:center; background-color:#CCC">
                <td style="text-align:center;" width="6%">
                  <b> Sr.</b>
                </td>
                <td style="text-align:center;" width="40%">
                  <b> Description </b>
                </td>
                <td style="text-align:center;" width="10%">
                  <b> Qty. </b>
                </td>
                <td style="text-align:center;" width="15%">
                  <b> Rate </b>
                </td>

                <td style="text-align:center;" width="7%">
                  <b> Vat(%) </b>
                </td>

                <td style="text-align:center;" width="22%">
                  <b> Amount(Rs) </b>
                </td>
              </tr>


              <tr style="height:350px">
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table>

          </td>
        </tr>
        <tr style="height:35px;vertical-align:middle">

          <td align="left" width="71%">
            <b>Final Payable Amount in Words : </b><br />

          </td>
          <td align="left">
            <b>Final Payable :</b>

          </td>
        </tr>

        <tr>
          <td colspan="2">
            <u> <b>Terms & Condition:</b> </u>
            <div width="100%" style="vertical-align:top;font-size:9px" align="left">



              01. 100% Payment against delivery by Cheque/Draft in favour of Aum Imagineering Pvt. Ltd,Ahmedabad.<br>
              02. Goods once sold will not be taken back or exchange in any case.<br>
              03. One Year Warranty.<br>
              04. Subject to Ahmedabad Jurisdiction.<br>

            </div>
            <br><br> <br><br />
            <b>Received the above goods in good condition</b>
            <span style="font-size:12px;float:right;margin-right:30px"><b>For, Aum Imagineering Pvt. Ltd.</b> </span><br />
            &nbsp;
            <br /><br />
            <span style="margin-left:50px; font-size:12px; float:left"><b>Receiver's Sign with Stamp</b></span><span
              style="font-size:12px; float:right; margin-right:20px"><b>Authorized Signatory</b> </span>

          </td>
        </tr>
      </table>
      <div style="height:60px;">
        <img src="foot.jpg" height="60" width="100%" />
      </div>

    <?php
    }
    $HtmlCode = ob_get_contents();
    ob_end_flush();
    $HtmlUrl = "customerbill-report-" . $_SESSION["eAgencyId"] . ".html";
    $HtmlPath = "report/" . $HtmlUrl;
    createHTMLReportPage($header_row_string, $HtmlUrl, $HtmlPath, $HtmlCode, true);
    ?>
    <br />
    <form name="frm" id="frm" action="" method="post">
      <input type="hidden" name="txtFile" id="txtFile" value="<?php echo $HtmlUrl; ?>" />
      <input type="button" name="btnPdf" id="btnPdf" value="Print" onClick="SetPageAction('PRINT');" />
      <input type="button" name="btnPdf" id="btnPdf" value="Create PDF" onClick="SetPageAction('PDF');" />
      <input type="button" name="btnHtml" id="btnHtml" value="Create HTML" onClick="SetPageAction('HTML');" />
      <input type="button" name="btnWord" id="btnWord" value="Create WORD" onClick="SetPageAction('WORD');" />
      <input type="button" name="btnExcel" id="btnExcel" value="Create EXCEL" onClick="SetPageAction('Excel');" />
    </form>
    <script language="javascript" type="text/javascript">
      function SetPageAction(varAction) {

        if (varAction == "PRINT") {
          document.frm.action = "print/create-print.php";
          document.frm.target = "_blank";
          document.frm.submit();
        }
        else if (varAction == "PDF") {
          document.frm.action = "convertpdf/create-pdf.php";
          document.frm.target = "_blank";
          document.frm.submit();
        }
        else if (varAction == "HTML") {
          document.frm.action = "<?php echo $HtmlPath; ?>";
          document.frm.target = "_blank";
          document.frm.submit();
        }
        else if (varAction == "WORD") {
          document.frm.action = "convertword/create-word.php";
          document.frm.target = "_blank";
          document.frm.submit();
        }
        else if (varAction == "Excel") {
          document.frm.action = "convertword/create-excel.php";
          document.frm.target = "_blank";
          document.frm.submit();
        }
      }
    </script>
  <?php } ?>
</div>
<?php require "_footer.php"; ?>