Jump to content

tejure

Members
  • Content count

    5
  • Joined

  • Last visited

  1. Yes, now are running correctly. Only I need make a the changes that I had before with care and backup. Thank you Frogger34.
  2. Hello, I have a problem with Independent invoice number + PDF invoice. When I was make the firts install with original oscommerce invoice, both contributions run ok, but whith PDF invoice, not appear an invoice number. somebody can help me?, please This is the code of PDF invoice (is clean without independent invoice number). I make some test with code, but don' work correctly. Thank you <?php /* $Id: create_customer_pdf,v 1.1 2007/07/25 clefty (osc forum id chris23) osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License Based on create_pdf , originally written by Neil Westlake (nwestlake@gmail.com Rewritten to display a PDF invoice for the customer to print / download within account_history_info.php Changelog v1.1 -------------- i) Added invoice date config choice - today or same as order date - date now follows locale format set in /includes/languages/your-lang/your-lang.php ii) Decode html entities for all invoice text (better multilinual support) iii) Remove hardcoded address format. Now uses $order->customer['format_id'] iv) Config option to only display pdf link for delivered orders. v) Remove all hardcoded English language vi) Support for vector store logo - ai / eps formats vii) Added customer reference. */ define('FPDF_FONTPATH','fpdf/font/'); require('fpdf/fpdf.php'); require('includes/application_top.php'); // perform security check to prevent "get" tampering to view other customer's invoices if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } if (!isset($HTTP_GET_VARS['order_id']) || (isset($HTTP_GET_VARS['order_id']) && !is_numeric($HTTP_GET_VARS['order_id']))) { tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL')); } $customer_info_query = tep_db_query("select customers_id from " . TABLE_ORDERS . " where orders_id = '". (int)$HTTP_GET_VARS['order_id'] . "'"); $customer_info = tep_db_fetch_array($customer_info_query); if ($customer_info['customers_id'] != $customer_id) { tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL')); } require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CUSTOMER_PDF); // function to return rgb value for fpdf from supplied hex (#abcdef) function html2rgb($color){ if ($color[0] == '#') $color = substr($color, 1); if (strlen($color) == 6) list($r, $g, $b) = array($color[0].$color[1], $color[2].$color[3], $color[4].$color[5]); elseif (strlen($color) == 3) list($r, $g, $b) = array($color[0], $color[1], $color[2]); else return false; $r = hexdec($r); $g = hexdec($g); $b = hexdec($b); return array($r,$g,$b); } // function to decode html entities function tep_html_entity_decode($text, $quote_style = ENT_QUOTES){ return html_entity_decode($text, $quote_style); } // find image type function findextension ($filename) { $filename = strtolower($filename); $extension= split("\.", $filename); $n = count($extension)-1; $extension = $extension[$n]; return $extension; } $border_color = html2rgb(PDF_INV_BORDER_COLOR); $cell_color = html2rgb(PDF_INV_CELL_COLOR); $invoice_line = html2rgb(PDF_INV_INVLINE_COLOR); $highlight_color = html2rgb(PDF_INV_HIGHLIGHT_COLOR); $standard_color = html2rgb(PDF_INV_STANDARD_COLOR); $watermark_color = html2rgb(PDF_INV_WATERMARK_COLOR); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_HISTORY_INFO); require(DIR_WS_CLASSES . 'order.php'); $order = new order($HTTP_GET_VARS['order_id']); // set invoice date - today or day ordered. set in config $date = (PDF_INV_DATE_TODAY == 'today') ? strftime(DATE_FORMAT_LONG) : tep_date_long($order->info['date_purchased']); class PDF extends FPDF { //Page header function RoundedRect($x, $y, $w, $h,$r, $style = '') { $k = $this->k; $hp = $this->h; if($style=='F') $op='f'; elseif($style=='FD' or $style=='DF') $op='B'; else $op='S'; $MyArc = 4/3 * (sqrt(2) - 1); $this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k )); $xc = $x+$w-$r; $yc = $y+$r; $this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k )); $this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc); $xc = $x+$w-$r; $yc = $y+$h-$r; $this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k)); $this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r); $xc = $x+$r; $yc = $y+$h-$r; $this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k)); $this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc); $xc = $x+$r; $yc = $y+$r; $this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k )); $this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r); $this->_out($op); } function _Arc($x1, $y1, $x2, $y2, $x3, $y3) { $h = $this->h; $this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k, $x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k)); } function Header() { global $HTTP_GET_VARS, $highlight_color, $date, $image_function, $customer_id; //Logo $size =getimagesize(PDF_INVOICE_IMAGE); $this->$image_function(PDF_INVOICE_IMAGE,7,10,($size[0]*PDF_INV_IMG_CORRECTION),($size[1]*PDF_INV_IMG_CORRECTION),'', FILENAME_DEFAULT); // Invoice Number, customer reference and date $this->SetFont(PDF_INV_CORE_FONT,'B',10); $this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]); $this->SetY(43); $this->Cell(100,6, tep_html_entity_decode(PRINT_INVOICE_TITLE) . (int)$HTTP_GET_VARS['order_id'],0,'L'); $this->SetY(48); $this->Cell(100,6, $date ,0,'L'); // Company name $this->SetX(-10); $this->SetY(12); $this->SetFont(PDF_INV_CORE_FONT,'B',12); $this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]); $this->Ln(0); $this->Cell(149); $this->MultiCell(50, 3.5, tep_html_entity_decode(STORE_NAME),0,'L'); // Company Address $this->SetX(-10); $this->SetY(16); $this->SetFont(PDF_INV_CORE_FONT,'B',10); $this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]); $this->Ln(0); $this->Cell(149); $this->MultiCell(50, 3.5, tep_html_entity_decode(STORE_NAME_ADDRESS),0,'L'); //Email $this->SetX(0); $this->SetY(43); $this->SetFont(PDF_INV_CORE_FONT,'B',10); $this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]); $this->Ln(0); $this->Cell(88); $this->MultiCell(100, 6, tep_html_entity_decode(PDF_INV_EMAIL) . STORE_OWNER_EMAIL_ADDRESS,0,'R'); //Website $this->SetX(0); $this->SetY(48); $this->SetFont(PDF_INV_CORE_FONT,'B',10); $this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]); $this->Ln(0); $this->Cell(88); $this->MultiCell(100, 6, tep_html_entity_decode(PDF_INV_WEB) . HTTP_SERVER,0,'R'); // VAT / Tax number (if enabled) if (DISPLAY_PDF_TAX_NUMBER == 'true'){ $this->SetX(0); $this->SetY(53); $this->SetFont(PDF_INV_CORE_FONT,'B',10); $this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]); $this->Ln(0); $this->Cell(88); $this->MultiCell(100, 6, tep_html_entity_decode(PDF_TAX_NAME) . " " . PDF_TAX_NUMBER,0,'R'); } } // function taken and modified from $Id: pdf_datasheet_functions v1.40 2005/06/16 13:46:29 ip chilipepper.it Exp $ function RotatedText($x,$y,$txt,$angle) { //Text rotated around its origin $this->Rotate($angle,$x,$y); $this->Text($x,$y,$txt); $this->Rotate(0); } function Watermark() { global $watermark_color; $this->SetFont(PDF_INV_CORE_FONT,'B',60); $this->SetTextColor($watermark_color[0], $watermark_color[1], $watermark_color[2]); $ang=30; $cos=cos(deg2rad($ang)); $wwm=($this->GetStringWidth(tep_html_entity_decode(PDF_INV_WATERMARK_TEXT))*$cos); $this->RotatedText(($this->w-$wwm)/2,$this->w,PDF_INV_WATERMARK_TEXT,$ang); } function Footer() { global $highlight_color, $invoice_line; // insert horiz line $this->SetY(-19); $this->SetDrawColor($invoice_line[0],$invoice_line[1],$invoice_line[2]); $this->Cell(198,.1,'',1,1,'L',1); //Position at 1.5 cm from bottom $this->SetY(-22); $this->SetFont(PDF_INV_CORE_FONT,'',8); $this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]); $this->Cell(0,10, tep_html_entity_decode(PDF_INV_FOOTER_TEXT), 0,0,'C'); //Position at 1.5 cm from bottom $this->SetY(-19); $this->SetFont(PDF_INV_CORE_FONT,'',8); $this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]); $this->Cell(0,10, tep_html_entity_decode(PDF_INV_FOOTER_TEXT2), 0,0,'C'); //Position at 1.5 cm from bottom $this->SetY(-16); $this->SetFont(PDF_INV_CORE_FONT,'',8); $this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]); $this->Cell(0,10, tep_html_entity_decode(PDF_INV_FOOTER_TEXT3), 0,0,'C'); } } /*************************** * Software: FPDF_EPS * Version: 1.3 * Date: 2006-07-28 * Author: Valentin Schmidt ****************************/ class PDF_EPS extends PDF{ function PDF_EPS($orientation='P',$unit='mm',$format='A4'){ parent::FPDF($orientation,$unit,$format); } function ImageEps ($file, $x, $y, $w=0, $h=0, $link='', $useBoundingBox=true){ $data = file_get_contents($file); if ($data===false) $this->Error('EPS file not found: '.$file); # strip binary bytes in front of PS-header $start = strpos($data, '%!PS-Adobe'); if ($start>0) $data = substr($data, $start); # find BoundingBox params ereg ("%%BoundingBox:([^\r\n]+)", $data, $regs); if (count($regs)>1){ list($x1,$y1,$x2,$y2) = explode(' ', trim($regs[1])); } else $this->Error('No BoundingBox found in EPS file: '.$file); $start = strpos($data, '%%EndSetup'); if ($start===false) $start = strpos($data, '%%EndProlog'); if ($start===false) $start = strpos($data, '%%BoundingBox'); $data = substr($data, $start); $end = strpos($data, '%%PageTrailer'); if ($end===false) $end = strpos($data, 'showpage'); if ($end) $data = substr($data, 0, $end); # save the current graphic state $this->_out('q'); $k = $this->k; if ($useBoundingBox){ $dx = $x*$k-$x1; $dy = $y*$k-$y1; }else{ $dx = $x*$k; $dy = $y*$k; } # translate $this->_out(sprintf('%.3f %.3f %.3f %.3f %.3f %.3f cm', 1,0,0,1,$dx,$dy+($this->hPt - 2*$y*$k - ($y2-$y1)))); if ($w>0){ $scale_x = $w/(($x2-$x1)/$k); if ($h>0){ $scale_y = $h/(($y2-$y1)/$k); }else{ $scale_y = $scale_x; $h = ($y2-$y1)/$k * $scale_y; } }else{ if ($h>0){ $scale_y = $h/(($y2-$y1)/$k); $scale_x = $scale_y; $w = ($x2-$x1)/$k * $scale_x; }else{ $w = ($x2-$x1)/$k; $h = ($y2-$y1)/$k; } } # scale if (isset($scale_x)) $this->_out(sprintf('%.3f %.3f %.3f %.3f %.3f %.3f cm', $scale_x,0,0,$scale_y, $x1*(1-$scale_x), $y2*(1-$scale_y))); # handle pc/unix/mac line endings $lines = split ("\r\n|[\r\n]", $data); $u=0; $cnt = count($lines); for ($i=0;$i<$cnt;$i++){ $line = $lines[$i]; if ($line=='' || $line{0}=='%') continue; $len = strlen($line); if ($len>2 && $line{$len-2}!=' ') continue; $cmd = $line{$len-1}; switch ($cmd){ case 'm': case 'l': case 'v': case 'y': case 'c': case 'k': case 'K': case 'g': case 'G': case 's': case 'S': case 'J': case 'j': case 'w': case 'M': case 'd' : case 'n' : case 'v' : $this->_out($line); break; case 'x': # custom colors list($c,$m,$y,$k) = explode(' ', $line); $this->_out("$c $m $y $k k"); break; case 'Y': $line{$len-1}='y'; $this->_out($line); break; case 'N': $line{$len-1}='n'; $this->_out($line); break; case 'V': $line{$len-1}='v'; $this->_out($line); break; case 'L': $line{$len-1}='l'; $this->_out($line); break; case 'C': $line{$len-1}='c'; $this->_out($line); break; case 'b': case 'B': $this->_out($cmd . '*'); break; case 'f': case 'F': if ($u>0){ $isU = false; $max = min($i+5,$cnt); for ($j=$i+1;$j<$max;$j++) $isU = ($isU || ($lines[$j]=='U' || $lines[$j]=='*U')); if ($isU) $this->_out("f*"); }else $this->_out("f*"); break; case 'u': if ($line{0}=='*') $u++; break; case 'U': if ($line{0}=='*') $u--; break; #default: echo "$cmd<br>"; #just for debugging } } # restore previous graphic state $this->_out('Q'); if ($link) $this->Link($x,$y,$w,$h,$link); } }# END CLASS # for backward compatibility if (!function_exists('file_get_contents')){ function file_get_contents($filename, $use_include_path = 0){ $file = @fopen($filename, 'rb', $use_include_path); if ($file){ if ($fsize = @filesize($filename)) $data = fread($file, $fsize); else { $data = ''; while (!feof($file)) $data .= fread($file, 1024); } fclose($file); return $data; }else return false; } } // Instanciation of inherited class - choose according to logo supplied, vector or raster if(findextension(PDF_INVOICE_IMAGE) == 'ai' || findextension(PDF_INVOICE_IMAGE) == 'eps'){ $pdf=new PDF_EPS(); $image_function = "ImageEps"; } else{ $pdf=new PDF(); $image_function = "Image"; } // Set the Page Margins $pdf->SetMargins(6,2,6); // Add the first page $pdf->AddPage(); // add watermark if required if(PDF_SHOW_WATERMARK == 'true'){ $pdf->Watermark(); } //Draw the top line with invoice text $pdf->Cell(50); $pdf->SetY(60); $pdf->SetDrawColor($invoice_line[0],$invoice_line[1],$invoice_line[2]); $pdf->Cell(15,.1,'',1,1,'L',1); $pdf->SetFont(PDF_INV_CORE_FONT,'BI',15); $pdf->SetTextColor($invoice_line[0],$invoice_line[1],$invoice_line[2]); $pdf->Text(22,61.5,tep_html_entity_decode(PRINT_INVOICE_HEADING)); $pdf->SetY(60); $pdf->SetDrawColor($invoice_line[0],$invoice_line[1],$invoice_line[2]); $pdf->Cell(38); $pdf->Cell(160,.1,'',1,1,'L',1); //Draw Box for Invoice Address $pdf->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); $pdf->SetLineWidth(0.2); $pdf->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); $pdf->RoundedRect(6, 67, 90, 35, 2, 'DF'); //Draw the invoice address text $pdf->SetFont(PDF_INV_CORE_FONT,'B',10); $pdf->SetTextColor($standard_color[0],$standard_color[1],$standard_color[2]); $pdf->Text(11,77, tep_html_entity_decode(ENTRY_SOLD_TO)); $pdf->SetX(0); $pdf->SetY(80); $pdf->Cell(9); $pdf->MultiCell(70, 3.3, tep_html_entity_decode(tep_address_format($order->customer['format_id'], $order->customer, '', '', "\n")),0,'L'); //Draw Box for Delivery Address $pdf->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); $pdf->SetLineWidth(0.2); $pdf->SetFillColor(255); $pdf->RoundedRect(108, 67, 90, 35, 2, 'DF'); //Draw the invoice delivery address text $pdf->SetFont(PDF_INV_CORE_FONT,'B',10); $pdf->SetTextColor($standard_color[0],$standard_color[1],$standard_color[2]); $pdf->Text(113,77,tep_html_entity_decode(ENTRY_SHIP_TO)); $pdf->SetX(0); $pdf->SetY(80); $pdf->Cell(111); $pdf->MultiCell(70, 3.3, tep_html_entity_decode(tep_address_format($order->delivery['format_id'], $order->delivery, '', '', "\n")),0,'L'); //Draw Box for Order Number, Date & Payment method $pdf->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); $pdf->SetLineWidth(0.2); $pdf->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); $pdf->RoundedRect(6, 107, 192, 14, 2, 'DF'); //Draw Order Number Text $pdf->Text(10,113, tep_html_entity_decode(PRINT_INVOICE_ORDERNR) . (int)$HTTP_GET_VARS['order_id']); //Draw Date of Order Text $pdf->Text(120,113, tep_html_entity_decode(PRINT_INVOICE_DATE) . tep_date_short($order->info['date_purchased'])); //Draw Payment Method Text $temp = substr ($order->info['payment_method'] , 0, 23); $pdf->Text(120,117, tep_html_entity_decode(ENTRY_PAYMENT_METHOD) . ' ' . tep_html_entity_decode($temp)); // Draw customer reference $pdf->Text(10,117, tep_html_entity_decode(PDF_INV_CUSTOMER_REF) . (int)$customer_id); //Draw Box for Comments $pdf->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); $pdf->SetLineWidth(0.2); $pdf->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); $pdf->RoundedRect(6, 124, 192, 22, 2, 'DF'); // Output comments - limited by $n, here set to 1. Any more and you need to adjust box height, product table y position etc $pdf->SetFont(PDF_INV_CORE_FONT,'B',10); $pdf->Text(10 ,128, tep_html_entity_decode(PDF_INV_COMMENTS)); $pdf->SetFont(PDF_INV_CORE_FONT,'',8); for ($i = 0, $n = 1; $i < $n; $i++){ $pdf->Text(10 , 133+(5*$i), $order->comments[$i]['comments']); } //Fields Name position $Y_Fields_Name_position = 150; //Table position, under Fields Name $Y_Table_Position = 156; function output_table_heading($Y_Fields_Name_position){ global $pdf, $cell_color; //First create each Field Name // Config color filling each Field Name box $pdf->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); //Bold Font for Field Name $pdf->SetFont(PDF_INV_CORE_FONT,'B',10); $pdf->SetY($Y_Fields_Name_position); $pdf->SetX(6); $pdf->Cell(9,6,tep_html_entity_decode(PDF_INV_QTY_CELL),1,0,'C',1); $pdf->SetX(15); $pdf->Cell(20,6,tep_html_entity_decode(TABLE_HEADING_PRODUCTS_MODEL),1,0,'C',1); $pdf->SetX(35); $pdf->Cell(100,6,tep_html_entity_decode(TABLE_HEADING_PRODUCTS),1,0,'C',1); //$pdf->SetX(118); //$pdf->Cell(20,6,tep_html_entity_decode(TABLE_HEADING_PRICE_EXCLUDING_TAX),1,0,'C',1); //$pdf->SetX(138); //$pdf->Cell(20,6,tep_html_entity_decode(TABLE_HEADING_PRICE_INCLUDING_TAX),1,0,'C',1); $pdf->SetX(135); $pdf->Cell(15,6,tep_html_entity_decode(TABLE_HEADING_TAX),1,0,'C',1); $pdf->SetX(150); $pdf->Cell(24,6,tep_html_entity_decode(TABLE_HEADING_TOTAL_EXCLUDING_TAX),1,0,'C',1); $pdf->SetX(174); $pdf->Cell(24,6,tep_html_entity_decode(TABLE_HEADING_TOTAL_INCLUDING_TAX),1,0,'C',1); $pdf->Ln(); } output_table_heading($Y_Fields_Name_position); //Show the products information line by line for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) { $pdf->SetFont(PDF_INV_CORE_FONT,'',10); $pdf->SetY($Y_Table_Position); $pdf->SetX(6); $pdf->MultiCell(9,6,$order->products[$i]['qty'],1,'C'); $pdf->SetY($Y_Table_Position); $pdf->SetX(35); $prod_attribs=''; //get attribs and concat if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) { for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) { $prod_attribs .= " - " .$order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value']; } } $product_name_attrib_contact = $order->products[$i]['name'] . $prod_attribs; if (strlen($product_name_attrib_contact) > 40 && strlen($product_name_attrib_contact) < 50){ $pdf->SetFont(PDF_INV_CORE_FONT,'',6); $pdf->MultiCell(100,6,tep_html_entity_decode($product_name_attrib_contact),1,'L'); } else if (strlen($product_name_attrib_contact) > 50){ $pdf->SetFont(PDF_INV_CORE_FONT,'',6); $pdf->MultiCell(100,6,tep_html_entity_decode(substr($product_name_attrib_contact,0,60)) ." .. ",1,'L'); } else{ $pdf->SetFont(PDF_INV_CORE_FONT,'',6); $pdf->MultiCell(78,6,tep_html_entity_decode($product_name_attrib_contact),1,'L'); $pdf->Ln(); } $pdf->SetFont('Arial','',10); $pdf->SetY($Y_Table_Position); $pdf->SetX(135); $pdf->MultiCell(15,6,tep_display_tax_value($order->products[$i]['tax']) . '%',1,'C'); $pdf->SetFont(PDF_INV_CORE_FONT,'',10); $pdf->SetY($Y_Table_Position); $pdf->SetX(15); $pdf->SetFont(PDF_INV_CORE_FONT,'',8); $pdf->MultiCell(20,6,tep_html_entity_decode($order->products[$i]['model']),1,'C'); //$pdf->SetY($Y_Table_Position); //$pdf->SetX(118); //$pdf->SetFont(PDF_INV_CORE_FONT,'',10); //$pdf->MultiCell(20,6,$currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']),1,'C'); //$pdf->SetY($Y_Table_Position); //$pdf->SetX(138); //$pdf->MultiCell(20,6,$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']),1,'C'); $pdf->SetY($Y_Table_Position); $pdf->SetX(150); $pdf->MultiCell(24,6,$currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']),1,'C'); $pdf->SetY($Y_Table_Position); $pdf->SetX(174); $pdf->MultiCell(24,6,$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']),1,'C'); $Y_Table_Position += 6; //Check for product line overflow $item_count++; if ((is_long($item_count / 32) && $i >= 20) || ($i == 20)){ $pdf->AddPage(); //Fields Name position $Y_Fields_Name_position = 125; //Table position, under Fields Name $Y_Table_Position = 70; output_table_heading($Y_Table_Position-6); if ($i == 20) $item_count = 1; } } for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) { $pdf->SetY($Y_Table_Position + 5); $pdf->SetX(95); $temp = substr ($order->totals[$i]['text'],0 ,3); if ($temp == '<b>') { $pdf->SetFont(PDF_INV_CORE_FONT,'B',10); $temp2 = substr($order->totals[$i]['text'], 3); $order->totals[$i]['text'] = substr($temp2, 0, strlen($temp2)-4); } $pdf->MultiCell(100,6,$order->totals[$i]['title'] . ' ' . $order->totals[$i]['text'],0,'R'); $Y_Table_Position += 5; } // set PDF metadata $pdf->SetTitle(PDF_META_TITLE); $pdf->SetSubject(PDF_META_SUBJECT . $HTTP_GET_VARS['order_id']); $pdf->SetAuthor(STORE_OWNER); // PDF created function safe_filename ($filename) { $search = array( '/ß/', '/ä/','/Ä/', '/ö/','/Ö/', '/ü/','/Ü/', '([^[:alnum:]._])' ); $replace = array( 'ss', 'ae','Ae', 'oe','Oe', 'ue','Ue', '_' ); // return a safe filename, lowercased and suffixed with invoice number. return strtolower(preg_replace($search,$replace,$filename)); } $file_name = safe_filename(STORE_NAME); $file_name .= "_invoice_" . $HTTP_GET_VARS['order_id'] . ".pdf"; $mode = (FORCE_PDF_INVOICE_DOWNLOAD == 'true') ? 'D' : 'I'; // what do we do? display inline or force download $pdf->Output($file_name , $mode); ?>
  3. tejure

    attribute calculator

    Sorry, the correct instruccion is: "onchange=\"stkmsg(this.form);showPrice(this.form);showPrice1(this.form);\"" ok
  4. tejure

    attribute calculator

    I have the solution!!! In pad_multiple_dropdowns.php file search line with this: $out.='<tr><td align="right" class=main><b>'.$attributes[$o]['oname'].":</b></td><td class=main>".tep_draw_pull_down_menu('id['.$attributes[$o]['oid'].']',array_values($attributes[$o]['ovals']), $attributes[$o]['default'], "onchange=\"stkmsg(this.form);\"")."</td></tr>\n"; replace stkmsg(this.form) for showPrice(this.form);showPrice1(this.form) for me ok!!
  5. tejure

    attribute calculator

    Hello, Sorry for my english... I have the same problem and I think this code may be can put on file pad_base.php on includes/classes/ directory, but I don't know where :blink: I think only is needed this function "onChange='showPrice(this.form);showPrice1(this.form);'" with QTpro, because if you put all appear another draw pull down menu. This is a pad_base.php file: --------------------------------- <?php /* QT Pro Version 4.1 pad_base.php Contribution extension to: osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2004, 2005 Ralph Day Released under the GNU General Public License Based on prior works released under the GNU General Public License: QT Pro prior versions Ralph Day, October 2004 Tom Wojcik aka TomThumb 2004/07/03 based on work by Michael Coffman aka coffman FREEZEHELL - 08/11/2003 freezehell@hotmail.com Copyright © 2003 IBWO Joseph Shain, January 2003 osCommerce MS2 Copyright © 2003 osCommerce Modifications made: 11/2004 - Created 12/2004 - Fix _draw_js_stock_array to prevent error when all attribute combinations are out of stock. ******************************************************************************** *********** QT Pro Product Attributes Display Plugin pad_base.php - Base Class Class Name: pad_base This base class, although functional, is not intended to be installed and used directly. It is extended by other classes to provide different display options for product attributes on the product information page (product_info.php). Methods: pad_base constructor _SetConfigurationProperties set local properties from DB config constants draw draw the product attributes _draw_table_start draw start of the table to enclose the attributes display _draw_stocked_attributes draw attributes that stock is tracked for _draw_nonstocked_attributes draw attributes that stock is not tracked for _draw_table_end draw end of the table to enclose the attributes display _draw_js_stock_array draw a Javascript array of in stock attribute combinations _build_attributes_array build an array of the attributes for the product _build_attributes_combinations build an array of the attribute combinations for the product Properties: products_id the product id for attribute display products_tax_class_id the products tax class id show_out_of_stock show out of stock attributes flag mark_out_of_stock mark out of stock attributes flag out_of_stock_msgline show out of stock message line flag no_add_out_of_stock prevent add to cart of out of stock attributes combinations */ class pad_base { var $products_id; var $products_tax_class_id; var $show_out_of_stock; var $mark_out_of_stock; var $out_of_stock_msgline; var $no_add_out_of_stock; /* Method: pad_base Class constructor Parameters: $products_id integer The product id of the product attributes are to be displayed for Returns: nothing */ function pad_base($products_id=0) { $this->products_id = $products_id; if ($this->products_id != 0) { $tax_class_query = tep_db_query('SELECT products_tax_class_id, products_price /* AGF */ FROM ' . TABLE_PRODUCTS . " WHERE products_id = '" . (int)$products_id . "'"); $tax_class_array = tep_db_fetch_array($tax_class_query); $this->products_tax_class_id = $tax_class_array['products_tax_class_id']; $this->products_original_price = $tax_class_array['products_price']; /* AGF */ } $this->_SetConfigurationProperties('PRODINFO_ATTRIBUTE_'); } /* Method: _SetConfigurationProperties Set local configuration properties from osCommerce configuration DB constants Parameters: $prefix sting Prefix for the osCommerce DB constants Returns: nothing */ function _SetConfigurationProperties($prefix) { $this->show_out_of_stock = constant($prefix . 'SHOW_OUT_OF_STOCK'); $this->mark_out_of_stock = constant($prefix . 'MARK_OUT_OF_STOCK'); $this->out_of_stock_msgline = constant($prefix . 'OUT_OF_STOCK_MSGLINE'); $this->no_add_out_of_stock = constant($prefix . 'NO_ADD_OUT_OF_STOCK'); } /* Method: draw Draws the product attributes. This is the only method other than the constructor that is intended to be called by a user of this class. Attributes that stock is tracked for are grouped first and drawn with one dropdown list per attribute. All attributes are drawn even if no stock is available for the attribute and no indication is given that the attribute is out of stock. Attributes that stock is not tracked for are then drawn with one dropdown list per attribute. Parameters: none Returns: string: HTML for displaying the product attributes */ function draw() { $out=$this->_draw_table_start(); $out.=$this->_draw_stocked_attributes(); $out.=$this->_draw_nonstocked_attributes(); $out.=$this->_draw_table_end(); return $out; } /* Method: _draw_table_start Draws the start of a table to wrap the product attributes display. Intended for class internal use only. Parameters: none Returns: string: HTML for start of table */ function _draw_table_start() { $out =' <table border="0" cellspacing="0" cellpadding="2">'; $out.=' <tr>'; $out.=' <td class="main" colspan="2"><b>' . TEXT_PRODUCT_OPTIONS . '</b></td>'; $out.=' </tr>'; return $out; } /* Method: _draw_stocked_attributes Draws the product attributes that stock is tracked for. Intended for class internal use only. Attributes that stock is tracked for are drawn with one dropdown list per attribute. All attributes are drawn even if no stock is available for the attribute and no indication is given that the attribute is out of stock. Parameters: none Returns: string: HTML for displaying the product attributes that stock is tracked for */ function _draw_stocked_attributes() { $out = ''; $attributes = $this->_build_attributes_array(true, false); if (sizeof($attributes)>0) { foreach ($attributes as $stocked) { $out .= '<tr><td align="right" class=main><b>' . $stocked['oname'] . ":</b></td><td class=main>" . tep_draw_pull_down_menu('id['.$stocked['oid'].']',array_values($stocked['ovals']),$stocked['default']) . "</td></tr>\n"; } } return $out; } /* Method: _draw_nonstocked_attributes Draws the product attributes that stock is not tracked for. Intended for class internal use only. Attributes that stock is not tracked for are drawn with one dropdown list per attribute. Parameters: none Returns: string: HTML for displaying the product attributes that stock is not tracked for */ function _draw_nonstocked_attributes() { $out=''; $nonstocked_attributes = $this->_build_attributes_array(false, true); foreach($nonstocked_attributes as $nonstocked) { $out.='<tr><td align="right" class=main><b>'.$nonstocked['oname'].":</b></td><td class=main>".tep_draw_pull_down_menu('id['.$nonstocked['oid'].']',$nonstocked['ovals'],$nonstocked['default'])."</td></tr>\n"; } return $out; } /* Method: _draw_table_end Draws the end of a table to wrap the product attributes display. Intended for class internal use only. Parameters: none Returns: string: HTML for end of table */ function _draw_table_end() { return ' </table>'; } /* Method: _build_attributes_array Build an array of the attributes for the product Parameters: $build_stocked boolean Flag indicating if stocked attributes should be built. $build_nonstocked boolean Flag indicating if non-stocked attribute should be built. Returns: array: Array of attributes for the product of the form: 'oid' => integer: products_options_id 'oname' => string: products_options_name 'ovals' => array: option values for the option id of the form 'id' => integer: products_options_values_id 'text' => string: products_options_values_name 'default' => integer: products_options_values_id that the product id contains for this option id and should be the default selection when this attribute is drawn. Set to zero if the product id did not contain this option. */ function _build_attributes_array($build_stocked, $build_nonstocked) { global $languages_id; global $currencies; global $cart; if (!($build_stocked | $build_nonstocked)) return null; if ($build_stocked && $build_nonstocked) { $stocked_where=''; } elseif ($build_stocked) { $stocked_where="and popt.products_options_track_stock = '1'"; } elseif ($build_nonstocked) { $stocked_where="and popt.products_options_track_stock = '0'"; } $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$this->products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' " . $stocked_where . " order by popt.products_options_name"); $attributes=array(); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $products_options_array = array(); $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$this->products_id . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'"); while ($products_options = tep_db_fetch_array($products_options_query)) { $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); //START of integration of contribution Actual "Price Pull Down v1.2.3a" if(PRODINFO_ATTRIBUTE_ACTUAL_PRICE_PULL_DOWN == 'True'){ //Option prices will displayed as a final product price. This can (currently) only be used with a satisfying result if you have only one option per product. $new_price ? $original_price = $new_price : $original_price = $this->products_original_price; //// check if set special price note $this variable if ($products_options['price_prefix'] == '-') {// in case price lowers, don't add values, subtract. $show_price = 0.0 + $original_price - $products_options['options_values_price']; // force float (in case) using the 0.0; } else { $show_price = 0.0 + $original_price + $products_options['options_values_price']; // force float (in case) using the 0.0; } $products_options_array[sizeof($products_options_array)-1]['text'] .= ' ' . $currencies->display_price( $show_price, tep_get_tax_rate($this->products_tax_class_id)) .' '; }else{ //Display the option prices as differece prices with +/- prefix as usually if ($products_options['options_values_price'] != '0') { $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($this->products_tax_class_id)) . ')'; } } //END of integration of contribution Actual "Price Pull Down v1.2.3a" } if (isset($cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']])) $selected = $cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']]; else $selected = 0; $attributes[]=array('oid'=>$products_options_name['products_options_id'], 'oname'=>$products_options_name['products_options_name'], 'ovals'=>$products_options_array, 'default'=>$selected); } return $attributes; } /* Method: _build_attributes_combinations A recursive method for building an array enumerating the attribute combinations for the product Parameters: $attributes array An array of the attributes that combinations will be built for. Format is as returned by _build_attributes_array. $showoos boolean Flag indicating if non-stocked attributes should be built. $markoos string 'Left' if out of stock indication is to be appended in front of the attribute combination text. 'Right' if out of stock indication is to be appended at the end of the attribute combination text. $combinations array Array of the attribute combinations is returned in this parameter. Should be set to an empty array before an external call to this method. 'comb' => array: array of a single attribute combination options_id => options_value_id 'id' => string: options/values string for this combination in the form for the key of the products_stock table opt_id-val_id,opt_id-val_id,... 'text' => string: Text for this combination. Values text is as built by _build_attributes_array and contains the add/subtract price for the option value if applicable. Form is: values_text, values_text $selected_combination integer Index into the $combinations array of the combination that should be the default selection when the combination is drawn is returned in this parameter. Determined from product id. Should be set to zero before an external call to this method. Parameters for internal recursion use only: $oidindex integer Index into the $attributes array of the option to operate on. $comb array Array containing option id/values of combination built so far products_options_id => products_options_value_id $id string Contains string of options/values built so far $text string Text for the options values constructed so far. $isselected boolean Flag indicating if so far all option values in this combination were indicated to be defaults in the product id. Returns: see $combinations and $selected_combination parameters above no actual function return value. */ function _build_attributes_combinations($attributes, $showoos, $markoos, &$combinations, &$selected_combination, $oidindex=0, $comb=array(), $id="", $text='', $isselected=true) { global $cart; foreach ($attributes[$oidindex]['ovals'] as $attrib) { $newcomb = $comb; $newcomb[$attributes[$oidindex]['oid']] = $attrib['id']; $newid=$id.','.$attributes[$oidindex]['oid'].'-'.$attrib['id']; $newtext = $text.", ".$attrib['text']; if (isset($cart->contents[$this->products_id]['attributes'][$attributes[$oidindex]['oid']])) $newisselected = ($cart->contents[$this->products_id]['attributes'][$attributes[$oidindex]['oid']] == $attrib['id']) ? $isselected : false; else $newisselected = false; if (isset($attributes[$oidindex+1])) { $this->_build_attributes_combinations($attributes, $showoos, $markoos, $combinations, $selected_combination, $oidindex+1, $newcomb, $newid, $newtext, $newisselected); } else { $is_out_of_stock=tep_check_stock(tep_get_prid($this->products_id),1,$newcomb); if (!$is_out_of_stock | ($showoos == true)) { switch ($markoos) { case 'Left': $newtext=($is_out_of_stock ? TEXT_OUT_OF_STOCK.' - ' : '').substr($newtext,2); break; case 'Right': $newtext=substr($newtext,2).($is_out_of_stock ? ' - '.TEXT_OUT_OF_STOCK : ''); break; default: $newtext=substr($newtext,2); break; } $combinations[] = array('comb'=>$newcomb, 'id'=>substr($newid,1), 'text'=>$newtext); if ($newisselected) $selected_combination = sizeof($combinations)-1; } } } } /* Method: _draw_js_stock_array Draw a Javascript array containing the given attribute combinations. Generally used to draw array of in-stock combinations for Javascript out of stock validation and messaging. Parameters: $combinations array Array of combinations to build the Javascript array for. Array must be of the form returned by _build_attributes_combinations Usually this array only contains in-stock combinations. Returns: string: Javacript array definition. Excludes the "var xxx=" and terminating ";". Form is: {optval1:{optval2:{optval3:1,optval3:1}, optval2:{optval3:1}}, optval1:{optval2:{optval3:1}}} For example if there are 3 options and the instock value combinations are: opt1 opt2 opt3 1 5 4 1 5 8 1 10 4 3 5 8 The string returned would be {1:{5:{4:1,8:1}, 10:{4:1}}, 3:{5:{8:1}}} */ function _draw_js_stock_array($combinations) { if (!((isset($combinations)) && (is_array($combinations)) && (sizeof($combinations) > 0))){ return '{}'; } $out=''; foreach ($combinations[0]['comb'] as $oid=>$ovid) { $out.='{'.$ovid.':'; $opts[]=$oid; } $out.='1'; for ($combindex=1; $combindex<sizeof($combinations); $combindex++) { $comb=$combinations[$combindex]['comb']; for ($i=0; $i<sizeof($opts)-1; $i++) { if ($comb[$opts[$i]]!=$combinations[$combindex-1]['comb'][$opts[$i]]) break; } $out.=str_repeat('}',sizeof($opts)-1-$i).','; if ($i<sizeof($opts)-1) { for ($j=$i; $j<sizeof($opts)-1; $j++) $out.=$comb[$opts[$j]].':{'; } $out.=$comb[$opts[sizeof($opts)-1]].':1'; } $out.=str_repeat('}',sizeof($opts)); return $out; } } ?> ------------------------------------- Thanks
×