facture avec les informations légales en France dans PDF Invoice plugin

  • Posts: 44
  • Thank you received: 11
  • Hikashop Business
3 months 1 week ago #361984

-- url of the page with the problem -- : complicitesminerales.com
-- HikaShop version -- : 5.0.2
-- Joomla version -- : 4.4.6
-- PHP version -- : 8.2.20
-- Browser(s) name and version -- : firefox

Bonjour,
j'avais fais des modifications sur HikaShop qui était bonne mais le rendu imprimé ne plaisait pas la la cliente.
du coup, la cliente à acheté "PDF Invoice plugin"
alors tout est à refaire :-(
www.hikashop.com/forum/5-support-en-fran...gales-en-france.html

ou dois-je faire les changements dans PDF Invoice plugin? merci

Note personnelle "hors sujet", mais qui peut avoir un intérêt.
Sur des CRM tel que dollibar il existe des modèles de facture avec les variables de l'on personnalise depuis un format .odt qui est converti en PDF. le fonctionnement est simple pour l'utilisateur, mais je ne connait pas de solution e-commerce intègrent ce système dommage.
Au cas ou ça intéresse :
wiki.dolibarr.org/index.php/Cr%C3%A9er_u...A8le_de_document_ODT

Last edit: 3 months 6 days ago by Complicités Minérales. Reason: [Résolu]

Please Log in or Create an account to join the conversation.

  • Posts: 82653
  • Thank you received: 13318
  • MODERATOR
3 months 1 week ago #361988

Bonjour,

1. Dans les options du plugin invoice PDF, vous avez une option pour choisir le layout à utiliser. Donc déjà, il y a plusieurs layouts de disponible par défaut. Et vous pouvez aussi choisir les couleurs utilisées pour la plupart.
Dans le dossier plugins/hikashop/attachinvoice/attachinvoice.php, vous allez trouver un fichier par layout.
Si vous voulez personnaliser le layout sélectionner dans les options du plugin, vous voulez copier le fichier correspondant de ce dossier dans le dossier media/com_hikashop/plugins/ via FTP. Ensuite, vous pouvez modifier la copie. Ainsi, lors des mises à jour du plugin, vous ne perdrez pas vos modifications.

2. L'utilisation de variables est en effet intéressante. Nous utilisons déjà cela pour les emails si vous les personnalisez dans le menu Système>Emails.

The following user(s) said Thank You: Complicités Minérales

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 11
  • Hikashop Business
3 months 6 days ago #362013

Merci pour toutes les infos
voici le code de mon fichier "invoice.php" et le résultat plus bas.

Version 2 du 12/07/2024

<?php
/**
 * @package	PDF invoice plugin for HikaShop
 * @version	2.0.4
 * @author	Adrien Baborier, Hikari Software
 * @copyright	(C) 2010-2023 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><style type="text/css">
<!--
.invoicetitle{ font-family:arial;text-align:left;font-size:12px; padding-top:5px;padding-bottom:5px}
legend { font-family:arial;padding:5px 10px; background-color:#5471B5;color:white;font-weight:bold;border-color:#ccc}
fieldset { font-family:arial;padding:10px; border-color:#ccc;}

div.date{font-family:arial;font-size:12px;text-align:left;color:#333;}

.storeaddress{
	color:#333;
font-family:arial;
}
.addresses{font-family:arial;padding-top:10px;width:320px;}
.addresses td{padding-left:20px;}
.addresses fieldset {float:left;}

table.products{font-family:arial;margin:auto;margin-top:20px;width:580px;border-collapse:collapse}
.price{text-align:center;}

.products td, .products th{border:1px solid #ccc;padding:7px 4px;}
.products th{background-color:#5471B5;color:white;}
td.newarea{text-align:right;padding-right:20px;}
tr.total{font-weight:bold;}

.products tr.limitation td{background-color:#ccc;padding:1px 0px;}

.hikashop_order_custom_fields_fieldset{margin-top : 20px;}

.footer{font-size:10px;color:#aaa;text-align:center;}
-->
</style>
<page style="font-size: 12px" backtop="14mm" backbottom="14mm" backleft="10mm" backright="10mm">
	<page_footer>
	<div class="footer">
		<?php
		$name = $this->params->get('footer');
		$trans = hikashop_translate($name);
		echo str_replace(array("\r\n","\n","\r"),array('<br/>','<br/>','<br/>'), $trans); ?>
	</div>
<?php /*modif denis*/ ?>
<hr>
<p style="font-family:arial;text-align: center;">ENTREPRISE - Sarl au capital de XXXX &euro; - ADRESSE - 85220 VILLE&ndash; Vend&eacute;e - France</br>
T&eacute;l. 02 12 34 56 - 06 23 34 56 - contact@DOMAINE.COM</br>
SIRET N&deg; : XXXXXXXXXXX RCS la Roche sur Yon - TVA intracommunautaire : FRXXXXXXXXXX</p>
<hr>
<?php /*fin modif denis*/ ?>
	</page_footer>
<?php
	$image_address_path = trim($config->get('image_address_path'));		
	if(!empty($image_address_path)) {
		$image_address_path = hikashop_cleanURL($image_address_path);
		$img_style_css = trim(strip_tags($config->get('img_style_css')));
		$img_style = 'margin-left:20%;width:400px;'; /*modif denis*/
		if ($img_style_css != '') {
			$img_style = $img_style_css;
		}
?>
			<div class="hika_invoice_img">
				<img src="<?php echo $image_address_path; ?>" style="<?php echo $img_style; ?>">
			</div>
<?php
	}
?>
<?php /* debut modif boutique et adresse */ ?>
<?php /*
<div class="storeaddress">
		<?php
			$store = str_replace(array("\r\n","\n","\r"),array('<br/>','<br/>','<br/>'),$config->get('store_address',''));
			if(JText::_($store)!=$store){
				$store = JText::_($store);
			}
			echo $store;
		?>
	</div>
*/  ?>
<?php /* fin modif boutique et adresse */ ?>
	<?php if(empty($order->order_invoice_number)){
		$order->order_invoice_number = $order->order_number;
	}
	if(empty($order->order_invoice_created)){
		$order->order_invoice_created = $order->order_created;
	}

	if($this->shipping_invoice){
		$number = JText::_('SHIPPING_INVOICE').' n째 ';
		if(JText::_('SHIPPING_INVOICE_NUMBER') != 'SHIPPING_INVOICE_NUMBER'){
			$number = JText::_('SHIPPING_INVOICE_NUMBER').' ';
		}
		$item_type = 'display:back_shipping_invoice=1';
	}else{
		$number = JText::_('INVOICE').' n째 ';
		if(JText::_('INVOICE_NUMBER') != 'INVOICE_NUMBER'){
			$number = JText::_('INVOICE_NUMBER').' ';
		}
		$item_type = 'display:back_invoice=1';
	}
        $number2 = JText::_('').'';
?>
	<div class="invoicetitle"><?php echo $number.$order->order_invoice_number; ?> </br>N&deg; de commande <?php echo $number2.$order->order_number; ?></div>
	<div class="date"><?php echo JText::_('DATE').': '.hikashop_getDate($order->order_invoice_created,'%d %B %Y');?></div>

	<table class="addresses">
		<tr>
			<?php
			$addresses = array('billing_address','shipping_address');
			foreach($addresses as $oneAddress){
			if(empty($order->$oneAddress)) continue;
			if ($oneAddress=='shipping_address' && empty($pluginsShipping)) continue; ?>
			<td valign="top">
				<fieldset>
				<legend><?php echo JText::_('HIKASHOP_'.strtoupper($oneAddress)); ?></legend>
					<?php
						$override = false;
						if(!empty($order->override_shipping_address) && $oneAddress=='shipping_address') {
							$override = $order->override_shipping_address;
						}
						if($override !== false ) {
							echo $override;
						} else {
							$addressClass = hikashop_get('class.address');
							if(hikashop_isClient('administrator')){
								$view = 'order';
							}else{
								$view = 'address';
							}
							echo $addressClass->displayAddress($order->fields,$order->$oneAddress,$view);
						}
					?>
				</fieldset>
			</td>
			<?php } ?>
		</tr>
	</table>
<?php
		$shipping_invoice = '';
		if($this->shipping_invoice){
			$shipping_invoice = 'shipping_';
		}
		$weight = bccomp(sprintf('%F',$order->order_weight), 0, 3);
		$unit_weight = false;
		if($weight && $config->get('show_'.$shipping_invoice.'invoice_unit_weight',0))
			$unit_weight = true;
		$total_weight = false;
		if($weight && $config->get('show_'.$shipping_invoice.'invoice_total_weight',0))
			$total_weight = true;
		$order_weight = false;
		if($weight && $config->get('show_'.$shipping_invoice.'invoice_weight',0))
			$order_weight = true;
?>
	<table class="products">
		<tr class="products_title">
<?php if($this->shipping_invoice){ ?>
			<th style="width:500px">
<?php }else{ ?>
			<th style="width:300px">
<?php } ?>
				<?php echo JText::_('PRODUCT'); ?>
			</th>
<?php
if($unit_weight) {
	echo '<th style="width:80px" class="price">' . JText::_('PRODUCT_WEIGHT') . '</th>';
}
if(!$this->shipping_invoice){ ?>
			<th style="width:100px" class="price">
				<?php /*echo JText::_('UNIT_PRICE'); */?> Prix unitaire HT <?php /*modif denis*/ ?>
			</th>
<?php } ?>
			<th style="width:80px" class="price">
				<?php /* echo JText::_('PRODUCT_QUANTITY'); */?> Qt&eacute; <?php /*modif denis*/ ?>
			</th>
<?php
	if($total_weight) {
		echo '<th style="width:80px" class="price">' . JText::_('TOTAL_WEIGHT') . '</th>';
	}
	if(!$this->shipping_invoice){ ?>
			<th style="width:100px" class="price">
				<?php /*echo JText::_('PRICE');*/ ?> Montant total HT <?php /*modif denis*/ ?>
			</th>
<?php } ?>
		</tr>
	<?php
		$fieldsClass = hikashop_get('class.field');
		$group = $config->get('group_options',0);
		foreach($order->products as $product){
			if($group && $product->order_product_option_parent_id) continue;
			?>
			<tr>
				<td>

					<?php echo implode('<br/>',$this->str_split_unicode(strip_tags($product->order_product_name),50));
					if($group && !$this->shipping_invoice){
						$display_item_price=false;
						foreach($order->products as $j => $optionElement){
							if($optionElement->order_product_option_parent_id != $product->order_product_id) continue;
							if($optionElement->order_product_price>0){
								$display_item_price = true;
							}

						}
						if($display_item_price){
							if($config->get('price_with_tax')){
								/*echo ' '.$currencyHelper->format($product->order_product_price+$product->order_product_tax,$order->order_currency_id);*/
								echo ' '.$currencyHelper->format($product->order_product_price,$order->order_currency_id);
							}else{
								echo ' '.$currencyHelper->format($product->order_product_price,$order->order_currency_id);
							}
						}
					}
					$itemFields = $fieldsClass->getFields($item_type,$product,'item');
					if(!empty($itemFields)){
						foreach($itemFields as $field){
							$namekey = $field->field_namekey;
							if(!empty($product->$namekey) && strlen($product->$namekey)) {
								echo '<p>'.implode('<br/>',$this->str_split_unicode(strip_tags($fieldsClass->getFieldName($field).': '.$fieldsClass->show($field,$product->$namekey,'user_email')),50)).'</p>';
							}
						}
					}
					if($group){
						foreach($order->products as $j => $optionElement){
							if($optionElement->order_product_option_parent_id != $product->order_product_id) continue;

							$product->order_product_weight += $optionElement->order_product_weight;
							$product->order_product_price +=$optionElement->order_product_price;
							$product->order_product_tax +=$optionElement->order_product_tax;
							$product->order_product_total_price+=$optionElement->order_product_total_price;
							$product->order_product_total_price_no_vat+=$optionElement->order_product_total_price_no_vat;
							?><br/><?php
							$option_name = $optionElement->order_product_name;
							if($optionElement->order_product_price>0 && !$this->shipping_invoice){
								if($config->get('price_with_tax')){
									$option_name .= ' ( + '.$currencyHelper->format($optionElement->order_product_price+$optionElement->order_product_tax,$order->order_currency_id).' )';
								}else{
									$option_name .= ' ( + '.$currencyHelper->format($optionElement->order_product_price,$order->order_currency_id).' )';
								}
							}
							echo '<p>'.implode('<br/>', $this->str_split_unicode(strip_tags($option_name),50)).'</p>';
						}
					}
					if ($config->get('show_code')) {
						echo '<br/>'.$product->order_product_code;
					} ?>
				</td>
<?php
	if($unit_weight) {
		echo '<td class="price">' . rtrim(rtrim($product->order_product_weight,'0'),',.').' '.JText::_($product->order_product_weight_unit) . '</td>';
	}
?>
<?php if(!$this->shipping_invoice){ ?>
				<td class="price">
				<?php
				if($config->get('price_with_tax')){
					/*modif denis*/ /*echo $currencyHelper->format($product->order_product_price+$product->order_product_tax,$order->order_currency_id);*/
                	echo $currencyHelper->format($product->order_product_price,$order->order_currency_id);
				}else{
					echo $currencyHelper->format($product->order_product_price,$order->order_currency_id);
				} ?>
				</td>
<?php } ?>
				<td class="price">
					<?php echo $product->order_product_quantity;?>
				</td>
<?php
		if($total_weight) {
			echo '<td class="price">' . rtrim(rtrim($product->order_product_weight*$product->order_product_quantity,'0'),',.').' '.JText::_($product->order_product_weight_unit) . '</td>';
		}
?>
<?php if(!$this->shipping_invoice){ ?>
				<td  class="price">
					<?php
					if($config->get('price_with_tax')){
						/* echo $currencyHelper->format($product->order_product_total_price,$order->order_currency_id); */
						echo $currencyHelper->format($product->order_product_total_price_no_vat,$order->order_currency_id);
					}else{
						echo $currencyHelper->format($product->order_product_total_price_no_vat,$order->order_currency_id);
					} ?>
				</td>
<?php } ?>
			</tr>
			<?php
		}
	?>
<?php if(!$this->shipping_invoice){ ?>
		<tr class="limitation"><td colspan="4"></td></tr>
		<tr>
			<td colspan="3" class="newarea">
					<?php echo JText::_( 'SUBTOTAL' ); ?>
			</td>
			<td  class="price">
				<?php
				if($config->get('price_with_tax')){
					/*modif denis*/ /*echo $currencyHelper->format($order->order_subtotal,$order->order_currency_id);*/
					echo $currencyHelper->format($order->order_subtotal_no_vat,$order->order_currency_id);
				}else{
					echo $currencyHelper->format($order->order_subtotal_no_vat,$order->order_currency_id);
				} ?>
			</td>
		</tr>
		<?php $taxes = $currencyHelper->round($order->order_subtotal - $order->order_subtotal_no_vat - $order->order_discount_tax + $order->order_shipping_tax + $order->order_payment_tax, $currencyHelper->getRounding($order->order_currency_id,true));

		if(!empty($order->order_discount_code)){ ?>
		<tr>
			<td colspan="3" class="newarea">
				<?php echo JText::_( 'HIKASHOP_COUPON' ); ?>
			</td>
			<td  class="price">
				<?php
				if($config->get('price_with_tax')){
					echo $currencyHelper->format($order->order_discount_price*-1,$order->order_currency_id);
				}else{
					echo $currencyHelper->format(($order->order_discount_price-@$order->order_discount_tax)*-1,$order->order_currency_id);
				}
				?>
			</td>
		</tr>

<?php /* modif denis je déplace la partie frias de port plus bas sous la TVA */ ?>

		<?php }
		if(!empty($order->additional)) {
			$exclude_additionnal = explode(',', $config->get('order_additional_hide', ''));
			foreach($order->additional as $additional) {
				if(in_array(@$additional->name, $exclude_additionnal)) continue;
				echo '<tr><td colspan="3" class="newarea">'. JText::_($additional->order_product_name).'</td><td  class="price">';
				if(!empty($additional->order_product_price) || empty($additionaltionnal->order_product_options)) {
					if($config->get('price_with_tax')){
						echo $currencyHelper->format($additional->order_product_price+@$additional->order_product_tax, $order->order_currency_id);
					}else{
						echo $currencyHelper->format($additional->order_product_price, $order->order_currency_id);
					}
				} else {
					echo $additional->order_product_options;
				}
				echo '</td></tr>';
			}
		}

		if(!empty($order->order_payment_method) && $order->order_payment_price != 0){ ?>
		<tr>
			<td colspan="3" class="newarea">
				<?php echo JText::_( 'HIKASHOP_PAYMENT' ); ?>
			</td>
			<td class="price"><?php
				if($config->get('price_with_tax')) {
					echo $currencyHelper->format($order->order_payment_price, $order->order_currency_id);
				} else {
					echo $currencyHelper->format($order->order_payment_price - @$order->order_payment_tax, $order->order_currency_id);
				}
			?></td>
		</tr>
		<?php }

		if($taxes > 0){
			if($config->get('detailed_tax_display') && !empty($order->order_tax_info)){
				foreach($order->order_tax_info as $tax){ ?>
				<tr>
					<td colspan="3" class="newarea">
						<?php
						if( function_exists('hikashop_translate'))
							echo hikashop_translate($tax->tax_namekey);
						else
							echo $tax->tax_namekey;
						?> 20% <?php /*modif denis*/ ?>
					</td>
					<td  class="price">
						<?php echo $currencyHelper->format($tax->tax_amount,$order->order_currency_id); ?>
					</td>
				</tr>
			<?php
				}
			}else{ ?>
				<tr>
					<td colspan="3" class="newarea">
						<?php echo JText::_( 'VAT' ); ?>
					</td>
					<td  class="price">
						<?php echo $currencyHelper->format($taxes,$order->order_currency_id); ?>
					</td>
				</tr>

<?php /* modif denis ici j'ai les frais de port */ ?>
		<?php }

		if(!empty($order->order_shipping_method)){ ?>
		<tr>
			<td colspan="3" class="newarea">
					<?php /* echo JText::_( 'SHIPPING' ); */?> Participation frais de port<?php /*modif denis*/ ?>
			</td>
			<td  class="price" >
				<?php
				if($config->get('price_with_tax')){
					echo $currencyHelper->format($order->order_shipping_price,$order->order_currency_id);
				}else{
					echo $currencyHelper->format($order->order_shipping_price-@$order->order_shipping_tax,$order->order_currency_id);
				} ?>
			</td>
		</tr>
<?php /* modif denis fin de la modif frais de port */ ?>

		<?php }
		} ?>
		<tr class="total">
			<td colspan="3" class="newarea">
				<?php echo JText::_( 'HIKASHOP_TOTAL' ); ?>
			</td>
			<td  class="price" >
				<?php echo $currencyHelper->format($order->order_full_price,$order->order_currency_id); ?>
			</td>
		</tr>
<?php } ?>
	</table>
	<p>
	<?php
		if (!empty($pluginsShipping)){
			echo JText::_('HIKASHOP_SHIPPING_METHOD').' : ';
			if(is_string($order->order_shipping_method)) {
				if(strpos($order->order_shipping_id, '-') !== false)
					echo $shippingClass->getShippingName($order->order_shipping_method, $order->order_shipping_id);
				else
					echo $pluginsShipping->getName($order->order_shipping_method, $order->order_shipping_id);
			}else{
				echo implode(', ', $order->order_shipping_method);
			}
			echo '<br/>';
		}
		if(!empty($pluginsPayment))
			echo JText::_('HIKASHOP_PAYMENT_METHOD').' : '.$pluginsPayment->getName($order->order_payment_method, $order->order_payment_id).'<br/>';
		if($order_weight) {
			echo '<br/>'.JText::_('HIKASHOP_TOTAL_ORDER_WEIGHT') . ' : ' . rtrim(rtrim($order->order_weight,'0'),',.').' '.JText::_($order->order_weight_unit);
		}
		$paymentClass = hikashop_get('class.payment');
		$payment = $paymentClass->get($order->order_payment_id);
		if(!empty($payment->payment_params->information))
			echo $payment->payment_params->information;
	?>

	</p>
	<br/>
	<?php if(hikashop_level(2) && !empty($fields['order'])){
		ob_start();
		foreach($fields['order'] as $fieldName => $oneExtraField) {
			if(!@$oneExtraField->field_frontcomp || empty($order->$fieldName)) continue;
		?>
			<tr class="hikashop_order_custom_field_<?php echo $fieldName;?>_line">
				<td class="key">
					<?php echo $fieldsClass->getFieldName($oneExtraField);?>
				</td>
				<td>
					<?php echo $fieldsClass->show($oneExtraField,$order->$fieldName,'user_email'); ?>
				</td>
			</tr>
		<?php
		}
		$additionalInfo = ob_get_clean();
		if(!empty($additionalInfo)){ ?>
		<fieldset class="hikashop_order_custom_fields_fieldset">
			<legend><?php echo JText::_('ADDITIONAL_INFORMATION'); ?></legend>
			<table class="hikashop_order_custom_fields_table adminlist" cellpadding="1" width="100%">
			<?php echo $additionalInfo; ?>
			</table>
		</fieldset>
		<br/>
		<?php
		}
	}
	JPluginHelper::importPlugin('hikashop');
	JPluginHelper::importPlugin('hikashopshipping');
	JPluginHelper::importPlugin('hikashoppayment');
	$app = JFactory::getApplication();
	ob_start();
	$mode = 'order_front_show';
	if(hikashop_isClient('administrator'))
		$mode = 'order_back_invoice';
	$app->triggerEvent('onAfterOrderProductsListingDisplay', array(&$order, $mode));
	$html = ob_get_clean();
	if(!empty($html)) { ?>
	<table class="hikashop_order_extra_table adminlist" cellpadding="1" width="100%">
		<tr>
			<td><?php echo $html; ?></td>
		</tr>
	</table>
	<?php
	}
	?>
</page>

Et le rendu, très propre (version2) :

Attachments:
Last edit: 3 months 5 days ago by Complicités Minérales. Reason: Version 2 du code et de la capture du rendu facture
The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 11
  • Hikashop Business
3 months 5 days ago #362050

Version 2 du code et de la capture dans le post précédent.
www.hikashop.com/forum/5-support-en-fran...e-plugin.html#362013

Correction des champs du tableau :
Produit | Prix unitaire HT | Qté | Montant total HT

Correction de l’ordre des totaux :
(Pour une présentation plus logique, car il n'y à pas toujours de TVA sur les frais de port, et ainsi, la lecture des totaux devient plus simple).
Total HT > TVA 20% > Participation frais de port > Total TTC

Last edit: 3 months 5 days ago by Complicités Minérales.

Please Log in or Create an account to join the conversation.

Time to create page: 0.072 seconds
Powered by Kunena Forum