浏览代码

Mise en page factures de situation & organisation options

Mathieu Moulin 1 年之前
父节点
当前提交
d44fbc091e
共有 3 个文件被更改,包括 169 次插入8 次删除
  1. 17 1
      admin/setup.php
  2. 128 0
      class/actions_mmidocuments.class.php
  3. 24 7
      langs/fr_FR/mmidocuments.lang

+ 17 - 1
admin/setup.php

@@ -29,24 +29,40 @@ require_once '../main_load.inc.php';
 $arrayofparameters = array(
 	'DOCUMENT_SHOW_COMPLEMENT'=>array('type'=>'yesno', 'enabled'=>1),
 	'DOCUMENT_COMPLEMENT_TITLE'=>array('type'=>'yesno', 'enabled'=>1),
+
+	'MMIDOCUMENT_ADMIN_SHIPPING'=>array('type'=>'separator','enabled'=>1),
 	'SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME'=>array('type'=>'yesno','enabled'=>1),
 	'SHIPPING_PDF_HIDE_BATCH'=>array('type'=>'yesno','enabled'=>1), // MMI Hack
 	'SHIPPING_PDF_HIDE_DELIVERY_DATE'=>array('type'=>'yesno','enabled'=>1), // MMI Hack
 	'MAIN_GENERATE_SHIPMENT_WITH_PICTURE'=>array('type'=>'yesno','enabled'=>1),
 	'MMI_SHIPPING_PDF_MESSAGE'=>array('type'=>'html','enabled'=>1),
+
+	'MMIDOCUMENT_ADMIN_DOCUMENTS_ALL'=>array('type'=>'separator','enabled'=>1),
+	'MAIN_DOCUMENTS_QTY_COL_WIDTH'=>array('type'=>'int','enabled'=>1),
+	'MAIN_DOCUMENTS_VAT_COL_WIDTH'=>array('type'=>'int','enabled'=>1),
+	
 	'MMI_DOCUMENT_PDF_SEPARATE_CONTACTS'=>array('type'=>'yesno','enabled'=>1),
 	'MMI_FIELD_CGV_CPV'=>array('type'=>'yesno','enabled'=>1),
 	'MMIDOCUMENT_CGP_TITLE'=>array('type'=>'yesno','enabled'=>1),
 	'MMIDOCUMENTS_VAT_NOTIF_PDF_DISPLAY'=>array('type'=>'yesno','enabled'=>1),
 	'MMI_DOCUMENT_PDF_HEIGHT_CALC'=>array('type'=>'yesno','enabled'=>1),
-	'INVOICE_RETAINED_WARRANTY_CUMULATED_SHOW'=>array('type'=>'yesno','enabled'=>1),
+
+	'MMIDOCUMENT_ADMIN_PDF_RENAME'=>array('type'=>'separator','enabled'=>1),
 	'MMIDOCUMENT_PDF_RENAME'=>array('type'=>'yesno','enabled'=>1),
 	'MMIDOCUMENT_PDF_RENAME_UPPERCASE'=>array('type'=>'yesno','enabled'=>1),
 	'MMIDOCUMENT_PDF_RENAME_MYSOC'=>array('type'=>'yesno','enabled'=>1),
 	'MMIDOCUMENT_PDF_RENAME_THIRDPARTY'=>array('type'=>'yesno','enabled'=>1),
 	'MMIDOCUMENT_PDF_RENAME_REF_CUSTOMER'=>array('type'=>'yesno','enabled'=>1),
+
+	'MMIDOCUMENT_ADMIN_SUPPLIER_PROPOSAL'=>array('type'=>'separator','enabled'=>1),
 	'MAIN_GENERATE_SUPPLIER_PROPOSAL_HIDE_DESC'=>array('type'=>'yesno','enabled'=>1),
 	'MAIN_GENERATE_SUPPLIER_PROPOSAL_HIDE_REF'=>array('type'=>'yesno','enabled'=>1),
+
+	'MMIDOCUMENT_ADMIN_SITUATION_INVOICES'=>array('type'=>'separator','enabled'=>1),
+	'MMIDOCUMENT_SITUATION_SHOW_CUMUL'=>array('type'=>'yesno','enabled'=>1),
+	'INVOICE_RETAINED_WARRANTY_CUMULATED_SHOW'=>array('type'=>'yesno','enabled'=>1),
+	'SITUATION_DISPLAY_100P_PER_LINE_PDF'=>array('type'=>'yesno','enabled'=>1),
+
 );
 
 require_once('../../mmicommon/admin/mmisetup_1.inc.php');

+ 128 - 0
class/actions_mmidocuments.class.php

@@ -242,6 +242,134 @@ class ActionsMMIDocuments extends MMI_Actions_1_0
 		}
 	}
 
