<?php require "_header.php";
include "Numbers/Words.php";
$_SESSION['header_image'] = '1'; ?>
<style type="text/css">

</style>
<div id="main-report" align="center">
  <center>
    <h4>Customer Invoice </h4>
  </center>
  <?php

  if ($_SESSION['cUserId'] != "" && isset($_SESSION['cUserId'])) {

    $receipt_no = Escape($_REQUEST["receipt_no"]);
    if ($receipt_no != "") {
      $rec_no = $receipt_no;
    }
    $sno = 1;
    $header_row_string = "";
    $query = "Select *
			 FROM lms_custinvoicereceipt lci,lms_customer lc
			 WHERE lci.customer_id=lc.customer_id and
			 receipt_no='" . $rec_no . "' and lci.company_id= '" . $_SESSION["cCompany_id"] . "' limit 1 ";

    ob_start();
    $rs = dbQuery($query);
    $nw = new Numbers_Words();
    //print_r($row);	
    $count = dbRows($rs);
    $totalcost = 0;
    if ($count > 0) {
      while ($row = dbArray($rs)) {


        ?>
        <!-- <div style="width:850px; margin-left:20px; margin-right:20px; margin-top:70px;">-->
        <div style="width:821px; margin:253px 0px 0px 0px;">
          <table width="100%" class="report" cellpadding="5px"
            style="background-image:url(back.jpg);background-position:center;background-size: 175px auto; background-repeat:no-repeat;">
            <tr style="border:none;border:!important">
              <td align="left" style="border:none;">
                <table width="160px" height="40px" border="1" style="margin-top:3px;margin-left:8px; border:solid">
                  <tr style="border-bottom:none">
                    <td align="center" style="border:none;font-weight:bold;font-size:14px;vertical-align:middle">
                      RECEIPT
                    </td>
                  </tr>
                </table>

                <b>
                  &nbsp;&nbsp;Receipt No.: </b><?php echo $row["receipt_no"]; ?>
                <br />
                <b>
                  &nbsp;&nbsp;Date : </b><?php echo date("d-m-Y", strtotime($row["receipt_date"])); ?>




              </td>
              <td align="right" style="border:none;vertical-align:top">
                <div style="font-weight:bold;font-size:25px;vertical-align:top;margin:8px 25px 0px 0px;font-style:normal;">
                  <u> <?php echo strtoupper($_SESSION["cCompany_name"]); ?></u>

                </div>
                <div
                  style="font-weight:bold;width:270px; line-height:12px; text-align:center; margin:10px 15px 10px 0px;font-size:10px;">
                  <?php echo strtoupper($_SESSION["cCompany_address"]); ?>

                </div>
              </td>

            </tr>
            <tr style="border:none;border:!important">
              <td colspan="2" align="left"
                style="vertical-align:middle;line-height:25px;margin-left:8px;border:none;border:!important">
                <div style="margin-left:8px; font-size:12px;">
                  <div style="float:left;width:21%;margin-left:10%;"><?php echo "Received with thanks from "; ?> </div>
                  <div style="float:left; border-bottom:solid;width:68%;text-align:center;border-width:1px;height:19px">
                    <?php echo ucwords($row["customer_orgname"]); ?> </div><br />

                  <div style="float:left;width:14%;"> an amount of Rs. </div>
                  <div
                    style="float:left;width:13%;text-decoration:underline;height:19px; border-bottom:solid;border-width:1px;text-align:center">
                    <?php echo $nw->formatInIndianStyle($row["amount"]); ?> </div>
                  <div style="float:left;margin-left:5px;">Rupees</div>

                  <div
                    style="float:left;width:66%;text-decoration:underline;height:19px; border-bottom:solid;border-width:1px;text-align:center">
                    <?php echo strtoupper($nw->toWords($row["amount"])); ?></div>
                  <br />
                  <?php if ($row["payment_mode"] == '1') { ?>
                    <div style="float:left;width:23%"> only by <s>cash</s>/cheque/<s>D.D.No.</s> </div>
                  <?php } else { ?>
                    <div style="float:left;width:23%"> only by cash/<s>cheque</s>/<s>D.D.No.</s></div>
                  <?php } ?>

                  <div
                    style="float:left;width:15%;text-decoration:underline;height:19px; border-bottom:solid;border-width:1px;text-align:center">
                    <?php if ($row["payment_mode"] == '1')
                      echo $row["chequeno"]; ?>
                  </div>
                  <div style="float:left;width:5%; margin-left:5px"> Date : </div>

                  <div
                    style="float:left;width:15%;text-decoration:underline;height:19px; border-bottom:solid;border-width:1px;text-align:center">
                    <?php if ($row["payment_mode"] == '1')
                      echo date("d-m-Y", strtotime($row["chk_date"])); ?></div>

                  <div style="float:left;width:8%; margin-left:5px;"> Drawn on </div>
                  <div
                    style="float:left;width:32%;text-decoration:underline;height:19px; border-bottom:solid;border-width:1px;text-align:center">
                    <?php if ($row["payment_mode"] == '1')
                      echo $row["bankname"]; ?> </div><br />
                  <div style="float:left;width:100%;"> an account of <?php echo ucwords($_SESSION["cCompany_name"]); ?>.</div>

                  <br />



                </div>
              </td>
            </tr>
            <tr style="border:none;border:!important">

              <td align="left" style="border:none;vertical-align:bottom">

                <table width="160px" height="40px" border="1"
                  style="margin-top:3px;margin-left:8px;margin-bottom:3px; border:solid;">
                  <tr style="border-bottom:none">
                    <td align="left" style="border:none;font-weight:bold;font-size:14px;vertical-align:middle">
                      Rs.&nbsp;<?php echo $nw->formatInIndianStyle($row["amount"]); ?>
                    </td>
                  </tr>
                </table>
              </td>
              <td align="right" style="border:none">
                <div style="margin-right:90px">
                  <table width="75px" height="85px" border="1"
                    style="margin-top:3px; border:solid;margin-left:8px;margin-bottom:3px">
                    <tr style="border-bottom:none">
                      <td align="center" style="border:none;font-weight:bold;font-size:14px;vertical-align:middle">
                        -
                      </td>
                    </tr>
                  </table>
                </div>

              </td>

            </tr>
          </table>
        </div>
      <?php
      }
      $sno++;
    }
    $HtmlCode = ob_get_contents();
    ob_end_flush();

    $HtmlUrl = "report-form-customer-receipt" . $_SESSION["cUserId"] . ".html";
    $HtmlPath = "report/" . $HtmlUrl;

    createHTMLReportPage($header_row_string, $HtmlUrl, $HtmlPath, $HtmlCode);

    ?>
    <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="btnHtml" id="btnHtml" value="Create HTML" onclick="SetPageAction('HTML');" />

    </form>
    <script language="javascript" type="text/javascript">
      <?php if ($_REQUEST['receiptno'] != "") { ?>
        SetPageAction('PRINT');
      <?php } ?>
      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>
    <br />
    <br />
    <?php

  } else {
    echo "Session Expired";
  }
  ?>

  <?php require "_footer.php"; ?>