Jump to content
Latest News: (loading..)

dennish

Members
  • Content count

    46
  • Joined

  • Last visited

Profile Information

  • Real Name
    Dennis Hoffland
  • Gender
    Male
  1. I noticed some particular behaviour on checkout_payment.php: first I entered some text in the field Comments e.g. Test 123 then I proceeded to checkout_confirmation.php and used the Change button (at the Comments section) to return to checkout_payment.php to edit my previous input in the field Comments If I change the text to Test, the field is updated correctly (as shown on checkout_confirmation.php) > the 123 part is removed If I remove the entire text instead (clearing the field) and proceed again to checkout_confirmation.php the old input Test 123 is still shown My conclusion: an empty value (for the session variable) is not accepted by osCommerce, when the form is (re)submitted to update a previously entered value. Note: I used a clean osC 2.3.4.1 installation to confirm the described behavior On my own website I use the Agree to terms extension. There I experience the same behaviour: needless to say that it is unacceptable that a customer can untick the checkbox when he returns to checkout_payment.php and can nevertheless proceed to checkout_confirmation.php, because the session variable is not updated (and osC thus regards the checkbox as still being ticked). Who can shed some light on this issue (and suggest a solution)? Kind regards, Dennis
  2. @MrPhil @Harald Ponce de Leon I am bit confused what you mean by Has the development of these 'official' versions 2.3.5 and 2.3.6 come to a halt? Will the next available stable version be just 2.4.0? And when will it approximately be relreased? With boostrap (3 or 4)? I already got the community-supported osC from https://github.com/gburton/Responsive-osCommerce/releases/tag/2341-Frozen Converting my current 2.3.4.1 osC will be no small task. So I am just wondering what's the best way to go, without wasting to much time.
  3. @Harald Ponce de Leon I currently using 2.3.4.1 and would like to migrate to 2.3.6 ( bootstrap version of osCommerce). Is there any indication of a release date? I noticed that other 'bootstrap-proof' versions are offered (see earlier posts), but would to stick to the 'official' release if possible, to avoid going through multiple upgrades/adaptations. Kind regards, Dennis
  4. dennish

    View Counter

    Hello Jack, Question #1: In the install file (instructions) I read: If your shop doesn't have the GeoIP.dat and geoip.inc files in admin/includes/, upload the ones in the Extra directory. On my website I already have those files in the directory admin/includes/GeoIP/. Where should I look for references to those files in the View Counter .php files (to subsequently adapt the links, reflecting my own file location)? Question #2: The suggested IP2Location™ DB24 Sample BIN database, expands to nearly 500MB when unzipped. Do you need all the detailed information involved or could I settle for a smaller DB? Which one would you suggest? Thanks in advance. Kind regards, Dennis
  5. dennish

    [CONTRIBUTION] PDF Customer Invoice

    Hello, I have implemented PDF Customer Invoice v1.2 (3/8/2008). My OsC version is 2.3.4 (and the server uses PHP 5.3.27). The hyperlink on account_history_info.php (to pdfinvoice.php in the main catalog/ folder) generates a PDF invoice as expected. No issues there. In addition, I want to sent a PDF invoice with the order confirmation email. To accomplish this, I've put a copy of the pdfinvoice.php file in the payment modules folder: catalog/includes/modules/payment/ (See below for a test version, with paths adjusted to reflect the new location), as described in the instructions by Chris23 (readme.txt in the _add ons and bufixes/pdf_invoice_email_attachment folder of the contribution package). All seems to work well, except for the extension of the FPDF class. Any call to a function defined in the PDF class (PDF extends FPDF) fails, which prevents a successful generation of the PDF file. If I exclude the functions depending the PDF class, the PDF gets generated (of course without the subparts relying on the PDF class). A simple example to explain: if I use $pdf=new PDF( PDF_INV_PORTRAIT_LANDSCAPE,'mm', 'A4' ); I get nothing. If instead I use the following $pdf = new FPDF('P', 'pt', array(500,233)); I get a (incomplete) PDF attachment with my confirmation mail. The full test version of pdfinvoice.php is <?php /* $Id: pdfinvoice.php FE invoice (customer) osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2014 osCommerce Released under the GNU General Public License */ // Contributions added: // - E.U. VAT Intracom Number (090218) // - Independent invoice number (071031) define('FPDF_FONTPATH', DIR_FS_CATALOG . 'fpdf/font/'); require(DIR_FS_CATALOG . 'fpdf/fpdf.php'); // Add PDF security require(DIR_FS_CATALOG . 'fpdf/fpdf_protection.php'); // prevents reinclusion if called from checkout_process.php // require('includes/application_top.php'); require_once(DIR_FS_CATALOG . 'includes/application_top.php'); require(DIR_FS_CATALOG . DIR_WS_LANGUAGES . $language . '/' . FILENAME_ORDERS_INVOICE ); require(DIR_FS_CATALOG . DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_HISTORY_INFO); // 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')); } */ $oID = tep_db_prepare_input($HTTP_GET_VARS['order_id']); $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'"); // prevents reinclusion if called from checkout_process.php // require(DIR_WS_CLASSES . 'order.php'); require_once(DIR_FS_CATALOG . DIR_WS_CLASSES . 'order.php'); // search order number $order = new order($oID); // Independent invoice number - Start $order->create_invoice((int)$oID); // Independent invoice number - End // 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); // PHP 5.3+ compliance - Start // $extension= split("\.", $filename); $extension= preg_split("[\.]", $filename); // PHP 5.3+ compliance - End $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); class PDF extends FPDF { // New code - Start function MultiCellLink($w,$h,$txt,$border=0,$align='J',$fill=0,$link='') // added #,$link=''# { //Output text with automatic or explicit line breaks $cw=&$this->CurrentFont['cw']; if($w==0) $w=$this->w-$this->rMargin-$this->x; $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; $s=str_replace("\r",'',$txt); $nb=strlen($s); if($nb>0 && $s[$nb-1]=="\n") $nb--; $b=0; if($border) { if($border==1) { $border='LTRB'; $b='LRT'; $b2='LR'; } else { $b2=''; if(strpos($border,'L')!==false) $b2.='L'; if(strpos($border,'R')!==false) $b2.='R'; $b=(strpos($border,'T')!==false) ? $b2.'T' : $b2; } } $sep=-1; $i=0; $j=0; $l=0; $ns=0; $nl=1; while($i<$nb) { //Get next character $c=$s{$i}; if($c=="\n") { //Explicit line break if($this->ws>0) { $this->ws=0; $this->_out('0 Tw'); } $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill,$link); // added #,$link# $i++; $sep=-1; $j=$i; $l=0; $ns=0; $nl++; if($border && $nl==2) $b=$b2; continue; } if($c==' ') { $sep=$i; $ls=$l; $ns++; } $l+=$cw[$c]; if($l>$wmax) { //Automatic line break if($sep==-1) { if($i==$j) $i++; if($this->ws>0) { $this->ws=0; $this->_out('0 Tw'); } $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill,$link); // added #,$link# } else { if($align=='J') { $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; $this->_out(sprintf('%.3f Tw',$this->ws*$this->k)); } $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill,$link); // added #,$link# $i=$sep+1; } $sep=-1; $j=$i; $l=0; $ns=0; $nl++; if($border && $nl==2) $b=$b2; } else $i++; } //Last chunk if($this->ws>0) { $this->ws=0; $this->_out('0 Tw'); } if($border && strpos($border,'B')!==false) $b.='B'; $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill,$link); // added #,$link# $this->x=$this->lMargin; } // New code - End // New code - Start var $B; var $I; var $U; var $HREF; function PDF($orientation='P',$unit='mm',$format='A4') { //Call parent constructor $this->FPDF($orientation,$unit,$format); //Initialization $this->B=0; $this->I=0; $this->U=0; $this->HREF=''; } function WriteHTML($html) { //HTML parser $html=str_replace("\n",' ',$html); $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE); foreach($a as $i=>$e) { if($i%2==0) { //Text if($this->HREF) $this->PutLink($this->HREF,$e); else $this->Write(5,$e); } else { //Tag if($e[0]=='/') $this->CloseTag(strtoupper(substr($e,1))); else { //Extract attributes $a2=explode(' ',$e); $tag=strtoupper(array_shift($a2)); $attr=array(); foreach($a2 as $v) { if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3)) $attr[strtoupper($a3[1])]=$a3[2]; } $this->OpenTag($tag,$attr); } } } } function OpenTag($tag,$attr) { //Opening tag if($tag=='B' || $tag=='I' || $tag=='U') $this->SetStyle($tag,true); if($tag=='A') $this->HREF=$attr['HREF']; if($tag=='BR') $this->Ln(5); } function CloseTag($tag) { //Closing tag if($tag=='B' || $tag=='I' || $tag=='U') $this->SetStyle($tag,false); if($tag=='A') $this->HREF=''; } function SetStyle($tag,$enable) { //Modify style and select corresponding font $this->$tag+=($enable ? 1 : -1); $style=''; foreach(array('B','I','U') as $s) { if($this->$s>0) $style.=$s; } $this->SetFont('',$style); } function PutLink($URL,$txt) { //Put a hyperlink $this->SetTextColor(0,0,255); $this->SetStyle('U',true); $this->Write(5,$txt,$URL); $this->SetStyle('U',false); $this->SetTextColor(0); } // New code - End // New code - Start function ImprovedTable($header,$data) { function is_odd($num) { if ($num % 2 == 0) { return false; } else { return true; } } //Column widths $w=array(33,33,33,33,33,33); //Header $this->Cell($w[0],7,$header[0],LTB,0,'L'); for($i=1;$i<count($header)-1;$i++){ if (is_odd($i)) { $this->Cell($w[$i],7,$header[$i],RTB,0,'L'); } else { $this->Cell($w[$i],7,$header[$i],TB,0,'L'); } } $this->Cell($w[count($header)-1],7,$header[count($header)-1],RTB,0,'L'); $this->Ln(); //Data foreach($data as $row) { $this->Cell($w[0],6,$row[0],'L'); $this->Cell($w[1],6,$row[1],'R'); $this->Cell($w[2],6,$row[2],'L',0,'L'); $this->Cell($w[3],6,$row[3],'R',0,'L'); $this->Cell($w[4],6,$row[4],'L',0,'L'); $this->Cell($w[5],6,$row[5],'R',0,'L'); $this->Ln(); } //Closure line $this->Cell(array_sum($w),0,'','T'); } // New code - End // New code - Start //Colored table function FancyTable($header2,$data2,$data3,$attribute_line,$data4) { // Column width $w=array(15,60,48,25,25,25); // Header // Colors, font and line width $this->SetFont( PDF_INV_TABLEHEADING_TEXT_FONT, PDF_INV_TABLEHEADING_TEXT_EFFECT, PDF_INV_TABLEHEADING_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_TABLEHEADING_TEXT_COLOR); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $cell_color=html2rgb(PDF_INV_TABLEHEADING_FILL_COLOR); $this->SetFillColor($cell_color[0], $cell_color[1], $cell_color[2]); $border_color=html2rgb(PDF_INV_TABLEHEADING_LINE_COLOR); $this->SetDrawColor($border_color[0], $border_color[1], $border_color[2]); $this->SetLineWidth(.3); // Header content $this->Cell($w[0],7,$header2[0],B,0,'C',true); $this->Cell($w[1],7,$header2[1],B,0,'L',true); $this->Cell($w[2],7,$header2[2],B,0,'L',true); $this->Cell($w[3],7,$header2[3],B,0,'C',true); $this->Cell($w[4],7,$header2[4],B,0,'C',true); $this->Cell($w[5],7,$header2[5],B,0,'C',true); $this->Ln(); // Data // Colors, font and line width $this->SetFont( PDF_INV_PRODUCTS_TEXT_FONT, PDF_INV_PRODUCTS_TEXT_EFFECT, PDF_INV_PRODUCTS_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_PRODUCTS_TEXT_COLOR ); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $cell_color=html2rgb(PDF_INV_PRODUCTS_FILL_COLOR ); $this->SetFillColor( $cell_color[0], $cell_color[1], $cell_color[2]); $border_color=html2rgb(PDF_INV_PRODUCTS_LINE_COLOR ); $this->SetDrawColor( $border_color[0], $border_color[1], $border_color[2]); // Data content $fill=false; ksort($data2); foreach($data2 as $key => $row) { $this->Cell($w[0],6,$row[0],'LR',0,'C',$fill); $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill); $this->Cell($w[2],6,$row[2],'LR',0,'L',$fill); $this->Cell($w[3],6,$row[3],'LR',0,'R',$fill); $this->Cell($w[4],6,$row[4],'LR',0,'R',$fill); $this->Cell($w[5],6,$row[5],'LR',0,'R',$fill); $this->Ln(); if (array_key_exists($key, $data3)) { $data3a = $data3[$key]; foreach($data3a as $row2) { $this->Cell($w[0],6,$row2[0],'LR',0,'C',$fill); $this->Cell($w[1],6,$row2[1],'LR',0,'L',$fill); $this->Cell($w[2],6,$row2[2],'LR',0,'L',$fill); $this->Cell($w[3],6,$row2[3],'LR',0,'C',$fill); $this->Cell($w[4],6,$row2[4],'LR',0,'C',$fill); $this->Cell($w[5],6,$row2[5],'LR',0,'C',$fill); $this->Ln(); } } $fill=!$fill; } // Closure line $this->Cell(array_sum($w),0,'','T'); // Totals // Colors, font and line width $this->SetFont( PDF_INV_ORDERTOTAL1_TEXT_FONT, PDF_INV_ORDERTOTAL1_TEXT_EFFECT, PDF_INV_ORDERTOTAL1_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_ORDERTOTAL1_TEXT_COLOR ); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $cell_color=html2rgb(PDF_INV_ORDERTOTAL1_FILL_COLOR ); $this->SetFillColor( $cell_color[0], $cell_color[1], $cell_color[2] ); $border_color=html2rgb(PDF_INV_ORDERTOTAL1_LINE_COLOR ); $this->SetDrawColor( $border_color[0], $border_color[1], $border_color[2] ); // Totals content ksort($data4); end($data4); $last = key($data4); $this->Ln(); foreach($data4 as $key => $row3) { if ($key === $last) { $this->SetFont( PDF_INV_ORDERTOTAL2_TEXT_FONT, PDF_INV_ORDERTOTAL2_TEXT_EFFECT, PDF_INV_ORDERTOTAL2_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_ORDERTOTAL2_TEXT_COLOR); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $cell_color=html2rgb(PDF_INV_ORDERTOTAL2_FILL_COLOR ); $this->SetFillColor($cell_color[0], $cell_color[1], $cell_color[2]); $border_color=html2rgb(PDF_INV_ORDERTOTAL2_LINE_COLOR ); $this->SetDrawColor($border_color[0], $border_color[1], $border_color[2]); $this->Cell($w[0],6,$row3[0],'' ,0,'C'); $this->Cell($w[1],6,$row3[1],'' ,0,'L'); $this->Cell($w[2],6,$row3[2],'' ,0,'L'); $this->Cell($w[3],6,$row3[3],'' ,0,'L'); $this->Cell($w[4],6,$row3[4],'',0,'R'); $this->Cell($w[5],6,$row3[5],LRTB,0,'R'); $this->Ln(); } else { $this->Cell($w[0],6,$row3[0],'' ,0,'C'); $this->Cell($w[1],6,$row3[1],'' ,0,'L'); $this->Cell($w[2],6,$row3[2],'' ,0,'L'); $this->Cell($w[3],6,$row3[3],'' ,0,'L'); $this->Cell($w[4],6,$row3[4],'',0,'R'); $this->Cell($w[5],6,$row3[5],LRTB,0,'R'); $this->Ln(); } } } // New code - End //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() { // FE - Start global $highlight_color, $image_function, $html; // FE - End $bg_color=html2rgb(PDF_INV_PAGE_FILL_COLOR ); $this->SetFillColor($bg_color[0], $bg_color[1], $bg_color[2]); $this->Rect($this->lMargin,0,$this->w-$this->rMargin,$this->h,'F'); //Logo if ( PDF_INV_SHOW_LOGO == 'true' ) { // $this->Image(DIR_FS_CATALOG . DIR_WS_IMAGES . STORE_LOGO , 10,10,30,10); $size =getimagesize(DIR_FS_CATALOG . DIR_WS_IMAGES . PDF_INVOICE_IMAGE); $this->$image_function(DIR_FS_CATALOG . DIR_WS_IMAGES . PDF_INVOICE_IMAGE,7,10,($size[0]*PDF_INV_IMG_CORRECTION),($size[1]*PDF_INV_IMG_CORRECTION),'', FILENAME_DEFAULT); } // Company name $this->SetX(0); $this->SetY(10); $this->SetFont( PDF_INV_HEADER_TEXT_FONT, PDF_INV_HEADER_TEXT_EFFECT, PDF_INV_HEADER_TEXT_HEIGHT); $this->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]); $cell_color=html2rgb(PDF_INV_HEADER_FILL_COLOR); $this->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); $border_color=html2rgb(PDF_INV_HEADER_LINE_COLOR); $this->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); $this->Ln(0); $this->Cell(30); $this->MultiCell(50, 3.5, tep_html_entity_decode(STORE_NAME),0,'L','1'); // Company Address $this->SetX(0); $this->SetY(13.5); $this->SetFont( PDF_INV_HEADER_TEXT_FONT, PDF_INV_HEADER_TEXT_EFFECT, PDF_INV_HEADER_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_HEADER_TEXT_COLOR); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $cell_color=html2rgb(PDF_INV_HEADER_FILL_COLOR); $this->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); $border_color=html2rgb(PDF_INV_HEADER_LINE_COLOR); $this->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); $this->Ln(0); $this->Cell(30); if ( PDF_INV_SHOW_ADRESSSHOP == 'true' ) { $this->MultiCell(50, 3.5, tep_html_entity_decode(STORE_NAME_ADDRESS),0,'L','1'); } // Telephone $this->SetX(0); $this->SetY(10); $this->SetFont( PDF_INV_HEADER_TEXT_FONT, PDF_INV_HEADER_TEXT_EFFECT, PDF_INV_HEADER_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_HEADER_TEXT_COLOR); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $cell_color=html2rgb(PDF_INV_HEADER_FILL_COLOR); $this->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); $border_color=html2rgb(PDF_INV_HEADER_LINE_COLOR); $this->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); $this->Ln(0); $this->Cell(90); $this->MultiCell(60, 3.5, tep_html_entity_decode(STORE_TELEPHONE),0,'L','1'); /* // Fax $this->SetX(0); $this->SetY(13.5); $this->SetFont( PDF_INV_HEADER_TEXT_FONT, PDF_INV_HEADER_TEXT_EFFECT, PDF_INV_HEADER_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_HEADER_TEXT_COLOR); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $cell_color=html2rgb(PDF_INV_HEADER_FILL_COLOR); $this->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); $border_color=html2rgb(PDF_INV_HEADER_LINE_COLOR); $this->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); $this->Ln(0); $this->Cell(90); $this->MultiCell(60, 3.5, tep_html_entity_decode(STORE_FAX),0,'L','1'); */ // Email $this->SetX(0); // $this->SetY(13.5); $this->SetY(17); $this->SetFont( PDF_INV_HEADER_TEXT_FONT, PDF_INV_HEADER_TEXT_EFFECT, PDF_INV_HEADER_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_HEADER_TEXT_COLOR ); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $cell_color=html2rgb(PDF_INV_HEADER_FILL_COLOR ); $this->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); $border_color=html2rgb(PDF_INV_HEADER_LINE_COLOR ); $this->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); $this->Ln(0); $this->Cell(90); if ( PDF_INV_SHOW_MAILWEB == 'true' ) { // $this->MultiCell(100, 6, tep_html_entity_decode(PDF_INV_EMAIL) . STORE_OWNER_EMAIL_ADDRESS,0,'R'); // $this->MultiCell(60, 3.5, STORE_OWNER_EMAIL_ADDRESS,0,'L','1'); // $html='<a href="mailto:' . STORE_OWNER_EMAIL_ADDRESS . '">' . STORE_OWNER_EMAIL_ADDRESS . '</a>'; // $link=$this->WriteHTML($html); // $this->MultiCell(60, 3.5, $link,0,'L','1'); $this->Cell(60, 3.5, STORE_OWNER_EMAIL_ADDRESS,0,1,'L','1','mailto:' . STORE_OWNER_EMAIL_ADDRESS); // $this->MultiCellLink(60, 3.5,STORE_OWNER_EMAIL_ADDRESS,0,'L','1','mailto:' . STORE_OWNER_EMAIL_ADDRESS); } //Website $this->SetX(0); // $this->SetY(17); $this->SetY(20.5); $this->SetFont( PDF_INV_HEADER_TEXT_FONT, PDF_INV_HEADER_TEXT_EFFECT, PDF_INV_HEADER_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_HEADER_TEXT_COLOR ); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $cell_color=html2rgb(PDF_INV_HEADER_FILL_COLOR ); $this->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); $border_color=html2rgb(PDF_INV_HEADER_LINE_COLOR ); $this->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); $this->Ln(0); $this->Cell(90); if ( PDF_INV_SHOW_MAILWEB == 'true' ) { // $this->MultiCell(100, 6, tep_html_entity_decode(PDF_INV_WEB) . HTTP_SERVER,0,'R'); // $this->MultiCell(60, 3.5, HTTP_SERVER,0,'L','1'); // $html='<a href="' . HTTP_SERVER . '">' . STORE_WEBSITE . '</a>'; // $link=$this->WriteHTML($html); // $this->MultiCell(60, 3.5, $link,0,'L','1'); $this->Cell(60, 3.5, STORE_WEBSITE,0,1,'L','1',HTTP_SERVER); // $this->MultiCellLink(60, 3.5, STORE_WEBSITE,0,'L','1',HTTP_SERVER); } //Draw the top line with invoice text $this->SetX(0); $this->SetY(10); $this->SetFont( PDF_INV_HEADINVOICE_TEXT_FONT, PDF_INV_HEADINVOICE_TEXT_EFFECT, PDF_INV_HEADINVOICE_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_HEADINVOICE_TEXT_COLOR ); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $cell_color=html2rgb(PDF_INV_HEADINVOICE_FILL_COLOR ); $this->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); $border_color=html2rgb(PDF_INV_HEADINVOICE_LINE_COLOR ); $this->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); $this->Ln(0); $this->Cell(150); $this->MultiCell(48, 16, PRINT_INVOICE,1,'C','0'); } // 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); $wwm=($this->GetStringWidth(tep_html_entity_decode(PRINT_INV_WATERMARK_TEXT))*$cos); // $this->RotatedText(($this->w-$wwm)/2,$this->w,PDF_INV_WATERMARK_TEXT,$ang); $this->RotatedText(($this->w-$wwm)/2,$this->w,PRINT_INV_WATERMARK_TEXT,$ang); } function Footer() { global $highlight_color, $invoice_line; // General terms (if enabled) if (DISPLAY_PDF_TERMS == 'true'){ $this->SetY(-27); $this->SetX(0); $this->SetFont( PDF_INV_FOOTER_TEXT_FONT, PDF_INV_FOOTER_TEXT_EFFECT, PDF_INV_FOOTER_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_FOOTER_TEXT_COLOR ); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $this->Ln(0); // New code - Start $this->MultiCell(0, 6, PRINT_TERMS,0,'C','0'); // New code - End } // insert horiz line $this->SetY(-21); $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(-19); // VAT / Tax number (if enabled) if (DISPLAY_PDF_TAX_NUMBER == 'true'){ $this->SetX(0); $this->SetFont( PDF_INV_FOOTER_TEXT_FONT, PDF_INV_FOOTER_TEXT_EFFECT, PDF_INV_FOOTER_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_FOOTER_TEXT_COLOR ); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $this->Ln(0); // BOF for VAT INTRACOM_v3.3 $this->MultiCell(0, 6, tep_html_entity_decode(ENTRY_TVA_INTRACOM) . " " . TVA_SHOP_INTRACOM,0,'C','0'); // EOF for TVA_INTRACOM_v3.3 } // Chambre of Commerce number (if enabled) if (DISPLAY_PDF_COC_NUMBER == 'true'){ $this->SetX(0); $this->SetFont( PDF_INV_FOOTER_TEXT_FONT, PDF_INV_FOOTER_TEXT_EFFECT, PDF_INV_FOOTER_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_FOOTER_TEXT_COLOR ); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $this->Ln(0); // New code - Start $this->MultiCell(0, 6, tep_html_entity_decode(ENTRY_STORE_COC) . " " . STORE_COC,0,'C','0'); // New code - End } // Bank details (if enabled) if (DISPLAY_PDF_BANK_NUMBER == 'true'){ $this->SetX(0); $this->SetFont( PDF_INV_FOOTER_TEXT_FONT, PDF_INV_FOOTER_TEXT_EFFECT, PDF_INV_FOOTER_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_FOOTER_TEXT_COLOR ); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $this->Ln(0); // New code - Start $this->MultiCell(0, 6, STORE_BANK_ACCOUNT . ', ' . STORE_BANK_IBAN . ' ' . STORE_BANK_BIC,0,'C','0'); // New code - End } $this->SetFont( PDF_INV_FOOTER_TEXT_FONT, PDF_INV_FOOTER_TEXT_EFFECT, PDF_INV_FOOTER_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_FOOTER_TEXT_COLOR ); $this->SetTextColor($text_color[0], $text_color[1], $text_color[2]); //$cell_color=html2rgb(PDF_INV_FOOTER_FILL_COLOR ); //$this->SetFillColor( $cell_color[0], $cell_color[1], $cell_color[2] ); } } /*************************** * 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; } } /* // Add PDF security $pdf=new FPDF_Protection(); $pdf->SetProtection(array('copy', 'print', 'annot-forms')); */ // 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( PDF_INV_PORTRAIT_LANDSCAPE,'mm',array(PDF_INV_PAPER_WIDTH, PDF_INV_PAPER_HEIGHT ) ) ; $pdf=new PDF( PDF_INV_PORTRAIT_LANDSCAPE,'mm', 'A4' ); $image_function = "Image"; } $pdf = new FPDF('P', 'pt', array(500,233)); // $pdf=new PDF( PDF_INV_PORTRAIT_LANDSCAPE,'mm', 'A4' ); // Define an alias for the total number of pages. It will be substituted as the document is closed. $pdf->AliasNbPages(); // Set the Page Margins $pdf->SetMargins(6,2,6); // Add the first page $pdf->AddPage(); // Check if customer resides in store home country (also a EU member!) or another EU country (relevant for VAT) $home_country_query_raw = "SELECT c.countries_id FROM " . TABLE_COUNTRIES . " c WHERE c.countries_name = '" . htmlspecialchars_decode($order->billing['country']['title']) . "' AND countries_id = '" . STORE_COUNTRY . "'"; $home_country_query = tep_db_query($home_country_query_raw); $eu_country_query_raw = "SELECT c.countries_id FROM " . TABLE_COUNTRIES . " c RIGHT JOIN " . TABLE_ZONES_TO_GEO_ZONES . " a ON c.countries_id = a.zone_country_id WHERE c.countries_name = '" . htmlspecialchars_decode($order->billing['country']['title']) . "' AND a.geo_zone_id = '2'"; $eu_country_query = tep_db_query($eu_country_query_raw); if (tep_db_num_rows($home_country_query) < 1 && tep_db_num_rows($eu_country_query) < 1) { $customer_country = 'non eu country'; // $pdf->Cell(50,10, 'buiten EU', 0,0,'L'); } elseif (tep_db_num_rows($home_country_query) < 1 && tep_db_num_rows($eu_country_query) >= 1) { $customer_country = 'eu country'; // $pdf->Cell(50,10, 'in EU', 0,0,'L'); } else { $customer_country = 'home country'; // $pdf->Cell(50,10, 'in NL', 0,0,'L'); } /* // Add watermark if required if(PDF_SHOW_WATERMARK_FE == 'true'){ $pdf->Watermark(); } */ // Set standard font $pdf->SetFont( PDF_INV_CORE_FONT, '', 10); //Draw Box for Invoice Address if ( PDF_INV_SHOW_SOLDTO == 'true' ) { // $text_color=html2rgb(PDF_INV_SOLDTO_LINE_COLOR ); // $pdf->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); // $pdf->SetLineWidth(0.2); // $cell_color=html2rgb(PDF_INV_SOLDTO_FILL_COLOR ); // $pdf->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); // $pdf->RoundedRect(6, 67, 90, 35, 2, 'DF'); // Draw the invoice address text $text_color=html2rgb(PDF_INV_SOLDTO_TEXT_COLOR ); $pdf->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $pdf->Text(7,40, tep_html_entity_decode(ENTRY_SOLD_TO)); $pdf->SetX(0); $pdf->SetY(45); // Inspringen // $pdf->Cell(10); $pdf->SetFont( PDF_INV_SOLDTO_TEXT_FONT, PDF_INV_SOLDTO_TEXT_EFFECT, PDF_INV_SOLDTO_TEXT_HEIGHT ); // Ancien code pour TVA_INTRACOM_v3.0 // $pdf->MultiCell(70, 3.3, tep_html_entity_decode(tep_address_format($order->customer['format_id'], $order->customer, '', '', "\n")),0,'L'); // Fin ancien code pour TVA_INTRACOM_v3.0 // BOF for VAT INTRACOM_v3.3 $pdf->MultiCell(70, 3.3, tep_html_entity_decode(tep_address_format($order->billing['format_id'], $order->billing, '', '', "\n")),0,'L'); // EOF for TVA_INTRACOM_v3.3 } // Return to standard font $pdf->SetFont( PDF_INV_CORE_FONT, '', 10); // Draw Box for Delivery Address // Geen afleveradres bij download if (($order_type_check == 'physical or mixed')) { if ( PDF_INV_SHOW_SENDTO == 'true' ) { // $text_color=html2rgb(PDF_INV_SENDTO_LINE_COLOR ); // $pdf->SetDrawColor($border_color[0],$border_color[1],$border_color[2]); // $pdf->SetLineWidth(0.2); // $cell_color=html2rgb(PDF_INV_SENDTO_FILL_COLOR ); // $pdf->SetFillColor($cell_color[0],$cell_color[1],$cell_color[2]); // $pdf->RoundedRect(108, 67, 90, 35, 2, 'DF'); //Draw the invoice delivery address text $text_color=html2rgb(PDF_INV_SENDTO_TEXT_COLOR ); $pdf->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $pdf->Text(100,40,tep_html_entity_decode(ENTRY_SHIP_TO)); $pdf->SetX(100); $pdf->SetY(45); // Inspringen // $pdf->Cell(111); $pdf->SetFont( PDF_INV_SENDTO_TEXT_FONT, PDF_INV_SENDTO_TEXT_EFFECT, PDF_INV_SENDTO_TEXT_HEIGHT ); $pdf->MultiCell(70, 3.3, tep_html_entity_decode(tep_address_format($order->delivery['format_id'], $order->delivery, '', '', "\n")),0,'L'); } } // Return to standard font $pdf->SetFont( PDF_INV_CORE_FONT, '', 9); // Thank you message to the customer $pdf->SetX(0); $pdf->SetY(80); $pdf->Cell(100,10, tep_html_entity_decode(PRINT_INVOICE_TEXT), 0,0,'L'); // In case of more than one page: pagenumber if ($pdf->PageNo() > 1) { // $pdf->Cell(100); //Page number $pdf->Cell(100,10,PRINT_INVOICE_PAGE_NUMBER . ' ' . $this->PageNo().' / {nb}',0,0,'R' ); } // Table containing invoice number, date and customer reference $pdf->SetX(0); $pdf->SetY(90); //Draw Payment Method Text $temp = substr ($order->info['payment_method'] , 0, 23); // Independent invoice number - Start // $header=array(PRINT_INVOICE_TITLE,(int)$HTTP_GET_VARS['order_id'],PRINT_ORDER_NUMBER,(int)$HTTP_GET_VARS['order_id'],'Betaling:',STORE_PAY_WITHIN); $header=array(PRINT_INVOICE_TITLE,$order->billing['invoice_serial'].$order->billing['invoice_number'],PRINT_ORDER_NUMBER, (int)$oID ,ENTRY_PAYMENT_METHOD, tep_html_entity_decode($temp)); $invoice_date_query = tep_db_query("select invoice_date as invoice_date from " . TABLE_ORDERS . " where orders_id = '" . (int)$HTTP_GET_VARS['order_id'] . "'"); $invoice_date = tep_db_fetch_array($invoice_date_query); // Independent invoice number - End function tep_unix_date($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false; $year = substr($raw_date, 0, 4); $month = (int)substr($raw_date, 5, 2); $day = (int)substr($raw_date, 8, 2); $hour = (int)substr($raw_date, 11, 2); $minute = (int)substr($raw_date, 14, 2); $second = (int)substr($raw_date, 17, 2); if (@[member=date]('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) { return mktime($hour, $minute, $second, $month, $day, $year); } else { return ereg_replace('2037' . '$', $year, mktime($hour, $minute, $second, $month, $day, 2037)); } } $interval = '+' . STORE_PAY_WITHIN . ' days'; $d = tep_unix_date($invoice_date['invoice_date']); $end_date = date(DATE_FORMAT,strtotime($interval,$d)); $data=array(); $data[0][0] = PRINT_INVOICE_DATE ; $data[0][1] = tep_date_short($invoice_date['invoice_date']); $data[0][2] = PRINT_ORDER_DATE ; $data[0][3] = tep_date_short($order->info['date_purchased']); $data[0][4] = PRINT_STATUS_PAYMENT ; if ($order->info['orders_status_id'] >= VAT_REPORT_ORDER_STATUS_PAYMENT) { $data[0][5] = PRINT_STATUS_ORDER_PAID ; } else { $data[0][5] = PRINT_STATUS_ORDER_UNPAID ; } $data[1][0] = PRINT_PAY_WITHIN_DATE ; $data[1][1] = $end_date; $data[1][2] = PRINT_CUSTOMER_NUMBER ; $data[1][3] = $order->customer['id']; $data[1][4] = PRINT_PAY_WITHIN ; if ($order->info['orders_status_id'] >= VAT_REPORT_ORDER_STATUS_PAYMENT) { $data[1][5] = PRINT_PAY_WITHIN_NA ; } else { $data[1][5] = STORE_PAY_WITHIN . PRINT_PAY_WITHIN_DAYS ; } /* $pdf->ImprovedTable($header,$data); */ // Table containing order details $pdf->SetFont( PDF_INV_ORDERDETAILS_TEXT_FONT, PDF_INV_ORDERDETAILS_TEXT_EFFECT, PDF_INV_ORDERDETAILS_TEXT_HEIGHT); $text_color=html2rgb(PDF_INV_ORDERDETAILS_TEXT_COLOR ); $pdf->SetTextColor($text_color[0], $text_color[1], $text_color[2]); // Draw Order Number Text // $pdf->Text(10,113, tep_html_entity_decode(PRINT_INVOICE_ORDER) . (int)$HTTP_GET_VARS['order_id']); // $pdf->Cell(15,6,TABLE_HEADING_TAX,1,0,'C',1); // $pdf->Cell(20,6,tep_html_entity_decode(TABLE_HEADING_PRICE_INCLUDING_TAX),1,0,'C',1); // $pdf->Cell(20,6,tep_html_entity_decode(TABLE_HEADING_TOTAL_INCLUDING_TAX),1,0,'C',1); $header2=array(TABLE_HEADING_QUANTITY, TABLE_HEADING_PRODUCTS, TABLE_HEADING_PRODUCTS_MODEL, TABLE_HEADING_PRICE_EXCLUDING_TAX, TABLE_HEADING_TAX, TABLE_HEADING_TOTAL_EXCLUDING_TAX); // Add to $header2 if needed: // TABLE_HEADING_TAX // TABLE_HEADING_PRICE_INCLUDING_TAX // TABLE_HEADING_TOTAL_INCLUDING_TAX $data2=array(); //Show the products information line by line $item_count = 0 ; for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) { $data2[$i][0] = $order->products[$i]['qty'] ; // New code - Start if (strlen($order->products[$i]['name']) > 40 && strlen($order->products[$i]['name']) < 50){ $data2[$i][1] = $order->products[$i]['name']; } else if (strlen($order->products[$i]['name']) > 50){ $data2[$i][1] = substr($order->products[$i]['name'],0,50); } else{ $data2[$i][1] = $order->products[$i]['name']; } $data2[$i][2] = $order->products[$i]['model']; $data2[$i][3] = str_replace(' ', ' ',$currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value'])); // Add to $data2 if needed (adjust/renumber subsequent array keys!): // For VAT purposes: // Check if product is an 'electronic service'. If so, determine the customer's country. if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) { for ($j = 0; $j < $k; $j++) { $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $order->products[$i]['id'] . "' and pov.products_options_values_name = '" . $order->products[$i]['attributes'][$j]['value'] . "' and pa.products_attributes_id = pad.products_attributes_id"); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['total'] > 0) { $product_type_check = 'virtual'; $order_type_check = 'virtual or mixed'; break; } } } if ($product_type_check == 'virtual') { if ($customer_country == 'home country') { $data2[$i][4] = str_replace(' ', ' ',tep_display_tax_value($order->products[$i]['tax']) . '%'); } elseif ($customer_country == 'eu country') { $data2[$i][4] = '***'; } else { $data2[$i][4] = str_replace(' ', ' ',tep_display_tax_value($order->products[$i]['tax']) . '%'); } } else { $data2[$i][4] = str_replace(' ', ' ',tep_display_tax_value($order->products[$i]['tax']) . '%'); } unset($product_type_check); // New code - End // $data2[$i][3] = str_replace(' ', ' ',$currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value'])); // Add to $data2 if needed (adjust/renumber subsequent array keys!): // $data2[$i][5] = str_replace(' ', ' ',$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value'])); $data2[$i][5] = str_replace(' ', ' ',$currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value'])) ; // Add to $data2 if needed (adjust/renumber subsequent array keys!): // $data2[$i][5] = str_replace(' ', ' ',$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'])); // Show the products attributes $data3 = array(); //get attribs if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) { $attribute_line = 'true'; for ($j = 0; $j < $k; $j++) { // New code - Start // Display product option only if option is not part of excluded list $dps = explode(',' , DISPLAY_PRODUCT_OPTIONS); if (!in_array($order->products[$i]['attributes'][$j]['option'], $dps)) { // New code - End if ($order->products[$i]['attributes'][$j]['price'] != '0') { $data3[$i][$j][1] = '- ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')' ; } else { $data3[$i][$j][1] = '- ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value']; } // New code - Start } // New code - End } //Check for product line overflow $item_count++; if ( $item_count > 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); $item_count = 1; } } // New code - End //Check for product line overflow $item_count++; // if ((is_long($item_count / 32) && $i >= 20) || ($i == 20)){ if ( $item_count > 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; } } // Add totals to product table $data4=array(); $data4[0][4] = ENTRY_SUB_TOTAL; // $data4[1][4] = ENTRY_TAX; $data4[2][4] = ENTRY_TOTAL; for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) { $temp = substr ($order->totals[$i]['text'],0 ,3); if ($temp == '<b>') { $temp2 = substr($order->totals[$i]['text'], 3); $order->totals[$i]['text'] = substr($temp2, 0, strlen($temp2)-4); } $data4[$i][0] = ''; $data4[$i][1] = ''; $data4[$i][2] = ''; $data4[$i][3] = ''; $data4[$i][4] = str_replace(' ', ' ',$order->totals[$i]['title']); $data4[$i][5] = str_replace(' ', ' ',$order->totals[$i]['text']); //Check for product line overflow $item_count++; if ( $item_count > 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); $item_count = 1; } } $pdf->Ln(); $pdf->SetY(120); /* $pdf->FancyTable($header2,$data2,$data3,$attribute_line,$data4); */ // For VAT purposes: // Check if one of the products is an 'electronic service'. If so, determine the customer's country. // $pdf->Cell(50,10, '* ' . $order->billing['country'], 0,0,'L'); // $pdf->Cell(50,10, '* ' . $order->delivery['country'], 0,0,'L'); if (($order_type_check == 'virtual or mixed') and ($order->billing['company'] != '' && $order->billing['tva_intracom'] != '' && $customer_country == 'eu country')) { $pdf->SetFont( PDF_INV_CORE_FONT, '', 10); // $highlight_color = html2rgb(PDF_INV_HIGHLIGHT_COLOR); $pdf->SetTextColor($highlight_color[0],$highlight_color[1],$highlight_color[2]); // $text_color=html2rgb(PDF_INV_HEADER_TEXT_COLOR ); // $pdf->SetTextColor($text_color[0], $text_color[1], $text_color[2]); $pdf->SetX(0); $pdf->SetY(180); $pdf->Cell(100,10, '*** ' . tep_html_entity_decode(VAT_SHIFTED_TEXT), 0,0,'L'); } // Set PDF metadata // Independent invoice number - Start // $pdf->SetTitle(PDF_META_TITLE); $pdf->SetTitle(TEXT_INVOICE.' '.$order->billing['invoice_serial'].$order->billing['invoice_number']); // $pdf->SetSubject(PDF_META_SUBJECT . $HTTP_GET_VARS['order_id']); $pdf->SetSubject(TEXT_INVOICE . ' ' . $order->billing['invoice_serial'] . $order->billing['invoice_number']); // Independent invoice number - End $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); // Independent invoice number - Start // $file_name .= "_invoice_" . $HTTP_GET_VARS['order_id'] . ".pdf"; // $file_name .= "_" . TEXT_INVOICE . "_" . $order->billing['invoice_serial'].$order->billing['invoice_number']; $file_name = $order->billing['invoice_serial'].$order->billing['invoice_number']; // Independent invoice number - End // Save the pdf to a folder with setting `F` // $pdf->Output(DIR_FS_CATALOG . 'invoices/' . $file_name . '.pdf', 'F'); // PDF is created, now output the file // are we streaming for email attachment or outputting to browser? if($stream){ // return $pdf->Output( "", "S" ); $pdf_data = $pdf->Output('' , 'S'); } else { $mode = (FORCE_PDF_INVOICE_DOWNLOAD == 'true') ? 'D' : 'I'; // what do we do? display inline or force download $pdf->Output($file_name , $mode); } ?> Can anyone explain to me why the extended class PDF fails in my payment folder, but works perfectly in the setting of the main catalog/ folder (and how to fix it)? Kind regards, Dennis
  6. dennish

    Enforce Dropdown Selection

    @@burt I've made a copy of the tep_draw_pull_down_menu function and renamed it tep_draw_pull_down_menu_required (with the changes described in post #1), so you can pick the appropriate function for your specific needs. The test I did on Firefox worked perfect as far as validation was concerned. Seems like a very simple solution to an otherwise more complex issue. One question remains: I have a multilanguage website. The error message that is displayed when you hover the drop down list after submitting the form (with no changes made yet) is in the same language (in my case Dutch) regardless of the language I switch to on the website. Any thoughts if that can be changed (or is this linked to the browser settings)? Kind regards, Dennis
  7. dennish

    [contribution] Super Download Store

    Hello, I found a pretty straightforward solution to the "blank page" issue (the question related to updating the remaining number of allowed downloads after each download click is still open: any suggestions to solve this are very much appreciated!). My solution involves the following changes: 1. In catalog/checkout_succes.php: After require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_SUCCESS); Insert // New code - Start $navigation->set_snapshot(); // New code - End 2. In catalog/account_history_info.php: After if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } Insert // New code - Start $navigation->set_snapshot(); // New code - End 3. In calatog/download.php: Replace if ($downloads['download_count'] <= 0) die; By // if ($downloads['download_count'] <= 0) die; // New code - Start if ($downloads['download_count'] <= 0) { // Return to the last page visited if (sizeof($navigation->snapshot) > 0) { $origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']); $navigation->clear_snapshot(); } else { $origin_href = tep_href_link(FILENAME_DEFAULT); } tep_redirect($origin_href); } // New code - End Done! Another thing I came accross is the message displayed at catalog/checkout_succes.php refering the customer to the catalog/account.php page (in case he/she wishes to download at a later moment). This message is shown even if there are no downloads left. In this case I would rather leave that message out. In catalog/includes/modules/downloads.php: Replace <?php if (!strstr($PHP_SELF, FILENAME_ACCOUNT_HISTORY_INFO)) { ?> <p><?php printf(FOOTER_DOWNLOAD, '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . HEADER_TITLE_MY_ACCOUNT . '</a>'); ?></p> <?php } ?> By <?php if (!strstr($PHP_SELF, FILENAME_ACCOUNT_HISTORY_INFO)) { // New code - Start // Don't refer customer to My account for downloads if no remaining downloads are left $downloads_query = tep_db_query("select o.orders_status, date_format(o.last_modified, '%Y-%m-%d') as date_purchased_day, opd.download_maxdays, op.products_name, opd.orders_products_download_id, opd.orders_products_filename, opd.download_count, opd.download_maxdays from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd where o.customers_id = '" . (int)$customer_id . "' and o.orders_status >= " . DOWNLOADS_CONTROLLER_ORDERS_STATUS . " and o.orders_id = '" . (int)$last_order . "' and o.orders_id = op.orders_id and op.orders_products_id = opd.orders_products_id and opd.orders_products_filename != ''"); $downloads = tep_db_fetch_array($downloads_query); if ( ($downloads['download_count'] > 0) && ( ($downloads['download_maxdays'] == 0) || ($download_timestamp > time())) ) { // New code - End ?> <p><?php printf(FOOTER_DOWNLOAD, '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . HEADER_TITLE_MY_ACCOUNT . '</a>'); ?></p> <?php // New code - Start } // New code - End } ?> Kind regards. Dennis
  8. dennish

    Official PayPal IPN Support Thread

    Hello, In the standard setup PayPal IPN deletes the (so-called temporary) order (and thereby also the order-ID) when a customer decides to interrupt (and thereby effectively cancel) his payment at the Paypal website. Obviously this approach saves space in the database (by clearing uncompleted orders), but also has an important drawback from an accounting/control viewpoint: it creates gaps in the subsequent numbering of orders. An solution would be to change the code in includes/functions/general.php: // START DELETE TEMP PAYPAL IPN ORDER // This is used in shopping_cart.php when a temporary order needs to be deleted // after it was cancelled by customer on paypal site. function tep_remove_order($order_id, $restock = false) { if ($restock == 'on') { $order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'"); while ($order = tep_db_fetch_array($order_query)) { tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity + " . $order['products_quantity'] . ", products_ordered = products_ordered - " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id'] . "'"); } } tep_db_query("delete from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"); tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'"); tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "'"); tep_db_query("delete from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . (int)$order_id . "'"); tep_db_query("delete from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "'"); } // END DELETE TEMP PAYPAL IPN ORDER Instead of deleting the order in the orders table, the order could be emptied (meaning all entries other than the order_id) and the orders_status set to a new status, reflecting that payment of the order was cancelled during the Paypal process. Can anyone point out possible problems with this approach (other than additional database size)? Kind regards, Dennis
  9. dennish

    [contribution] Super Download Store

    Hello, I am struggling with an issue already raised some time ago (See post #569 and the provided answer post#570): how to get the pages displaying the remaining downloads (checkout_success.php and account_history_info.php) to refresh and show the actual number of downloads still allowed after clicking the download button. (Hopefully this should also take care of the blank page emerging after the customer has exceeded the maximum number of downloads). As suggested in post #570, the pages should be reloaded (from the server) when the download button is clicked to acheive the desired result. I found some suggestions on how to accomplish this with javascript here: http://www.mediacollege.com/internet/javascript/page/reload.html http://stackoverflow.com/questions/5404839/how-can-i-refresh-a-page-with-jquery?rq=1 I added the following code to the download button links in catalog/includes/modules/downloads.php: onClick="window.location.reload(true);" The full code for the link now looks like this: echo ' <td class="main" align="left" width="70%"><div><a href="' . tep_href_link(FILENAME_DOWNLOAD, 'order=' . $last_order . '&id=' . $downloads['orders_products_download_id']) . '" onClick="window.location.reload(true);">' . tep_image_button('button_download.gif', 'Download', 'style="vertical-align:middle;padding-top:5px;padding-bottom:5px;"') . '</a><span style=""> ' . $downloads['products_name'] . ' - '. $file_array['download_group_file_description'] . '</span></div></td>' . "\n"; The resulting output is: <td class="main" align="left" width="25%"><a href="http://www.mydomain.com/catalog/download.php?order=67&id=72" onClick="window.location.reload(true);"><img src="includes/languages/english/images/buttons/button_download.gif" alt="Download" title="Download" width="120" height="20" style="vertical-align:middle;padding-top:5px;padding-bottom:5px;" /></a></td> However, the page is still not updated after the download button is clicked. If I refresh the page manually using the browser (in my case Firefox), the remaining number of downloads is set to 0 (as would be expected when the allowed 2 downloads in my case are fully used). Can anyone offer an explantion (and possibly a solution) for this issue? Thanks in advance. Kind regards, Dennis
  10. dennish

    osCommerce Online Merchant v2.3.4

    I found the answer to my question (post #46) in the Release notes to OsC 2.3.4: http://library.oscommerce.com/Online&en&oscom_2_3&release_notes&v2_3_4 The contents of account.php can be adjusted in includes/modules/pages/tp_account.php.
  11. dennish

    osCommerce Online Merchant v2.3.4

    Hello, I am finishing my upgrade to osC 2.3.4. On the account.php page I would like to change the layout for the section headers and the individual link items (e.g. remove the icon preceding an item). The directory includes/modules/content/account is the only one missing a templates directory. Where can I make these changes? Kind regards, Dennis
  12. dennish

    Display error message on checkout_payment

    @@Bob I found a solution here: http://coredogs.com/lesson/form-and-php-validation-one-page (with a full explanation of the method used). My code for checkout_payment.php now looks like this: <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2010 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); // if the customer is not logged on, redirect them to the login page if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } // if there is nothing in the customers cart, redirect them to the shopping cart page if ($cart->count_contents() < 1) { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART)); } // if no shipping method has been selected, redirect the customer to the shipping method selection page if (!tep_session_is_registered('shipping')) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } // avoid hack attempts during the checkout procedure by checking the internal cartID if (isset($cart->cartID) && tep_session_is_registered('cartID')) { if ($cart->cartID != $cartID) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } } // Stock Check if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) { $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { if (tep_check_stock($products[$i]['id'], $products[$i]['quantity'])) { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART)); break; } } } // if no billing destination address was selected, use the customers own address as default if (!tep_session_is_registered('billto')) { tep_session_register('billto'); $billto = $customer_default_address_id; } else { // verify the selected billing address if ( (is_array($billto) && empty($billto)) || is_numeric($billto) ) { $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$billto . "'"); $check_address = tep_db_fetch_array($check_address_query); if ($check_address['total'] != '1') { $billto = $customer_default_address_id; if (tep_session_is_registered('payment')) tep_session_unregister('payment'); } } } // New code - Start $process = false; if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) { $process = true; $payment = tep_db_prepare_input($HTTP_POST_VARS['payment']); $sisow_bank = tep_db_prepare_input($HTTP_POST_VARS['sisow_bank']); $agree = tep_db_prepare_input($HTTP_POST_VARS['agree']); $error = false; if ($HTTP_POST_VARS['sisow_bank'] == '') { $error = true; $messageStack->add('checkout_payment', ENTRY_SISOWIDEAL_ERROR); } // New code - End require(DIR_WS_CLASSES . 'order.php'); $order = new order; if (!tep_session_is_registered('comments')) tep_session_register('comments'); if (isset($HTTP_POST_VARS['comments']) && tep_not_null($HTTP_POST_VARS['comments'])) { $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']); } $total_weight = $cart->show_weight(); $total_count = $cart->count_contents(); // load all enabled payment modules require(DIR_WS_CLASSES . 'payment.php'); $payment_modules = new payment; require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PAYMENT); // New code - Start if ($error == false) { if ($HTTP_POST_VARS['sisow_bank'] != '') { tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, 'sisow_bank=' . $sisow_bank . '&agree=' . $agree, 'SSL')); } else { tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, 'agree=' . $agree, 'SSL')); } } } // New code - End $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); require(DIR_WS_INCLUDES . 'template_top.php'); ?> <script type="text/javascript"><!-- var selected; function selectRowEffect(object, buttonselect) { if (!selected) { if (document.getElementById) { selected = document.getElementById('defaultSelected'); } else { selected = document.all['defaultSelected']; } } if (selected) selected.className = 'moduleRow'; object.className = 'moduleRowSelected'; selected = object; // one button is not an array if (document.checkout_payment.payment[0]) { document.checkout_payment.payment[buttonselect].checked=true; } else { document.checkout_payment.payment.checked=true; } } function rowOverEffect(object) { if (object.className == 'moduleRow') object.className = 'moduleRowOver'; } function rowOutEffect(object) { if (object.className == 'moduleRowOver') object.className = 'moduleRow'; } //--></script> <?php // echo $payment_modules->javascript_validation(); ?> <h1><?php echo HEADING_TITLE; ?></h1> <!-- New code - Start //--> <?php // echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'), 'post', 'onsubmit="return check_form();"', true); ?> <?php echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'), 'post', 'onsubmit="return check_form();"', true) . tep_draw_hidden_field('action', 'process'); ?> <!-- New code - End //--> <div class="contentContainer"> <?php if (isset($HTTP_GET_VARS['payment_error']) && is_object(${$HTTP_GET_VARS['payment_error']}) && ($error = ${$HTTP_GET_VARS['payment_error']}->get_error())) { ?> <div class="contentText"> <?php echo '<strong>' . tep_output_string_protected($error['title']) . '</strong>'; ?> <p class="messageStackError"><?php echo tep_output_string_protected($error['error']); ?></p> </div> <?php } ?> <!-- New code - Start //--> <?php if ($messageStack->size('checkout_payment') > 0) { echo $messageStack->output('checkout_payment'); } ?> <!-- New code - End //--> <!-- New code - Start //--> <!-- Only for testing purposes! Outputs $HTTP_POST_VARS / $_POST //--> <?php foreach ($_POST as $key => $value) { echo $key ." => ". $value . '<br>'; } ?> <!-- New code - End //--> <h2><?php echo TABLE_HEADING_BILLING_ADDRESS; ?></h2> <div class="contentText"> <div class="ui-widget infoBoxContainer" style="float: right;"> <div class="ui-widget-header infoBoxHeading"><?php echo TITLE_BILLING_ADDRESS; ?></div> <div class="ui-widget-content infoBoxContents"> <?php echo tep_address_label($customer_id, $billto, true, ' ', '<br />'); ?> </div> </div> <?php echo TEXT_SELECTED_BILLING_DESTINATION; ?><br /><br /><?php echo tep_draw_button(IMAGE_BUTTON_CHANGE_ADDRESS, 'home', tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL')); ?> </div> <div style="clear: both;"></div> <h2><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></h2> <?php $selection = $payment_modules->selection(); if (sizeof($selection) > 1) { ?> <div class="contentText"> <div style="float: right;"> <?php echo '<strong>' . TITLE_PLEASE_SELECT . '</strong>'; ?> </div> <?php echo TEXT_SELECT_PAYMENT_METHOD; ?> </div> <?php } elseif ($free_shipping == false) { ?> <div class="contentText"> <?php echo TEXT_ENTER_PAYMENT_INFORMATION; ?> </div> <?php } ?> <div class="contentText"> <?php $radio_buttons = 0; for ($i=0, $n=sizeof($selection); $i<$n; $i++) { ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <?php if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) { echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n"; } else { echo ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n"; } ?> <td><strong><?php echo $selection[$i]['module']; ?></strong></td> <td align="right"> <?php if (sizeof($selection) > 1) { echo tep_draw_radio_field('payment', $selection[$i]['id'], ($selection[$i]['id'] == $payment)); } else { echo tep_draw_hidden_field('payment', $selection[$i]['id']); } ?> </td> </tr> <?php if (isset($selection[$i]['error'])) { ?> <tr> <td colspan="2"><?php echo $selection[$i]['error']; ?></td> </tr> <?php } elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) { ?> <tr> <td colspan="2"><table border="0" cellspacing="0" cellpadding="2"> <?php for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) { ?> <tr> <td><?php echo $selection[$i]['fields'][$j]['title']; ?></td> <td><?php echo $selection[$i]['fields'][$j]['field']; ?></td> </tr> <?php } ?> </table></td> </tr> <?php } ?> </table> <?php $radio_buttons++; } ?> </div> <h2><?php echo TABLE_HEADING_COMMENTS; ?></h2> <div class="contentText"> <?php echo tep_draw_textarea_field('comments', 'soft', '60', '5', $comments); ?> </div> <!-- Must agree to terms - Start //--> <div class="subHeader"> <h2><?php echo TITLE_CONDITION_AGREEMENT; ?></h2> </div> <?php if ($order->content_type == 'virtual' or $order->content_type == 'mixed') { ?> <?php echo TEXT_LICENSE_AGREEMENT; ?> <?php } else { ?> <?php echo TEXT_CONDITION_AGREEMENT; ?> <?php } ?> <?php echo tep_draw_checkbox_field('agree','true'); ?> <!-- Must agree to terms - End //--> <div class="contentText"> <div style="float: left; width: 60%; padding-top: 5px; padding-left: 15%;"> <div id="coProgressBar" style="height: 5px;"></div> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td align="center" width="33%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_DELIVERY . '</a>'; ?></td> <td align="center" width="33%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_PAYMENT; ?></td> <td align="center" width="33%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td> </tr> </table> </div> <div style="float: right;"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', null, 'primary'); ?></div> </div> </div> <script type="text/javascript"> $('#coProgressBar').progressbar({ value: 66 }); </script> </form> <?php require(DIR_WS_INCLUDES . 'template_bottom.php'); require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Notice the adapted redirect with parameters (line 101): // New code - Start if ($error == false) { if ($HTTP_POST_VARS['sisow_bank'] != '') { tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, 'sisow_bank=' . $sisow_bank . '&agree=' . $agree, 'SSL')); } else { tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, 'agree=' . $agree, 'SSL')); } } } // New code - End The variables used are defined as (line 71): $payment = tep_db_prepare_input($HTTP_POST_VARS['payment']); $sisow_bank = tep_db_prepare_input($HTTP_POST_VARS['sisow_bank']); $agree = tep_db_prepare_input($HTTP_POST_VARS['agree']); I omitted the first variable $payment in my previous code (see post #3), but this needs to be included for the script to function correctly. Finally, I changed the code for checkout_confirmation.php to: // Must agree to terms - Start // if ($HTTP_POST_VARS['agree'] != 'true') { if ($_GET['agree'] != 'true') { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_redirect(tep_href_link(FILENAME_CHECKOUT_FAIL)), 'SSL')); } // Must agree to terms - End Thanks for putting me on the right track. Kind regards, Dennis
  13. dennish

    Display error message on checkout_payment

    @@Bob Thanks for your suggestion. I decided to continue on the "create_account" path and came up with the following code (Look for New code markers. Original checkout_payment.php file was taken from the osC 2.3.3.4 package): <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2010 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); // if the customer is not logged on, redirect them to the login page if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } // if there is nothing in the customers cart, redirect them to the shopping cart page if ($cart->count_contents() < 1) { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART)); } // if no shipping method has been selected, redirect the customer to the shipping method selection page if (!tep_session_is_registered('shipping')) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } // avoid hack attempts during the checkout procedure by checking the internal cartID if (isset($cart->cartID) && tep_session_is_registered('cartID')) { if ($cart->cartID != $cartID) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } } // Stock Check if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) { $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { if (tep_check_stock($products[$i]['id'], $products[$i]['quantity'])) { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART)); break; } } } // if no billing destination address was selected, use the customers own address as default if (!tep_session_is_registered('billto')) { tep_session_register('billto'); $billto = $customer_default_address_id; } else { // verify the selected billing address if ( (is_array($billto) && empty($billto)) || is_numeric($billto) ) { $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$billto . "'"); $check_address = tep_db_fetch_array($check_address_query); if ($check_address['total'] != '1') { $billto = $customer_default_address_id; if (tep_session_is_registered('payment')) tep_session_unregister('payment'); } } } // New code - Start $process = false; if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) { $process = true; $error = false; if ($HTTP_POST_VARS['sisow_bank'] == '') { $error = true; $messageStack->add('checkout_payment', ENTRY_SISOWIDEAL_ERROR); } // New code - End require(DIR_WS_CLASSES . 'order.php'); $order = new order; if (!tep_session_is_registered('comments')) tep_session_register('comments'); if (isset($HTTP_POST_VARS['comments']) && tep_not_null($HTTP_POST_VARS['comments'])) { $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']); } $total_weight = $cart->show_weight(); $total_count = $cart->count_contents(); // load all enabled payment modules require(DIR_WS_CLASSES . 'payment.php'); $payment_modules = new payment; require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PAYMENT); // New code - Start if ($error == false) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL')); } } // New code - End $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); require(DIR_WS_INCLUDES . 'template_top.php'); ?> <script type="text/javascript"><!-- var selected; function selectRowEffect(object, buttonselect) { if (!selected) { if (document.getElementById) { selected = document.getElementById('defaultSelected'); } else { selected = document.all['defaultSelected']; } } if (selected) selected.className = 'moduleRow'; object.className = 'moduleRowSelected'; selected = object; // one button is not an array if (document.checkout_payment.payment[0]) { document.checkout_payment.payment[buttonselect].checked=true; } else { document.checkout_payment.payment.checked=true; } } function rowOverEffect(object) { if (object.className == 'moduleRow') object.className = 'moduleRowOver'; } function rowOutEffect(object) { if (object.className == 'moduleRowOver') object.className = 'moduleRow'; } //--></script> <?php echo $payment_modules->javascript_validation(); ?> <h1><?php echo HEADING_TITLE; ?></h1> <!-- New code - Start //--> <?php // echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'), 'post', 'onsubmit="return check_form();"', true); ?> <?php echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'), 'post', 'onsubmit="return check_form();"', true) . tep_draw_hidden_field('action', 'process'); ?> <!-- New code - End //--> <div class="contentContainer"> <?php if (isset($HTTP_GET_VARS['payment_error']) && is_object(${$HTTP_GET_VARS['payment_error']}) && ($error = ${$HTTP_GET_VARS['payment_error']}->get_error())) { ?> <div class="contentText"> <?php echo '<strong>' . tep_output_string_protected($error['title']) . '</strong>'; ?> <p class="messageStackError"><?php echo tep_output_string_protected($error['error']); ?></p> </div> <?php } ?> <!-- New code - Start //--> <?php if ($messageStack->size('checkout_payment') > 0) { echo $messageStack->output('checkout_payment'); } ?> <!-- New code - End //--> <!-- New code - Start //--> <!-- Only for testing purposes! Outputs $HTTP_POST_VARS / $_POST //--> <?php foreach ($_POST as $key => $value) { echo $key ." => ". $value . '<br>'; } ?> <!-- New code - End //--> <h2><?php echo TABLE_HEADING_BILLING_ADDRESS; ?></h2> <div class="contentText"> <div class="ui-widget infoBoxContainer" style="float: right;"> <div class="ui-widget-header infoBoxHeading"><?php echo TITLE_BILLING_ADDRESS; ?></div> <div class="ui-widget-content infoBoxContents"> <?php echo tep_address_label($customer_id, $billto, true, ' ', '<br />'); ?> </div> </div> <?php echo TEXT_SELECTED_BILLING_DESTINATION; ?><br /><br /><?php echo tep_draw_button(IMAGE_BUTTON_CHANGE_ADDRESS, 'home', tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL')); ?> </div> <div style="clear: both;"></div> <h2><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></h2> <?php $selection = $payment_modules->selection(); if (sizeof($selection) > 1) { ?> <div class="contentText"> <div style="float: right;"> <?php echo '<strong>' . TITLE_PLEASE_SELECT . '</strong>'; ?> </div> <?php echo TEXT_SELECT_PAYMENT_METHOD; ?> </div> <?php } elseif ($free_shipping == false) { ?> <div class="contentText"> <?php echo TEXT_ENTER_PAYMENT_INFORMATION; ?> </div> <?php } ?> <div class="contentText"> <?php $radio_buttons = 0; for ($i=0, $n=sizeof($selection); $i<$n; $i++) { ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <?php if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) { echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n"; } else { echo ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n"; } ?> <td><strong><?php echo $selection[$i]['module']; ?></strong></td> <td align="right"> <?php if (sizeof($selection) > 1) { echo tep_draw_radio_field('payment', $selection[$i]['id'], ($selection[$i]['id'] == $payment)); } else { echo tep_draw_hidden_field('payment', $selection[$i]['id']); } ?> </td> </tr> <?php if (isset($selection[$i]['error'])) { ?> <tr> <td colspan="2"><?php echo $selection[$i]['error']; ?></td> </tr> <?php } elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) { ?> <tr> <td colspan="2"><table border="0" cellspacing="0" cellpadding="2"> <?php for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) { ?> <tr> <td><?php echo $selection[$i]['fields'][$j]['title']; ?></td> <td><?php echo $selection[$i]['fields'][$j]['field']; ?></td> </tr> <?php } ?> </table></td> </tr> <?php } ?> </table> <?php $radio_buttons++; } ?> </div> <h2><?php echo TABLE_HEADING_COMMENTS; ?></h2> <div class="contentText"> <?php echo tep_draw_textarea_field('comments', 'soft', '60', '5', $comments); ?> </div> <!-- Must agree to terms - Start //--> <div class="subHeader"> <h2><?php echo TITLE_CONDITION_AGREEMENT; ?></h2> </div> <?php if ($order->content_type == 'virtual' or $order->content_type == 'mixed') { ?> <?php echo TEXT_LICENSE_AGREEMENT; ?> <?php } else { ?> <?php echo TEXT_CONDITION_AGREEMENT; ?> <?php } ?> <?php echo tep_draw_checkbox_field('agree','true'); ?> <!-- Must agree to terms - End //--> <div class="contentText"> <div style="float: left; width: 60%; padding-top: 5px; padding-left: 15%;"> <div id="coProgressBar" style="height: 5px;"></div> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td align="center" width="33%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_DELIVERY . '</a>'; ?></td> <td align="center" width="33%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_PAYMENT; ?></td> <td align="center" width="33%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td> </tr> </table> </div> <div style="float: right;"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', null, 'primary'); ?></div> </div> </div> <script type="text/javascript"> $('#coProgressBar').progressbar({ value: 66 }); </script> </form> <?php require(DIR_WS_INCLUDES . 'template_bottom.php'); require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> This works fine, in line with my requirements (see post #1). However, a new issue emerged related to some (not all) $HTTP_POST_VARS (or $_POST) data. For the Must agree to terms contribution (http://addons.oscommerce.com/info/574) I use in my shop, the customer is required to fill in: <?php echo tep_draw_checkbox_field('agree','true'); ?> At the start of checkout_confirmation.php the value of the field agree (true/false) is needed to perform a check to (dis)allow the customer to continue: // Must agree to terms - Start if ($HTTP_POST_VARS['agree'] != 'true') { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_redirect(tep_href_link(FILENAME_CHECKOUT_FAIL)), 'SSL')); } // Must agree to terms - End However, in checkout_confirmation.php $HTTP_POST_VARS['agree'] (or $_POST['agree']) turns up empty! On the contrary, in checkout_payment.php $HTTP_POST_VARS['agree'] renders true, as expected (see my testing code). The same goes for the new drop down menu rendered by my payment module (field sisow_bank). Any ideas why these (new) fields drop their values when I go from checkout_payment.php to checkout_confirmation.php? Kind regards, Dennis
  14. Hello, I've installed a payment module, which displays a drop down menu (on checkout_payment.php), from which the customer should select the name of his/her bank. The HTML code: <td><select name="sisow_bank" enabled>\n<option value="">Select your bank</option>\n<option value="99">Sisow Bank (Test)</option>\n</select></td> The module (1) uses javascript validation, and (2) allows the customer to proceed to checkout_conformation.php despite the fact no bank was selected (after which the customer is redirected again to checkout_payment.php, where an error is displayed). Instead, I would like to (1) use the regular messageStack for error messages, and (2) let the customer stay on checkout_payment.php, until a bank is selected as required. To accomplish this, I've added two pieces of code to checkout_payment.php: 1. First, to produce an error when the customer fails to select a bank, I inserted: if ($payment == 'sisowideal') { if ($sisow_bank == '') { $error = true; $messageStack->add('checkout_payment', ENTRY_SISOWIDEAL_ERROR); } } before: require(DIR_WS_INCLUDES . 'template_top.php'); ?> 2. Secondly, to display the error message I added: <?php if ($messageStack->size('checkout_payment') > 0) { echo $messageStack->output('checkout_payment'); } ?> after: <?php if (isset($HTTP_GET_VARS['payment_error']) && is_object(${$HTTP_GET_VARS['payment_error']}) && ($error = ${$HTTP_GET_VARS['payment_error']}->get_error())) { ?> <div class="contentText"> <?php echo '<strong>' . tep_output_string_protected($error['title']) . '</strong>'; ?> <p class="messageStackError"><?php echo tep_output_string_protected($error['error']); ?></p> </div> <?php } ?> What do I need to change in addition, to: let the customer stay on checkout_pament.php as long as errors remain (no selection made in drop down menu) let the customer move on to chechout_confirmation.php as soon as errors have cleared (bank was selected) I took a look at both: <?php echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'), 'post', 'onsubmit="return check_form();"', true); ?> and create_account.php (similar approach) but couldn't figure out how to get it right. Any help is much appreciated. Kind regards, Dennis
  15. dennish

    Contribution Tracker

    To comply with osC 2.3.3.2 and higher in catalog/contrib_tracker.php (around line 209) replace: if (mysql_affected_rows()) { By: if (mysqli_affected_rows(tep_db_connect())) {
×