
<?php
	include("my_functions.php");

require_once __DIR__ . '/vendor/autoload.php';

$actual_link = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$parts = explode('thebarcodes/' , $actual_link);

 
$barcode = 0;
if(!empty($parts)){
    
    $barcode = $parts[1];
     

}else exit();
 
 
$jobdata = getjob_by_barcode($barcode);

 $shop = 2;
 
 $customer = $captured = $pickup=  $status ='';
 $kx =$kxm = 0;
 if(!empty($jobdata)){
    foreach($jobdata as $row){
        $customer =$row['customer_name'];
        $pickup  = $row['pickon'];
        $status  = $row['status'];
        $captured = $row['value_date'];
        $barcode  = $row['parent_bar_code'];
        $shop  = 2;//$row['shop'];
        $kx = $row['bill'];
        $kxm = $row['amount'];
    }

 }

 $shopdata = brachdetails($shop);

 $full_name =  $logo = $address_line_1 =  $address_line_2 =  $address_line_3 =  $phone =  $city = '';
 
 if(!empty($shopdata)){
    foreach($shopdata as $row){
        $full_name = $row['full_name'];
        $logo = $row['logo_file'];
        $address_line_1 = $row['address_line_1'];
        $address_line_2 = $row['address_line_2'];
        $address_line_3 = $row['address_line_3'];
        $phone = $row['phone'];
        $city = $row['city'];

    }
 }
 

$html = '';

 
 
  

$total = 0;

 

$categorydata = barcode_jobs_for_receipt($barcode);


//print_r($categorydata);

 //'. ucwords(strtolower($customer)).'

//exit();
if(!empty($categorydata)){
   

 $bill = 0;
 $count =0;
 $catsum = sizeof($categorydata);

foreach ($categorydata as $row)
				 {
					 $count +=1;
                    $recept_number =  $row['receipt_number']; 
                    $receipt_items = receipt_item_by_barcodes2($recept_number); 
                    $rowspan = sizeof($receipt_items) +1;
					 
					
					 $html  .= ' <table       width="100%" style="font-size:8px;padding: 1px;">

                           ';

                     
					
					 
					

                   $htmly = ' ';
				   $html .= '
				  
				   <tr>   <td>  Customer:  <b style="font-size:8px;padding: 0">'.$customer.'</b></td>  </tr>
					
				 
				   
				   <tr>     <td  style="font-size:7px;padding: 0"  > <b>ITEM: </b> '.strtoupper($row['jobdata']).' ,( '.$row['taskmemo'].') </td> </tr>
				   <tr>    <td  style="font-size:7px;padding: 0"  ><b>Ready by: </b>  <b style="font-size:7px;padding: 0">'. strtoupper(date('D', strtotime($pickup))).' </b>of  '.$pickup.'</td> </tr>
				    
					 ';
                    $sub_total = 0;

                    foreach($receipt_items as $items){
                        $sub_total  += $items['sell_price'];
                       

                         $htmly .= ' '.$items['job_name'].',';
                    }
					 
					
					
					 
					
					   $html .= '<tr>   <td  style="font-size:9px;padding: 0"  > Tasks  '.$htmly.'     </td> </tr> 
					    <tr>   <td  > 
				    <barcode code="'.$row['receipt_number'].'"  type="I25"    size="0.8"/> 
				   <p align="left"  style="font-size:8px;padding: 0">  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '.$row['receipt_number'].'    </p></td> </tr>
					     </table>   ';
						 
						 if($count < $catsum ){
							 $html .= '<pagebreak />';
						 }

                     
					
					 
				   
			 
				 }
             
				 

                
               
				  
				   

                  
                }
 
 
 
 
 
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8','format' =>  array(60, 40), 'setAutoTopMargin' => 'stretch'  
	,'margin_left' => 1, 'margin_top' => 1, 'margin_right' => 0,  'margin_bottom' => 0,  'margin_header' =>1  
	]); 
     
  $stylesheet2 = file_get_contents($base_url.'barcodeextended.css');  
    $mpdf->WriteHTML($stylesheet2,\Mpdf\HTMLParserMode::HEADER_CSS);
	
	 $stylesheet = file_get_contents('table.css'); 
    $mpdf->WriteHTML($stylesheet,\Mpdf\HTMLParserMode::HEADER_CSS); 
  $mpdf->WriteHTML($html );

    
  // $mpdf->Output( 'devnote.pdf', 'F' ); 
	 $mpdf->Output();
	exit;
?>