<?php 
// 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%;
        margin:5px;
    }
    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);
                 
                  $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=$getd['bl_pak'];
                  $nogstamt=(floatval($currentc)*(100/118));
                  $gstamt=(floatval($currentc)-floatval($nogstamt));


                  $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($packbill)+floatval($gst);
                     $gsth=round(floatval($gst)/2,2);
                     $toalcharges=(floatval($packamt)-floatval($getd['bl_disc']))+floatval($prevdue);
                     if( floatval($getd['oth_due'])>0){


                            $onlyprev=floatval($prevdue)-floatval($getd['oth_due']);

                     }else{

                        $onlyprev=floatval($prevdue);

                     }


                     $string = trim($getcust['custid']);
                                        $type='code128';
                                        $orientation='horizontal';
                                        $size='20';
                                        $print='true';

                  
                ?>
                <!-- <div style="border:1px solid gray;"> -->
                <table>
                       <tr>
                           <td style="text-align: center;"><span style="text-decoration: underline;">MONEY RECEIPT </span></td>
                           
                       </tr> 
                       <tr>
                           
                        <td style="text-align: left;font-size: 14px;">
                            <table>

                            <tr>
                                <td>
                            <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>
                            Email: </b><?=$getcom['c_email']?><br>
                            </td>
                            <td style="text-align:right;padding-right:10px;">
                                <img src="vendors/images/mmsbill.png" style="width:120px;">
                            </td>
                            </tr>
                            </table>

                            
                        </td>
                        
                        
                        
                       </tr>
                       <!-- <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>
                              
                                Collector: Office<br>
                                <br>
                                VC NO:<br>
                                STB NO:<?=$getcust['stb']?>

                           </td> 
                    </tr> -->
                    <tr>
                    <td  style="border:1px solid gray;">
                                    <table>
                                        <tr>
                                            <td><b>CUSTOMER CODE</b></td>
                                            <td><?=$getcust['custid']?></td>
                                        </tr>
                                        <tr>
                                            <td><b>CUSTOMER NAME</b></td>
                                            <td><?=$getcust['name']?></td>
                                        </tr>
                                        <tr>
                                            <td><b>BOX NO</b></td>
                                            <td><?=$getcust['vc']?></td>
                                        </tr>
                                        
                                         <tr>
                                            <td><b>BILL NO</b>&nbsp;<?=$getd['bl_no']?></td>
                                            <td><b>BILL MONTH:</b>&nbsp; <?=$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>শুরুর তারিখ</b>&nbsp;<?=date("d-m-Y", strtotime($getd['bl_stdt']))?></td>
                                            <td><b>শেষ তারিখ</b>&nbsp;<?=date("d-m-Y", strtotime($getd['bl_expiry']))?></td>
                                        </tr>
                                        <tr>
                                            <td><b>BOUQUET/MONTHLY SUBSCRIPTION: </b></td>
                                            <td><b>&nbsp;<?=round($packbill,2)?></b></td>
                                        </tr>
                                        <tr>
                                            <td><b>REBATE/DISCOUNT </b></td>
                                            <td><b>&nbsp;<?=round($getd['bl_disc'],2)?></b></td>
                                        </tr>
                                        <tr>
                                            <td><b>GST @18% </b></td>
                                            <td><b>&nbsp;<?=round($gst,2)?></b></td>
                                        </tr>
                                        <tr>
                                            <td><b>PREVIOUS DUES </b></td>
                                            <td><b>&nbsp;<?=$onlyprev?></b></td>
                                        </tr>
                                        <tr>
                                            <td><b>TOTAL CHARGES (ROUNDED OFF) </b></td>
                                            <td><b>&nbsp;<?=round($toalcharges,0)?></b></td>
                                        </tr>
                                        
                                        

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

                    <tr>
                        <td>
                                <table>
                                            <tr>
                               
                                                    <td colspan="2"> 
                                                        <?php 
                                                                $custchannels='';
                                                                echo "SELECT * FROM tbl_change_package_details WHERE customer_id='$getcust[id]'";
                                                            $getch=mysqli_query($con,"SELECT * FROM tbl_change_package_details WHERE customer_id='$getcust[id]'");
                                                            while($arr=mysqli_fetch_array($getch)){
                                                                $getchan=f(q("SELECT * FROM tbl_pack WHERE pid='$arr[chid]'"));
                                                                $custchannels=$custchannels.$getchan['pname'].',';


                                                            }
                                                        
                                                        ?>

                                                   <span style="word-wrap: break-word;white-space: -moz-pre-wrap; white-space: pre-wrap;margin-bottom:15px;"> Package : <?php echo $custchannels;?></span>

                                                    </td>
                                                   

                                            </tr>
                                            <tr style="border-top:1px solid #000;border-bottom:1px solid #000;">
                               
                                                    <td> <br><br>

                                                        <b>PAYMENT DATE: </b> <?=date("d-m-Y", strtotime($getd['bl_paydt']))?>

                                                    </td>
                                                    <td> <br><br>

                                                        <b>PAID AMT: </b> <?php echo $getd['bl_payamt']?> 

                                                    </td>
                                                   

                                            </tr>
                                            <tr>
                               
                                                    <td colspan="2" style="font-weight:700;margin-bottom:15px;"> <br>

                                                    কলের সময় - সকাল 10:00 থেকে রাত 8:00 , হোয়াটসঅ্যাপ নম্বর: 9378377811 / 8436028495 | অনলাইন পেমেন্টের জন্য: 9378377811 / 8436028495

                                                    </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>MONTHLY SUBSCRIPTION</td>
                                                     <td><?=round($curcharges,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><?=$onlyprev?></td>

                                            </tr>
                                            <?php 
                                                 if( floatval($getd['oth_due'])>0){
                                            ?>
                                            <tr>
                                                    <td>Other Dues <br><small style="font-weight:600;">(<?=$getd['oth_reason']?>)</small></td>
                                                    <td><?=$getd['oth_due']?></td>

                                            </tr>


                                            <?php } ?>

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

                                            </tr>
                                            <tr>
                                                    <td style="text-align: center;padding: 5px;border-bottom:1px solid gray;"></td>
                                                     <td style="text-align: center;padding: 5px;border-bottom:1px solid gray;"></td>

                                            </tr>
                                            <tr>
                                                    <td>Pay Date</td>
                                                     <td><?=date("d-m-Y", strtotime($getd['bl_paydt']))?></td>

                                            </tr>
                                            <tr>
                                                    <td>Pay Amount</td>
                                                     <td><?=$getd['bl_payamt']?></td>

                                            </tr>
                                            <tr>
                                                    <td>Due</td>
                                                     <td><?=$duess?></td>

                                            </tr> -->
                                            </table>
                       </td>
                    </tr> 
                    <!-- <tr>
                                
                                <td  style="text-align: center;padding: 5px;border-bottom:1px solid gray;"></td>
                                 
                                 
                                 

                    </tr> 
                    <tr>
                        <td style="text-align:center;">Signature</td>
                    </tr>    -->

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



       <script>

            window.print();
       </script>

        

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