+	function defineColumnField($parameters, &$pdf, &$action, $hookmanager)
+	{
+		global $langs, $user, $conf;
+		
+		$error = '';
+
+		if ($this->in_context($parameters, 'pdfgeneration')) {
+
+			// Largeur colonne VAT
+			if (!empty($conf->global->MAIN_DOCUMENTS_VAT_COL_WIDTH)) {
+				$pdf->cols['vat']['width'] = $conf->global->MAIN_DOCUMENTS_VAT_COL_WIDTH;
+			}
+
+			// Largeur colonne Quantité
+			if (!empty($conf->global->MAIN_DOCUMENTS_QTY_COL_WIDTH)) {
+				$pdf->cols['qty']['width'] = $conf->global->MAIN_DOCUMENTS_QTY_COL_WIDTH;
+			}
+
+			// Unité juste après quantité
+			$pdf->cols['unit']['rank'] = $pdf->cols['qty']['rank']+1;
+
+			// Factures de situation
+			if ($pdf->situationinvoice) {
+				if ($conf->global->MMIDOCUMENT_SITUATION_SHOW_CUMUL) {
+					$pdf->cols['progress']['title'] = ['textkey'=>'ProgressAndCumulated'];
+
+					$pdf->cols['totalexcltax']['title'] = ['textkey'=>'TotalHTSituation'];
+				}
+				if ($conf->global->SITUATION_DISPLAY_100P_PER_LINE_PDF) {
+					$pdf->cols['situationtotal'] = array(
+						// Peu après qté & unité
+						'rank' => $pdf->cols['unit']['rank']+5,
+						'width' => 19, // in mm
+						'status' => true,
+						'title' => array(
+							'textkey' => 'Total HT 100%'
+						),
+						'border-left' => true, // add left line separator
+					);
+				}
+			}
+		}
+
+		if (!$error) {
+			return isset($ret) ?$ret :0; // or return 1 to replace standard code
+		} else {
+			$this->errors[] = $error;
+			return -1;
+		}
+	}
+
+	// @todo terminer la migration proprement
+	function NONONOprintStdColumnContent($parameters, &$pdf, &$action, $hookmanager)
+	{
+		global $langs, $user, $conf;
+		
+		// $parameters = array(
+		// 	'curY' => &$curY,
+		// 	'columnText' => $columnText,
+		// 	'colKey' => $colKey,
+		// 	'pdf' => &$pdf,
+		// );
+
+		$error = '';
+
+		if ($this->in_context($parameters, 'pdfgeneration')) {
+			if ($parameters['colKey'] == 'totalexcltax') {
+				$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
+				// MMI Hack
+				if ($total_excl_tax != ' ' && $object->lines[$i]->situation_percent>0) {
+					if (!empty($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF)) {
+						$total_excl_tax = $total_excl_tax.'<br />('.number_format(round(str_replace(',', '.', $qty)*str_replace([' ', ','], ['', '.'], $up_excl_tax)*str_replace(',', '.', $object->lines[$i]->situation_percent)/100, 2), 2, ',', ' ').')';
+					}
+					else {
+						$total_excl_tax = number_format(round($object->lines[$i]->total_ht, 2), 2, ',', ' ');
+					}
+				}
+				
+			}
+		}
+
+		if (!$error) {
+			return isset($ret) ?$ret :0; // or return 1 to replace standard code
+		} else {
+			$this->errors[] = $error;
+			return -1;
+		}
+	}
+
+	function printPDFline($parameters, &$pdftpl, &$action, $hookmanager)
+	{
+		global $langs, $user, $conf;
+
+		// $parameters = array(
+		// 	'object' => $object,
+		// 	'i' => $i,
+		// 	'pdf' =>& $pdf,
+		// 	'curY' =>& $curY,
+		// 	'nexY' =>& $nexY,
+		// 	'outputlangs' => $outputlangs,
+		// 	'hidedetails' => $hidedetails
+		// );
+
+		$error = '';
+
+		extract($parameters, EXTR_SKIP);
+
+		// MMI Hack
+		// Situation Total
+		if ($pdftpl->getColumnStatus('situationtotal') && !empty($conf->global->SITUATION_DISPLAY_100P_PER_LINE_PDF)) {
+			if ($object->lines[$i]->qty>0 && $object->lines[$i]->subprice>0) {
+				$situationtotal = number_format(round($object->lines[$i]->qty*$object->lines[$i]->subprice, 2), 2, ',', ' ');
+			}
+			else {
+				$situationtotal = '';
+			}
+			$pdftpl->printStdColumnContent($pdf, $curY, 'situationtotal', $situationtotal);
+			$nexY = max($pdf->GetY(), $nexY);
+		}
+
+		if (!$error) {
+			return isset($ret) ?$ret :0; // or return 1 to replace standard code
+		} else {
+			$this->errors[] = $error;
+			return -1;
+		}
+	}
+
 	function downloadDocument($parameters, &$object, &$action, $hookmanager)
 	{
 		global $langs, $user, $conf;

+ 24 - 7
langs/fr_FR/mmidocuments.lang

@@ -28,26 +28,40 @@ ModuleMMIDocumentsDesc = Nouveaux modèles de PDF pour les Propales, Commandes,
 MMIDocumentsSetup = MMIDocuments setup
 Settings = Settings
 MMIDocumentsSetupPage = MMIDocuments setup page
-DOCUMENT_SHOW_COMPLEMENT = Afficher les informations complémentaires
 MMIDOCUMENTS_MYPARAM1Tooltip = Afficher les CGV, etc. dans les documents PDF : Propales, Commandes, Factures, etc.
+
+DOCUMENT_SHOW_COMPLEMENT = Afficher les informations complémentaires
 MMI_DOCUMENT_PDF_SEPARATE_CONTACTS = Séparer l'affichage des contacts de livraison et facturation
 MMI_FIELD_CGV_CPV = Ajout du champ CGV/CPV dans les propales, commandes et factures
+
+MMIDOCUMENT_ADMIN_SHIPPING = Expéditions
 SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME = Cacher poids et volume dans les expéditions
 SHIPPING_PDF_HIDE_BATCH = Cacher les numéros de lot dans les expéditions
 SHIPPING_PDF_HIDE_DELIVERY_DATE = Cacher la date d'expédition dans les expéditions
 MAIN_GENERATE_SHIPMENT_WITH_PICTURE = Affiche les images produit dans les expéditions
 MMI_SHIPPING_PDF_MESSAGE = Message affiché dans le cadre note des expéditions
 MMIDOCUMENTS_VAT_NOTIF_PDF_DISPLAY = Gestion de l'exonération de TVA dans les documents (Propales, Commandes, Factures)
-INVOICE_RETAINED_WARRANTY_CUMULATED_SHOW = Afficher la retenue de garantie cumulée sur les factures
+
+MMIDOCUMENT_ADMIN_PDF_RENAME = Renommage des PDF
 MMIDOCUMENT_PDF_RENAME = Renommer les PDF des documents
-MMIDOCUMENT_PDF_RENAME_UPPERCASE = PDF en majuscule
-MMIDOCUMENT_PDF_RENAME_MYSOC = Ajouter le nom de notre société dans le PDF
-MMIDOCUMENT_PDF_RENAME_THIRDPARTY = Ajouter le nom du client dans le PDF
-MMIDOCUMENT_PDF_RENAME_REF_CUSTOMER = AJouter la référence client dans le PDF
+MMIDOCUMENT_PDF_RENAME_UPPERCASE = Nom de fichier PDF en majuscule
+MMIDOCUMENT_PDF_RENAME_MYSOC = Ajouter le nom de notre société dans le nom de fichier PDF
+MMIDOCUMENT_PDF_RENAME_THIRDPARTY = Ajouter le nom du client dans le nom de fichier PDF
+MMIDOCUMENT_PDF_RENAME_REF_CUSTOMER = AJouter la référence client dans le nom de fichier PDF
+
+MMIDOCUMENT_ADMIN_DOCUMENTS_ALL = Tous les documents
+MAIN_DOCUMENTS_QTY_COL_WIDTH = Largeur de colonne QTY en mm dans les documents (défaut 16, recommandé 11)
+MAIN_DOCUMENTS_VAT_COL_WIDTH = Largeur de colonne VAT en mm dans les documents (défaut 16, recommandé 11)
 
+MMIDOCUMENT_ADMIN_SUPPLIER_PROPOSAL = Demandes de prix fournisseur
 MAIN_GENERATE_SUPPLIER_PROPOSAL_HIDE_DESC = Cacher les descriptions de produit dans les demandes de prix
 MAIN_GENERATE_SUPPLIER_PROPOSAL_HIDE_REF = Cacher les références produit dans les demandes de prix
 
+MMIDOCUMENT_ADMIN_SITUATION_INVOICES = Factures de situation
+MMIDOCUMENT_SITUATION_SHOW_CUMUL = Afficher les cumuls dans les factures de situation
+INVOICE_RETAINED_WARRANTY_CUMULATED_SHOW = Afficher la retenue de garantie cumulée sur les factures
+SITUATION_DISPLAY_100P_PER_LINE_PDF = Afficher la colonne du total 100%% dans les lignes de factures de situation
+
 #
 # About page
 #
@@ -99,4 +113,7 @@ VATIsNotUsedForEU = Exonération de TVA art. 262 ter, I du CGI
 VATIsNotUsedForIslands = TVA non applicable – art. 259-1 du CGI (îles)
 VATIsNotUsedForExport = TVA non applicable – art. 259-1 du CGI (Export hors UE)
 
-RetainedWarrantyCumulated = Retenue de garantie cumulée
+RetainedWarrantyCumulated = Retenue de garantie cumulée
+
+TotalHTSituation = Total HT (Cumulé)
+ProgressAndCumulated = Progression (Cumulé)