diff --git a/core/modules/facture/doc/doc_easydoc_invoice_html.modules.php b/core/modules/facture/doc/doc_easydoc_invoice_html.modules.php index 1fe24f9..d233a9c 100644 --- a/core/modules/facture/doc/doc_easydoc_invoice_html.modules.php +++ b/core/modules/facture/doc/doc_easydoc_invoice_html.modules.php @@ -441,7 +441,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails ], ]; foreach ($typescontact as $key => $value) { - foreach ($value as $type) { + foreach ($value as $idx => $type) { $arrayidcontact = $object->getIdContact($key, $type); $contacts = []; foreach ($arrayidcontact as $idc) { @@ -454,6 +454,13 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $contacts[] = $contact; } $substitutions = array_merge($substitutions, getEachVarObject($contacts, $outputlangs, 1, strtolower($type) . '_' . $key)); + if (!empty($substitutions[strtolower($type) . '_' . $key])) { + foreach ($substitutions[strtolower($type) . '_' . $key] as $jdx => $substitution) { + if (!empty($substitution['photo'])) { + $substitutions[strtolower($type) . '_' . $key][$jdx]['picture'] = $conf->{$substitution['element']}->multidir_output[$conf->entity] . '/' . $substitution['ref'] . '/' . $substitution['photo']; + } + } + } } } @@ -471,6 +478,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $subtotal_ht = 0; $subtotal_ttc = 0; $linenumber = 1; + $linesarray = []; foreach ($object->lines as $key => $line) { $subtotal_ht += $line->total_ht; $subtotal_ttc += $line->total_ttc; @@ -480,27 +488,33 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $subtotal_ht = 0; $subtotal_ttc = 0; } - $substitutions['lines'][$key] = [ - 'linenumber' => $linenumber, - 'qty' => $line->qty, - 'ref' => $line->product_ref, - 'label' => $line->label, - 'description' => $line->desc, - 'product_label' => $line->product_label, - 'product_description' => $line->product_desc, - 'subprice' => price($line->subprice), - 'total_ht' => price($line->total_ht), - 'total_ttc' => price($line->total_ttc), - 'vatrate' => price($line->tva_tx) . '%', - 'special_code' => $line->special_code, - 'product_type' => $line->product_type, - 'line_options' => [], - 'product_options' => [], - ]; + $linearray = getEachVarObject($line, $outputlangs, 1, 'line'); + $linesarray[$key] = $linearray['line']; + $linesarray[$key]['linenumber'] = $linenumber; + // $substitutions['lines'][$key] = [ + // 'linenumber' => $linenumber, + // 'qty' => $line->qty, + // 'ref' => $line->product_ref, + // 'label' => $line->label, + // 'description' => $line->desc, + // 'product_label' => $line->product_label, + // 'product_description' => $line->product_desc, + // 'subprice' => price($line->subprice), + // 'total_ht' => price($line->total_ht), + // 'total_ttc' => price($line->total_ttc), + // 'vatrate' => price($line->tva_tx) . '%', + // 'special_code' => $line->special_code, + // 'product_type' => $line->product_type, + // 'line_options' => [], + // 'product_options' => [], + // ]; if (empty($line->special_code)) { $linenumber++; } } + $substitutions = array_merge($substitutions, ['lines' => $linesarray]); + + // Discounts $substitutions['discounts'] = []; // Loop on each discount available (deposits and credit notes and excess of payment included) $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,"; @@ -565,7 +579,6 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails $i++; } } - // var_dump($substitutions); if (getDolGlobalInt('EASYDOCGENERATOR_ENABLE_DEVELOPPER_MODE')) { $substitutions['debug'] = '
' . print_r($substitutions, true) . '
'; } diff --git a/langs/fr_FR/easydocgenerator.lang b/langs/fr_FR/easydocgenerator.lang index 31b8cee..86a1a0c 100644 --- a/langs/fr_FR/easydocgenerator.lang +++ b/langs/fr_FR/easydocgenerator.lang @@ -46,4 +46,5 @@ EasydocStopThePropalAtSumOf=Arrêté la proposition commerciale à la somme de : EasydoCantAddPdfToDoc=Easydocgenerator ne peux pas ajouter le fichier %s au document EASYDOC_ADD_TEMPLATE_SUFFIX_TO_FILENAME=Ajouter le nom du modèle au nom du fichier PDF généré EasydocEditor=Éditeur de template +YourSalesRepresentatives=Vos représentants commerciaux diff --git a/lib/easydocgenerator.lib.php b/lib/easydocgenerator.lib.php index 7950706..1467a2f 100644 --- a/lib/easydocgenerator.lib.php +++ b/lib/easydocgenerator.lib.php @@ -99,7 +99,7 @@ function getEachVarObject($object, $outputlangs, $recursive = 1, $objectname = ' $array_other = []; if (!empty($object)) { foreach ($object as $key => $value) { - if (in_array($key, ['db', 'fields', 'lines', 'modelpdf', 'model_pdf'])) { // discard some properties + if (in_array($key, ['db', 'fields', 'lines', 'modelpdf', 'model_pdf', 'api_key', 'pass_indatabase_crypted'])) { // discard some properties continue; } if (!empty($value)) { diff --git a/templates/easydoc_invoice b/templates/easydoc_invoice index 0a32890..8ad2bd1 100644 --- a/templates/easydoc_invoice +++ b/templates/easydoc_invoice @@ -5,7 +5,9 @@ body { font-family: sans-serif; font-size: 9pt; } -p { margin: 0pt; } +p { + margin: 0pt; +} table.items { border: 0.1mm solid #000000; } @@ -77,7 +79,10 @@ table thead th { .freetext { page-break-inside: avoid; } - +.picture { + max-width : 35px; + height : auto; +} @@ -104,6 +109,7 @@ table thead th { {{ trans('VATIntraShort') }}: {{ mysoc.tva_intra }}
{% endif %} + {% if object.type == 1 %} @@ -157,7 +163,7 @@ mpdf--> {% endif %} {% else %} - - - + {% if line.fk_product > 0 %} + + + {% else %} + + + {% endif %} + - - + + {% endif %} {% endfor %} @@ -284,8 +304,34 @@ mpdf-->
-SOLD TO:
{{ thirdparty.name }}
{{ thirdparty.address }}
{{ thirdparty.zip }} {{ thirdparty.town }}
{{ thirdparty.country }}
+{{ trans('BillAddress')}}:
{{ thirdparty.name }}
{{ thirdparty.address }}
{{ thirdparty.zip }} {{ thirdparty.town }}
{{ thirdparty.country }}
{% if thirdparty.phone %} {{ thirdparty.phone }}
{% endif %} @@ -167,7 +173,7 @@ mpdf-->
  -SHIP TO:
{{ thirdparty.name }}
{{ thirdparty.address }}
{{ thirdparty.zip }} {{ thirdparty.town }}
{{ thirdparty.country }}
+{{ trans('DeliveryAddress')}}:
{{ thirdparty.name }}
{{ thirdparty.address }}
{{ thirdparty.zip }} {{ thirdparty.town }}
{{ thirdparty.country }}
{% if thirdparty.phone %} {{ thirdparty.phone }}
{% endif %} @@ -219,16 +225,30 @@ mpdf-->
{{ line.label }}{{ line.qty }}{{ line.ref }} - {{ line.product_label }}
- {{ line.product_description }}
- -
{{ line.vatrate }}{{ line.ref }} + {% if line.product_label %} + {{ line.product_label }}
+ {% endif %} + {{ line.product_description }}
+ {% if line.product.barcode %} + + {% endif %} +
+ {% if line.label %} + {{ line.label }}
+ {% endif %} + {{ line.description }}
+
{{ price(line.tva_tx) }} {{ line.qty }}{{ line.subprice }}{{ line.total_ht }}{{ price(line.subprice) }}{{ price(line.total_ht) }}
{% endif %}
- +{% if salesrepfoll_internal is iterable %} +
+
{{ trans('YourSalesRepresentatives') }}.
+ + + {% for salesrepfoll in salesrepfoll_internal %} + + + + + {% endfor %} + +
+ {{ salesrepfoll.lastname }} {{ salesrepfoll.firstname }} + {% if salesrepfoll.office_phone %} +
{{ salesrepfoll.office_phone }} + {% endif %} + {% if salesrepfoll.user_mobile %} +
{{ salesrepfoll.user_mobile }} + {% endif %} + {% if salesrepfoll.email %} +
{{ salesrepfoll.email }} + {% endif %} +
+{% else %} + {# salesrepfoll_internal is empty #} +{% endif %}
{{ freetext }}
- +
{{ debug }}