Skip to content

Commit 656ea49

Browse files
authored
Merge pull request #55 from frederic34/dev
Update version
2 parents 24a2f68 + 2428b9a commit 656ea49

File tree

8 files changed

+77
-51
lines changed

8 files changed

+77
-51
lines changed

core/modules/commande/doc/doc_easydoc_order_html.modules.php

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
441441
],
442442
];
443443
foreach ($typescontact as $key => $value) {
444-
foreach ($value as $type) {
444+
foreach ($value as $idx => $type) {
445445
$arrayidcontact = $object->getIdContact($key, $type);
446446
$contacts = [];
447447
foreach ($arrayidcontact as $idc) {
@@ -454,6 +454,13 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
454454
$contacts[] = $contact;
455455
}
456456
$substitutions = array_merge($substitutions, getEachVarObject($contacts, $outputlangs, 1, strtolower($type) . '_' . $key));
457+
if (!empty($substitutions[strtolower($type) . '_' . $key])) {
458+
foreach ($substitutions[strtolower($type) . '_' . $key] as $jdx => $substitution) {
459+
if (!empty($substitution['photo'])) {
460+
$substitutions[strtolower($type) . '_' . $key][$jdx]['picture'] = $conf->{$substitution['element']}->multidir_output[$conf->entity] . '/' . $substitution['ref'] . '/' . $substitution['photo'];
461+
}
462+
}
463+
}
457464
}
458465
}
459466

@@ -471,6 +478,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
471478
$subtotal_ht = 0;
472479
$subtotal_ttc = 0;
473480
$linenumber = 1;
481+
$linesarray = [];
474482
foreach ($object->lines as $key => $line) {
475483
$subtotal_ht += $line->total_ht;
476484
$subtotal_ttc += $line->total_ttc;
@@ -480,29 +488,32 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
480488
$subtotal_ht = 0;
481489
$subtotal_ttc = 0;
482490
}
483-
$substitutions['lines'][$key] = [
484-
'linenumber' => $linenumber,
485-
'qty' => $line->qty,
486-
'ref' => $line->product_ref,
487-
'label' => $line->label,
488-
'description' => $line->desc,
489-
'product_label' => $line->product_label,
490-
'product_description' => $line->product_desc,
491-
'subprice' => price($line->subprice),
492-
'total_ht' => price($line->total_ht),
493-
'total_ttc' => price($line->total_ttc),
494-
'vatrate' => price($line->tva_tx) . '%',
495-
'special_code' => $line->special_code,
496-
'product_type' => $line->product_type,
497-
'line_options' => [],
498-
'product_options' => [],
499-
];
491+
$linearray = getEachVarObject($line, $outputlangs, 1, 'line');
492+
$linesarray[$key] = $linearray['line'];
493+
$linesarray[$key]['linenumber'] = $linenumber;
494+
$linesarray[$key]['subtotal_ht'] = $subtotal_ht;
495+
// $substitutions['lines'][$key] = [
496+
// 'linenumber' => $linenumber,
497+
// 'qty' => $line->qty,
498+
// 'ref' => $line->product_ref,
499+
// 'label' => $line->label,
500+
// 'description' => $line->desc,
501+
// 'product_label' => $line->product_label,
502+
// 'product_description' => $line->product_desc,
503+
// 'subprice' => $line->subprice,
504+
// 'total_ht' => $line->total_ht,
505+
// 'total_ttc' => $line->total_ttc,
506+
// 'vatrate' => $line->tva_tx,
507+
// 'special_code' => $line->special_code,
508+
// 'product_type' => $line->product_type,
509+
// 'line_options' => [],
510+
// 'product_options' => [],
511+
// ];
500512
if (empty($line->special_code)) {
501513
$linenumber++;
502514
}
503515
}
504-
505-
// var_dump($substitutions);
516+
$substitutions = array_merge($substitutions, ['lines' => $linesarray]);
506517
if (getDolGlobalInt('EASYDOCGENERATOR_ENABLE_DEVELOPPER_MODE')) {
507518
$substitutions['debug'] = '<pre>' . print_r($substitutions, true) . '</pre>';
508519
}

