'.$setting[desc][$_GET[lang]].' '.$setting[qty][$_GET[lang]].' '.$setting[unit_price][$_GET[lang]].' '.$setting[dis][$_GET[lang]].' '.$setting[total][$_GET[lang]].' ';*/ $query = " SELECT MAX(row) FROM `bill_detail` WHERE bill_number = '$number' AND (item <> '' OR description <> '' OR qty >0 OR unit_price >0)"; $rows= mysql_query($query) ; $temp = mysql_fetch_row($rows); $max_row = $temp[0]; $query = " SELECT description , qty ,units, unit_price ,dis , item ,row FROM `bill_detail` WHERE bill_number = '$number' ORDER By row"; $rows= mysql_query($query) ;//echo $query; $page =1; while($temp = mysql_fetch_row($rows)) { $i++; if($temp[4] > 0 ){$temp[total] = $temp[1] * $temp[3] *($temp[4] /100) ;$temp[4] .= '%';} else{$temp[total] = $temp[1] * $temp[3];} $sum += $temp[total]; if($temp[3] == 0 ){$temp[3] ='';}else{$temp[3] = '$ '.number_format($temp[3], 1);} if($temp[1] == 0 ){$temp[1] ='';} if($temp[total] == 0 ){$temp[total] ='';}else{$temp[total] = '$ '.number_format($temp[total], 1);} $row[$page] .= '
'.$temp[5].' '.$temp[0].' '.$temp[1].' '.$temp[3].' '.$temp[total].'
';// '.$temp[4].' if($i%30 == 0){$i=0; $page++;} if($max_row == $temp[6]) { $row[$page] .= '
'.$setting[sum][$_GET[lang]].' : $ '.number_format($sum , 1 ).'
'; break; } } $sum_amount = NumtoStr($sum); //echo $sum_amount[c]; $sum = number_format($sum , 1 ); //*************************************** if($bill[6] == 7) { $title[e] = $bill[12]; $title[c] = $bill[12]; } else { $title[e] = $bill[4]; $title[c] = $bill[5]; } $name = $setting[name][$_GET[lang]]; //*************************************** $host = $_SERVER["HTTP_HOST"]; $html =<<


