Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add format setup #17

Merged
merged 2 commits into from
Feb 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 39 additions & 17 deletions admin/setup.php
Original file line number Diff line number Diff line change
@@ -25,15 +25,14 @@
// Load Dolibarr environment
include '../config.php';

global $langs, $user;
global $db, $langs, $user;

// Libraries
require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
//require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php';
require_once '../lib/easydocgenerator.lib.php';

// Translations
$langs->loadLangs(["admin", 'oauth', "Easydocgenerator@easydocgenerator"]);
$langs->loadLangs(['admin', 'companies', 'languages', 'members', 'other', 'products', 'stocks', 'trips', 'easydocgenerator@easydocgenerator']);

// Access control
if (!$user->admin) {
@@ -43,15 +42,30 @@
// Parameters
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');

// Define $urlwithroot
// $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root));
// $urlwithouturlroot = str_replace('http://', 'https://', $urlwithouturlroot);
// This is to use external domain name found into config file
// $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
// $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// paper formats
$sql = "SELECT code, label, width, height, unit";
$sql .= " FROM " . $db->prefix() . "c_paper_format";
$sql .= " WHERE active=1";
$paperformats = [];
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($resql);
$unitKey = $langs->trans('SizeUnit' . $obj->unit);
$paperformats[$obj->code] = $langs->trans('PaperFormat' . strtoupper($obj->code)) . ' - ' . round($obj->width) . 'x' . round($obj->height) . ' ' . ($unitKey == 'SizeUnit' . $obj->unit ? $obj->unit : $unitKey);
$i++;
}
}

$arrayofparameters = [
'EASYDOC_PDF_FORMAT' => [
'css' => 'minwidth500',
'type' => 'selectarray',
'array' => $paperformats,
'default' => dol_getDefaultFormat(),
],
'EASYDOC_PDF_MARGIN_LEFT' => [
'css' => 'minwidth500',
'type' => 'number',
@@ -184,14 +198,19 @@
print '<tr class="liste_titre"><td class="titlefield">' . $langs->trans("Parameter") . '</td><td>' . $langs->trans("Value") . '</td></tr>';

foreach ($arrayofparameters as $key => $val) {
print '<tr class="oddeven">';
print '<td>';
$tooltiphelp = (($langs->trans($key . 'Tooltip') != $key . 'Tooltip') ? $langs->trans($key . 'Tooltip') : '');
print $form->textwithpicto($langs->trans($key), $tooltiphelp);
$type = empty($val['type']) ? 'text' : $val['type'];
$value = !empty($conf->global->$key) ? $conf->global->$key : (isset($val['default']) ? $val['default'] : '');
print '</td>';
print '<td><input name="' . $key . '" type="' . $type . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . $value . '"></td>';
print '<tr class="oddeven">';
if ($type == 'selectarray') {
print '<td>' . $langs->trans('EASYDOC_PDF_FORMAT') . '</td>';
print '<td>' . $form->selectarray('EASYDOC_PDF_FORMAT', $val['array'], $value) . '</td>';
} else {
print '<td>';
$tooltiphelp = (($langs->trans($key . 'Tooltip') != $key . 'Tooltip') ? $langs->trans($key . 'Tooltip') : '');
print $form->textwithpicto($langs->trans($key), $tooltiphelp);
print '</td>';
print '<td><input name="' . $key . '" type="' . $type . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . $value . '"></td>';
}
print '</tr>';
}
print '</table>';
@@ -214,10 +233,13 @@
$tooltiphelp = (($langs->trans($key . 'Tooltip') != $key . 'Tooltip') ? $langs->trans($key . 'Tooltip') : '');
print $form->textwithpicto($langs->trans($key), $tooltiphelp);
print '</td><td>';
$value = getDolGlobalString('$key', $val['default']);
$value = getDolGlobalString($key, $val['default']);
if (isset($val['type']) && $val['type'] == 'password') {
$value = preg_replace('/./i', '*', $value);
}
if (isset($val['type']) && $val['type'] == 'selectarray') {
$value = $val['array'][$value];
}
print $value;
print '</td></tr>';
}
10 changes: 7 additions & 3 deletions core/modules/facture/doc/doc_easydoc_invoice_html.modules.php
Original file line number Diff line number Diff line change
@@ -313,7 +313,7 @@
$flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
}
if ($object->cond_reglement_code) {
$label_payment_conditions = ($outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) != 'PaymentCondition' . $object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);

