Skip to content

Commit

Permalink
Merge pull request #49 from frederic34/dev
Browse files Browse the repository at this point in the history
add representatives
  • Loading branch information
frederic34 authored Feb 10, 2024
2 parents 3f8d669 + d952369 commit 9c01ced
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 35 deletions.
51 changes: 32 additions & 19 deletions core/modules/facture/doc/doc_easydoc_invoice_html.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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'];
}
}
}
}
}

Expand All @@ -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;
Expand All @@ -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,";
Expand Down Expand Up @@ -565,7 +579,6 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$i++;
}
}
// var_dump($substitutions);
if (getDolGlobalInt('EASYDOCGENERATOR_ENABLE_DEVELOPPER_MODE')) {
$substitutions['debug'] = '<pre>' . print_r($substitutions, true) . '</pre>';
}
Expand Down
1 change: 1 addition & 0 deletions langs/fr_FR/easydocgenerator.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion lib/easydocgenerator.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
76 changes: 61 additions & 15 deletions templates/easydoc_invoice
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -77,7 +79,10 @@ table thead th {
.freetext {
page-break-inside: avoid;
}

.picture {
max-width : 35px;
height : auto;
}
</style>
</head>
<body>
Expand All @@ -104,6 +109,7 @@ table thead th {
{{ trans('VATIntraShort') }}: {{ mysoc.tva_intra }}<br />
{% endif %}
</td>
<td class="barcodecell"><barcode code="{{ object.ref }}" type="QR" class="barcode" size="0.8" error="H" disableborder="1" /></td>
<td width="45%" style="text-align: right;">
<span style="font-weight: bold; font-size: 14pt;"><b>
{% if object.type == 1 %}
Expand Down Expand Up @@ -157,7 +163,7 @@ mpdf-->
<table width="100%" style="font-family: serif; " cellpadding="10">
<tr>
<td width="46%" style="border: 0.1mm solid #888888; ">
<span style="font-size: 7pt; color: #555555; font-family: sans;">SOLD TO:</span><br /><b>{{ thirdparty.name }}</b><br />{{ thirdparty.address }}<br />{{ thirdparty.zip }} {{ thirdparty.town }}<br /><img src="{{ thirdparty.flag }}"> {{ thirdparty.country }}<br />
<span style="font-size: 7pt; color: #555555; font-family: sans;">{{ trans('BillAddress')}}:</span><br /><b>{{ thirdparty.name }}</b><br />{{ thirdparty.address }}<br />{{ thirdparty.zip }} {{ thirdparty.town }}<br /><img src="{{ thirdparty.flag }}"> {{ thirdparty.country }}<br />
{% if thirdparty.phone %}
<span style="font-family:dejavusanscondensed;">&#9742; </span>{{ thirdparty.phone }}<br />
{% endif %}
Expand All @@ -167,7 +173,7 @@ mpdf-->
</td>
<td width="8%">&nbsp;</td>
<td width="46%" style="border: 0.1mm solid #888888;">
<span style="font-size: 7pt; color: #555555; font-family: sans;">SHIP TO:</span><br /><b>{{ thirdparty.name }}</b><br />{{ thirdparty.address }}<br />{{ thirdparty.zip }} {{ thirdparty.town }}<br /><img src="{{ thirdparty.flag }}"> {{ thirdparty.country }}<br />
<span style="font-size: 7pt; color: #555555; font-family: sans;">{{ trans('DeliveryAddress')}}:</span><br /><b>{{ thirdparty.name }}</b><br />{{ thirdparty.address }}<br />{{ thirdparty.zip }} {{ thirdparty.town }}<br /><img src="{{ thirdparty.flag }}"> {{ thirdparty.country }}<br />
{% if thirdparty.phone %}
<span style="font-family:dejavusanscondensed;">&#9742; </span>{{ thirdparty.phone }}<br />
{% endif %}
Expand Down Expand Up @@ -219,16 +225,30 @@ mpdf-->
<td class="subtotal" colspan="6" align="left">{{ line.label }}{{ line.qty }}</td>
{% endif %}
{% else %}
<td align="center">{{ line.ref }}</td>
<td>
{{ line.product_label }}<br />
{{ line.product_description }}<br />
<span class="barcodecell"><barcode code="978-0-9542246-0" text="1" class="barcode" height="0.50" /></span>
</td>
<td align="right">{{ line.vatrate }}</td>
{% if line.fk_product > 0 %}
<td align="center">{{ line.ref }}</td>
<td>
{% if line.product_label %}
{{ line.product_label }}<br />
{% endif %}
{{ line.product_description }}<br />
{% if line.product.barcode %}
<span class="barcodecell"><barcode code="{{ line.product.barcode }}" text="1" class="barcode" height="0.50" /></span>
{% endif %}
</td>
{% else %}
<td align="center"></td>
<td>
{% if line.label %}
{{ line.label }}<br />
{% endif %}
{{ line.description }}<br />
</td>
{% endif %}
<td align="right">{{ price(line.tva_tx) }}</td>
<td align="center">{{ line.qty }}</td>
<td class="cost">{{ line.subprice }}</td>
<td class="cost">{{ line.total_ht }}</td>
<td class="cost">{{ price(line.subprice) }}</td>
<td class="cost">{{ price(line.total_ht) }}</td>
{% endif %}
</tr>
{% endfor %}
Expand Down Expand Up @@ -284,8 +304,34 @@ mpdf-->
</table>
{% endif %}
<br>

{% if salesrepfoll_internal is iterable %}
<br>
<div class="freetext">{{ trans('YourSalesRepresentatives') }}.</div>
<table class="items" style="font-size: 6pt; border-collapse: collapse;" cellpadding="8" width="100%">
<tbody>
{% for salesrepfoll in salesrepfoll_internal %}
<tr>
<td width="10%" align="center"><img src="{{ salesrepfoll.picture }}" class="picture"/></td>
<td>
{{ salesrepfoll.lastname }} {{ salesrepfoll.firstname }}
{% if salesrepfoll.office_phone %}
<br><span style="font-family:dejavusanscondensed;">&#9742; </span>{{ salesrepfoll.office_phone }}
{% endif %}
{% if salesrepfoll.user_mobile %}
<br><span style="font-family:dejavusanscondensed;">&#9742; </span>{{ salesrepfoll.user_mobile }}
{% endif %}
{% if salesrepfoll.email %}
<br><span style="font-family:dejavusanscondensed;">&#9993; </span>{{ salesrepfoll.email }}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
{# salesrepfoll_internal is empty #}
{% endif %}
<div class="freetext">{{ freetext }}</div>

<div class="freetext">{{ debug }}</div>
</body>
</html>

0 comments on commit 9c01ced

Please sign in to comment.