/**
  * @param $path
  * @param $print_portrait
  * @param $print_paper_size
  * @param $labels
  * @return bool|string
  */
 public function explodePDF($path, $print_portrait, $print_paper_size, $labels)
 {
     ini_set('memory_limit', '1024M');
     if (!is_file($path)) {
         return false;
     }
     $isPortrait = $print_portrait;
     $paperSize = in_array($print_paper_size, ['A2', 'A3', 'A4', 'A5']) ? $print_paper_size : 'A4';
     $pdfInfo = $this->pdfInfo($path);
     if (!$pdfInfo) {
         return false;
     }
     $pdfSize = array_map(function ($item) {
         return trim((int) $item);
     }, explode('x', $pdfInfo['Page size']));
     $pdfSize['w'] = $pdfSize[0] * 0.75;
     $pdfSize['h'] = $pdfSize[1] * 0.75;
     $paperSizes = ['A2' => ['w' => 420, 'h' => 594], 'A3' => ['w' => 297, 'h' => 420], 'A4' => ['w' => 210, 'h' => 297], 'A5' => ['w' => 148, 'h' => 210]];
     include dirname(__DIR__) . "/lib/mpdf/mpdf.php";
     $mgl = 10;
     $mgr = 10;
     $mgt = 20 + 10;
     $mgb = 5 + 10;
     $mgh = 9;
     $mgf = 9;
     if ($isPortrait) {
         $mgl = 20;
         $mgr = 10;
         $mgt = 5 + 10;
         $mgb = 5 + 10;
         $mgh = 9;
         $mgf = 9;
     }
     $mpdf = new \mPDF('c', $paperSize . ($isPortrait ? '-P' : '-L'));
     $mpdf->SetImportUse();
     $mpdf->SetDisplayMode('fullpage');
     $mpdf->SetCompression(true);
     //$mpdf->SetAutoPageBreak(true);
     $mpdf->mirrorMargins = true;
     $source = $mpdf->SetSourceFile($path);
     $page_w = $isPortrait ? $paperSizes[$paperSize]['w'] : $paperSizes[$paperSize]['h'];
     $page_h = $isPortrait ? $paperSizes[$paperSize]['h'] : $paperSizes[$paperSize]['w'];
     $iter_w = ceil($pdfSize['w'] / $page_w / 2);
     $iter_h = ceil($pdfSize['h'] / $page_h / 1);
     $crop_x = 0;
     $crop_y = 0;
     $head_left = isset($labels['head_left']) ? $labels['head_left'] : '';
     $head_center = isset($labels['head_center']) ? $labels['head_center'] : '';
     $head_right = isset($labels['head_right']) ? $labels['head_right'] : '';
     $footer_left = isset($labels['footer_left']) ? $labels['footer_left'] : '';
     $footer_center = isset($labels['footer_center']) ? $labels['footer_center'] : '';
     $footer_right = isset($labels['footer_right']) ? $labels['footer_right'] : '';
     $header = '
         <table width="100%" style="vertical-align: bottom; font-size: 12pt; font-weight: bold"><tr>
         <td width="33%">' . $head_left . '</td>
         <td width="33%" align="center">' . $head_center . '</td>
         <td width="33%" style="text-align: right;">' . $head_right . '</td>
         </tr></table>
         ';
     $footer = '
         <table width="100%" style="vertical-align: bottom; font-size: 12pt; font-weight: bold"><tr>
         <td width="33%">' . $footer_left . '</td>
         <td width="33%" align="center">' . $footer_center . '</td>
         <td width="33%" style="text-align: right;">' . $footer_right . '</td>
         </tr></table>
         ';
     $mpdf->SetHTMLHeader($header);
     $mpdf->SetHTMLHeader($header, 'E');
     $mpdf->SetHTMLFooter($footer);
     $mpdf->SetHTMLFooter($footer, 'E');
     for ($i = 0; $i < $iter_w; $i++) {
         if ($i > 0) {
             $mpdf->AddPage();
         }
         // '', '', '', '', '', $mgl, $mgr, $mgt, $mgb, $mgh, $mgf
         $tpl = $mpdf->ImportPage($source, $crop_x, $crop_y, $page_w - ($mgl + $mgr), $page_h - ($mgt + $mgb));
         $mpdf->UseTemplate($tpl, $mgl, $mgt);
         if ($iter_h > 2) {
             $mpdf->AddPage();
             $tpl = $mpdf->ImportPage($source, $crop_x, $crop_y, $page_w - ($mgl + $mgr), $page_h - ($mgt + $mgb));
             $mpdf->UseTemplate($tpl, $mgl, $mgt);
         }
         $crop_x += $page_w - ($mgl + $mgr);
     }
     $mpdf->Output($path . 'gen.pdf', 'F');
     return $path . 'gen.pdf';
 }
