<html>
    <head>
        <title><?php echo $b_header['title']; ?></h3></title>
       <style>
            @media print
            {
                * {-webkit-print-color-adjust:exact;}
                  //.super_container {page-break-before: always; padding-top:10px; margin-bottom:150px !important;}
                //.page_break {page-break-after: always;}
                @page {margin:0in 0.10in 0in 0in; }
                .super_container
{
page-break-after: always;
// margin-bottom:200px;
 margin-top:0.25in;
position:relative;
width:100%;
height:710px;
}
.no-print
    {
        display: none !important;
    }
            }
body {margin: 0.25in 0.25in 0.63in 0.25in; box-sizing:border-box;width:90%; height:100vh;padding-bottom:0.63in;}
            *{margin:0;padding:0;font-family:calibri;}
            .clear:after{content:"";clear:both;display:block;}
            .left{float:left;}
            .right{float:right;}
            .wd-10{width:10%;}
            .wd-20{width:20%;}
            .wd-30{width:30%;}
            .wd-40{width:40%;}
            .wd-50{width:50%;}
            .wd-60{width:60%;}
            .wd-70{width:70%;}
            .wd-80{width:80%;}
            .wd-90{width:90%;}
            .wd-100{width:100%;}
            .wd-15{width:15%;}
            .wd-25{width:25%;}
            .wd-35{width:35%;}
            .wd-45{width:45%;}
            .wd-55{width:55%;}
            .wd-65{width:65%;}
            .wd-75{width:75%;}
            .wd-85{width:85%;}
            .wd-95{width:95%;}
            .wd-100{width:100%;}
            .title{font-size:35px;}
            .super_container
            {
            margin-bottom:200px;
            position:relative;
            width:100%;
            height:710px;
            }
            .wrapper{
                //width:calc(100% - 20px);
                //height:710px;
                //margin:10px;
              
                outline-offset: 5px;
                box-sizing: border-box;
                padding:5px;
                
                
            }
           
            .super_wrapper
            {
                position:absolute;
                top:0;
                left:0;
                width:100%;
                height:710px;
                z-index:120;
                margin:0;
                padding:0;
            }
            .watermark
            {
                height:200px;
                width:300px;
                /*align:center;*/
                margin:40px;
                margin-left:200px;
                padding-top:200px;
                padding-left:100px;
                opacity:0.1;
                background:url("<?php echo base_url().$b_header['logo1']; ?>");
                background-size:100% 100%;
            }
            .watermark_wrapper
            {
                height:500px;
                width:100%;
                margin-top:150px;
                display:inline-flex;
                display:-webkit-inline-flex;
             }
            .wrapper.left2{
                width: calc(100%);
                margin-right: 20px;
                margin-left: 20px;
            }
            
            h1,h2,h3{
                color:#5A7BC1;
                font-family:calibri;
                text-align:center;
            }
            //h3{font-weight: 700;}
              .boxed{color:#000000;width:80%;margin:0 auto;}
            .header{
                width:100%;
                //height:110px;
                border-bottom:4px solid #5A7BC1;
                padding-bottom:10px;          
                }
            .body{
                padding:10px;
            }
            .row{
                width:100%;
                margin: 10px auto;  
            }
            .text-center{text-align:center;}
            .bold{font-weight:bold;}
            .b-u-l{
                border-bottom: 1px solid #000;
                height:inherit;
            }
            .x-small{
                font-size: 10px;
            }
            .x-x-small{
                font-size: 7px;
            }
            .page_break{
                width: 100%;
                height: 100vh;
                padding: 10px 0px;
                box-sizing: border-box;
            }
            .tbl1
            {
                border-collapse:collapse;
                border: 2px solid #000;
                text-align:center;
                width:100%;
                min-height:20px;
                border-bottom: 1px solid;
            }
            .tbl2{
                border-top: 1px solid;
            }
            th{
                border: 1px solid #000;
                background-color:#ccccb3; 
                color: #fff;
                padding: 7px;
                padding-top:.5em;
                font-size: 18px;
                padding-bottom:.5em;
            }
            td{
                border: 1px solid #000;
                padding: 7px !important;
            }
            .normal{
                font-weight: normal !important;
            }
            .text-right{
                text-align: right !important;
            }
            .bold{
                font-size: 18px;
                font-weight: bold;
            }
        </style>
    </head>
    <body class="clear">
<?php 
date_default_timezone_set("Asia/Karachi");

?>
<div class="super_container">
    <div class="page_break clear">
     <div class="watermark_wrapper">
        <div class="watermark"></div>
        </div>
        <div class="super_wrapper">
        <div class="wrapper left2 left">
            <div class="header">
                 <div class="wd-100 clear">
                    <div class=" text-left left ">
                        <img src="<?php echo base_url().$b_header['logo1']; ?>" style="width:50px;height:50px;">
                    </div>
                    <div class=" text-left right ">
                        <img src="<?php echo base_url().$b_header['logo1']; ?>" style="width:50px;height:50px;">
                    </div>
                    <div style="">
                        <center><h1><?php echo $b_header['title']; ?></h1></center>
                        <center><h3 style="color:#000 !important;"><i><?php echo $b_header['tagline']; ?></i></h3></center>
                        <center><h4>Contact# <?php echo $b_header['phone_no']; ?></h4></center>
                        <center><h4>Email: <?php echo $b_header['email']; ?></h4></center>
                         <center><h3 class="boxed" style="margin-top:0px !important;font-size:23px;"><?php echo strtoupper($fetch_record[0]['type']); ?></h3></center>
                        
                    </div>
                </div>
            </div>
                   <br>
              
            <div class="body">
            
           <div class="wd-100 left" style="line-height:3em;">
                <div class="wd-100 clear">
            
                    <table class="tbl1">
                        <tr class="center">
                            <td class="wd-20">From</td>
                            <td colspan="2" class="bold" style="text-align: left"><?php echo $fetch_record[0]['paid_from']; ?>
                            </td>
                            <td colspan="2" class="wd-20">Voucher#</td>
                            <td  class="bold" style="text-align: left">
                                <?php echo $fetch_record[0]['voucher_no']; ?>
                            </td> 
                        </tr>
                        <tr><td>Date</td>
<?php $newDate = date("d-m-Y", strtotime($fetch_record[0]['date'])); ?>
<td class="bold"><?php echo $newDate; ?></td>
                     
                        <td>Program</td><td class="bold"><?php echo $fetch_record[0]['program_name'];?></td>
                        <td>Project</td><td class="bold"><?php echo  $fetch_record[0]['project_name']; ?></td>
                        </tr>
                    </table>
       
     
            <table class="tbl1 tbl2">
              <thead>
              <tr >
              <th class="td">#</th>
                 <th class="">Head Of Account</th>
                 <th class="td">Narration</th>
                 <th class="td">Dr</th>
                 <th class="td">Cr</th>
                 
              </tr>
              </thead>
              <tbody>
              <?php $cr=0;$dr=0; foreach ($fetch_record as $key => $value) { ?>
              
              <tr style="padding-top:15em;">
                 <td class="td"><?php echo ++$key; ?></td>
                 <td class="bold">
                     <?php echo $value['head_name'] ?>
               </td>
               <td class="bold"><?php echo $value['narration']; ?></td>
                 <td class="td bold" >
                     <?php 
                     if($value['has_cr']==1)
                     { 
                     echo number_format($value['amount']);
                     $dr+=$value['amount'];  
                     } 
                     ?>
                     </td>
                 <td class="td bold">
                     <?php 
                     if($value['has_cr']==0)
                     { 
                     echo number_format($value['amount']);
                     $cr+=$value['amount']; 
                     }  
                     ?></td>
                 
              </tr>
              <?php } ?>
              <tr>
                  <td colspan="3" class="bold">Total</td>
                  <td id="dr" class="bold">
                      <?php echo number_format($dr); ?>
                      </td>
                      <td class="bold">
                          <?php echo number_format($cr); ?>
                          </td>
                          </tr>
              <tr><td colspan="5" class="bold" id="words"></td></tr>
              </tbody>
            </table>
            
            
            
            
            
            
            
<br/>
            <div class="wd-100 left" style="line-height:3em;">
                <div class="wd-100 clear">
                     <div class="wd-50 left">
                        <div class="wd-50 left"><h3></h3></div>
                        <div class="wd-50 left"><h4></h4></div>
                    </div>
                <div class="wd-100 left">
                        <div class="wd-30 left"><h3>Created By _________</h3></div>
                        <div class="wd-30 left"><h4></h4></div>
                        <div class="wd-30 left"><h3>Checked By __________</h3></div>
                        <div class="wd-30 left"><h4></h4></div>
                        <div class="wd-40 right"><h3>Approved By _________</h3></div>
                        <div class="wd-50 right"><h4></h4></div>
                 </div>      
                </div>
            </div>
<a href="<?php echo base_url(); ?>account/cash_receipts" class="no-print"  ><button type="button" style="width:12%">close</button></a>

                </div><!--Class Body end-->
                

                
            </div>
            
                
                
             
                
            </div>
        </div>
        
           
    </div>
</div>
</div>

    </body>
    <script src="<?php echo base_url(); ?>assets/vendors/jquery/dist/jquery.min.js"></script>
    <script>
       window.print();
       $(document).ready(function(){
           var val=$('#dr').html();
           var string=convertNumberToWords(val);
           $('#words').html("Amount IN Words ( "+string+" )" );
       });
function convertNumberToWords(amount) {
    var words = new Array();
    words[0] = '';
    words[1] = 'One';
    words[2] = 'Two';
    words[3] = 'Three';
    words[4] = 'Four';
    words[5] = 'Five';
    words[6] = 'Six';
    words[7] = 'Seven';
    words[8] = 'Eight';
    words[9] = 'Nine';
    words[10] = 'Ten';
    words[11] = 'Eleven';
    words[12] = 'Twelve';
    words[13] = 'Thirteen';
    words[14] = 'Fourteen';
    words[15] = 'Fifteen';
    words[16] = 'Sixteen';
    words[17] = 'Seventeen';
    words[18] = 'Eighteen';
    words[19] = 'Nineteen';
    words[20] = 'Twenty';
    words[30] = 'Thirty';
    words[40] = 'Forty';
    words[50] = 'Fifty';
    words[60] = 'Sixty';
    words[70] = 'Seventy';
    words[80] = 'Eighty';
    words[90] = 'Ninety';
    amount = amount.toString();
    var atemp = amount.split(".");
    var number =parseInt(atemp[0].split(",").join(""));
    var n_length = number.toString().length;
    number = '' + number;
    var words_string = "";
    if (n_length <= 9) {
        var n_array = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0);
        var received_n_array = new Array();
        for (var i = 0; i < n_length; i++) {
            received_n_array[i] = number.substr(i, 1);
        }
        for (var i = 9 - n_length, j = 0; i < 9; i++, j++) {
            n_array[i] = received_n_array[j];
        }
        for (var i = 0, j = 1; i < 9; i++, j++) {
            if (i == 0 || i == 2 || i == 4 || i == 7) {
                if (n_array[i] == 1) {
                    n_array[j] = 10 + parseInt(n_array[j]);
                    n_array[i] = 0;
                }
            }
        }
        value = "";
        for (var i = 0; i < 9; i++) {
            if (i == 0 || i == 2 || i == 4 || i == 7) {
                value = n_array[i] * 10;
            } else {
                value = n_array[i];
            }
            if (value != 0) {
                words_string += words[value] + " ";
            }
            if ((i == 1 && value != 0) || (i == 0 && value != 0 && n_array[i + 1] == 0)) {
                words_string += "Crores ";
            }
            if ((i == 3 && value != 0) || (i == 2 && value != 0 && n_array[i + 1] == 0)) {
                words_string += "Lakhs ";
            }
            if ((i == 5 && value != 0) || (i == 4 && value != 0 && n_array[i + 1] == 0)) {
                words_string += "Thousand ";
            }
            if (i == 6 && value != 0 && (n_array[i + 1] != 0 && n_array[i + 2] != 0)) {
                words_string += "Hundred and ";
            } else if (i == 6 && value != 0) {
                words_string += "Hundred ";
            }
        }
        words_string = words_string.split("  ").join(" ");
    }
    return words_string;
}
    </script>
</html>
