<? 
namespace Dompdf;
require_once 'dompdf/autoload.inc.php';
ob_start();
include "top.php";
 ?>
<style type="text/css">
  .textlayer span{
    font-size: 16px !important;
  }
</style>
<!-- Home -->
<?
function getIndianCurrency($number)
{
    $decimal = round($number - ($no = floor($number)), 2) * 100;
    $hundred = null;
    $digits_length = strlen($no);
    $i = 0;
    $str = array();
    $words = array(0 => '', 1 => 'one', 2 => 'two',
        3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six',
        7 => 'seven', 8 => 'eight', 9 => 'nine',
        10 => 'ten', 11 => 'eleven', 12 => 'twelve',
        13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen',
        16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen',
        19 => 'nineteen', 20 => 'twenty', 30 => 'thirty',
        40 => 'forty', 50 => 'fifty', 60 => 'sixty',
        70 => 'seventy', 80 => 'eighty', 90 => 'ninety');
    $digits = array('', 'hundred','thousand','lakh', 'crore');
    while( $i < $digits_length ) {
        $divider = ($i == 2) ? 10 : 100;
        $number = floor($no % $divider);
        $no = floor($no / $divider);
        $i += $divider == 10 ? 1 : 2;
        if ($number) {
            $plural = (($counter = count($str)) && $number > 9) ? 's' : null;
            $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
            $str [] = ($number < 21) ? $words[$number].' '. $digits[$counter]. $plural.' '.$hundred:$words[floor($number / 10) * 10].' '.$words[$number % 10]. ' '.$digits[$counter].$plural.' '.$hundred;
        } else $str[] = null;
    }
    $Rupees = implode('', array_reverse($str));
    $paise = ($decimal) ? "." . ($words[$decimal / 10] . " " . $words[$decimal % 10]) . ' Paise' : '';
    return ($Rupees ? $Rupees . 'Rupees ' : '') . $paise;
}


?>
<style type="text/css">
    th{
        font-size: 15px !important;
    }
    table{

        width: 100%;
    }
    tr{

        width: 100%;
        font-size: 14px;
    }
    td{

        font-size: 12px;
    }