Exemplo n.º 2
0
			 }
			
			
			$html12=file_get_contents(home_url().'/pdf12/?order_id='.$order_id);
			  
			$html13=file_get_contents(home_url().'/pdf13/?order_id='.$order_id);
			 
			$html14=file_get_contents(home_url().'/pdf14/?order_id='.$order_id);
			//print_r($weight_range_new);
			
		// mode, format, default_font_size, default_font, margin_left, margin_right,
				// margin_top, margin_bottom, margin_header, margin_footer, orientation
			//echo "after for loop";
			$mpdf = new mPDF('UTF-8','A4-L');
			$mpdf->defaultPagebreakType='clonebycss';
			$mpdf->SetCompression(true);
			$mpdf->useLang = true;
			//$mpdf->use_kwt = true;  
			$css=file_get_contents(get_template_directory_uri().'-child/PDF_html/pdf_style.css');
		
			//--------------------------------------------------, L , R , T , B , 
			$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,0,0,0, 'L');
			$mpdf->WriteHTML($css,1);
			
			$mpdf->WriteHTML(htmlspecialchars_decode($html1),2);
			//file_put_contents($uppath1.'status.json',json_encode(array('current'=>'58','total'=>'100')));
			$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,0,0,0, 'L');
			$mpdf->WriteHTML(htmlspecialchars_decode($html2));

			$header3=__('<div style="padding:0px 0px 0px 0px;height:12mm;width:100%;background:#FFF;border:0;outline:none;margin:0;">
							<div style="padding:1px 38.4px 0px 37px;">
Exemplo n.º 3
0
$petrol = str_replace("None", "Без топлива", $petrol);
$tormoz = str_replace("Hydraulic", "Гидравлический", $row['field16']);
$tormoz = str_replace("Pneumatic", "Пневматический", $tormoz);
$tormoz = str_replace("Mechanical", "Механический", $tormoz);
$tormoz = str_replace("Combined", "Комбинированный", $tormoz);
$tormoz = str_replace("None", "Отстутствует", $tormoz);
include "mpdf50/mpdf.php";
for ($i = 1; $i < 27; $i++) {
    if (empty($row['field' . $i])) {
        $row['field' . $i] = iconv('WINDOWS-1251', 'UTF-8', 'ОТСУТСТВУЕТ');
    }
}
$mpdf = new mPDF();
$mpdf->SetImportUse();
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetCompression(false);
// Add First page
$pagecount = $mpdf->SetSourceFile('2.pdf');
$tplIdx = $mpdf->ImportPage(1);
$mpdf->UseTemplate($tplIdx);
$html = '
 <table border="0" class="startusq">
  <tr>
						<td></td>
						<td></td>
						<td></td>
						<td>' . $rowzaw[3] . '</td>
						<td>' . $rowzaw[4] . '</td>
						<td>' . $rowzaw[5] . '</td>
						<td>' . $rowzaw[6] . '</td>
						<td>' . $rowzaw[7] . '</td>
Exemplo n.º 4
0
function pdf_file_creation($atts){
	
	require_once 'mpdf/mpdf.php';
	global $wpdb, $shopkeeper_theme_options;
	try{
	 $site_logo = $shopkeeper_theme_options['light_transparent_header_logo']['url'];
	//$order_id=$_REQUEST['order_id'];
	//echo $order_id;

		$order_id=$atts['order_id'];
		$order_item_id=$atts['order_item_id'];	
		
		$billing_first_name = get_post_meta($order_id,'_billing_first_name',true);
		$billing_last_name = get_post_meta($order_id,'_billing_last_name',true);
		$billing_email = get_post_meta($order_id,'_billing_email',true);

		$order=new WC_Order($order_id);
		$items = $order->get_items();
		$item_data=$items [array_keys($items)[0]];
		
		$plan_id=$item_data['item_meta']['_product_id'][0];
		$site_id=get_current_blog_id();
		$plan_details=get_post($plan_id);
		$plan_period=get_post_meta($plan_id,'plan_period',true);
		$path = wp_upload_dir();
		$pdfname='';
		
		$order_details=$wpdb->get_results('select id,meals_per_day,no_of_weeks,regenerate,current_weight from up_user_nutrition_plans where order_id='.$order_id.' AND site_id='.$site_id);
		
		$weight_range=$wpdb->get_results('select expected_weight from up_plan_logs where user_nutrition_plan_id=(select id from  up_user_nutrition_plans where order_id='.$order_id.' AND site_id='.$site_id.')',ARRAY_N);
		
		$no_of_weeks=$order_details[0]->no_of_weeks;

		if(isset($order_details) && !empty($order_details)){
		  
			$plan_name=$items [array_keys($items)[0]]['name'];
			$username="******";
			$password="******";
			$opts = array(
				  'http'=>array(
					'method'=>"GET",
					'header'=>"Accept-language: en\r\n" .
							  "Cookie: foo=bar\r\n".
							  "Authorization: Basic " . base64_encode("$username:$password")
				  )
				);
		
			$context = stream_context_create($opts);
			
			$html1=file_get_contents(home_url().'/pdf1/?order_id='.$order_id,false,$context);
		 
			$html2=file_get_contents(home_url().'/pdf2/?order_id='.$order_id,false,$context);
			  
			$html3=file_get_contents(home_url().'/pdf3/?order_id='.$order_id,false,$context);
			
			  //echo $html1;
			for($i=1;$i<=$no_of_weeks;$i++){
			
				$weight_range_new[$i]=$weight_range[$i-1][0];
				
				// echo $weight_range_new[$i].'<br/>';
				// echo "in for loop".$i;
				$html4[$i]=file_get_contents(home_url().'/pdf4/?order_id='.$order_id.'&week_no='.$i,false,$context);
				  
				$html5[$i]=file_get_contents(home_url().'/pdf5/?order_id='.$order_id.'&week_no='.$i,false,$context);
				  
				$html6[$i]=file_get_contents(home_url().'/pdf6/?order_id='.$order_id.'&week_no='.$i,false,$context);
			  
				$html7[$i]=file_get_contents(home_url().'/pdf7/?order_id='.$order_id.'&week_no='.$i,false,$context);
				 
				$html8[$i]=file_get_contents(home_url().'/pdf8/?order_id='.$order_id.'&week_no='.$i,false,$context);
			  
				$html9[$i]=file_get_contents(home_url().'/pdf9/?order_id='.$order_id.'&week_no='.$i,false,$context);
					  
				$html10[$i]=file_get_contents(home_url().'/pdf10/?order_id='.$order_id.'&week_no='.$i,false,$context);
		
				$html11[$i]=file_get_contents(home_url().'/shopping/?order_id='.$order_id.'&week_no='.$i,false,$context);
			 }
			
			
			$html12=file_get_contents(home_url().'/pdf12/?order_id='.$order_id,false,$context);
			  
			$html13=file_get_contents(home_url().'/pdf13/?order_id='.$order_id,false,$context);
			 
			//$html14=file_get_contents(home_url().'/pdf14/?order_id='.$order_id);
		//	print_r($weight_range_new);
			
		// mode, format, default_font_size, default_font, margin_left, margin_right,
				// margin_top, margin_bottom, margin_header, margin_footer, orientation
			//echo "after for loop";
			$mpdf = new mPDF('UTF-8','A4-L');
			$mpdf->defaultPagebreakType='clonebycss';
			$mpdf->SetCompression(true);
			$mpdf->useLang = true;
			//$mpdf->use_kwt = true;  
			$css=file_get_contents(get_template_directory_uri().'-child/PDF_html/pdf_style.css',false,$context);
		
			//--------------------------------------------------, L , R , T , B , 
			$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,0,0,0, 'L');
			$mpdf->WriteHTML($css,1);
			
			$mpdf->WriteHTML(htmlspecialchars_decode($html1),2);
			//file_put_contents($uppath1.'status.json',json_encode(array('current'=>'58','total'=>'100')));
			$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,0,0,0, 'L');
			$mpdf->WriteHTML(htmlspecialchars_decode($html2));

			$header3=__('<div style="padding:0px 0px 0px 0px;height:12mm;width:100%;background:#FFF;border:0;outline:none;margin:0;">
							<div style="padding:1px 38.4px 0px 37px;">
								 <div style="width:20%; float:left; color:#162c5d;text-align:left; line-height:10px;">
									  <p style="float:left;">Tipps & Tricks</p>
								</div>
								<div style="float:left;width:60%;text-align:center; vertical-align:middle;">
									<img style="margin-top:8px;" width="" height="28"  src="'.$site_logo.'"></div>
								<div style="float:right;width:19%;padding-right:2px; color:#162c5d;text-align:right;line-height:10px; ">
									<p>Seite {PAGENO}/{nbpg}</p>
								</div>
							</div>     
						  </div>', 'shopkeeper' );
						  
			$mpdf->SetHTMLHeader(htmlspecialchars_decode($header3));
			
		//	$mpdf->SetHTMLFooter(htmlspecialchars_decode($header3));
			$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,16.7,10.18,0,0);
			$mpdf->WriteHTML(htmlspecialchars_decode($html3));
/*<div style="width:30%; float:left; color:#162c5d;text-align:left; line-height:10px;">
								  <p class="p4-header_green">Abnahme Woche '.$i.': ca. '.$min_w.' - '.$max_w.' kg</p>
							  </div> */
			for($i=1;$i<=$no_of_weeks;$i++){
				/*if($i==1){ 
					$min_w=str_replace(".",",",0.1);
				}
				else{
					//$min_w=	str_replace(".",",",(float)$order_details[0]->current_weight-(float)$weight_range_new[$i]);
					$min_w=$max_w;
				}*/
		
				$wr= (float)$order_details[0]->current_weight-(float)$weight_range_new[$i];
				$min_w=($wr*0.75);
				$max_w=($wr*1.75);
				$max_w=	number_format($max_w,"1",",","");
				$min_w=	number_format($min_w,"1",",","");

				$header4[$i]=__('<div style="padding:0px 0px 0px 0px;width:100%;background:#FFF;border:0;outline:none;margin:0;">
							<div style="padding:1px 38.4px 0px 37px;">
							  <div style="width:43%; float:left; color:#162c5d;text-align:left;padding-bottom:1px; line-height:10px;">
								  <p style="float:left;">Woche '.$i.': Montag</p>
							  </div>
							 
							  <div style="float:left;width:12%;text-align:center; vertical-align:middle;">
								<img style="margin-top:8px;" width="" height="28"  src="'.$site_logo.'">
							</div>
							  <div style="float:right;width:44%; color:#162c5d;text-align:right;line-height:10px; ">
								  <p>Seite {PAGENO}/{nbpg}</p>
							  </div>
							</div>     
						  </div>', 'shopkeeper' );
				$mpdf->SetHTMLHeader(htmlspecialchars_decode($header4[$i]));
			
				$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,16.7,10.18,0,0);
				$mpdf->WriteHTML(htmlspecialchars_decode($html4[$i]));

				$header5[$i]=__('<div style="padding:0px 0px 0px 0px;width:100%;background:#FFF;border:0;outline:none;margin:0;">
							<div style="padding:1px 38.4px 0px 37px;">
							  <div style="width:43%; float:left; color:#162c5d;text-align:left; line-height:10px;">
								  <p style="float:left;">Woche '.$i.': Dienstag</p>
							  </div>
							   
							  <div style="float:left;width:12%;text-align:center; vertical-align:middle;">
								<img style="margin-top:8px;" width="" height="28"  src="'.$site_logo.'"></div>
							  <div style="float:right;width:44%; color:#162c5d;text-align:right;line-height:10px; ">
								  <p>Seite {PAGENO}/{nbpg}</p>
							  </div>
							</div>     
						  </div>', 'shopkeeper' );

				$mpdf->SetHTMLHeader(htmlspecialchars_decode($header5[$i]));
				$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,16.7,10.18,0,0);
				$mpdf->WriteHTML(htmlspecialchars_decode($html5[$i]));

				$header6[$i]=__('<div style="padding:0px 0px 0px 0px;width:100%;background:#FFF;border:0;outline:none;margin:0;">
							<div style="padding:1px 38.4px 0px 37px;">
							  <div style="width:43%; float:left; color:#162c5d;text-align:left; line-height:10px;">
								  <p style="float:left;">Woche '.$i.': Mittwoch</p>
							  </div>
							 
							  <div style="float:left;width:12%;text-align:center; vertical-align:middle;">
								<img style="margin-top:8px;" width="" height="28"  src="'.$site_logo.'"></div>
							  <div style="float:right;width:44%; color:#162c5d;text-align:right;line-height:10px; ">
								  <p>Seite {PAGENO}/{nbpg}</p>
							  </div>
							</div>     
						  </div>', 'shopkeeper' );
				$mpdf->SetHTMLHeader(htmlspecialchars_decode($header6[$i]));
				$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,16.7,10.18,0,0);
				$mpdf->WriteHTML(htmlspecialchars_decode($html6[$i]));

				$header7[$i]=__('<div style="padding:0px 0px 0px 0px;width:100%;background:#FFF;border:0;outline:none;margin:0;">
							<div style="padding:1px 38.4px 0px 37px;">
							  <div style="width:43%; float:left; color:#162c5d;text-align:left; line-height:10px;">
								  <p style="float:left;">Woche '.$i.': Donnerstag</p>
							  </div>
							 
							  <div style="float:left;width:12%;text-align:center; vertical-align:middle;">
								<img style="margin-top:8px;" width="" height="28"  src="'.$site_logo.'"></div>
							  <div style="float:right;width:44%; color:#162c5d;text-align:right;line-height:10px; ">
								  <p>Seite {PAGENO}/{nbpg}</p>
							  </div>
							</div>     
						  </div>', 'shopkeeper' );
				$mpdf->SetHTMLHeader(htmlspecialchars_decode($header7[$i]));
				$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,16.7,10.18,0,0);
				$mpdf->WriteHTML(htmlspecialchars_decode($html7[$i]));
			
				$header8[$i]=__( '<div style="padding:0px 0px 0px 0px;width:100%;background:#FFF;border:0;outline:none;margin:0;">
							<div style="padding:1px 38.4px 0px 37px;">
							  <div style="width:43%; float:left; color:#162c5d;text-align:left; line-height:10px;">
								  <p style="float:left;">Woche '.$i.': Freitag</p>
							  </div>
							 
							   <div style="float:left;width:12%;text-align:center; vertical-align:middle;">
								<img style="margin-top:8px;" width="" height="28"  src="'.$site_logo.'"></div>
							  <div style="float:right;width:44%; color:#162c5d;text-align:right;line-height:10px; ">
								  <p>Seite {PAGENO}/{nbpg}</p>
							  </div>
							</div>     
						  </div>', 'shopkeeper' );

				$mpdf->SetHTMLHeader(htmlspecialchars_decode($header8[$i]));
				$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,16.7,10.18,0,0);
				$mpdf->WriteHTML(htmlspecialchars_decode($html8[$i]));
				
				$header9[$i]=__('<div style="padding:0px 0px 0px 0px;width:100%;background:#FFF;border:0;outline:none;margin:0;">
							<div style="padding:1px 38.4px 0px 37px;">
							  <div style="width:43%; float:left; color:#162c5d;text-align:left; line-height:10px;">
								  <p style="float:left;">Woche '.$i.': Samstag</p>
							  </div>
							  
							   <div style="float:left;width:12%;text-align:center; vertical-align:middle;">
								<img style="margin-top:8px;" width="" height="28"  src="'.$site_logo.'"></div>
							  <div style="float:right;width:44%; color:#162c5d;text-align:right;line-height:10px; ">
								  <p>Seite {PAGENO}/{nbpg}</p>
							  </div>
							</div>     
						  </div>', 'shopkeeper' );
				$mpdf->SetHTMLHeader(htmlspecialchars_decode($header9[$i]));
				$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,16.7,10.18,0,0);
				$mpdf->WriteHTML(htmlspecialchars_decode($html9[$i]));
				
				$header10[$i]=__('<div style="padding:0px 0px 0px 0px;width:100%;background:#FFF;border:0;outline:none;margin:0;">
							<div style="padding:1px 38.4px 0px 37px;">
							  <div style="width:43%; float:left; color:#162c5d;text-align:left; line-height:10px;">
								  <p style="float:left;">Woche '.$i.': Sonntag</p>
							  </div>
							 
							   <div style="float:left;width:12%;text-align:center; vertical-align:middle;">
								<img style="margin-top:8px;" width="" height="28"  src="'.$site_logo.'"></div>
							  <div style="float:right;width:44%; color:#162c5d;text-align:right;line-height:10px; ">
								  <p>Seite {PAGENO}/{nbpg}</p>
							  </div>
							</div>     
						  </div>', 'shopkeeper' );
				$mpdf->SetHTMLHeader(htmlspecialchars_decode($header10[$i]));
				
				$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,16.7,10.18,0,0);
				$mpdf->WriteHTML(htmlspecialchars_decode($html10[$i]));

				$header11[$i]=__('<div style="padding:0px 0px 0px 0px;width:100%;background:#FFF;border:0;outline:none;margin:0;">
								<div style="padding:1px 38.4px 0px 37px;">
									  <div style="width:20%; float:left; color:#162c5d;text-align:left; line-height:10px;">
										  <p style="float:left;">Einkaufsliste</p>
										 
										</div>
									 <div style="float:left;width:60%;text-align:center; vertical-align:middle;">
										<img style="margin-top:8px;" width="" height="28"  src="'.$site_logo.'"></div>
									<div style="float:right;width:19%;padding-right:2px; color:#162c5d;text-align:right;line-height:10px; ">
										<p>Seite {PAGENO}/{nbpg}</p>
									</div>
								</div>     
							  </div>', 'shopkeeper' );
				$mpdf->SetHTMLHeader(htmlspecialchars_decode($header11[$i]));
				$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,16.7,10.18,0,0);
				$mpdf->WriteHTML(htmlspecialchars_decode($html11[$i]));
		}
		
			$header12=__('<div style="padding:0px 0px 0px 0px;width:100%;background:#FFF;border:0;outline:none;margin:0;">
							<div style="padding:1px 38.4px 0px 37px;">
								  <div style="width:20%; float:left; color:#162c5d;text-align:left; line-height:10px;">
									  <p style="float:left;">Fatburner Getrankeliste</p>
									 </div>
								  <div style="float:left;width:60%;text-align:center; vertical-align:middle;">
									<img style="margin-top:8px;" width="" height="28"  src="'.$site_logo.'"></div>
								<div style="float:right;width:19%;padding-right:2px; color:#162c5d;text-align:right;line-height:10px; ">
									<p>Seite {PAGENO}/{nbpg}</p>
								</div>
							</div>     
						  </div>', 'shopkeeper' );
			$mpdf->SetHTMLHeader(htmlspecialchars_decode($header12));
			$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,16.7,10.18,0,0);
			$mpdf->WriteHTML(htmlspecialchars_decode($html12));

			$mpdf->SetHTMLHeader('');
			$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,0,0,0,0);
			$mpdf->WriteHTML(htmlspecialchars_decode($html13));
			
		/*	$mpdf->SetHTMLHeader('');
			$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,0,0,0,0);
			$mpdf->WriteHTML(htmlspecialchars_decode($html14));*/
			
			$path = wp_upload_dir(); 
			//$path['basedir']
			if(!file_exists($path['path'] . '/pdf')){mkdir($path['path'] . '/pdf/',0777, true);}
			/*for($i=71;$i<100;$i++){
				file_put_contents($uppath1.'status.json',json_encode(array('current'=>$i,'total'=>'100')));
				usleep(300000);
			}*/
		$pdfpath="";
		if($order_details[0]->regenerate == 1){
			//echo "if";
			$plan_name = str_replace(' ', "_", $plan_name);
			$pdfpath_db=$path['url'] . '/'.'pdf/'.$plan_name.'_Ernährungsplan_'.$billing_first_name.'_'.$billing_last_name.'_update_'.$order_id.'.pdf';			
			$pdf_name=$plan_name."_Ernährungsplan_".$billing_first_name."_".$billing_last_name."_update";
			$pdfpath=$path['path'] . '/'.'pdf/'.$plan_name.'_Ernährungsplan_'.$billing_first_name.'_'.$billing_last_name.'_update_'.$order_id.'.pdf';
			$sql="update up_user_nutrition_plans set regenerate=0 where order_id=".$order_id;
			$wpdb->query($sql);
			$q=$wpdb->query('UPDATE  up_user_nutrition_plans SET `re_pdf_name`="'.$pdf_name.'",`re_pdf_path`="'.$pdfpath_db.'" WHERE `order_id` ='.$order_id.' AND site_id='.$site_id);
		}
		else
		{// Ernährungsplan
			$plan_name = str_replace(' ', "_", $plan_name);
			$pdfpath_db=$path['url'].'/'.'pdf/'.$plan_name.'_Ernährungsplan_'.$billing_first_name.'_'.$billing_last_name.'_'.$order_id.'.pdf';			
			$pdf_name=$plan_name."_Ernährungsplan_".$billing_first_name."_".$billing_last_name;
			$pdfpath=$path['path'].'/'.'pdf/'.$plan_name.'_Ernährungsplan_'.$billing_first_name.'_'.$billing_last_name.'_'.$order_id.'.pdf';
			$q=$wpdb->query('UPDATE  up_user_nutrition_plans SET `pdf_name`="'.$pdf_name.'",`pdf_path`="'.$pdfpath_db.'" WHERE `order_id` ='.$order_id.' AND site_id='.$site_id);
		}
		//echo $pdfpath;
		//exit;
		
		//$pdfdoc = $mpdf->Output();
	//	exit;
		$mpdf->Output($pdfpath, "F");
		
		if($order_item_id != ''){
			$pdf_processing_description='Nutrition Plan(PDF) is generated';
			$sql1="Update ".$wpdb->prefix."woocommerce_order_itemmeta set meta_value = 3 WHERE order_item_id=".$order_item_id." and meta_key = 'pdf_processing_status'";
			$wpdb->query($sql1);
			$sql2="Update ".$wpdb->prefix."woocommerce_order_itemmeta set meta_value ='".$pdf_processing_description."' WHERE order_item_id=".$order_item_id." and meta_key = 'pdf_processing_description'";
				$wpdb->query($sql2);
		}
		$blog_id = get_current_blog_id();
		$date1 = date('Y-m-d H:i:s');
		$dataq = $wpdb->get_results("select meta_value from  ".$wpdb->prefix."woocommerce_order_itemmeta where order_item_id='".$order_item_id."' and meta_key='pdf_processing_status'");
		$dataq= json_decode(json_encode($dataq),true); 
		$cron_sql="insert into up_cron_status (order_id,description,pdf_processing_status,description_done_datetime,site_id) values ('".$order_id."','pdf has been successfully generated.','3','".$date1."','".$blog_id."')";
		//echo "3rd".$cron_sql."</br>";
		//$cron=$wpdb->query($cron_sql);
				
			if($dataq[0]['meta_value']==3 && (get_post_meta($order->id, '_payment_method', true) != 'bacs' || get_post_meta($order->id, '_payment_method', true) == ''))
			{
		//		echo 'here';
				//wp_mail('*****@*****.**','test-cron-pdf','mail sent successfully from pdf_function');
				$order = new WC_Order( $order_id );
				$status=$order->get_status();
				if($order->has_status('processing')){
					//echo 'in processing';
					$order->update_status( 'completed' );
				}
				/*$pdf_processing_description='Mail is sent to user successfully in pdf_function';
				$wpdb->query('update '.$wpdb->prefix.'woocommerce_order_itemmeta set meta_value=4 where meta_key="pdf_processing_status" and order_item_id="'.$order_item_id.'"');
				$sql2="Update ".$wpdb->prefix."woocommerce_order_itemmeta set meta_value ='".$pdf_processing_description."' WHERE order_item_id=".$order_item_id." and meta_key = 'pdf_processing_description'";
				$wpdb->query($sql2);*/
				$cron_sql="insert into up_cron_status (order_id,description,pdf_processing_status,description_done_datetime,site_id) values ('".$order_id."','order is completed and mail is sent','4','".$date1."','".$blog_id."')";
				//echo "4th".$cron_sql."</br>";
				//$cron=$wpdb->query($cron_sql);
		
				/*$ml = new WC_Email_Customer_Completed_Order();
				$ml->trigger($order_id);*/
			}
		
		}
	}
	catch(Exception $e) {
		echo 'Message: ' .$e->getMessage();
	}
	//exit;
//wp_die();
}
Exemplo n.º 5
-1
        private function writeByMpdf(){
            $tmpfile = 'logs/temp_' . str_replace('/', '_', $this->invNO)  . '.pdf';
            $this->Output($tmpfile,'F');
            include_once ('mpdf/mpdf.php');
            $mpdf=new \mPDF('','','','',15,15,57,16,9,9); 

            $mpdf->SetImportUse();
            $mpdf->SetDisplayMode('fullpage');
            $mpdf->SetCompression(false);
            $pagecount = $mpdf->SetSourceFile($tmpfile);
            for ($i=1; $i<=$pagecount; $i++) {
                $tplIdx = $mpdf->ImportPage($i);
                $mpdf->UseTemplate($tplIdx);
                if ($i < $pagecount)
                    $pdf->AddPage($this->orientaion);
            }
            $mpdf->Output();
            unlink($tmpfile);
//            $newfile = $this->invNO . '.pdf';
//            $mpdf->Output($newfile, 'I');
        }