core/modules/facture/doc/doc_easydoc_invoice_html.modules.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,10 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
511511
// 'description' => $line->desc,
512512
// 'product_label' => $line->product_label,
513513
// 'product_description' => $line->product_desc,
514-
// 'subprice' => price($line->subprice),
515-
// 'total_ht' => price($line->total_ht),
516-
// 'total_ttc' => price($line->total_ttc),
517-
// 'vatrate' => price($line->tva_tx) . '%',
514+
// 'subprice' => $line->subprice,
515+
// 'total_ht' => $line->total_ht,
516+
// 'total_ttc' => $line->total_ttc,
517+
// 'vatrate' => $line->tva_tx,
518518
// 'special_code' => $line->special_code,
519519
// 'product_type' => $line->product_type,
520520
// 'line_options' => [],

core/modules/modEasydocgenerator.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function __construct($db)
8585
$this->editor_url = $this->configuration['editor_url'];
8686

8787
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'
88-
$this->version = '1.0.2'; // TODO remove this line
88+
$this->version = '1.0.3'; // TODO remove this line
8989
$this->version = $this->configuration['version'];
9090
// Url to the file with your last numberversion of this module
9191
// $this->url_last_version = 'http://www.example.com/versionmodule.txt';

core/modules/propale/doc/doc_easydoc_propale_html.modules.php

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __construct($db)
6363
global $langs, $mysoc;
6464

6565
// Load translation files required by the page
66-
$langs->loadLangs(["main", "companies", "easydocgenerator@easydocgenerator"]);
66+
$langs->loadLangs(['main', 'companies', "easydocgenerator@easydocgenerator"]);
6767

6868
$this->db = $db;
6969
$this->name = "Easydoc templates";
@@ -306,7 +306,8 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
306306
$twig->addFunction($function);
307307
// create twig function which return price formatted
308308
$function = new \Twig\TwigFunction('price', function ($price) {
309-
return price($price, 0);
309+
global $outputlangs, $langs;
310+
return price($price, 0, $outputlangs);
310311
});
311312
$twig->addFunction($function);
312313
// create twig function which return number to words
@@ -401,7 +402,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
401402
],
402403
];
403404
foreach ($typescontact as $key => $value) {
404-
foreach ($value as $type) {
405+
foreach ($value as $idx => $type) {
405406
$arrayidcontact = $object->getIdContact($key, $type);
406407
$contacts = [];
407408
foreach ($arrayidcontact as $idc) {
@@ -414,6 +415,13 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
414415
$contacts[] = $contact;
415416
}
416417
$substitutions = array_merge($substitutions, getEachVarObject($contacts, $outputlangs, 1, strtolower($type) . '_' . $key));
418+
if (!empty($substitutions[strtolower($type) . '_' . $key])) {
419+
foreach ($substitutions[strtolower($type) . '_' . $key] as $jdx => $substitution) {
420+
if (!empty($substitution['photo'])) {
421+
$substitutions[strtolower($type) . '_' . $key][$jdx]['picture'] = $conf->{$substitution['element']}->multidir_output[$conf->entity] . '/' . $substitution['ref'] . '/' . $substitution['photo'];
422+
}
423+
}
424+
}
417425
}
418426
}
419427

@@ -431,6 +439,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
431439
$subtotal_ht = 0;
432440
$subtotal_ttc = 0;
433441
$linenumber = 1;
442+
$linesarray = [];
434443
foreach ($object->lines as $key => $line) {
435444
$subtotal_ht += $line->total_ht;
436445
$subtotal_ttc += $line->total_ttc;
@@ -440,27 +449,32 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
440449
$subtotal_ht = 0;
441450
$subtotal_ttc = 0;
442451
}
443-
$substitutions['lines'][$key] = [
444-
'linenumber' => $linenumber,
445-
'qty' => $line->qty,
446-
'ref' => $line->product_ref,
447-
'label' => $line->label,
448-
'description' => $line->desc,
449-
'product_label' => $line->product_label,
450-
'product_description' => $line->product_desc,
451-
'subprice' => price($line->subprice),
452-
'total_ht' => price($line->total_ht),
453-
'total_ttc' => price($line->total_ttc),
454-
'vatrate' => price($line->tva_tx) . '%',
455-
'special_code' => $line->special_code,
456-
'product_type' => $line->product_type,
457-
'line_options' => [],
458-
'product_options' => [],
459-
];
452+
$linearray = getEachVarObject($line, $outputlangs, 1, 'line');
453+
$linesarray[$key] = $linearray['line'];
454+
$linesarray[$key]['linenumber'] = $linenumber;
455+
$linesarray[$key]['subtotal_ht'] = $subtotal_ht;
456+
// $substitutions['lines'][$key] = [
457+
// 'linenumber' => $linenumber,
458+
// 'qty' => $line->qty,
459+
// 'ref' => $line->product_ref,
460+
// 'label' => $line->label,
461+
// 'description' => $line->desc,
462+
// 'product_label' => $line->product_label,
463+
// 'product_description' => $line->product_desc,
464+
// 'subprice' => $line->subprice,
465+
// 'total_ht' => $line->total_ht,
466+
// 'total_ttc' => $line->total_ttc,
467+
// 'vatrate' => $line->tva_tx,
468+
// 'special_code' => $line->special_code,
469+
// 'product_type' => $line->product_type,
470+
// 'line_options' => [],
471+
// 'product_options' => [],
472+
// ];
460473
if (empty($line->special_code)) {
461474
$linenumber++;
462475
}
463476
}
477+
$substitutions = array_merge($substitutions, ['lines' => $linesarray]);
464478

