<?php require_once('../auth/auth.php');?>
<?php
$layout=$_GET['layout'];
$pritner_setup_query= mysqli_query($conn,"SELECT *,company.signature,company.co_logo FROM printer_setup 
  INNER JOIN company ON (printer_setup.coid = company.coid)
  LEFT JOIN branch b ON(printer_setup.brid=b.brid)
 WHERE printer_setup.coid ='$coid' AND printer_setup.bid ='$bid' AND printer_setup.brid='$brid' AND layout=1 LIMIT 1 ") or die (mysql_error());
$rowps= mysqli_fetch_assoc ($pritner_setup_query);
$psid=$rowps['psid'];
$co_logo=$rowps['co_logo'];
 ?>

<div class="card card-primary card-outline direct-chat direct-chat-primary shadow-none" style="border-left:1px solid #969c9d;border-right:1px solid #969c9d;border-bottom:1px solid #969c9d;">
  <div class="card-header" style="padding: 3px 8px;">
    <h3 class="card-title">Invoice Preview</h3>
    <div class="card-tools">
      <button type="button" onclick="pdfMe('#m_receipt');" class="btn btn-tool" title="Download Pdf"><i class="fas fa-download"></i></button>
      <button type="button" class="btn btn-tool" onclick="printMe('#m_receipt')" title="Print Now"><i class="fas fa-print"></i></button>
      <button type="button" class="btn btn-tool" data-card-widget="remove" data-dismiss="modal">
      <i class="fas fa-times"></i>
      </button>
    </div>
  </div>
  <div class="card-body p-1" id="m_receipt" style="overflow:hidden;position: relative;">
    <div class="secondary_style" style="background-color: #f5f6fa;padding: 10px;">
      <table class="invoice_table" cellpadding="0" cellspacing="0"  <?php if ($rowps['bg_color'] !== "" ) {  ?> style="border-color:<?php echo $rowps['bg_color']; ?> "<?php } ?> >
        <thead>
          <tr>
            <th class="px-3" colspan="8">
              <div class="invoice_head mt-1">
                <div class="invoice_left">
                <?php if ($rowps['invoice_logo']=="On") {  ?>
                  <div class="tm_logo">
                      <?php if($co_logo != ""): ?>
                            <img class="profile-user-img img-fluid img-circle" src="data:image/gif;base64,<?php echo $co_logo;?>" style="width:80px;height:75px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?>!important">
                        <?php else : ?>
                           <img class="profile-user-img img-fluid img-circle  " src="../../dist/img/a.png" style="width:80px;height:75px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?>!important"></div>
                        <?php endif; ?>

                  </div>
                  <?php } ?>
                </div>
                <div class="invoice_middle"   style="margin-left:7px;">
                <sss class="invoice_add_head lanbn" style="font-size:<?php echo $rowps['com_font_size'];?>px;color:<?php echo $rowps['com_color'];?>!important;"><?php echo $rowps['company_name'];?></sss><br>
                  <sss><?php echo $rowps['company_email'];?></sss> #
                  <sss><?php echo $rowps['company_phone'];?></sss><br>
                  <sss><?php echo $rowps['company_address'];?></sss><br>
                  <?php if ($rowps['invoice_tin']=="On") {  ?>
                  <sss>Tin Number : <?php echo $rowps['invoice_tin'];?></sss>
                  <?php } ?>
                </div>
                <div class="invoice_right heading_color" style="margin-top:19px;text-align:center;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
                  <div>
                    <b class="invoice_name"  style="color:<?php echo $rowps['com_color'];?>!important;">Sale Invoice</b>
                  </div>
                </div>
                <div class="shape  shape_bg shape_border" style="<?php if ($rowps['head_bg'] !== "" ) { echo 'background-color:'.$rowps['head_bg'];} ?>!important;;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"   ></div>
                <div class="shape1 shape_bg shape_border" style="<?php if ($rowps['head_bg'] !== "" ) { echo 'background-color:'.$rowps['head_bg'];} ?>!important;;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"></div>
                
              </div>
              <div class="p-3 mt-1 shape_border" style="<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">



<?php if ($rowps['branch_info'] == "On" ) {  ?>
                <div class="tm_grid_row"  style="grid-template-columns: repeat(3, 1fr);"  >
                <div class="border_right"  style="<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
                    <sss class="invoice_add_head heading_color" style="<?php if ($rowps['border_color'] !== "" ) { echo 'color:'.$rowps['border_color'];} ?>!important">From</sss><br>
                    <sss class="invoice_address">
                    <?php echo $rowps['branch_name'];?> <br>
                     <?php echo $rowps['branch_number'];?> <br>
                    <?php echo $rowps['branch_email'];?> <br>
                   <?php echo $rowps['branch_address'];?>
                    </sss>
                  </div>
<?php } else{  ?>
 <div class="tm_grid_row"  style="grid-template-columns: repeat(2, 1fr);"  >
<?php } ?>
<div class="border_right" style="<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
                    <sss class="invoice_add_head heading_color" style="<?php if ($rowps['com_color'] !== "" ) { echo 'color:'.$rowps['com_color'];} ?>!important;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['bg_color'];} ?> !important;">Bill To</sss><br>
                    Outlet Code : <sss class="invoice_address lanbn"><?php echo 'outlet_id' ?> </sss><br>
                     Name  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <sss class="invoice_address lanbn"> <?php echo 'Md demo Customer';?></sss><br>
                     Number &nbsp; : <sss class="invoice_address lanbn">  <?php echo '01790126565';?></sss><br>
                    
                     <?php if ($rowps['cemail_info']=="On") {  ?>
                     Email &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <sss class="invoice_address lanbn"><?php echo 'welldivbd@gmail.com';?> </sss><br>
                     <?php } ?>
                     Address &nbsp;&nbsp;: <sss class="invoice_address lanbn"><?php echo 'Akubpur Gangni Meherpur';?>  </sss><br>
                     <?php if ($rowps['route_info']=="On") {  ?>
                     Route  &nbsp;&nbsp;: <sss class="invoice_address lanbn"><?php echo  'Gangni School';?>  </sss><br>
                     <?php } ?>

                    </sss>
                  </div>

                  <div>
                  <?php if ($rowps['m_invoice']=="On") {  ?>
                    Memo No &nbsp;&nbsp;&nbsp; : <sss class="invoice_address lanbn"><?php echo 'Memo No';?></sss><br>
                    <?php } ?>
                    <?php if ($rowps['print_time']=="On") {  ?>
                    Print time &nbsp; : <sss class="invoice_address lanbn"><?php echo date('d/m/y h:i:s a', strtotime($datetime));?></sss><br>
                    <?php } ?>
                    Created Date &nbsp; : <sss class="invoice_address lanbn"><?php echo date('d/m/y h:i:s a', strtotime($datetime));?></sss><br>
                    Created &nbsp; : <sss class="invoice_address lanbn"> <?php echo 'Employee Name'; ?></sss><br>
                    <?php if ($rowps['wh_info']=="On") {  ?>
                    wharehouse Code &nbsp;&nbsp;&nbsp; : <sss class="invoice_address lanbn"><?php echo 'warehouse_code';?></sss><br>
                    <?php } ?>

                    <?php if ($rowps['dman_info']=="On") {  ?>
                      Delivery Man &nbsp;&nbsp;&nbsp; : <sss class="invoice_address lanbn"><?php echo 'Delevery Man';?></sss><br>
                    <?php } ?>
                    
                    
                    Invoice : <sss class="invoice_address lanbn"><?php echo 'ECSL-3-3-4-21062023-8LH3B-5';?>
                    </sss>
                  </div>
                </div>
              </div>
            </th>
          </tr>
          <tr>
            <th colspan="8">&nbsp;</th>
          </tr>
          <tr >
          <th style="width:15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"></th>
            <th  class="text-center shape_border thstyle w-5" style="padding: 10px 15px;border-right:;<?php if ($rowps['text_color'] !== "" ) { echo 'color:'.$rowps['text_color'];} ?>!important;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;
            <?php if ($rowps['bg_color'] !== "" ) { echo 'background:'.$rowps['bg_color'];} ?> !important; <?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">  S/L</th>
            <th class="shape_border thstyle" style="padding: 10px 15px;border-right:;border-left:none;<?php if ($rowps['text_color'] !== "" ) { echo 'color:'.$rowps['text_color'];} ?>!important;<?php if ($rowps['bg_color'] !== "" ) { echo 'background:'.$rowps['bg_color'];} ?>!important;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">Item Description</th>
            <th class="text-center shape_border thstyle w-10" style="padding: 10px 15px;border-right:;border-left:none;<?php if ($rowps['text_color'] !== "" ) { echo 'color:'.$rowps['text_color'];} ?>!important;<?php if ($rowps['bg_color'] !== "" ) { echo 'background:'.$rowps['bg_color'];} ?>!important;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">QTY</th>
            <th class="text-center shape_border thstyle w-15" style="padding: 10px 15px;border-right:;border-left:none;<?php if ($rowps['text_color'] !== "" ) { echo 'color:'.$rowps['text_color'];} ?>!important;<?php if ($rowps['bg_color'] !== "" ) { echo 'background:'.$rowps['bg_color'];} ?>!important;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">Price</th>
            <th class="text-right shape_border thstyle w-10" style="padding: 10px 15px;border-right:;border-left:none;<?php if ($rowps['text_color'] !== "" ) { echo 'color:'.$rowps['text_color'];} ?>!important;<?php if ($rowps['bg_color'] !== "" ) { echo 'background:'.$rowps['bg_color'];} ?>!important;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">Discount</th>
            <th class="text-right shape_border thstyle w-15" style="padding: 10px 15px;border-left:none;<?php if ($rowps['text_color'] !== "" ) { echo 'color:'.$rowps['text_color'];} ?>!important;<?php if ($rowps['bg_color'] !== "" ) { echo 'background:'.$rowps['bg_color'];} ?>!important;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">Total</th>
            <th style="width:15px;"></th>
          </tr>
        </thead>
        <tbody>
          
          <tr>
             <td style="width:15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"></td>
             <td class="text-center shape_border" style="padding: 5px 15px;border-right:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"></td>
            </td>

            <td class=" shape_border" style="padding: 5px 15px;border-right:none;border-left:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
              <?php if ($rowps['item_group']=="On") {
              echo 'item_group';
              } if ($rowps['item_brand']=="On"){
              echo 'item_brand';
              } if ($rowps['item_catagory']=="On"){
              echo 'item_catagory';
              } ;?>
              <?php echo 'item_name';?> <?php echo 'item_details';?> ,  <?php if ($rowps['item_code']=="On") {echo 'item_code'; } ?>
              <?php if ($rowps['item_warranty']=="On") {echo 'item_warranty';} ?>
              <?php  
         
          echo  $rowps['imei_sl_text'].'<br>';
          echo  'Imei_code001';
          
          ?>
            </td>
            <td class="text-center shape_border" style="padding: 5px 15px;border-right:none;border-left:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
              <dt><?php echo 50;?></dt>
            </td>
            <td class="text-center shape_border" style="padding: 5px 15px;border-right:none;border-left:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
              <dt><?php echo 100;?></dt>
            </td>
            <td class="text-center shape_border" style="padding: 5px 15px;border-right:none;border-left:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
              <dt><?php echo 100;?></dt>
            </td>
            <td class="text-right shape_border" style="padding: 5px 15px;border-left:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
              <dt><?php echo 4900;?></dt>
            </td>
            <td style="width:15px;"></td>
          </tr>

 
        </tbody>
        <tfoot>
        <tr>
          <td style="width:15px;"></td>
          <td colspan="2" class="text-right shape_border" style="padding: 5px 15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"><dt>Total </dt></td>
          <td class="text-center shape_border" style="padding: 5px 15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">50
          </td>
          <!-- <td class="text-center shape_border" style="padding: 5px 15px;">
          </td> -->
          <td colspan="2" class="text-center shape_border" style="padding: 5px 15px;border-right:none !important;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"><dt></dt></td>
          <td class="text-right shape_border" style="padding: 5px 15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
            <dt><?php echo 4900;?></dt>
          </td>
          <td style="width:15px;"></td>
        </tr>
        <tr>
          <th class="pt-1" colspan="8"></th>
        </tr>
        <tr>
          <td style="width:15px;" rowspan="7"></td>
          <td style="padding: 5px 15px;" colspan="2">
            <span style="font-weight: 600;">In Word :</span> <?php echo "one thousand only ";?></td>
            <td rowspan="7"></td>
            <td colspan="2" class="text-right shape_border" style="padding: 5px 15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"><dt>Delivery Charge :</dt></td>
            <td class="text-right shape_border" style="padding: 5px 15px;border-left:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
              <dt>
              <?php
              
              echo 100;
              ?>
              </dt>
            </td>
            <td style="width:15px;"></td>
          </tr>
          <tr>
            <td colspan="2"></td>
            <td colspan="2" class="text-right shape_border" style="padding: 5px 15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"><dt>Sub Total :</dt></td>
            <td class="text-right shape_border" style="padding: 5px 15px;border-left:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
              <dt><?php
              
              echo 100;
              ?></dt>
            </td>
            <td style="width:15px;"></td>
          </tr>
          <tr>
            <td colspan="2"></td>
            <td colspan="2" class="text-right shape_border" style="padding: 5px 15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"><dt>Sub Total :</dt></td>
            <td class="text-right shape_border" style="padding: 5px 15px;border-left:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
              <dt><?php
              
              echo 100;
              ?></dt>
            </td>
            <td style="width:15px;"></td>
          </tr>
          <tr>
            <?php if ( $rowps['invoice_narrtion']=="On") { ?>
            <td colspan="2" rowspan="3" class="shape_border" style="padding: 5px 15px;vertical-align: text-top;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"><dt> Narration :</dt>
            <?php echo 'details';?>
          </td>
          <?php  } else{ ?>
          <td colspan="2" rowspan="3" > </td>
          <?php } ?>
          <td colspan="2" class="text-right shape_border" style="padding: 5px 15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"><dt>Payment :</dt></td>
          <td class="text-right shape_border" style="padding: 5px 15px;border-left:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
            <dt>
            <?php
            
            echo 100;
            ?>
            </dt>
          </td>
          <td style="width:15px;"></td>
        </tr>


        <tr>
                  <?php if ($rowps['previous_due']=="On") { ?>

          <td colspan="2" class="text-right shape_border" style="padding: 5px 15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"><dt>Current Invoice Due :</dt></td>
          <td class="text-right shape_border" style="padding: 5px 15px;border-left:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
            <dt><?php
            
            echo 100;
            ?></dt>
          </td>
          <td style="width:15px;"></td>
                  <?php } ?>

        </tr>


        <?php if ($rowps['current_in_due']=="On") { ?>

        <tr>
          <td colspan="2" class="text-right shape_border" style="padding: 5px 15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"><dt>Previous Balance :</dt></td>
          <td class="text-right shape_border" style="padding: 5px 15px;border-left:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
            <dt><?php
            
            echo 100;
            ?></dt>
          </td>
          <td style="width:15px;"></td>
        </tr>

              <?php }else{ ?>
          <td colspan="2"> </td>

              <?php        } ?>

        <tr>
          <td colspan="2"></td>
          <td colspan="2" class="text-right shape_border" style="padding: 5px 15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"><dt>current due :</dt></td>
          <td class="text-right shape_border" style="padding: 5px 15px;border-left:none;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;">
            <dt>
            <?php
            
            echo 100;
            ?>
            </dt>
          </td>
          <td style="width:15px;"></td>
        </tr>
        <tr>
          <th colspan="8">
            <dt>&nbsp;</dt>
            <dt>&nbsp;</dt>
            <dt>&nbsp;</dt>
            <dt>&nbsp;</dt>
          </th>
        </tr>
        <?php if ( $rowps['invoice_trams']=="On") { ?>
          <tr>
          <td style="width:15px; padding:15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"></td>
          <td colspan="6" class="lanbn" >
            <dt class="invoice_add_head heading_color "  style="<?php if ($rowps['bg_color'] !== "" ) { echo 'color:'.$rowps['bg_color'];} ?>;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"> Terms & Condition : </dt>
            <?php echo $rowps['terms'];?>
          </td>
          <td style="width:15px;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important;"></td>
        </tr>
        <?php } ?>
        <tr>
          <th colspan="8">&nbsp;</th>
        </tr>
        <tr>
          <th colspan="8">&nbsp;</th>
        </tr>
        <tr>
          <th colspan="8">
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </th>
        </tr>
        <th >
          
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td class="text-center">
            <?php if ($rowps['sig_nature']=="On") { ?>
            <img id="img_data" style="height: 100px;width:150px;" src="data:image/gif;base64,<?php echo $rowps['signature'];?>" alt="User signature ">
            <span >   <?php echo $date; ?>   </span>
            <?php } ?>
          </td>
        </th>
        <tr>
            
            
            <td colspan="2"  style="font-size: 12px; text-align:center;font-weight:700 ; border-top:1px dotted;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important; ">
            <?php echo $rowps['fop_one']; ?>
            </td>
            
            
            <td colspan="2"  style="font-size: 12px; text-align: center;font-weight:700 ;border-top:1px dotted;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important; ">
              
             <?php echo $rowps['fop_two']; ?>
            </td>
            <td colspan="2"  style="font-size: 12px; text-align: center;font-weight:700 ;border-top:1px dotted;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important; ">
              
             <?php echo $rowps['fop_three']; ?>
            </td>
            <td colspan="2"  style="font-size: 12px; text-align: center;font-weight:700 ;border-top:1px dotted;<?php if ($rowps['border_color'] !== "" ) { echo 'border-color:'.$rowps['border_color'];} ?> !important; ">
             <?php echo $rowps['fop_four']; ?>
            </td>
          </tr>
        <tr>
          <th colspan="8">&nbsp;</th>
        </tr>
        <tr>
          <th class="powerby text-center" colspan="8" style="font-size:10px;<?php if ($rowps['text_color'] !== "" ) { echo 'color:'.$rowps['text_color'];} ?>!important;<?php if ($rowps['bg_color'] !== "" ) { echo 'background:'.$rowps['bg_color'];} ?>!important"> Powered by : www.welldiv.com</th>
        </tr>
        </tfoot>
      </table>
    </div>
  </div>
</div>
</div>