Check warning on line 316 in core/modules/facture/doc/doc_easydoc_invoice_html.modules.php

GitHub Actions / build

Line exceeds 300 characters; contains 386 characters
$label_payment_conditions = str_replace('\n', "\n", $label_payment_conditions);
if ($object->deposit_percent > 0) {
$label_payment_conditions = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $label_payment_conditions);
@@ -478,9 +478,13 @@
$mpdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$mpdf->SetCreator('Dolibarr ' . DOL_VERSION);
$mpdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$mpdf->SetWatermarkText(getDolGlobalString('COMMANDE_DRAFT_WATERMARK'));

$mpdf->showWatermarkText = ($object->statut == Commande::STATUS_DRAFT && getDolGlobalString('COMMANDE_DRAFT_WATERMARK'));
// Watermark
$text = getDolGlobalString('FACTURE_DRAFT_WATERMARK');
$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, null);
complete_substitutions_array($substitutionarray, $outputlangs, null);
$text = make_substitutions($text, $substitutionarray, $outputlangs);
$mpdf->SetWatermarkText($outputlangs->convToOutputCharset($text));
$mpdf->showWatermarkText = ($object->statut == Commande::STATUS_DRAFT && getDolGlobalString('FACTURE_DRAFT_WATERMARK'));
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;

1 change: 1 addition & 0 deletions langs/fr_FR/easydocgenerator.lang
Original file line number Diff line number Diff line change
@@ -44,4 +44,5 @@ EASYDOC_PDF_MARGIN_TOP=Marge haut sur les PDF
EASYDOC_PDF_MARGIN_BOTTOM=Marge bas sur les PDF
EASYDOC_PDF_MARGIN_HEADER=En-tête sur les PDF
EASYDOC_PDF_MARGIN_FOOTER=Pied de page sur les PDF
EASYDOC_PDF_FORMAT=Format papiers

15 changes: 13 additions & 2 deletions templates/invoice.twig
Original file line number Diff line number Diff line change
@@ -75,8 +75,19 @@ table thead th {
{{ trans('VATIntraShort') }}: {{ mysoc.tvanumber }}<br />
</td>
<td width="45%" style="text-align: right;">
<span style="font-weight: bold; font-size: 14pt;"><b>{{ trans('PdfOrderTitle') }}</b></span>
<br /><span style="font-weight: bold; font-size: 10pt;">{{ trans('Ref') }}: {{ object.ref }}</span>
<span style="font-weight: bold; font-size: 14pt;"><b>
{% if object.type == 1 %}
{{ trans('InvoiceReplacement') }}
{% elseif object.type == 2 %}
{{ trans('InvoiceAvoir') }}
{% elseif object.type == 3 %}
{{ trans('InvoiceDeposit') }}
{% elseif object.type == 4 %}
{{ trans('InvoiceProForma') }}
{% else %}
{{ trans('PdfInvoiceTitle') }}
{% endif %}
{{ object.ref }}</span>
<br /><span style="font-weight: bold; font-size: 10pt;">{{ trans('OrderDate') }}: {{ object.date }}</span>
{% if object.ref_customer %}
<br /><span style="font-weight: bold; font-size: 10pt;">{{ trans('RefCustomer') }}: {{ object.ref_customer }}</span>

Unchanged files with check annotations Beta

$flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
}
if ($object->cond_reglement_code) {
$label_payment_conditions = ($outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) != 'PaymentCondition' . $object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);

Check warning on line 317 in core/modules/commande/doc/doc_easydoc_order_html.modules.php

GitHub Actions / build

Line exceeds 300 characters; contains 386 characters
$label_payment_conditions = str_replace('\n', "\n", $label_payment_conditions);
if ($object->deposit_percent > 0) {
$label_payment_conditions = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $label_payment_conditions);
$flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
}
if ($object->cond_reglement_code) {
$label_payment_conditions = ($outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) != 'PaymentCondition' . $object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);

Check warning on line 317 in core/modules/propale/doc/doc_easydoc_propale_html.modules.php

GitHub Actions / build

Line exceeds 300 characters; contains 386 characters
$label_payment_conditions = str_replace('\n', "\n", $label_payment_conditions);
if ($object->deposit_percent > 0) {
$label_payment_conditions = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $label_payment_conditions);