465479
if (getDolGlobalInt('EASYDOCGENERATOR_ENABLE_DEVELOPPER_MODE')) {
466480
$substitutions['debug'] = '<pre>' . print_r($substitutions, true) . '</pre>';

json/configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"numero": 13371234,
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"rights_class": "easydocgenerator",
55
"family": "other",
66
"picto": "pdf",

templates/easydoc_invoice

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ mpdf-->
245245
{{ line.description }}<br />
246246
</td>
247247
{% endif %}
248-
<td align="right">{{ price(line.tva_tx) }}</td>
248+
<td align="right">{{ price(line.tva_tx) }}%</td>
249249
<td align="center">{{ line.qty }}</td>
250250
<td class="cost">{{ price(line.subprice) }}</td>
251251
<td class="cost">{{ price(line.total_ht) }}</td>

templates/easydoc_order

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ mpdf-->
210210
{{ line.product_label }}<br />
211211
{{ line.product_description }}
212212
</td>
213-
<td align="right">{{ line.vatrate }}</td>
213+
<td align="right">{{ price(line.tva_tx) }}%</td>
214214
<td align="center">{{ line.qty }}</td>
215-
<td class="cost">{{ line.subprice }}</td>
216-
<td class="cost">{{ line.total_ht }}</td>
215+
<td class="cost">{{ price(line.subprice) }}</td>
216+
<td class="cost">{{ price(line.total_ht) }}</td>
217217
{% endif %}
218218
</tr>
219219
{% endfor %}
@@ -245,6 +245,7 @@ mpdf-->
245245

246246
<div style="text-align: center; ">{{ trans('PaymentConditions') }}: {{ labelpaymentconditions }}</div>
247247
<div class="freetext">{{ freetext }}</div>
248+
<div class="freetext">{{ debug }}</div>
248249

249250
</body>
250251
</html>

templates/easydoc_propale

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ mpdf-->
188188
{% else %}
189189
<td align="center">{{ line.ref }}</td>
190190
<td>{{ line.product_label }}<br />{{ line.product_description }}</td>
191-
<td align="right">{{ price(line.tva_tx) }}</td>
191+
<td align="right">{{ price(line.tva_tx) }}%</td>
192192
<td align="center">{{ line.qty }}</td>
193193
<td class="cost">{{ price(line.subprice) }}</td>
194194
<td class="cost">{{ price(line.total_ht) }}</td>

0 commit comments

Comments
 (0)