</style>
<!-- ============================================================== -->
        <!-- Page wrapper  -->
        <!-- ============================================================== -->
        <div class="page-wrapper">
            <!-- ============================================================== -->
            <!-- Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->

            <!-- ============================================================== -->
            <!-- End Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- Container fluid  -->
            <!-- ============================================================== -->
            <div id="print-content">
            <div class="container-fluid" style="padding: 0 5% 0 5%;">

                <!-- ============================================================== -->
                <!-- Start Page Content -->
                <!-- ============================================================== -->
                <?
                  $bid=$_REQUEST['bookids'];
                 //$bid="a74abb961b1955a050f8";
                  // $_SESSION['typeserv']="Internet";
                  // $_SESSION['razpayid']="nbchudj".rand(0,20);
                  //$getcom=f(q("SELECT * FROM tbl_company WHERE c_id=1"));
                  $getd=f(q("SELECT * FROM cbill WHERE bl_trn='$bid'"));
                  $getcust=f(q("SELECT * FROM adduser WHERE id='$getd[bl_cid]'"));
                   $getcom=f(q("SELECT * FROM tbl_company WHERE c_id=$getcust[com_id]"));

                  if($getcust['is_cable']=='0' || $getcust['is_cable']=='1'){ 


                                $packamt=$getd['bl_amt'];
                                
                                


                        }else{

                                $packamt=$getd['bl_amt'];

                        }
                  //$prc=floatval($getcust['price'])*(0);
                  $prevdue=$getd['bl_prevdue'];


                  $currentc=$getcust['price'];
                  $gstamt=(floatval($currentc)*(0.18));


                  $gst=$gstamt;
                    $subto=$packamt;//floatval($getcust['price'])+floatval($gst);
                    $prc=floatval($subto)*(0);
                    $package=$packamt;//getcust['price'];
                    // if($prevdue!='0'){
                    //       $total=floatval($getcust['price'])+floatval($prc)+$gst+$prevdue;
                    //     }else{

                    //       $total=floatval($getcust['price'])+floatval($prc)+$gst;
                    //     }
                    //$total=floatval($getcust['price'])+floatval($prc)+$gst;
                    $total=$package;
                    $packbill=floatval($packamt)-floatval($gst);
                    $curcharges=floatval($currentc)+floatval($gst);
                     $gsth=round(floatval($gst)/2,2);
                     $toalcharges=floatval($packamt)-floatval($getd['bl_disc']);

                  
                ?>
                <div style="border:1px solid gray;padding:2%;">
                <table>
                       <tr>
                           <td colspan="2" style="text-align: center;"><span style="text-decoration: underline;">MONEY RECEIPT</span></td>
                           
                       </tr> 
                       <tr>
                           <td style="width: 30px;">
                               <!-- <img src="image/namahshibay.png" style="width: 100px;"> -->

                           </td> 
                           <td style="text-align: left;font-size: 14px;">

                            <strong style="text-decoration: underline;text-transform: uppercase;font-size: 20px;"><?=$getcom['c_name']?></strong><br>
                            <?=$getcom['c_address']?></strong><br>
                            Phone : <?=$getcom['c_mobile']?> , <?=$getcom['c_phone']?>    <br>
                            <!-- GSTN: </b><?=$getcom['c_emailalt']?><br> -->
                        </td>
                       </tr>

                       


                </table>
                <table>
                       
                       
                        <tr>
                           <td style="border:1px solid gray;"><b style="text-transform: uppercase;"><?=$getcust['name']?> </b><br>
                                <b><?=$getcust['address']?> </b><br>
                                <b>Mobile: <?=$getcust['phone']?> </b><br>
                                <b>Cust GST: <?=$getcust['gender']?> </b><br>
                                Collector: Office<br>
                                <br>
                                VC NO:<?=$getcust['vc']?><br>
                                STB NO:<?=$getcust['stb']?>

                           </td> 
                             <td  style="border:1px solid gray;">
                                    <table>
                                        <tr>
                                            <td><b>A/C No</b></td>
                                            <td><?=$getcust['custid']?></td>
                                        </tr>
                                         <tr>
                                            <td><b>Invoice No</b></td>
                                            <td><?=$getd['bl_no']?></td>
                                        </tr>
                                        <tr>
                                            <td><b>Invoice Period</b></td>
                                            <td><?=$getd['bl_month']?>, <?=$getd['bl_year']?></td>
                                        </tr>
                                         <tr>
                                            <td><b>Invoice Date</b></td>
                                            <td><?=date("d-m-Y", strtotime($getd['bl_dt']))?></td>
                                        </tr>
                                        
                                          <tr>
                                            <td><b>Start Date</b></td>
                                            <td><?=date("d-m-Y", strtotime($getd['bl_stdt']))?></td>
                                        </tr>
                                          <tr>
                                            <td><b>End Date</b></td>
                                            <td><?=date("d-m-Y", strtotime($getd['bl_expiry']))?></td>
                                        </tr>

                                    </table>
                           
                           </td>
                       </tr>
                       
                       
                       


                </table>
                <table>
                    <tr>
                        <td colspan="2" style="background-color: #d1d0d0;padding: 5px;">Your Account Summary</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td style="text-align: center;padding: 5px;border:1px solid gray;">
                            <b>Package</b><br>
                            <?=round($currentc,2)?>

                        </td>
                        <td style="text-align: center;padding: 5px;border:1px solid gray;">
                            <b>Discount</b><br>
                            <?=$getd['bl_disc']?>

                        </td>
                       <!--  <td style="text-align: center;padding: 5px;border:1px solid gray;">
                            <b>GST</b><br>
                             <?=round($gst,2)?>

                        </td> -->
                         <td style="text-align: center;padding: 5px;border:1px solid gray;" colspan="2">
                            <b>Current Charge</b><br>
                           <?=round($curcharges,2)?>

                        </td>
                         <td style="text-align: center;padding: 5px;border:1px solid gray;">
                            <b>Previous Dues</b><br>
                           <?=$getd['bl_prevdue']?>

                        </td>
                         <td style="text-align: center;padding: 5px;border:1px solid gray;">
                            <b>Total Charages</b><br>
                           <?=round($toalcharges,2)?>

                        </td>
                    </tr>
                </table>
                <table>
                    <tr>
                            <td  style="border:1px solid gray;padding: 5px;width: 400px;">
                                    <table>
                                            <tr>
                                                    <td>BOUQUET / MONTHLY SUBSCRIPTION</td>
                                                     <td>0.00</td>

                                            </tr>
                                             <tr>
                                                    <td>Pay Channel / Package Charge</td>
                                                     <td><?=round($packbill,2)?></td>

                                            </tr>
                                             <tr>
                                                    <td>Rebate / Discount</td>
                                                     <td><?=round($getd['bl_disc'],2)?></td>

                                            </tr>
                                             <tr>
                                                    <td>BOUQUET / MONTHLY SUBSCRIPTION</td>
                                                     <td><?=round($packbill,2)?></td>

                                            </tr>
                                             <!-- <tr>
                                                    <td>CGST</td>
                                                     <td><?=round($gsth,2)?></td>

                                            </tr>
                                            <tr>
                                                    <td>SGST</td>
                                                     <td><?=round($gsth,2)?></td>

                                            </tr> -->
                                            <tr>
                                                    <td>Previous Dues / Advances</td>
                                                     <td><?=$getd['bl_prevdue']?></td>

                                            </tr>
                                            <tr>
                                                    <td>Total Charges including all Services & Tax (Round Off)</td>
                                                     <td><?=round($toalcharges,2)?></td>

                                            </tr>

                                    </table>


                            </td>
                            <td style="border:1px solid gray;padding: 5px;">
                                    <?=$getc['pay_ch']?>

                            </td>


                    </tr>
                    <tr>
                        <td colspan="2" style="border-bottom: 1px solid gray;"></td>
                    </tr>
                    <tr>
                        <td colspan="2" style="border-bottom: 1px solid gray;font-size: 14px;">
                            CONTACT US FOR HIGHSPEED BROADBAND CONNECTION
                        </td>
                    </tr>

                </table>
                <table>
                        <tr>
                                <td style="text-align: right;"><b>Pay Date</b></td>
                                <td style="text-align: center;padding: 5px;border:1px solid gray;"><?=date("d-m-Y", strtotime($getd['bl_paydt']))?></td>
                                 <td style="text-align: right;"><b>Amount Paid</b></td>
                                  <td style="text-align: center;padding: 5px;border:1px solid gray;"><?=$getd['bl_payamt']?></td>
                                  <td style="text-align: right;"><b>Due After Payment</b></td>
                                  <td style="text-align: center;padding: 5px;border:1px solid gray;"><b><?=$getd['bl_due']?></b></td>

                        </tr>
                         <tr>
                                <td style=""><br><br></td>
                                <td colspan="2" style=""></td>
                                 
                                  <td colspan="3" style="">
                                      
                                  </td>
                                 

                        </tr>
                         <tr>
                                <td style="text-align: right;"><b>Signature</b></td>
                                <td colspan="2" style="text-align: center;padding: 5px;border-bottom:1px solid gray;"></td>
                                 
                                  <td colspan="3" style="text-align: center;padding: 5px;border:1px solid gray;">
                                      
                                  </td>
                                 

                        </tr>

                </table><br>
                <table>
                    <tr>
                        <td style="border-bottom:1px solid gray;"></td>
                    </tr>
                </table>
                <br>
                <table>
                    <tr>
                        <td style="background-color: #d1d0d0;padding: 5px;font-weight: bold;text-transform: uppercase;">
                            <?=$getcust['name']?>
                        </td>
                        <td style="max-width: 100px;">
                            Payment Slip
                        </td>
                    </tr>
                    <tr>
                        <td style="border:1px solid gray;padding: 5px;"> <b><?=$getcust['address']?> </b><br>
                             Phone : <?=$getcom['c_mobile']?> , <?=$getcom['c_phone']?>    <br>
                            GSTN: </b><?=$getcom['c_emailalt']?><br>



                        </td>
                        <td style="border:1px solid gray;padding: 5px;">
                            <b>A/C No : </b><?=$getcust['custid']?><br>
                            <b>Total Charges : </b><?=round($toalcharges,2)?>

                        </td>
                    </tr>
                </table>
                <table>
                    <tr>
                        <td style="border-bottom:1px solid gray;">
                               STB:   <?=$getcust['stb']?> 
                        </td>
                        <td style="border-bottom:1px solid gray;">
                            
                            Invoice No: <?=$getd['bl_no']?>

                        </td>
                    </tr>
                    <tr>
                        <td style="border-bottom:1px solid gray;">
                              VC No:   <?=$getcust['vc']?>
                        </td>
                        <td style="border-bottom:1px solid gray;">
                            
                            Total Charges <?=round($toalcharges,2)?>
                        </td>
                    </tr>
                    <tr>
                        <td style="border-bottom:1px solid gray;">
                                
                        </td>
                        <td style="border-bottom:1px solid gray;">
                            <?
                                    $duedate=date('Y-m-d',(strtotime ( '7 days' , strtotime ($getd['bl_dt']) ) ));
                                ?>
                              Due Date: <?=date("d-m-Y", strtotime($getd['bl_expiry']))?>
                           
                        </td>
                    </tr>
                    <tr>
                        <td style="border-bottom:1px solid gray;">
                               LCO NAME : <strong style="text-decoration: underline;text-transform: uppercase;"><?=$getcom['c_name']?></strong>
                        </td>
                        <td style="border-bottom:1px solid gray;">
                            
                            Invoice Period : <?=$getd['bl_month']?>, <?=$getd['bl_year']?>
                           
                        </td>
                    </tr>
                </table>
                <table>
                    <tr>
                        <td style="border-bottom:1px solid gray;"> </td>
                    </tr>
                </table>
                 <table>
                    <tr>        
                                <td style="text-align: right;"><b>Signature</b></td>
                                 <td style="text-align: right;border-bottom: 1px solid gray;width: 150px;"></td>
                                <td style="text-align: right;"><b>Pay Date</b></td>
                                <td style="text-align: center;padding: 5px;border:1px solid gray;"><?=date("d-m-Y", strtotime($getd['bl_paydt']))?></td>
                                 <td style="text-align: right;"><b>Amount Paid</b></td>
                                  <td style="text-align: center;padding: 5px;border:1px solid gray;"><?=$getd['bl_payamt']?></td>
                                  <td style="text-align: right;"><b>Due</b></td>
                                  <td style="text-align: center;padding: 5px;border:1px solid gray;"><b><?=$getd['bl_due']?></b></td>

                        </tr>
                </table>
                <br><br>
                </div>
                <!-- editor -->
                
                <!-- ============================================================== -->
                <!-- End PAge Content -->
                <!-- ============================================================== -->
                <!-- ============================================================== -->
                <!-- Right sidebar -->
                <!-- ============================================================== -->
                <!-- .right-sidebar -->
                <!-- ============================================================== -->
                <!-- End Right sidebar -->
                <!-- ============================================================== -->
            </div>
        </div>
            </div>

         <?php
$html = ob_get_clean();
$dompdf = new Dompdf();
$dompdf->setPaper('A4', 'portrait');
$dompdf->load_html($html);
$dompdf->render();
$filename=$getcust['name'].".pdf";
//For view
//$dompdf->stream("",array("Attachment" => false));//comment this line for download
// for download
$output = $dompdf->output();
$dompdf->stream($filename);
//file_put_contents($filename, $output);
//$upcust=mysqli_query($con,"UPDATE adduser SET price='0' WHERE id='$getd[user]'"));
unset($_SESSION['razpayid']);
unset($_SESSION['bookids']);
unset($_SESSION['result']);

?>
<? include "footer.php"; ?>