{}
{} : {$number}
{$setting[date][$_GET[lang]]} : {$bill[1]}
{$setting[to][$_GET[lang]]} : {$client[name][$_GET[lang]]}
{$setting[address_header][$_GET[lang]]} : {$client[7]}
{$setting[attention][$_GET[lang]]} : {$client[2]}
{$setting[tel_name][$_GET[lang]]} / {$setting[fax_name][$_GET[lang]]} : {$client[3]} / {$client[4]}
{$setting[mobile_name][$_GET[lang]]} : {$client[5]}
{$setting[email_name][$_GET[lang]]} : {$client[6]}
EOD; $footer_sum = $setting[total_amount][$_GET[lang]].' : '.$bill[8].' '.$sum_amount[$_GET[lang]].' ( '.$bill[13].' $ '.$sum.' )'; require_once('./tcpdf/tcpdf.php'); class PDF_report1 extends TCPDF { public function Header() { global $setting; global $_GET; global $html; global $title; global $number; global $client; global $bill; if($_GET[lang]== 'c'){$this->SetFont('DroidSansFallback', '', 18, '', true);} if($_GET[lang]== 'e'){$this->SetFont('DroidSansFallback', '', 18, '', true);} // Logo $ _file = './logo.jpg'; $this->Image($image_file, 15, 13, '', 12, 'JPG', '', 'T', true, 1000, '', false, false, 0, false, false, false); // Set font //$this->SetFont('helvetica', 'B', 20); // Title //$this->Text(53, 13, $setting[name][$_GET[lang]]); if($_GET[lang]== 'c'){$this->SetFont('DroidSansFallback', '', 8, '', true);} if($_GET[lang]== 'e'){$this->SetFont('DroidSansFallback', '', 8, '', true);} $this->Text(15, 21, $setting[address][$_GET[lang]]); $this->Text(15, 25, $setting[tel][$_GET[lang]]); $this->Text(35, 25, $setting[fax][$_GET[lang]]); $this->Text(55, 25, $setting[email_name][$_GET[lang]].': '.$setting[email][$_GET[lang]]); if($_GET[lang]== 'c'){$this->SetFont('DroidSansFallback', '', 18, '', true);} if($_GET[lang]== 'e'){$this->SetFont('DroidSansFallback', '', 18, '', true);} $this->TexT(15 ,33 , $title[$_GET[lang]] , false , false, true , 0 , 0 , 'C') ; if($_GET[lang]== 'c'){$this->SetFont('DroidSansFallback', '', 10, '', true);} if($_GET[lang]== 'e'){$this->SetFont('DroidSansFallback', '', 10, '', true);} //************************************************************************************************ $this->TexT(15 ,45 , $setting[to][$_GET[lang]] , false , false, true , 0 , 0 , 'L') ; $this->TexT(28 ,45 , ': '.$client[name][$_GET[lang]] , false , false, true , 0 , 0 , 'L') ; $this->TexT(150 ,45 , $setting['date'][$_GET[lang]] , false , false, true , 0 , 0 , 'L') ; $this->TexT(168 ,45 , ': '.$bill[1] , false , false, true , 0 , 0 , 'L') ; //************************************************************************************************ $this->TexT(15 ,50 , $setting[address_header][$_GET[lang]] , false , false, true , 0 , 0 , 'L') ; $this->MultiCell( 120, 10 ,': '.$client[7] ,0 ,'L' ,false ,1 , 28 ,50); $this->TexT(150 ,50 , $setting[number][$_GET[lang]] , false , false, true , 0 , 0 , 'L') ; $this->TexT(168 ,50 , ': '.$number , false , false, true , 0 , 0 , 'L') ; if(!empty($bill[10])) { $this->TexT(150 ,55 , $setting[valid][$_GET[lang]] , false , false, true , 0 , 0 , 'L') ; $this->TexT(168 ,55 , ': '.$bill[10] , false , false, true , 0 , 0 , 'L') ; } if(!empty($bill[11])) { $this->TexT(150 ,60 , $setting[payment][$_GET[lang]] , false , false, true , 0 , 0 , 'L') ; $this->TexT(168 ,60 , ': '.$bill[11] , false , false, true , 0 , 0 , 'L') ; } $this->TexT(150 ,65 , $setting[pages][$_GET[lang]] , false , false, true , 0 , 0 , 'L') ; $this->TexT(168 ,65 , ': '.$this->getAliasNumPage().'/'.$this->getAliasNbPages() , false , false, true , 0 , 0 , 'L') ; //************************************************************************************************ $this->TexT(15 ,60 , $setting[attention][$_GET[lang]] , false , false, true , 0 , 0 , 'L') ; $this->TexT(28 ,60 , ': '.$client[2] , false , false, true , 0 , 0 , 'L') ; //************************************************************************************************ $this->TexT(15 ,65 , $setting[tel_name][$_GET[lang]] , false , false, true , 0 , 0 , 'L') ; $this->TexT(28 ,65 , ': '.$client[3].' / '.$setting[fax_name][$_GET[lang]].' : ' .$client[4] , false , false, true , 0 , 0 , 'L') ; //************************************************************************************************ $this->Line(15, 75, 195, 75, ''); $this->MultiCell( 10, 5 , $setting[item][$_GET[lang]] ,0 ,'C' ,false ,1 , 15 ,75); $this->MultiCell( 117, 5 , $setting[desc][$_GET[lang]] ,0 ,'C' ,false ,1 , 25 ,75); $this->MultiCell( 14, 5 , $setting[qty][$_GET[lang]] ,0 ,'C' ,false ,1 , 142 ,75); $this->MultiCell( 20, 5 , $setting[unit_price][$_GET[lang]] ,0 ,'C' ,false ,1 , 156 ,75); $this->MultiCell( 20, 5 , $setting[amount][$_GET[lang]] ,0 ,'C' ,false ,1 , 176 ,75); $this->Line(15, 80, 195, 80, ''); //$this->TexT(15 ,40 , $setting[number][$_GET[lang]] , false , false, true , 0 , 0 , 'L') ; //$this->TexT(25 ,40 , $number , false , false, true , 0 , 0 , 'L') ; } public function Footer() { // Position at 15 mm from bottom $this->SetY(-15); global $footer_sum; global $_GET; global $setting; if($_GET[lang]== 'c'){$this->SetFont('DroidSansFallback', '', 10, '', true);} if($_GET[lang]== 'e'){$this->SetFont('DroidSansFallback', '', 10, '', true);} if ($this->end == true) { //$this->Text(15, 230, $footer_sum ,false,false,true,0,0,'',false,'',5); $this->MultiCell(0, 15, $footer_sum, 0 , 'L' ,false , 0 , 15, 220 ,true,0,false, true, 15 ,'B'); } $this->Line(15, 235, 195, 235, ''); $this->Text(15, 240, $setting[name][$_GET[lang]]); $this->Text(130, 240, $setting[accepted][$_GET[lang]]); $image_file = './chop.jpg'; $this->Image($image_file, 35, 250, '', 30, 'JPG', '', 'T', true, 1000, '', false, false, 0, false, false, false); $this->Line(15, 280, 80, 280, ''); $this->Line(130, 280, 195, 280, ''); //$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); $this->Text(130, 280, $setting[chop][$_GET[lang]]); $this->Text(15, 280, $setting[chop][$_GET[lang]]); } } $pdf = new PDF_report1(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); //$font = TCPDF_FONTS::addTTFfont('../tcpdf/fonts/DroidSansFallback.ttf'); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor(''); $pdf->SetPrintHeader(true); $pdf->SetPrintFooter(true); $pdf->approve = $by['approve'] ; $pdf->received = $by['received'] ; $pdf->SetTitle($title[e]); $pdf->SetSubject($title[e]); $pdf->SetKeywords($title[e]); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setLanguageArray($l); $pdf->setFontSubsetting(true); //$pdf->addTTFfont('fonts/DroidSansFallback.ttf'); if($_GET[lang]== 'c'){$pdf->SetFont('DroidSansFallback', '', 9, '', true);} if($_GET[lang]== 'e'){$pdf->SetFont('DroidSansFallback', '', 9, '', true);} foreach($row as $page =>$temp) { $pdf->AddPage('R', 'A4'); $pdf->SetTopMargin(80); //$pdf->SetAutoPageBreak(true, 76); //$pdf->writeHTMLcell(0, 0, 10, 5, $html, 0, 1, 0, true, '', true); //$pdf->writeHTML($html); $pdf->writeHTML($temp); } $pdf->writeHTML($footer); $pdf->end = true; $file_name = strtolower($number).'_'.date('YmdHis').'.pdf'; $pdf->Output($file_name, 'I'); if($_GET[header] == "mail") { require './phpmailer/PHPMailerAutoload.php'; //Create a new PHPMailer instance $mail = new PHPMailer; // Set PHPMailer to use the sendmail transport $mail->isSendmail(); //Set who the message is to be sent from $mail->setFrom('devin6@gmail.com', 'IZ SERVICE'); //Set an alternative reply-to address $mail->addReplyTo('devin6@gmail.com', 'IZ SERVICE'); //Set who the message is to be sent to $mail->addAddress('devin6@gmail.com', 'DEVIN'); $mail->addAddress('pangliuhk@gmail.com', 'PANG'); //Set the subject line $mail->Subject = $title[$_GET[lang]].' / '.$number; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $mail->msgHTML($client[name][e]); //Replace the plain text body with one created manually $mail->AltBody = 'This is a plain-text message body'; //Attach an image file $att = $pdf->Output('example_001.pdf', 'S'); $mail->AddStringAttachment($att , $file_name); //send the message, check for errors if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } //********************************************************************************************************************************** /* $att = chunk_split(base64_encode($att)); $boundary = strtoupper(md5(uniqid(time()))); $recipient = "$email , pangliuhk@gmail.com , devin6@gmail.com"; $headers = "From: info@izservice.com \n"; $subject = "$title #$number From IZ Service"; $message = 'test'; echo mail($recipient , $subject , $message ,$headers); //============================================================+*/ } ?>