Antoniocrevi Posted May 3, 2018 Share Posted May 3, 2018 Hola, necesito ayuda con un modulo Tengo un módulo "CartoPDF", y me hace la suma con el envío, me gustaria quitar ese envio de la suma. Lo que hace el modulo es lo que tengo en el carrito me lo pasa a PDF, y me suma el envio. Adjunto los dos archivos importantes, si me pudieran ayudar muchas gracias. {if $doc} <TABLE width="100%"> {else} <TABLE width="100%"> {/if} <TR> <TD> <TABLE width="100%;float:right" border="0"> <TR> <TD scope="col"><IMG align="left" src="{$logoImagen}" /></TD> <TD> <TABLE> <TR> <TD scope="col" style="font-size:20pt;"><DIV align="right"><B>{Configuration::get('CtoPDF_titulo')}</B></DIV></TD> </TR> <TR> <TD scope="col"><DIV align="right">{l s='Fecha' mod='cartopdf'}: {$cart->date_add|date_format:"%d/%m/%Y"}</DIV></TD> </TR> <TR> <TD scope="col"><DIV align="right">{l s='Referencia pedido' mod='cartopdf'}: <B>{$refPedido}</B></DIV></TD> </TR> {if $numeracion} <TR> <TD scope="col"><DIV align="right">{l s='Numeración' mod='cartopdf'}: <B>{$numeracion}</B></DIV></TD> </TR> {/if} </TABLE> </TD> </TR> </TABLE> <DIV style="line-height: 1px"> </DIV> {if $order} <!-- ADDRESSES --> <TABLE style="width: 100%"> <TR> <TD style="width:100%"> {if !empty($delivery_address)} <TABLE style="width: 100%;"> <TR> <TD style="width: 46%"> <TABLE style="width: 100%"> <TR style="background-color:#999999;color:#ffffff;font-size:16pt;padding:5"> <TD style="padding-top: 7pt; padding-bottom: 7pt; padding-left: 5pt">{l s='Dirección de envío' mod='cartopdf'}</TD> </TR> <TR style="width: 50%; background-color: #F2F2F2;"> <TD style="padding-top: 10pt; padding-bottom: 10pt; padding-left: 5pt; font-size: 10pt;"> {if !doc} <DIV style="line-height: 0.1pt"> </DIV> {/if} {$delivery_address}<BR/> </TD> </TR> </TABLE> </TD> <TD style="width: 8%"></TD> <TD style="width: 46%"> <TABLE style="width: 100%"> <TR style="background-color:#999999;color:#ffffff;font-size:16pt;padding:5"> <TD style="padding-top: 7pt; padding-bottom: 7pt; padding-left: 5pt">{l s='Dirección de facturación' mod='cartopdf'}</TD> </TR> <TR style="width: 50%; background-color: #F2F2F2;"> <TD style="padding-top: 10pt; padding-bottom: 10pt; padding-left: 5pt; font-size: 10pt;"> {if !doc} <DIV style="line-height: 0.1pt"> </DIV> {/if} {$invoice_address}<BR /> </TD> </TR> </TABLE> </TD> </TR> </TABLE> {else} <TABLE style="width: 100%"> <TR> <TD style="width: 46%"> <TABLE style="width: 100%"> <TR style="background-color:#999999;color:#ffffff;font-size:16pt;padding:5"> <TD style="padding-top: 7pt; padding-bottom: 7pt; padding-left: 5pt">{l s='Dirección de envío' mod='cartopdf'}</TD> </TR> <TR style="width: 50%; background-color: #F2F2F2;"> <TD style="padding-top: 10pt; padding-bottom: 10pt; padding-left: 5pt; font-size: 10pt; color:#404040"> {if !doc} <DIV style="line-height: 0.1pt"> </DIV> {/if} {$invoice_address}<BR /> </TD> </TR> </TABLE> </TD> <TD style="width: 8%"></TD> <TD style="width: 46%"> <TABLE style="width: 100%"> <TR style="background-color:#999999;color:#ffffff;font-size:16pt;padding:5"> <TD style="padding-top: 7pt; padding-bottom: 7pt; padding-left: 5pt">{l s='Dirección de facturación' mod='cartopdf'}</TD> </TR> <TR style="width: 50%; background-color: #F2F2F2;"> <TD style="padding-top: 10pt; padding-bottom: 10pt; padding-left: 5pt; font-size: 10pt; color:#404040"> {if !doc} <DIV style="line-height: 0.1pt"> </DIV> {/if} {$invoice_address}<BR/> </TD> </TR> </TABLE> </TD> </TR> </TABLE> {/if} </TD> </TR> </TABLE> {/if} <DIV><HR /></DIV> <TABLE width="100%" border="1"> <TR> <TH colspan="5" scope="col" style="background-color:#999999;color:#ffffff;font-size:16pt;padding:5"><DIV align="center">Productos</DIV></TH> </TR> <TR> <TD width="10%" style="background-color:#999999;color:#ffffff;font-size:10pt;line-height:1.5pt"><B> {l s='Ref.' mod='cartopdf'}</B></TD> <TD width="50%" style="background-color:#999999;color:#ffffff;font-size:10pt;line-height:1.5pt"><B> {l s='Nombre' mod='cartopdf'}</B></TD> <TD width="15%" style="background-color:#999999;color:#ffffff;font-size:10pt;line-height:1.5pt"><B> {l s='Precio' mod='cartopdf'}</B></TD> <TD width="10%" style="background-color:#999999;color:#ffffff;font-size:10pt;line-height:1.5pt"><B> {l s='unidades' mod='cartopdf'}</B></TD> <TD width="15%" style="background-color:#999999;color:#ffffff;font-size:10pt;line-height:1.5pt"><B> {l s='Total' mod='cartopdf'}</B></TD> </TR> {if $order} {foreach from=$order->getProductsDetail() item=producto} {cycle values='#FFF,#d7d9d7' assign=bgcolor} <TR style="background-color:{$bgcolor}"> <TD style="font-size:7pt;line-height:2pt;text-align: center"> {$producto.reference}</TD> <TD style="font-size:9pt;line-height:2pt"> {$producto.product_name}</TD> <TD style="font-size:9pt;line-height:2pt;text-align: center"> {displayPrice currency=$order->id_currency price=$producto.unit_price_tax_incl}</TD> <TD style="font-size:9pt;line-height:2pt;text-align: center"> {$producto.product_quantity}</TD> <TD style="font-size:9pt;line-height:2pt;text-align: center"> {displayPrice currency=$order->id_currency price=$producto.total_price_tax_incl}</TD> </TR> {/foreach} {else} {foreach from=$cart->getProducts() item=producto} {cycle values='#FFF,#d7d9d7' assign=bgcolor} <TR style="background-color:{$bgcolor}"> <TD style="font-size:7pt;line-height:2pt;text-align: center"> {$producto.reference}</TD> <TD style="font-size:9pt;line-height:2pt"> {$producto.name} {if $producto.attributes != ''} -{$producto.attributes}{/if}</TD> <TD style="font-size:9pt;line-height:2pt;text-align: center"> {displayPrice currency=$cart->id_currency price=$producto.price_wt}</TD> <TD style="font-size:9pt;line-height:2pt;text-align: center"> {$producto.cart_quantity}</TD> <TD style="font-size:9pt;line-height:2pt;text-align: center"> {displayPrice currency=$cart->id_currency price=$producto.total_wt}</TD> </TR> {/foreach} {/if} </TABLE> <DIV style="line-height: 1px"> </DIV> {if $total_dto > 0 } <DIV style="width:100%:float:right"> <TABLE style="width:100%"> <TR> <TD width="50%"> </TD> <TD> <TABLE border="1" style="width:100%" > <TR> <TD colspan="2" style="background-color:#999999;color:#ffffff;font-size:12pt;padding:5;text-align:center"><B>{l s='Descuentos' mod='cartopdf'}</B></TD> </TR> {foreach from=$dtos item=d} <TR> <TD width="70%" style="font-size:9pt;line-height:2pt"> {$d.name}</TD> <TD width="30%" style="font-size:9pt;line-height:2pt"> {round($d.value,2)} {$sign}</TD> </TR> {/foreach} </TABLE> </TD> </TR> </TABLE> </DIV> {/if} <DIV> <TABLE style="width:100%"> <TR> <TD width="40%"> </TD> <TD width="60%"> <TABLE width="100%" border="1"> <TR> <TD colspan="2" style="background-color:#999999;color:#ffffff;font-size:12pt;padding:5;text-align:center"><B>{l s='Totales' mod='cartopdf'}</B></TD> </TR> <TR> <TD width="70%" style="font-size:9pt;line-height:2pt"> {l s='Total Productos sin I.V.A' mod='cartopdf'}</TD> {if $order} <TD width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$order->id_currency price=$order->total_products}</TD> {else} <TD width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$cart->id_currency price=$cart->getOrderTotal(false,Cart::ONLY_PRODUCTS)}</TD> {/if} </TR> <TR> <TD width="70%" style="font-size:9pt;line-height:2pt"> {l s='Total Productos con I.V.A' mod='cartopdf'}</TD> {if $order} <TD width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$order->id_currency price=$order->total_products_wt}</TD> {else} <TD width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$cart->id_currency price=$cart->getOrderTotal(true,Cart::ONLY_PRODUCTS)}</TD> {/if} </TR> <!-- <tr> <td width="70%" style="font-size:9pt;line-height:2pt"> {l s='Gastos de envío sin I.V.A' mod='cartopdf'}</td> {if $order} <td width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$order->id_currency price=$order->total_shipping_tax_excl}</td> {else} <td width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$cart->id_currency price=$cart->getOrderTotal(false,Cart::ONLY_SHIPPING)}</td> {/if} </tr> <tr> <td width="70%" style="font-size:9pt;line-height:2pt"> {l s='Gastos de envío con I.V.A' mod='cartopdf'}</td> {if $order} <td width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$order->id_currency price=$order->total_shipping_tax_incl}</td> {else} <td width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$cart->id_currency price=$cart->getOrderTotal(true,Cart::ONLY_SHIPPING)}</td> {/if} </tr> !--> <TR> <TD width="70%" style="font-size:9pt;line-height:2pt"> {l s='Total descuentos' mod='cartopdf'}</TD> {if $order} <TD width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$order->id_currency price=$order->total_discounts}</TD> {else} <TD width="30%" style="font-size:9pt;line-height:2pt"> {$total_dto} {$sign}</TD> {/if} </TR> <TR> <TD width="70%" style="font-size:9pt;line-height:2pt"> {l s='Base Imponible' mod='cartopdf'}</TD> {if $order} <TD width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$order->id_currency price=$order->total_products + $order->total_shipping_tax_excl}</TD> {else} <TD width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$cart->id_currency price=$cart->getOrderTotal(false,Cart::ONLY_PRODUCTS) + $cart->getOrderTotal(false,Cart::ONLY_SHIPPING) - $total_dto}</TD> {/if} </TR> <TR> <TD width="70%" style="font-size:9pt;line-height:2pt"> {l s='Impuestos' mod='cartopdf'}</TD> {if $order} <TD width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$order->id_currency price=$order->total_paid - ($order->total_products + $order->total_shipping_tax_excl) }</TD> {else} <TD width="30%" style="font-size:9pt;line-height:2pt"> {displayPrice currency=$cart->id_currency price=($cart->getOrderTotal(true,Cart::ONLY_PRODUCTS) - $cart->getOrderTotal(false,Cart::ONLY_PRODUCTS))+($cart->getOrderTotal(true,Cart::ONLY_SHIPPING) - $cart->getOrderTotal(false,Cart::ONLY_SHIPPING)) }</TD> {/if} </TR> <TR> <TD width="70%" style="background-color:#999999;color:#ffffff;font-size:14pt;padding:7"> <B>{l s='Total' mod='cartopdf'}</B></TD> {if $order} <TD width="30%" style="background-color:#999999;color:#ffffff;font-size:14pt;padding:7"> <B>{displayPrice currency=$order->id_currency price=$order->total_paid }</B></TD> {else} <TD width="30%" style="background-color:#999999;color:#ffffff;font-size:14pt;padding:7"> <B>{displayPrice currency=$cart->id_currency price=$cart->getOrderTotal() - $total_dto + $cart->getOrderTotal(true,Cart::ONLY_DISCOUNTS) }</B></TD> {/if} </TR> </TABLE> </TD> </TR> </TABLE> </DIV> <H1 align="left"> </H1> <P align="center">{Configuration::get('CtoPDF_pie')}</P> </TD> </TR> </TABLE> <?php include(dirname(__FILE__).'/../../config/config.inc.php'); $refPedido = ''; $order = null; $numeracion = null; if (isset($_POST['id_order'])) { //Llega desde el BO $sql = sprintf("SELECT numeracion FROM %scartopdf WHERE id_order = %d",_DB_PREFIX_,(int)$_POST['id_order']); $r = Db::getInstance()->executeS($sql); if (count($r) > 0) $numeracion = $r[0]['numeracion']; $order = new Order($_POST['id_order']); $refPedido = $order->reference; $cart = new Cart($order->id_cart); $country = new Country((int)$order->id_address_invoice); $invoice_address = new Address((int)$order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($order->id_address_delivery != $order->id_address_invoice) { $delivery_address = new Address((int)$order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } } else { //Desde el Front if (isset($cookie->id_cart)) $cart = new Cart($cookie->id_cart); } $productos = @$cart->getProducts(); $descuentos = @$cart->getCartRules(); $total_dto = 0; $dtos = array(); $inc_transportes = false; foreach ($descuentos as $key => $value) { $dto = 0; if ($value['reduction_amount'] > 0) { //Cupón con descuento en el precio $dto = $value['reduction_amount']; if ($value['reduction_tax'] == 0) { $cart_amount_ti = $cart->getOrderTotal(true, Cart::ONLY_PRODUCTS).'<br>'; $cart_amount_te = $cart->getOrderTotal(false, Cart::ONLY_PRODUCTS).'<br>'; $cart_vat_amount = $cart_amount_ti - $cart_amount_te; $rate = Tools::ps_round($cart_vat_amount / $cart_amount_te, 3); $dto = $dto * (1 + $rate); } if ($value['free_shipping'] == 1 && !$inc_transportes) { $dto += $value['value_real']; $inc_transportes = true; } if ($dto > $cart->getOrderTotal(true, Cart::BOTH) ) $dto = $cart->getOrderTotal(true, Cart::BOTH) + $cart->getOrderTotal(true, Cart::ONLY_SHIPPING); } elseif ($value['reduction_percent'] != 0) { $dto += $value['value_real']; } else { $dto += $value['value_real']; } $d = array( 'name' => $value['description'], 'value' => $dto, ); $dtos[] = $d; $total_dto += $dto; } require_once(_PS_TOOL_DIR_.'tcpdf/tcpdf.php'); class MYPDF extends TCPDF { //Page header public function Header() { // Logo $image_file = _PS_IMG_DIR_.'logo.jpg'; $this->SetFont('helvetica', 'B', 20); } // Page footer public function Footer() { // Position at 15 mm from bottom $this->SetY(-15); // Set font $this->SetFont('helvetica', 'I', 8); // Page number $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); } } // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('PrestaMarketing.com'); $pdf->SetTitle('Hoja de Pedido'); $pdf->SetSubject('Hoja de pedido'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { require_once(dirname(__FILE__).'/lang/eng.php'); $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set font //$pdf->SetFont('times', 'BI', 12); // add a page $pdf->AddPage(); //$string = $context->smarty->fetch(dirname(__FILE__).'/../../modules/cartopdf/pdf/invoice.tpl'); $logo = ''; $context = Context::getContext(); $physical_uri = 'http://'.$_SERVER['SERVER_NAME'].Context::getContext()->shop->physical_uri.'img/'; //$physical_uri = Context::getContext()->shop->physical_uri.'img/'; if (Configuration::get('PS_LOGO_INVOICE', null, null, (int)$context->shop->id) != false && file_exists(_PS_IMG_DIR_.Configuration::get('PS_LOGO_INVOICE', null, null, (int)$context->shop->id))) $logo = _PS_IMG_DIR_.Configuration::get('PS_LOGO_INVOICE', null, null, (int)$context->shop->id); elseif (Configuration::get('PS_LOGO', null, null, (int)$context->shop->id) != false && file_exists(_PS_IMG_DIR_.Configuration::get('PS_LOGO', null, null, (int)$context->shop->id))) $logo = _PS_IMG_DIR_.Configuration::get('PS_LOGO', null, null, (int)$context->shop->id); if (Configuration::get('CtoPDF_doc') == 0) $doc = false; else $doc = true; global $smarty; $smarty->assign(array( 'order' => $order, 'product_title' => urlencode(@$product_infos->name), 'cart' => $cart, 'refPedido' => $refPedido, 'logoImagen' => $logo, 'dtos' => $dtos, 'total_dto' => $total_dto, 'doc' => $doc, 'sign' => '€', 'delivery_address' => @$formatted_delivery_address, 'invoice_address' => @$formatted_invoice_address, 'numeracion' => $numeracion, )); // print a block of text using Write() //$pdf->Write(0, $context->smarty->fetch(dirname(__FILE__).'/../../modules/cartopdf/pdf/invoice.tpl'), '', 0, 'C', true, 0, false, false, 0); $content = $context->smarty->fetch(dirname(__FILE__).'/../../modules/cartopdf/pdf/hoja.tpl'); header("Content-type: application/vnd.ms-word"); header("Content-Disposition: attachment;Filename=document_name.doc"); if($doc) { echo "<html>"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"; echo "<body>"; echo '<div style="background:#000000">'; echo $content; echo '</div>'; echo "</body>"; echo "</html>"; } else { $pdf->writeHTML($content); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('hoja_pedido.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+ } ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now