Merge branch 'develop' into patch-3

This commit is contained in:
Cédric 2020-09-07 17:22:18 +02:00 committed by GitHub
commit 5992641360
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
197 changed files with 39699 additions and 39618 deletions

View File

@ -119,7 +119,7 @@ install:
echo echo
- | - |
echo "Installing Composer dependencies (PHP Unit, Parallel Lint & PHP CodeSniffer" echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer - for $TRAVIS_PHP_VERSION"
if [ "$TRAVIS_PHP_VERSION" = '5.4' ] || [ "$TRAVIS_PHP_VERSION" = '5.5' ]; then if [ "$TRAVIS_PHP_VERSION" = '5.4' ] || [ "$TRAVIS_PHP_VERSION" = '5.5' ]; then
composer -n require phpunit/phpunit ^4 \ composer -n require phpunit/phpunit ^4 \
jakub-onderka/php-parallel-lint ^0 \ jakub-onderka/php-parallel-lint ^0 \
@ -129,14 +129,14 @@ install:
if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \ if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \
[ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then
composer -n require phpunit/phpunit ^5 \ composer -n require phpunit/phpunit ^5 \
jakub-onderka/php-parallel-lint ^0 \ php-parallel-lint/php-parallel-lint ^0 \
jakub-onderka/php-console-highlighter ^0 \ php-parallel-lint/php-console-highlighter ^0 \
squizlabs/php_codesniffer ^3 squizlabs/php_codesniffer ^3
fi fi
if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \ composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \
jakub-onderka/php-parallel-lint ^0 \ php-parallel-lint/php-parallel-lint ^1 \
jakub-onderka/php-console-highlighter ^0 \ php-parallel-lint/php-console-highlighter ^0 \
squizlabs/php_codesniffer ^3 squizlabs/php_codesniffer ^3
fi fi
echo echo
@ -283,7 +283,7 @@ script:
# Ensure we catch errors # Ensure we catch errors
set -e set -e
#parallel-lint --exclude htdocs/includes --blame . #parallel-lint --exclude htdocs/includes --blame .
parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/myclabs --exclude htdocs/includes/webmozart --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/composer/autoload_static.php --blame . parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/myclabs --exclude htdocs/includes/webmozart --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/composer/autoload_static.php --blame .
set +e set +e
echo echo

View File

@ -13,7 +13,8 @@ WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* Properties ->contactid has been renamed into ->contact_id * Properties ->contactid has been renamed into ->contact_id
* Rename property $paiementid in API api_supplier_invoices into $payment_mode_id * Rename property $paiementid in API api_supplier_invoices into $payment_mode_id
* The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you still use old syntax in
your email templates.
***** ChangeLog for 12.0.2 compared to 12.0.1 ***** ***** ChangeLog for 12.0.2 compared to 12.0.1 *****
FIX: computation of the bottom margin of <body> returns NaN because body is not loaded yet FIX: computation of the bottom margin of <body> returns NaN because body is not loaded yet

View File

@ -46,8 +46,8 @@ $action = GETPOST('action', 'aZ09');
// Parameters ACCOUNTING_* and others // Parameters ACCOUNTING_* and others
$list = array( $list = array(
'ACCOUNTING_LENGTH_GACCOUNT', 'ACCOUNTING_LENGTH_GACCOUNT',
'ACCOUNTING_LENGTH_AACCOUNT', 'ACCOUNTING_LENGTH_AACCOUNT',
// 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
// 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
); );
@ -67,17 +67,17 @@ if ($action == 'update') {
if (!$error) if (!$error)
{ {
foreach ($list as $constname) foreach ($list as $constname)
{ {
$constvalue = GETPOST($constname, 'alpha'); $constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++; $error++;
} }
} }
if ($error) { if ($error) {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
foreach ($list_binding as $constname) foreach ($list_binding as $constname)
{ {
@ -96,46 +96,46 @@ if ($action == 'update') {
} }
} }
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} }
} }
if ($action == 'setlistsorttodo') { if ($action == 'setlistsorttodo') {
$setlistsorttodo = GETPOST('value', 'int'); $setlistsorttodo = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
if (!$res > 0) if (!$res > 0)
$error++; $error++;
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'mesgs'); setEventMessages($langs->trans("Error"), null, 'mesgs');
} }
} }
if ($action == 'setlistsortdone') { if ($action == 'setlistsortdone') {
$setlistsortdone = GETPOST('value', 'int'); $setlistsortdone = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
if (!$res > 0) if (!$res > 0)
$error++; $error++;
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'mesgs'); setEventMessages($langs->trans("Error"), null, 'mesgs');
} }
} }
if ($action == 'setmanagezero') { if ($action == 'setmanagezero') {
$setmanagezero = GETPOST('value', 'int'); $setmanagezero = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
if (!$res > 0) if (!$res > 0)
$error++; $error++;
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'mesgs'); setEventMessages($langs->trans("Error"), null, 'mesgs');
} }
} }
if ($action == 'setdisabledirectinput') { if ($action == 'setdisabledirectinput') {
@ -163,15 +163,15 @@ if ($action == 'setenabledraftexport') {
} }
if ($action == 'setenablesubsidiarylist') { if ($action == 'setenablesubsidiarylist') {
$setenablesubsidiarylist = GETPOST('value', 'int'); $setenablesubsidiarylist = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity);
if (!$res > 0) if (!$res > 0)
$error++; $error++;
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'mesgs'); setEventMessages($langs->trans("Error"), null, 'mesgs');
} }
} }
if ($action == 'setdisablebindingonsales') { if ($action == 'setdisablebindingonsales') {

View File

@ -93,7 +93,7 @@ $formaccounting = new FormAccounting($db);
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{ {
$search_societe = ''; $search_societe = '';
$search_lineid = ''; $search_lineid = '';
$search_ref = ''; $search_ref = '';
$search_invoice = ''; $search_invoice = '';
$search_label = ''; $search_label = '';
@ -203,7 +203,7 @@ if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
if ($search_lineid) { if ($search_lineid) {
$sql .= natural_search("fd.rowid", $search_lineid, 1); $sql .= natural_search("fd.rowid", $search_lineid, 1);
} }
if (strlen(trim($search_invoice))) { if (strlen(trim($search_invoice))) {
$sql .= natural_search("f.ref", $search_invoice); $sql .= natural_search("f.ref", $search_invoice);
@ -251,13 +251,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -309,9 +309,9 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre center nowraponall">'; print '<td class="liste_titre center nowraponall">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
} }
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5); $formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>'; print '</td>';
@ -349,10 +349,10 @@ if ($result) {
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";
$thirdpartystatic = new Societe($db); $thirdpartystatic = new Societe($db);
$facturestatic = new Facture($db); $facturestatic = new Facture($db);
$productstatic = new Product($db); $productstatic = new Product($db);
$accountingaccountstatic = new AccountingAccount($db); $accountingaccountstatic = new AccountingAccount($db);
$i = 0; $i = 0;
while ($i < min($num_lines, $limit)) { while ($i < min($num_lines, $limit)) {
@ -362,16 +362,16 @@ if ($result) {
$facturestatic->id = $objp->facid; $facturestatic->id = $objp->facid;
$facturestatic->type = $objp->ftype; $facturestatic->type = $objp->ftype;
$thirdpartystatic->id = $objp->socid; $thirdpartystatic->id = $objp->socid;
$thirdpartystatic->name = $objp->name; $thirdpartystatic->name = $objp->name;
$thirdpartystatic->client = $objp->client; $thirdpartystatic->client = $objp->client;
$thirdpartystatic->fournisseur = $objp->fournisseur; $thirdpartystatic->fournisseur = $objp->fournisseur;
$thirdpartystatic->code_client = $objp->code_client; $thirdpartystatic->code_client = $objp->code_client;
$thirdpartystatic->code_compta_client = $objp->code_compta_client; $thirdpartystatic->code_compta_client = $objp->code_compta_client;
$thirdpartystatic->code_fournisseur = $objp->code_fournisseur; $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
$thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
$thirdpartystatic->email = $objp->email; $thirdpartystatic->email = $objp->email;
$thirdpartystatic->country_code = $objp->country_code; $thirdpartystatic->country_code = $objp->country_code;
$productstatic->ref = $objp->product_ref; $productstatic->ref = $objp->product_ref;
$productstatic->id = $objp->product_id; $productstatic->id = $objp->product_id;
@ -412,7 +412,7 @@ if ($result) {
print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>'; print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
// Thirdparty // Thirdparty
print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'customer') . '</td>'; print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>';
// Country // Country
print '<td>'; print '<td>';
@ -425,7 +425,7 @@ if ($result) {
print '<td>'.$objp->tva_intra.'</td>'; print '<td>'.$objp->tva_intra.'</td>';
print '<td class="center">'; print '<td class="center">';
print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">'; print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
@ -434,14 +434,14 @@ if ($result) {
print '</tr>'; print '</tr>';
$i++; $i++;
} }
print '</table>'; print '</table>';
print "</div>"; print "</div>";
if ($nbtotalofrecords > $limit) { if ($nbtotalofrecords > $limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
} }
print '</form>'; print '</form>';
} else { } else {
print $db->lasterror(); print $db->lasterror();
} }

View File

@ -114,7 +114,7 @@ if (empty($reshook))
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{ {
$search_societe=''; $search_societe = '';
$search_lineid = ''; $search_lineid = '';
$search_ref = ''; $search_ref = '';
$search_invoice = ''; $search_invoice = '';
@ -386,7 +386,7 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>'; print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>'; print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="' . dol_escape_htmltag($search_societe) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1); print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1);
//print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">'; //print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
@ -582,7 +582,7 @@ if ($result) {
print '</td>'; print '</td>';
// Thirdparty // Thirdparty
print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'customer') . '</td>'; print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>';
// Country // Country
print '<td>'; print '<td>';

View File

@ -201,16 +201,16 @@ if ($resql) {
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} else print $row[1]; } else print $row[1];
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
} }
print '<td class="nowrap right">'.price($row[13]).'</td>'; print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>'; print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>'; print '</tr>';
} }
$db->free($resql); $db->free($resql);
} else { } else {
print $db->lasterror(); // Show last sql error print $db->lasterror(); // Show last sql error
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
@ -275,16 +275,16 @@ if ($resql) {
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} else print $row[1]; } else print $row[1];
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
} }
print '<td class="nowrap right">'.price($row[13]).'</td>'; print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>'; print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>'; print '</tr>';
} }
$db->free($resql); $db->free($resql);
} else { } else {
print $db->lasterror(); // Show last sql error print $db->lasterror(); // Show last sql error
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
@ -293,60 +293,60 @@ print '</div>';
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ? if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ?
{ {
print '<br>'; print '<br>';
print '<br>'; print '<br>';
print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
//print load_fiche_titre($langs->trans("OtherInfo"), '', ''); //print load_fiche_titre($langs->trans("OtherInfo"), '', '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>'; print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,"; $sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM(erd.total_ht) as total"; $sql .= " SUM(erd.total_ht) as total";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
// Define begin binding date // Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; $sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
} }
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/expensereport/index.php'); dol_syslog('htdocs/accountancy/expensereport/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr><td>'.$row[0].'</td>'; print '<tr><td>'.$row[0].'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
} }
print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>'; print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
print '</tr>'; print '</tr>';
} }
$db->free($resql); $db->free($resql);
} else { } else {
print $db->lasterror(); // Show last sql error print $db->lasterror(); // Show last sql error
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
} }
// End of page // End of page

View File

@ -86,8 +86,8 @@ $formaccounting = new FormAccounting($db);
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
{ {
$search_login = ''; $search_login = '';
$search_expensereport = ''; $search_expensereport = '';
$search_label = ''; $search_label = '';
$search_desc = ''; $search_desc = '';
$search_amount = ''; $search_amount = '';
@ -178,7 +178,7 @@ $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't sha
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
// Add search filter like // Add search filter like
if (strlen(trim($search_login))) { if (strlen(trim($search_login))) {
$sql .= natural_search("u.login", $search_login); $sql .= natural_search("u.login", $search_login);
} }
if (strlen(trim($search_expensereport))) { if (strlen(trim($search_expensereport))) {
$sql .= natural_search("er.ref", $search_expensereport); $sql .= natural_search("er.ref", $search_expensereport);
@ -207,13 +207,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -228,7 +228,7 @@ if ($result) {
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_login) $param .= '&search_login='.urlencode($search_login); if ($search_login) $param .= '&search_login='.urlencode($search_login);
if ($search_expensereport) $param .= "&search_expensereport=".urlencode($search_expensereport); if ($search_expensereport) $param .= "&search_expensereport=".urlencode($search_expensereport);
if ($search_label) $param .= "&search_label=".urlencode($search_label); if ($search_label) $param .= "&search_label=".urlencode($search_label);
if ($search_desc) $param .= "&search_desc=".urlencode($search_desc); if ($search_desc) $param .= "&search_desc=".urlencode($search_desc);
@ -257,12 +257,12 @@ if ($result) {
$moreforfilter = ''; $moreforfilter = '';
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>'; print '<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
@ -278,14 +278,14 @@ if ($result) {
print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_vat" size="1" placeholder="%" value="'.dol_escape_htmltag($search_vat).'"></td>'; print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_vat" size="1" placeholder="%" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
$searchpicto = $form->showFilterButtons(); $searchpicto = $form->showFilterButtons();
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
@ -296,31 +296,31 @@ if ($result) {
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
$checkpicto = $form->showCheckAddButtons(); $checkpicto = $form->showCheckAddButtons();
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";
$expensereportstatic = new ExpenseReport($db); $expensereportstatic = new ExpenseReport($db);
$accountingaccountstatic = new AccountingAccount($db); $accountingaccountstatic = new AccountingAccount($db);
$userstatic = new User($db); $userstatic = new User($db);
$i = 0; $i = 0;
while ($i < min($num_lines, $limit)) { while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$expensereportstatic->ref = $objp->ref; $expensereportstatic->ref = $objp->ref;
$expensereportstatic->id = $objp->erid; $expensereportstatic->id = $objp->erid;
$userstatic->id = $objp->rowid; $userstatic->id = $objp->rowid;
$userstatic->ref = $objp->label; $userstatic->ref = $objp->label;
$userstatic->login = $objp->login; $userstatic->login = $objp->login;
$userstatic->statut = $objp->statut; $userstatic->statut = $objp->statut;
$userstatic->email = $objp->email; $userstatic->email = $objp->email;
$userstatic->gender = $objp->gender; $userstatic->gender = $objp->gender;
$userstatic->firstname = $objp->firstname; $userstatic->firstname = $objp->firstname;
$userstatic->lastname = $objp->lastname; $userstatic->lastname = $objp->lastname;
$userstatic->employee = $objp->employee; $userstatic->employee = $objp->employee;
$userstatic->photo = $objp->photo; $userstatic->photo = $objp->photo;
$accountingaccountstatic->rowid = $objp->fk_compte; $accountingaccountstatic->rowid = $objp->fk_compte;
$accountingaccountstatic->label = $objp->label; $accountingaccountstatic->label = $objp->label;
@ -329,15 +329,15 @@ if ($result) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Login // Login
print '<td class="nowraponall">'; print '<td class="nowraponall">';
print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
print '</td>'; print '</td>';
// Line id // Line id
print '<td>'.$objp->rowid.'</td>'; print '<td>'.$objp->rowid.'</td>';
// Ref Expense report // Ref Expense report
print '<td>'.$expensereportstatic->getNomUrl(1).'</td>'; print '<td>'.$expensereportstatic->getNomUrl(1).'</td>';
// Date validation // Date validation
@ -347,10 +347,10 @@ if ($result) {
print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>'; print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>';
// Fees label // Fees label
print '<td class="tdoverflow">'.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).'</td>'; print '<td class="tdoverflow">'.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).'</td>';
// Fees description -- Can be null // Fees description -- Can be null
print '<td>'; print '<td>';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments)); $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments));
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
@ -360,13 +360,13 @@ if ($result) {
// Amount without taxes // Amount without taxes
print '<td class="nowrap right">'.price($objp->total_ht).'</td>'; print '<td class="nowrap right">'.price($objp->total_ht).'</td>';
// Vat rate // Vat rate
print '<td class="center">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>'; print '<td class="center">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
// Accounting account affected // Accounting account affected
print '<td class="center">'; print '<td class="center">';
print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
print ' <a class="editfielda reposition marginleftonly marginrightonly" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">'; print ' <a class="editfielda reposition marginleftonly marginrightonly" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>'; print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
@ -379,7 +379,7 @@ if ($result) {
print "</div>"; print "</div>";
if ($nbtotalofrecords > $limit) { if ($nbtotalofrecords > $limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
} }
print '</form>'; print '</form>';

View File

@ -102,16 +102,16 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{ {
$search_login = ''; $search_login = '';
$search_expensereport = ''; $search_expensereport = '';
$search_label = ''; $search_label = '';
$search_desc = ''; $search_desc = '';
$search_amount = ''; $search_amount = '';
$search_account = ''; $search_account = '';
$search_vat = ''; $search_vat = '';
$search_day = ''; $search_day = '';
$search_month = ''; $search_month = '';
$search_year = ''; $search_year = '';
} }
// Mass actions // Mass actions
@ -124,46 +124,46 @@ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($massaction == 'ventil') { if ($massaction == 'ventil') {
$msg = ''; $msg = '';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (!empty($mesCasesCochees)) { if (!empty($mesCasesCochees)) {
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>'; $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
$msg .= '<div class="detail">'; $msg .= '<div class="detail">';
$cpt = 0; $cpt = 0;
$ok = 0; $ok = 0;
$ko = 0; $ko = 0;
foreach ($mesCasesCochees as $maLigneCochee) { foreach ($mesCasesCochees as $maLigneCochee) {
$maLigneCourante = explode("_", $maLigneCochee); $maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0]; $monId = $maLigneCourante[0];
$monCompte = GETPOST('codeventil'.$monId); $monCompte = GETPOST('codeventil'.$monId);
if ($monCompte <= 0) if ($monCompte <= 0)
{ {
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>'; $msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
$ko++; $ko++;
} else { } else {
$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
$sql .= " SET fk_code_ventilation = ".$monCompte; $sql .= " SET fk_code_ventilation = ".$monCompte;
$sql .= " WHERE rowid = ".$monId; $sql .= " WHERE rowid = ".$monId;
$accountventilated = new AccountingAccount($db); $accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, ''); $accountventilated->fetch($monCompte, '');
dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG);
if ($db->query($sql)) { if ($db->query($sql)) {
$msg .= '<div><font color="green">'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>'; $msg .= '<div><font color="green">'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
$ok++; $ok++;
} else { } else {
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>'; $msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>';
$ko++; $ko++;
} }
} }
$cpt++; $cpt++;
} }
$msg .= '</div>'; $msg .= '</div>';
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>'; $msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
} }
} }
@ -181,8 +181,8 @@ if (empty($chartaccountcode))
{ {
print $langs->trans("ErrorChartOfAccountSystemNotSelected"); print $langs->trans("ErrorChartOfAccountSystemNotSelected");
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();
exit; exit;
} }
@ -204,25 +204,25 @@ if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
} }
// Add search filter like // Add search filter like
if (strlen(trim($search_login))) { if (strlen(trim($search_login))) {
$sql .= natural_search("u.login", $search_login); $sql .= natural_search("u.login", $search_login);
} }
if (strlen(trim($search_expensereport))) { if (strlen(trim($search_expensereport))) {
$sql .= natural_search("er.ref", $search_expensereport); $sql .= natural_search("er.ref", $search_expensereport);
} }
if (strlen(trim($search_label))) { if (strlen(trim($search_label))) {
$sql .= natural_search("f.label", $search_label); $sql .= natural_search("f.label", $search_label);
} }
if (strlen(trim($search_desc))) { if (strlen(trim($search_desc))) {
$sql .= natural_search("erd.comments", $search_desc); $sql .= natural_search("erd.comments", $search_desc);
} }
if (strlen(trim($search_amount))) { if (strlen(trim($search_amount))) {
$sql .= natural_search("erd.total_ht", $search_amount, 1); $sql .= natural_search("erd.total_ht", $search_amount, 1);
} }
if (strlen(trim($search_account))) { if (strlen(trim($search_account))) {
$sql .= natural_search("aa.account_number", $search_account); $sql .= natural_search("aa.account_number", $search_account);
} }
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= natural_search("erd.tva_tx", $search_vat, 1); $sql .= natural_search("erd.tva_tx", $search_vat, 1);
} }
$sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year); $sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year);
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
@ -233,13 +233,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -255,7 +255,7 @@ if ($result) {
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_login) $param .= '&search_login='.urlencode($search_login); if ($search_login) $param .= '&search_login='.urlencode($search_login);
if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid); if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid);
if ($search_day) $param .= '&search_day='.urlencode($search_day); if ($search_day) $param .= '&search_day='.urlencode($search_day);
if ($search_month) $param .= '&search_month='.urlencode($search_month); if ($search_month) $param .= '&search_month='.urlencode($search_month);
@ -267,7 +267,7 @@ if ($result) {
if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); if ($search_vat) $param .= '&search_vat='.urlencode($search_vat);
$arrayofmassactions = array( $arrayofmassactions = array(
'ventil' => $langs->trans("Ventilate") 'ventil' => $langs->trans("Ventilate")
); );
$massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1);
@ -295,12 +295,12 @@ if ($result) {
$moreforfilter = ''; $moreforfilter = '';
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// We add search filter // We add search filter
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
@ -324,7 +324,7 @@ if ($result) {
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
@ -356,23 +356,23 @@ if ($result) {
$expensereport_static->ref = $objp->ref; $expensereport_static->ref = $objp->ref;
$expensereport_static->id = $objp->erid; $expensereport_static->id = $objp->erid;
$userstatic->id = $objp->rowid; $userstatic->id = $objp->rowid;
$userstatic->ref = $objp->label; $userstatic->ref = $objp->label;
$userstatic->login = $objp->login; $userstatic->login = $objp->login;
$userstatic->statut = $objp->statut; $userstatic->statut = $objp->statut;
$userstatic->email = $objp->email; $userstatic->email = $objp->email;
$userstatic->gender = $objp->gender; $userstatic->gender = $objp->gender;
$userstatic->firstname = $objp->firstname; $userstatic->firstname = $objp->firstname;
$userstatic->lastname = $objp->lastname; $userstatic->lastname = $objp->lastname;
$userstatic->employee = $objp->employee; $userstatic->employee = $objp->employee;
$userstatic->photo = $objp->photo; $userstatic->photo = $objp->photo;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Login // Login
print '<td class="nowraponall">'; print '<td class="nowraponall">';
print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
print '</td>'; print '</td>';
// Line id // Line id
print '<td>'.$objp->rowid.'</td>'; print '<td>'.$objp->rowid.'</td>';
@ -400,7 +400,7 @@ if ($result) {
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments); print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
print '</td>'; print '</td>';
// Amount without taxes // Amount without taxes
print '<td class="nowrap right">'; print '<td class="nowrap right">';
print price($objp->price); print price($objp->price);
print '</td>'; print '</td>';

View File

@ -331,9 +331,9 @@ $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog('htdocs/accountancy/supplier/index.php'); dol_syslog('htdocs/accountancy/supplier/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
@ -346,16 +346,16 @@ if ($resql) {
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} else print $row[1]; } else print $row[1];
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
} }
print '<td class="nowrap right">'.price($row[13]).'</td>'; print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>'; print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>'; print '</tr>';
} }
$db->free($resql); $db->free($resql);
} else { } else {
print $db->lasterror(); // Show last sql error print $db->lasterror(); // Show last sql error
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
@ -364,60 +364,60 @@ print '</div>';
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ?
{ {
print '<br>'; print '<br>';
print '<br>'; print '<br>';
print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
//print load_fiche_titre($langs->trans("OtherInfo"), '', ''); //print load_fiche_titre($langs->trans("OtherInfo"), '', '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>'; print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT '".$langs->trans("CAHTF")."' AS label,"; $sql = "SELECT '".$langs->trans("CAHTF")."' AS label,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM(ffd.total_ht) as total"; $sql .= " SUM(ffd.total_ht) as total";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'";
// Define begin binding date // Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; $sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
} }
$sql .= " AND ff.fk_statut > 0"; $sql .= " AND ff.fk_statut > 0";
$sql .= " AND ffd.product_type <= 2"; $sql .= " AND ffd.product_type <= 2";
$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/supplier/index.php'); dol_syslog('htdocs/accountancy/supplier/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr><td>'.$row[0].'</td>'; print '<tr><td>'.$row[0].'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
} }
print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>'; print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
print '</tr>'; print '</tr>';
} }
$db->free($resql); $db->free($resql);
} else { } else {
print $db->lasterror(); // Show last sql error print $db->lasterror(); // Show last sql error
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
} }
// End of page // End of page

View File

@ -94,7 +94,7 @@ $formaccounting = new FormAccounting($db);
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{ {
$search_societe = ''; $search_societe = '';
$search_lineid = ''; $search_lineid = '';
$search_ref = ''; $search_ref = '';
$search_invoice = ''; $search_invoice = '';
$search_label = ''; $search_label = '';
@ -196,7 +196,7 @@ if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
if ($search_lineid) { if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1); $sql .= natural_search("l.rowid", $search_lineid, 1);
} }
if (strlen(trim($search_invoice))) { if (strlen(trim($search_invoice))) {
$sql .= natural_search("f.ref", $search_invoice); $sql .= natural_search("f.ref", $search_invoice);
@ -250,13 +250,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -318,7 +318,7 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>'; print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>'; print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="' . dol_escape_htmltag($search_societe) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1); print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1);
// print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">'; // print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
@ -348,29 +348,29 @@ if ($result) {
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";
$thirdpartystatic = new Societe($db); $thirdpartystatic = new Societe($db);
$facturefournisseur_static = new FactureFournisseur($db); $facturefournisseur_static = new FactureFournisseur($db);
$productstatic = new ProductFournisseur($db); $productstatic = new ProductFournisseur($db);
$accountingaccountstatic = new AccountingAccount($db); $accountingaccountstatic = new AccountingAccount($db);
$i = 0; $i = 0;
while ($i < min($num_lines, $limit)) while ($i < min($num_lines, $limit))
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$facturefournisseur_static->ref = $objp->ref; $facturefournisseur_static->ref = $objp->ref;
$facturefournisseur_static->id = $objp->facid; $facturefournisseur_static->id = $objp->facid;
$thirdpartystatic->id = $objp->socid; $thirdpartystatic->id = $objp->socid;
$thirdpartystatic->name = $objp->name; $thirdpartystatic->name = $objp->name;
$thirdpartystatic->client = $objp->client; $thirdpartystatic->client = $objp->client;
$thirdpartystatic->fournisseur = $objp->fournisseur; $thirdpartystatic->fournisseur = $objp->fournisseur;
$thirdpartystatic->code_client = $objp->code_client; $thirdpartystatic->code_client = $objp->code_client;
$thirdpartystatic->code_compta_client = $objp->code_compta_client; $thirdpartystatic->code_compta_client = $objp->code_compta_client;
$thirdpartystatic->code_fournisseur = $objp->code_fournisseur; $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
$thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
$thirdpartystatic->email = $objp->email; $thirdpartystatic->email = $objp->email;
$thirdpartystatic->country_code = $objp->country_code; $thirdpartystatic->country_code = $objp->country_code;
$productstatic->ref = $objp->product_ref; $productstatic->ref = $objp->product_ref;
$productstatic->id = $objp->product_id; $productstatic->id = $objp->product_id;
@ -415,7 +415,7 @@ if ($result) {
print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>'; print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
// Thirdparty // Thirdparty
print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'supplier') . '</td>'; print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
// Country // Country
print '<td>'; print '<td>';
@ -428,7 +428,7 @@ if ($result) {
print '<td>'.$objp->tva_intra.'</td>'; print '<td>'.$objp->tva_intra.'</td>';
print '<td class="center">'; print '<td class="center">';
print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">'; print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
@ -437,14 +437,14 @@ if ($result) {
print '</tr>'; print '</tr>';
$i++; $i++;
} }
print '</table>'; print '</table>';
print "</div>"; print "</div>";
if ($nbtotalofrecords > $limit) { if ($nbtotalofrecords > $limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
} }
print '</form>'; print '</form>';
} else { } else {
print $db->lasterror(); print $db->lasterror();
} }

View File

@ -118,7 +118,7 @@ if (empty($reshook))
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{ {
$search_societe=''; $search_societe = '';
$search_lineid = ''; $search_lineid = '';
$search_ref = ''; $search_ref = '';
$search_invoice = ''; $search_invoice = '';
@ -385,7 +385,7 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>'; print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>'; print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="' . dol_escape_htmltag($search_societe) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1); print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1);
//print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">'; //print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
@ -419,7 +419,7 @@ if ($result) {
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";
$thirdpartystatic=new Societe($db); $thirdpartystatic = new Societe($db);
$facturefourn_static = new FactureFournisseur($db); $facturefourn_static = new FactureFournisseur($db);
$product_static = new Product($db); $product_static = new Product($db);
@ -569,7 +569,7 @@ if ($result) {
print '</td>'; print '</td>';
// Thirdparty // Thirdparty
print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'supplier') . '</td>'; print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
// Country // Country
print '<td>'; print '<td>';

View File

@ -47,15 +47,15 @@ $error = 0;
// Editing global variables not related to a specific theme // Editing global variables not related to a specific theme
$constantes = array( $constantes = array(
'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))), 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))),
'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member', 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member',
'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */ 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */
'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */ 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */
'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */ 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */
'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */ 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */
'ADHERENT_MAIL_FROM'=>'string', 'ADHERENT_MAIL_FROM'=>'string',
'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string', 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string',
'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html', 'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html',
); );
@ -66,16 +66,16 @@ $constantes = array(
// //
if ($action == 'updateall') { if ($action == 'updateall') {
$db->begin(); $db->begin();
$res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0;
$res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); $res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) {
setEventMessages('ErrorFailedToSaveDate', null, 'errors'); setEventMessages('ErrorFailedToSaveDate', null, 'errors');
$db->rollback(); $db->rollback();
} else { } else {
setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
$db->commit(); $db->commit();
} }
} }
// Action to update or add a constant // Action to update or add a constant

View File

@ -335,8 +335,8 @@ if (empty($reshook)) {
if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) {
setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
} else { } else {
// Create thumbs // Create thumbs
$object->addThumbs($newfile); $object->addThumbs($newfile);
} }
} }
} else { } else {
@ -354,8 +354,8 @@ if (empty($reshook)) {
} }
} }
$rowid = $object->id; $rowid = $object->id;
$id = $object->id; $id = $object->id;
$action = ''; $action = '';
if (!empty($backtopage)) { if (!empty($backtopage)) {
@ -402,7 +402,7 @@ if (empty($reshook)) {
// $skype=GETPOST("member_skype", 'alpha'); // $skype=GETPOST("member_skype", 'alpha');
// $twitter=GETPOST("member_twitter", 'alpha'); // $twitter=GETPOST("member_twitter", 'alpha');
// $facebook=GETPOST("member_facebook", 'alpha'); // $facebook=GETPOST("member_facebook", 'alpha');
// $linkedin=GETPOST("member_linkedin", 'alpha'); // $linkedin=GETPOST("member_linkedin", 'alpha');
$email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha'));
$login = GETPOST("member_login", 'alpha'); $login = GETPOST("member_login", 'alpha');
$pass = GETPOST("password", 'alpha'); $pass = GETPOST("password", 'alpha');
@ -755,7 +755,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($result <= 0) dol_print_error('', $object->error); if ($result <= 0) dol_print_error('', $object->error);
} }
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
$objcanvas->display_canvas($action); // Show template $objcanvas->display_canvas($action); // Show template
} else { } else {
// ----------------------------------------- // -----------------------------------------
// When used in standard mode // When used in standard mode
@ -778,16 +778,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$object->country = $tmparray['label']; $object->country = $tmparray['label'];
} }
if (!empty($socid)) { if (!empty($socid)) {
$object = new Societe($db); $object = new Societe($db);
if ($socid > 0) $object->fetch($socid); if ($socid > 0) $object->fetch($socid);
if (!($object->id > 0)) { if (!($object->id > 0)) {
$langs->load("errors"); $langs->load("errors");
print($langs->trans('ErrorRecordNotFound')); print($langs->trans('ErrorRecordNotFound'));
exit; exit;
} }
} }
$adht = new AdherentType($db); $adht = new AdherentType($db);
@ -829,7 +829,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<input type="hidden" name="socid" value="'.$socid.'">'; print '<input type="hidden" name="socid" value="'.$socid.'">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">'; if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
dol_fiche_head(''); dol_fiche_head('');
print '<table class="border centpercent">'; print '<table class="border centpercent">';
print '<tbody>'; print '<tbody>';
@ -934,14 +934,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<tr><td>'.$langs->trans("PhoneMobile").'</td>'; print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
print '<td>'.img_picto('', 'object_phoning_mobile').' <input type="text" name="phone_mobile" size="20" value="'.(GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td></tr>'; print '<td>'.img_picto('', 'object_phoning_mobile').' <input type="text" name="phone_mobile" size="20" value="'.(GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td></tr>';
if (!empty($conf->socialnetworks->enabled)) { if (!empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) { foreach ($socialnetworks as $key => $value) {
if (!$value['active']) break; if (!$value['active']) break;
print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="member_'.$key.'" size="40" value="'.(GETPOSTISSET('member_'.$key) ? GETPOST('member_'.$key, 'alpha') : $object->socialnetworks[$key]).'"></td></tr>'; print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="member_'.$key.'" size="40" value="'.(GETPOSTISSET('member_'.$key) ? GETPOST('member_'.$key, 'alpha') : $object->socialnetworks[$key]).'"></td></tr>';
} }
} }
// Birth Date // Birth Date
print "<tr><td>".$langs->trans("DateToBirth")."</td><td>\n"; print "<tr><td>".$langs->trans("DateToBirth")."</td><td>\n";
print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc'); print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
print "</td></tr>\n"; print "</td></tr>\n";
@ -1167,14 +1167,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<tr><td>'.$langs->trans("PhoneMobile").'</td>'; print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
print '<td>'.img_picto('', 'object_phoning_mobile').' <input type="text" name="phone_mobile" value="'.(GETPOSTISSET("phone_mobile") ? GETPOST("phone_mobile") : $object->phone_mobile).'"></td></tr>'; print '<td>'.img_picto('', 'object_phoning_mobile').' <input type="text" name="phone_mobile" value="'.(GETPOSTISSET("phone_mobile") ? GETPOST("phone_mobile") : $object->phone_mobile).'"></td></tr>';
if (!empty($conf->socialnetworks->enabled)) { if (!empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) { foreach ($socialnetworks as $key => $value) {
if (!$value['active']) break; if (!$value['active']) break;
print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="'.$key.'" class="minwidth100" value="'.(GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : $object->socialnetworks[$key]).'"></td></tr>'; print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="'.$key.'" class="minwidth100" value="'.(GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : $object->socialnetworks[$key]).'"></td></tr>';
} }
} }
// Birth Date // Birth Date
print "<tr><td>".$langs->trans("DateToBirth")."</td><td>\n"; print "<tr><td>".$langs->trans("DateToBirth")."</td><td>\n";
print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc'); print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
print "</td></tr>\n"; print "</td></tr>\n";
@ -1447,10 +1447,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
dol_banner_tab($object, 'rowid', $linkback); dol_banner_tab($object, 'rowid', $linkback);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield centpercent">'; print '<table class="border tableforfield centpercent">';
// Login // Login
@ -1483,13 +1483,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $object->pass); print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $object->pass);
if ($object->pass) print preg_replace('/./i', '*', $object->pass); if ($object->pass) print preg_replace('/./i', '*', $object->pass);
else { else {
if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted; if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
else print $langs->trans("Hidden"); else print $langs->trans("Hidden");
} }
if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) { if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) {
$langs->load("errors"); $langs->load("errors");
$htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); $htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); print ' '.$form->textwithpicto('', $htmltext, 1, 'warning');
} }
print '</td></tr>'; print '</td></tr>';
} }
@ -1503,8 +1503,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
} }
} else { } else {
if ($object->need_subscription == 0) { if ($object->need_subscription == 0) {
print $langs->trans("SubscriptionNotNeeded"); print $langs->trans("SubscriptionNotNeeded");
} elseif (!$adht->subscription) { } elseif (!$adht->subscription) {
print $langs->trans("SubscriptionNotRecorded"); print $langs->trans("SubscriptionNotRecorded");
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
} else { } else {
@ -1560,14 +1560,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
} }
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<div class="fichehalfright"><div class="ficheaddleft">'; print '<div class="fichehalfright"><div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield tableforfield" width="100%">'; print '<table class="border tableforfield tableforfield" width="100%">';
// Birth Date // Birth Date
print '<tr><td class="titlefield">'.$langs->trans("DateToBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("DateToBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
@ -1585,12 +1585,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
//VCard //VCard
print '<tr><td>'; print '<tr><td>';
print $langs->trans("VCard").'</td><td colspan="3">'; print $langs->trans("VCard").'</td><td colspan="3">';
print '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'">'; print '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'">';
print img_picto($langs->trans("Download"), 'vcard.png', 'class="paddingrightonly"'); print img_picto($langs->trans("Download"), 'vcard.png', 'class="paddingrightonly"');
print $langs->trans("Download"); print $langs->trans("Download");
print '</a>'; print '</a>';
print '</td></tr>'; print '</td></tr>';
// Other attributes // Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
@ -1598,9 +1598,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print "</table>\n"; print "</table>\n";
print "</div></div></div>\n"; print "</div></div></div>\n";
print '<div style="clear:both"></div>'; print '<div style="clear:both"></div>';
dol_fiche_end(); dol_fiche_end();
/* /*
@ -1769,7 +1769,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$morehtmlright .= '</a>'; $morehtmlright .= '</a>';
// List of actions on element // List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions = new FormActions($db); $formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', $MAX, '', $morehtmlright); $somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', $MAX, '', $morehtmlright);

View File

@ -62,26 +62,26 @@ class AdherentType extends CommonObject
public $libelle; public $libelle;
/** /**
* @var string Adherent type label * @var string Adherent type label
*/ */
public $label; public $label;
/** /**
* @var string Adherent type nature * @var string Adherent type nature
*/ */
public $morphy; public $morphy;
public $duration; public $duration;
/* /*
* type expiration * type expiration
*/ */
public $duration_value; public $duration_value;
/** /**
* Expiration unit * Expiration unit
*/ */
public $duration_unit; public $duration_unit;
/** /**
* @var int Subsription required (0 or 1) * @var int Subsription required (0 or 1)
@ -101,7 +101,7 @@ class AdherentType extends CommonObject
/** @var array Array of members */ /** @var array Array of members */
public $members = array(); public $members = array();
public $multilangs = array(); public $multilangs = array();
/** /**
@ -115,157 +115,157 @@ class AdherentType extends CommonObject
$this->status = 1; $this->status = 1;
} }
/** /**
* Load array this->multilangs * Load array this->multilangs
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function getMultiLangs() public function getMultiLangs()
{ {
global $langs; global $langs;
$current_lang = $langs->getDefaultLang(); $current_lang = $langs->getDefaultLang();
$sql = "SELECT lang, label, description, email"; $sql = "SELECT lang, label, description, email";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql .= " WHERE fk_type=".$this->id; $sql .= " WHERE fk_type=".$this->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
while ($obj = $this->db->fetch_object($result)) { while ($obj = $this->db->fetch_object($result)) {
//print 'lang='.$obj->lang.' current='.$current_lang.'<br>'; //print 'lang='.$obj->lang.' current='.$current_lang.'<br>';
if ($obj->lang == $current_lang) { // si on a les traduct. dans la langue courante on les charge en infos principales. if ($obj->lang == $current_lang) { // si on a les traduct. dans la langue courante on les charge en infos principales.
$this->label = $obj->label; $this->label = $obj->label;
$this->description = $obj->description; $this->description = $obj->description;
$this->email = $obj->email; $this->email = $obj->email;
} }
$this->multilangs["$obj->lang"]["label"] = $obj->label; $this->multilangs["$obj->lang"]["label"] = $obj->label;
$this->multilangs["$obj->lang"]["description"] = $obj->description; $this->multilangs["$obj->lang"]["description"] = $obj->description;
$this->multilangs["$obj->lang"]["email"] = $obj->email; $this->multilangs["$obj->lang"]["email"] = $obj->email;
} }
return 1; return 1;
} else { } else {
$this->error = "Error: ".$this->db->lasterror()." - ".$sql; $this->error = "Error: ".$this->db->lasterror()." - ".$sql;
return -1; return -1;
} }
} }
/** /**
* Update or add a translation for a product * Update or add a translation for a product
* *
* @param User $user Object user making update * @param User $user Object user making update
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function setMultiLangs($user) public function setMultiLangs($user)
{ {
global $conf, $langs; global $conf, $langs;
$langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2); $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2);
$current_lang = $langs->getDefaultLang(); $current_lang = $langs->getDefaultLang();
foreach ($langs_available as $key => $value) { foreach ($langs_available as $key => $value) {
if ($key == $current_lang) { if ($key == $current_lang) {
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql .= " WHERE fk_type=".$this->id; $sql .= " WHERE fk_type=".$this->id;
$sql .= " AND lang='".$key."'"; $sql .= " AND lang='".$key."'";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($this->db->num_rows($result)) { // if there is already a description line for this language if ($this->db->num_rows($result)) { // if there is already a description line for this language
$sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang"; $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
$sql2 .= " SET "; $sql2 .= " SET ";
$sql2 .= " label='".$this->db->escape($this->label)."',"; $sql2 .= " label='".$this->db->escape($this->label)."',";
$sql2 .= " description='".$this->db->escape($this->description)."'"; $sql2 .= " description='".$this->db->escape($this->description)."'";
$sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
} else { } else {
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
$sql2 .= ")"; $sql2 .= ")";
$sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',"; $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
$sql2 .= " '".$this->db->escape($this->description)."'"; $sql2 .= " '".$this->db->escape($this->description)."'";
$sql2 .= ")"; $sql2 .= ")";
} }
dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key); dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
if (!$this->db->query($sql2)) { if (!$this->db->query($sql2)) {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
return -1; return -1;
} }
} elseif (isset($this->multilangs[$key])) { } elseif (isset($this->multilangs[$key])) {
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql .= " WHERE fk_type=".$this->id; $sql .= " WHERE fk_type=".$this->id;
$sql .= " AND lang='".$key."'"; $sql .= " AND lang='".$key."'";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($this->db->num_rows($result)) { // if there is already a description line for this language if ($this->db->num_rows($result)) { // if there is already a description line for this language
$sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang"; $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
$sql2 .= " SET "; $sql2 .= " SET ";
$sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
$sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
} else { } else {
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
$sql2 .= ")"; $sql2 .= ")";
$sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',"; $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
$sql2 .= ")"; $sql2 .= ")";
} }
// We do not save if main fields are empty // We do not save if main fields are empty
if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) { if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
if (!$this->db->query($sql2)) { if (!$this->db->query($sql2)) {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
return -1; return -1;
} }
} }
} else { } else {
// language is not current language and we didn't provide a multilang description for this language // language is not current language and we didn't provide a multilang description for this language
} }
} }
// Call trigger // Call trigger
$result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user); $result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user);
if ($result < 0) { if ($result < 0) {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
return -1; return -1;
} }
// End call triggers // End call triggers
return 1; return 1;
} }
/** /**
* Delete a language for this product * Delete a language for this product
* *
* @param string $langtodelete Language code to delete * @param string $langtodelete Language code to delete
* @param User $user Object user making delete * @param User $user Object user making delete
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function delMultiLangs($langtodelete, $user) public function delMultiLangs($langtodelete, $user)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; $sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'";
dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG); dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
// Call trigger // Call trigger
$result = $this->call_trigger('ADHERENT_TYPE_DEL_MULTILANGS', $user); $result = $this->call_trigger('ADHERENT_TYPE_DEL_MULTILANGS', $user);
if ($result < 0) { if ($result < 0) {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
return -1; return -1;
} }
// End call triggers // End call triggers
return 1; return 1;
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
return -1; return -1;
} }
} }
/** /**
* Fonction qui permet de creer le status de l'adherent * Fonction qui permet de creer le status de l'adherent
@ -337,7 +337,7 @@ class AdherentType extends CommonObject
*/ */
public function update($user, $notrigger = 0) public function update($user, $notrigger = 0)
{ {
global $langs, $conf, $hookmanager; global $langs, $conf, $hookmanager;
$error = 0; $error = 0;
@ -359,15 +359,15 @@ class AdherentType extends CommonObject
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$this->description = $this->db->escape($this->note); $this->description = $this->db->escape($this->note);
// Multilangs // Multilangs
if (!empty($conf->global->MAIN_MULTILANGS)) { if (!empty($conf->global->MAIN_MULTILANGS)) {
if ($this->setMultiLangs($user) < 0) { if ($this->setMultiLangs($user) < 0) {
$this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
return -2; return -2;
} }
} }
$action = 'update'; $action = 'update';
@ -439,7 +439,7 @@ class AdherentType extends CommonObject
*/ */
public function fetch($rowid) public function fetch($rowid)
{ {
global $langs, $conf; global $langs, $conf;
$sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote"; $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
@ -465,10 +465,10 @@ class AdherentType extends CommonObject
$this->note = $obj->note; $this->note = $obj->note;
$this->vote = $obj->vote; $this->vote = $obj->vote;
// multilangs // multilangs
if (!empty($conf->global->MAIN_MULTILANGS)) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$this->getMultiLangs(); $this->getMultiLangs();
} }
} }
return 1; return 1;
@ -478,7 +478,7 @@ class AdherentType extends CommonObject
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of members' type * Return list of members' type
* *
@ -487,7 +487,7 @@ class AdherentType extends CommonObject
*/ */
public function liste_array($status = -1) public function liste_array($status = -1)
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs;
$adherenttypes = array(); $adherenttypes = array();
@ -578,31 +578,31 @@ class AdherentType extends CommonObject
//return $morphy; //return $morphy;
} }
/** /**
* Return clicable name (with picto eventually) * Return clicable name (with picto eventually)
* *
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param int $maxlen length max label * @param int $maxlen length max label
* @param int $notooltip 1=Disable tooltip * @param int $notooltip 1=Disable tooltip
* @return string String with URL * @return string String with URL
*/ */
public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0)
{ {
global $langs; global $langs;
$result = ''; $result = '';
$label = $langs->trans("ShowTypeCard", $this->label); $label = $langs->trans("ShowTypeCard", $this->label);
$linkstart = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkstart = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend = '</a>'; $linkend = '</a>';
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label); if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
$result .= $linkend; $result .= $linkend;
return $result; return $result;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
@ -611,7 +611,7 @@ class AdherentType extends CommonObject
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status * @return string Label of status
*/ */
public function getLibStatut($mode = 0) public function getLibStatut($mode = 0)
{ {
return $this->LibStatut($this->status, $mode); return $this->LibStatut($this->status, $mode);
} }
@ -623,9 +623,9 @@ class AdherentType extends CommonObject
* @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Status label * @return string Status label
*/ */
public function LibStatut($status, $mode = 0) public function LibStatut($status, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
$langs->load('companies'); $langs->load('companies');
@ -640,10 +640,10 @@ class AdherentType extends CommonObject
} }
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
* *
@ -655,7 +655,7 @@ class AdherentType extends CommonObject
*/ */
public function _load_ldap_dn($info, $mode = 0) public function _load_ldap_dn($info, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$dn = ''; $dn = '';
if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN; if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
@ -665,8 +665,8 @@ class AdherentType extends CommonObject
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Initialize the info array (array of LDAP values) that will be used to call LDAP functions * Initialize the info array (array of LDAP values) that will be used to call LDAP functions
* *
@ -674,7 +674,7 @@ class AdherentType extends CommonObject
*/ */
public function _load_ldap_info() public function _load_ldap_info()
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs;
$info = array(); $info = array();
@ -766,15 +766,15 @@ class AdherentType extends CommonObject
* *
* @return string Return mail model content of type or empty * @return string Return mail model content of type or empty
*/ */
public function getMailOnResiliate() public function getMailOnResiliate()
{ {
global $conf; global $conf;
// NOTE mail_resiliate not defined so never used // NOTE mail_resiliate not defined so never used
if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined
return $this->mail_resiliate; return $this->mail_resiliate;
} }
return ''; return '';
} }
} }

View File

@ -81,10 +81,10 @@ $extrafields->fetch_name_optionals_label($object->table_element);
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$search_lastname = ""; $search_lastname = "";
$search_login = ""; $search_login = "";
$search_email = ""; $search_email = "";
$type = ""; $type = "";
$sall = ""; $sall = "";
} }
@ -226,8 +226,8 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
$newcardbutton = ''; $newcardbutton = '';
if ($user->rights->adherent->configurer) { if ($user->rights->adherent->configurer) {
$newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create');
} }
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -247,7 +247,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Ref").'</th>'; print '<th>'.$langs->trans("Ref").'</th>';
print '<th>'.$langs->trans("Label").'</th>'; print '<th>'.$langs->trans("Label").'</th>';
print '<th class="center">'.$langs->trans("MemberNature").'</th>'; print '<th class="center">'.$langs->trans("MemberNature").'</th>';
print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>'; print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>';
print '<th class="center">'.$langs->trans("VoteAllowed").'</th>'; print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
print '<th class="center">'.$langs->trans("Status").'</th>'; print '<th class="center">'.$langs->trans("Status").'</th>';
@ -270,9 +270,9 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
//<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a> //<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a>
print '</td>'; print '</td>';
print '<td>'.dol_escape_htmltag($objp->label).'</td>'; print '<td>'.dol_escape_htmltag($objp->label).'</td>';
print '<td class="center">'; print '<td class="center">';
if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else print $langs->trans("MorPhy"); if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else print $langs->trans("MorPhy");
print '</td>'; print '</td>';
print '<td class="center">'.yn($objp->subscription).'</td>'; print '<td class="center">'.yn($objp->subscription).'</td>';
print '<td class="center">'.yn($objp->vote).'</td>'; print '<td class="center">'.yn($objp->vote).'</td>';
print '<td class="center">'.$membertype->getLibStatut(5).'</td>'; print '<td class="center">'.$membertype->getLibStatut(5).'</td>';
@ -308,7 +308,7 @@ if ($action == 'create') {
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
dol_fiche_head(''); dol_fiche_head('');
print '<table class="border centpercent">'; print '<table class="border centpercent">';
print '<tbody>'; print '<tbody>';
@ -319,10 +319,10 @@ if ($action == 'create') {
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1); print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1);
print '</td></tr>'; print '</td></tr>';
// Morphy // Morphy
$morphys = array(); $morphys = array();
$morphys[""] = $langs->trans("MorPhy"); $morphys[""] = $langs->trans("MorPhy");
$morphys["phy"] = $langs->trans("Physical"); $morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral"); $morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>'; print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy'); print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy');
@ -447,11 +447,11 @@ if ($rowid > 0) {
} }
// Add // Add
if ($user->rights->adherent->configurer && !empty($object->status)) { if ($user->rights->adherent->configurer && !empty($object->status)) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
} else { } else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoAddMember")).'">'.$langs->trans("AddMember").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoAddMember")).'">'.$langs->trans("AddMember").'</a></div>';
} }
// Delete // Delete
if ($user->rights->adherent->configurer) { if ($user->rights->adherent->configurer) {
@ -479,7 +479,7 @@ if ($rowid > 0) {
$sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall); $sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall);
} }
if ($status != '') { if ($status != '') {
$sql .= natural_search('d.statut', $status, 2); $sql .= natural_search('d.statut', $status, 2);
} }
if ($action == 'search') { if ($action == 'search') {
if (GETPOST('search', 'alpha')) { if (GETPOST('search', 'alpha')) {
@ -495,12 +495,12 @@ if ($rowid > 0) {
if (!empty($search_email)) { if (!empty($search_email)) {
$sql .= natural_search("d.email", $search_email); $sql .= natural_search("d.email", $search_email);
} }
if ($filter == 'uptodate') { if ($filter == 'uptodate') {
$sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)"; $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)";
} }
if ($filter == 'outofdate') { if ($filter == 'outofdate') {
$sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
} }
$sql .= " ".$db->order($sortfield, $sortorder); $sql .= " ".$db->order($sortfield, $sortorder);
@ -508,71 +508,71 @@ if ($rowid > 0) {
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) $nbtotalofrecords = $db->num_rows($result); if ($resql) $nbtotalofrecords = $db->num_rows($result);
else dol_print_error($db); else dol_print_error($db);
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= " ".$db->plimit($conf->liste_limit + 1, $offset); $sql .= " ".$db->plimit($conf->liste_limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$titre = $langs->trans("MembersList"); $titre = $langs->trans("MembersList");
if ($status != '') { if ($status != '') {
if ($status == '-1,1') { if ($status == '-1,1') {
$titre = $langs->trans("MembersListQualified"); $titre = $langs->trans("MembersListQualified");
} elseif ($status == '-1') { } elseif ($status == '-1') {
$titre = $langs->trans("MembersListToValid"); $titre = $langs->trans("MembersListToValid");
} elseif ($status == '1' && !$filter) { } elseif ($status == '1' && !$filter) {
$titre = $langs->trans("MembersListValid"); $titre = $langs->trans("MembersListValid");
} elseif ($status == '1' && $filter == 'uptodate') { } elseif ($status == '1' && $filter == 'uptodate') {
$titre = $langs->trans("MembersListUpToDate"); $titre = $langs->trans("MembersListUpToDate");
} elseif ($status == '1' && $filter == 'outofdate') { } elseif ($status == '1' && $filter == 'outofdate') {
$titre = $langs->trans("MembersListNotUpToDate"); $titre = $langs->trans("MembersListNotUpToDate");
} elseif ($status == '0') { } elseif ($status == '0') {
$titre = $langs->trans("MembersListResiliated"); $titre = $langs->trans("MembersListResiliated");
} }
} elseif ($action == 'search') { } elseif ($action == 'search') {
$titre = $langs->trans("MembersListQualified"); $titre = $langs->trans("MembersListQualified");
} }
if ($type > 0) { if ($type > 0) {
$membertype = new AdherentType($db); $membertype = new AdherentType($db);
$result = $membertype->fetch($type); $result = $membertype->fetch($type);
$titre .= " (".$membertype->label.")"; $titre .= " (".$membertype->label.")";
} }
$param = "&rowid=".$object->id; $param = "&rowid=".$object->id;
if (!empty($status)) $param .= "&status=".$status; if (!empty($status)) $param .= "&status=".$status;
if (!empty($search_lastname)) $param .= "&search_lastname=".$search_lastname; if (!empty($search_lastname)) $param .= "&search_lastname=".$search_lastname;
if (!empty($search_firstname)) $param .= "&search_firstname=".$search_firstname; if (!empty($search_firstname)) $param .= "&search_firstname=".$search_firstname;
if (!empty($search_login)) $param .= "&search_login=".$search_login; if (!empty($search_login)) $param .= "&search_login=".$search_login;
if (!empty($search_email)) $param .= "&search_email=".$search_email; if (!empty($search_email)) $param .= "&search_email=".$search_email;
if (!empty($filter)) $param .= "&filter=".$filter; if (!empty($filter)) $param .= "&filter=".$filter;
if ($sall) { if ($sall) {
print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
} }
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>'; print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>';
print '<br>'; print '<br>';
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
$moreforfilter = ''; $moreforfilter = '';
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Fields title search // Fields title search
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
@ -590,105 +590,105 @@ if ($rowid > 0) {
print '<td class="liste_titre right" colspan="2">'; print '<td class="liste_titre right" colspan="2">';
print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '&nbsp; '; print '&nbsp; ';
print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">'; print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
print "</tr>\n"; print "</tr>\n";
while ($i < $num && $i < $conf->liste_limit) { while ($i < $num && $i < $conf->liste_limit) {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$datefin = $db->jdate($objp->datefin); $datefin = $db->jdate($objp->datefin);
$adh = new Adherent($db); $adh = new Adherent($db);
$adh->lastname = $objp->lastname; $adh->lastname = $objp->lastname;
$adh->firstname = $objp->firstname; $adh->firstname = $objp->firstname;
// Lastname // Lastname
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if ($objp->company != '') { if ($objp->company != '') {
print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).'</a></td>'."\n"; print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).'</a></td>'."\n";
} else { } else {
print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n"; print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n";
} }
// Login // Login
print "<td>".$objp->login."</td>\n"; print "<td>".$objp->login."</td>\n";
// Type // Type
/*print '<td class="nowrap">'; /*print '<td class="nowrap">';
$membertypestatic->id=$objp->type_id; $membertypestatic->id=$objp->type_id;
$membertypestatic->label=$objp->type; $membertypestatic->label=$objp->type;
print $membertypestatic->getNomUrl(1,12); print $membertypestatic->getNomUrl(1,12);
print '</td>'; print '</td>';
*/ */
// Moral/Physique // Moral/Physique
print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n"; print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n";
// EMail // EMail
print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n"; print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n";
// Statut // Statut
print '<td class="nowrap">'; print '<td class="nowrap">';
print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2); print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2);
print "</td>"; print "</td>";
// Date end subscription // Date end subscription
if ($datefin) { if ($datefin) {
print '<td class="nowrap center">'; print '<td class="nowrap center">';
if ($datefin < dol_now() && $objp->status > 0) { if ($datefin < dol_now() && $objp->status > 0) {
print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate")); print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate"));
} else { } else {
print dol_print_date($datefin, 'day'); print dol_print_date($datefin, 'day');
} }
print '</td>'; print '</td>';
} else { } else {
print '<td class="nowrap left">'; print '<td class="nowrap left">';
if ($objp->subscription == 'yes') { if ($objp->subscription == 'yes') {
print $langs->trans("SubscriptionNotReceived"); print $langs->trans("SubscriptionNotReceived");
if ($objp->status > 0) print " ".img_warning(); if ($objp->status > 0) print " ".img_warning();
} else { } else {
print '&nbsp;'; print '&nbsp;';
} }
print '</td>'; print '</td>';
} }
// Actions // Actions
print '<td class="center">'; print '<td class="center">';
if ($user->rights->adherent->creer) { if ($user->rights->adherent->creer) {
print '<a class="editfielda" href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>'; print '<a class="editfielda" href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>';
} }
print '&nbsp;'; print '&nbsp;';
if ($user->rights->adherent->supprimer) { if ($user->rights->adherent->supprimer) {
print '<a href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"), 'disable.png').'</a>'; print '<a href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"), 'disable.png').'</a>';
} }
print "</td>"; print "</td>";
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
print '</form>'; print '</form>';
if ($num > $conf->liste_limit) { if ($num > $conf->liste_limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
@ -719,18 +719,18 @@ if ($rowid > 0) {
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>'; print '<tr><td>'.$langs->trans("Status").'</td><td>';
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status); print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status);
print '</td></tr>'; print '</td></tr>';
// Morphy // Morphy
$morphys[""] = $langs->trans("MorPhy"); $morphys[""] = $langs->trans("MorPhy");
$morphys["phy"] = $langs->trans("Physical"); $morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral"); $morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>'; print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy); print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy);
print "</td></tr>"; print "</td></tr>";
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>'; print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
print $form->selectyesno("subscription", $object->subscription, 1); print $form->selectyesno("subscription", $object->subscription, 1);
print '</td></tr>'; print '</td></tr>';

View File

@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
$langs->loadLangs(array("admin", "companies", "bills", "other", "banks")); $langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$actionsave = GETPOST('save', 'alpha'); $actionsave = GETPOST('save', 'alpha');
@ -240,31 +240,31 @@ $i = 0;
$nbofbank = count($bankorder); $nbofbank = count($bankorder);
while ($i < $nbofbank) { while ($i < $nbofbank) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$bankorder[$i][0]."</td><td>\n"; print '<td>'.$bankorder[$i][0]."</td><td>\n";
print $bankorder[$i][1]; print $bankorder[$i][1];
print '</td>'; print '</td>';
print '<td class="nowrap">'; print '<td class="nowrap">';
$tmparray = explode(' ', $bankorder[$i][2]); $tmparray = explode(' ', $bankorder[$i][2]);
foreach ($tmparray as $key => $val) { foreach ($tmparray as $key => $val) {
if ($key > 0) if ($key > 0)
print ', '; print ', ';
print $langs->trans($val); print $langs->trans($val);
} }
print "</td>\n"; print "</td>\n";
if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) { if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) {
print '<td class="center">'; print '<td class="center">';
print img_picto($langs->trans("Activated"), 'on'); print img_picto($langs->trans("Activated"), 'on');
print '</td>'; print '</td>';
} else { } else {
print '<td class="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setbankorder&amp;value='.$i.'">'; print '<td class="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setbankorder&amp;value='.$i.'">';
print img_picto($langs->trans("Disabled"), 'off'); print img_picto($langs->trans("Disabled"), 'off');
print '</a></td>'; print '</a></td>';
} }
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'."\n"; print '</tr>'."\n";
$i++; $i++;
} }
print '</table>'."\n"; print '</table>'."\n";
@ -287,15 +287,15 @@ $sql .= " WHERE type = '".$type."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) { while ($i < $num_rows) {
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
print "<table class=\"noborder\" width=\"100%\">\n"; print "<table class=\"noborder\" width=\"100%\">\n";
@ -311,100 +311,100 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) { foreach ($dirmodels as $reldir) {
foreach (array('', '/doc') as $valdir) { foreach (array('', '/doc') as $valdir) {
$dir = dol_buildpath($reldir."core/modules/bank".$valdir); $dir = dol_buildpath($reldir."core/modules/bank".$valdir);
if (is_dir($dir)) { if (is_dir($dir)) {
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) { if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) { while (($file = readdir($handle)) !== false) {
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) { foreach ($filelist as $file) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (file_exists($dir.'/'.$file)) { if (file_exists($dir.'/'.$file)) {
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
$modulequalified = 0; $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
$modulequalified = 0; $modulequalified = 0;
if ($modulequalified) { if ($modulequalified) {
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print(empty($module->name) ? $name : $module->name); print(empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) if (method_exists($module, 'info'))
print $module->info($langs); print $module->info($langs);
else print $module->description; else print $module->description;
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) { if (in_array($name, $def)) {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} else { } else {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->BANKADDON_PDF == $name) { if ($conf->global->BANKADDON_PDF == $name) {
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} }
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') { if ($module->type == 'pdf') {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
//$htmltooltip .= '<br>' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1); //$htmltooltip .= '<br>' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1);
//$htmltooltip .= '<br>' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1); //$htmltooltip .= '<br>' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
// $htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); // $htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
// $htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); // $htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
//$htmltooltip .= '<br>' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); //$htmltooltip .= '<br>' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1);
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>'; print '</td>';
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') { if ($module->type == 'pdf') {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
} }
} }
} }
} }
} }
} }
print '</table>'; print '</table>';
//} //}
@ -423,38 +423,38 @@ print $langs->trans('BankColorizeMovementDesc');
print "</td>"; print "</td>";
// Active // Active
if ($conf->global->BANK_COLORIZE_MOVEMENT) { if ($conf->global->BANK_COLORIZE_MOVEMENT) {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetbankcolorizemovement">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetbankcolorizemovement">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} else { } else {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setbankcolorizemovement">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setbankcolorizemovement">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>"; print "</td>";
} }
print "</tr>\n"; print "</tr>\n";
if (!empty($conf->global->BANK_COLORIZE_MOVEMENT)) if (!empty($conf->global->BANK_COLORIZE_MOVEMENT))
{ {
$i = 1; $i = 1;
while ($i <= 2) while ($i <= 2)
{ {
$key = $i; $key = $i;
$color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key; $color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Label // Label
print '<td colspan="4" width="180" class="nowrap">'.$langs->trans("BankColorizeMovementName".$key)."</td>"; print '<td colspan="4" width="180" class="nowrap">'.$langs->trans("BankColorizeMovementName".$key)."</td>";
// Color // Color
print '<td class="nowrap right">'; print '<td class="nowrap right">';
print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset'); print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset');
print '</td>'; print '</td>';
print "</tr>"; print "</tr>";
$i++; $i++;
} }
} }
print '</table>'; print '</table>';
@ -482,15 +482,15 @@ print $langs->trans('AutoReportLastAccountStatement');
print '</td>'; print '</td>';
// Active // Active
if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetreportlastnumreleve">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetreportlastnumreleve">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} else { } else {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setreportlastnumreleve">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setreportlastnumreleve">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>"; print "</td>";
} }
print "</tr>\n"; print "</tr>\n";

View File

@ -55,11 +55,11 @@ if ($action == 'updateMask')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') } elseif ($action == 'specimen')
{ {
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
@ -72,7 +72,7 @@ if ($action == 'updateMask')
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound = 1; $filefound = 1;
@ -110,7 +110,7 @@ elseif ($action == 'set')
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0)
{ {
if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity); if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity);
} }
} }
@ -144,11 +144,11 @@ elseif ($action == 'setdoc')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_BOM_FREE_TEXT') } elseif ($action == 'set_BOM_FREE_TEXT')
{ {
$freetext = GETPOST("BOM_FREE_TEXT", 'none'); // No alpha here, we want exact string $freetext = GETPOST("BOM_FREE_TEXT", 'none'); // No alpha here, we want exact string
@ -158,11 +158,11 @@ elseif ($action == 'setdoc')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
@ -211,7 +211,7 @@ foreach ($dirmodels as $reldir)
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php') if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{ {
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
@ -229,13 +229,13 @@ foreach ($dirmodels as $reldir)
print $module->info(); print $module->info();
print '</td>'; print '</td>';
// Show example of numbering model // Show example of numbering model
print '<td class="nowrap">'; print '<td class="nowrap">';
$tmp = $module->getExample(); $tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->BOM_ADDON == $file) if ($conf->global->BOM_ADDON == $file)
@ -256,16 +256,16 @@ foreach ($dirmodels as $reldir)
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$bom->type = 0; $bom->type = 0;
$nextval = $module->getNextValue($mysoc, $bom); $nextval = $module->getNextValue($mysoc, $bom);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
} }
} }
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
@ -324,108 +324,108 @@ clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
foreach (array('', '/doc') as $valdir) foreach (array('', '/doc') as $valdir)
{ {
$realpath = $reldir."core/modules/bom".$valdir; $realpath = $reldir."core/modules/bom".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file)
{ {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{ {
if (file_exists($dir.'/'.$file)) if (file_exists($dir.'/'.$file))
{ {
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified) if ($modulequalified)
{ {
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description; else print $module->description;
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} else { } else {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->BOM_ADDON_PDF == $name) if ($conf->global->BOM_ADDON_PDF == $name)
{ {
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} }
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1); $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>'; print '</td>';
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
} }
} }
} }
} }
} }
} }
print '</table>'; print '</table>';
@ -457,11 +457,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("
$variablename = 'BOM_FREE_TEXT'; $variablename = 'BOM_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{ {
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create(); print $doleditor->Create();
} }
print '</td><td class="right">'; print '</td><td class="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';

View File

@ -48,99 +48,99 @@ $boxes = array();
if ($action == 'addconst') if ($action == 'addconst')
{ {
dolibarr_set_const($db, "MAIN_BOXES_MAXLINES", $_POST["MAIN_BOXES_MAXLINES"], '', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_BOXES_MAXLINES", $_POST["MAIN_BOXES_MAXLINES"], '', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_ACTIVATE_FILECACHE", $_POST["MAIN_ACTIVATE_FILECACHE"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_ACTIVATE_FILECACHE", $_POST["MAIN_ACTIVATE_FILECACHE"], 'chaine', 0, '', $conf->entity);
} }
if ($action == 'add') { if ($action == 'add') {
$error = 0; $error = 0;
$db->begin(); $db->begin();
if (isset($_POST['boxid']) && is_array($_POST['boxid'])) if (isset($_POST['boxid']) && is_array($_POST['boxid']))
{ {
foreach ($_POST['boxid'] as $boxid) foreach ($_POST['boxid'] as $boxid)
{ {
if (is_numeric($boxid['pos']) && $boxid['pos'] >= 0) // 0=Home, 1=... if (is_numeric($boxid['pos']) && $boxid['pos'] >= 0) // 0=Home, 1=...
{ {
$pos = $boxid['pos']; $pos = $boxid['pos'];
// Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos") // Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos")
$distinctfkuser = array(); $distinctfkuser = array();
if (!$error) if (!$error)
{ {
$sql = "SELECT fk_user"; $sql = "SELECT fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."user_param"; $sql .= " FROM ".MAIN_DB_PREFIX."user_param";
$sql .= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'"; $sql .= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG); dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$distinctfkuser[$obj->fk_user] = $obj->fk_user; $distinctfkuser[$obj->fk_user] = $obj->fk_user;
$i++; $i++;
} }
} else { } else {
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
$error++; $error++;
} }
} }
$distinctfkuser['0'] = '0'; // Add entry for fk_user = 0. We must use string as key and val $distinctfkuser['0'] = '0'; // Add entry for fk_user = 0. We must use string as key and val
foreach ($distinctfkuser as $fk_user) foreach ($distinctfkuser as $fk_user)
{ {
if (!$error && $fk_user != '') if (!$error && $fk_user != '')
{ {
$arrayofexistingboxid = array(); $arrayofexistingboxid = array();
$nbboxonleft = $nbboxonright = 0; $nbboxonleft = $nbboxonright = 0;
$sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes"; $sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes";
$sql .= " WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity; $sql .= " WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity;
dol_syslog("boxes.php activate box", LOG_DEBUG); dol_syslog("boxes.php activate box", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
while ($obj = $db->fetch_object($resql)) while ($obj = $db->fetch_object($resql))
{ {
$boxorder = $obj->box_order; $boxorder = $obj->box_order;
if (preg_match('/A/', $boxorder)) $nbboxonleft++; if (preg_match('/A/', $boxorder)) $nbboxonleft++;
if (preg_match('/B/', $boxorder)) $nbboxonright++; if (preg_match('/B/', $boxorder)) $nbboxonright++;
$arrayofexistingboxid[$obj->box_id] = 1; $arrayofexistingboxid[$obj->box_id] = 1;
} }
} else dol_print_error($db); } else dol_print_error($db);
if (empty($arrayofexistingboxid[$boxid['value']])) { if (empty($arrayofexistingboxid[$boxid['value']])) {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
$sql .= "box_id, position, box_order, fk_user, entity"; $sql .= "box_id, position, box_order, fk_user, entity";
$sql .= ") values ("; $sql .= ") values (";
$sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity; $sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity;
$sql .= ")"; $sql .= ")";
dol_syslog("boxes.php activate box", LOG_DEBUG); dol_syslog("boxes.php activate box", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) if (!$resql)
{ {
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
$error++; $error++;
} }
} else { } else {
dol_syslog("boxes.php activate box - already exists in database", LOG_DEBUG); dol_syslog("boxes.php activate box - already exists in database", LOG_DEBUG);
} }
} }
} }
} }
} }
} }
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
$action = ''; $action = '';
} else { } else {
$db->rollback(); $db->rollback();
} }
} }
if ($action == 'delete') if ($action == 'delete')
@ -150,23 +150,23 @@ if ($action == 'delete')
$resql = $db->query($sql); $resql = $db->query($sql);
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (!empty($obj->box_id)) if (!empty($obj->box_id))
{ {
$db->begin(); $db->begin();
// Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes) // Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes)
// $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; // $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
// $sql.= " WHERE param LIKE 'MAIN_BOXES_%'"; // $sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
// $resql = $db->query($sql); // $resql = $db->query($sql);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
$sql .= " WHERE entity = ".$conf->entity; $sql .= " WHERE entity = ".$conf->entity;
$sql .= " AND box_id=".$obj->box_id; $sql .= " AND box_id=".$obj->box_id;
$resql = $db->query($sql); $resql = $db->query($sql);
$db->commit(); $db->commit();
} }
} }
if ($action == 'switch') if ($action == 'switch')
@ -184,14 +184,14 @@ if ($action == 'switch')
$resultupdateto = 0; $resultupdateto = 0;
if (is_object($objfrom) && is_object($objto)) if (is_object($objfrom) && is_object($objto))
{ {
$newfirst = $objto->box_order; $newfirst = $objto->box_order;
$newsecond = $objfrom->box_order; $newsecond = $objfrom->box_order;
if ($newfirst == $newsecond) if ($newfirst == $newsecond)
{ {
$newsecondchar = preg_replace('/[0-9]+/', '', $newsecond); $newsecondchar = preg_replace('/[0-9]+/', '', $newsecond);
$newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond); $newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond);
$newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1); $newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1);
} }
$sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$newfirst."' WHERE rowid=".$objfrom->rowid; $sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$newfirst."' WHERE rowid=".$objfrom->rowid;
dol_syslog($sql); dol_syslog($sql);
$resultupdatefrom = $db->query($sql); $resultupdatefrom = $db->query($sql);
@ -268,7 +268,7 @@ if ($resql)
if ($decalage) if ($decalage)
{ {
// If we have renumbered, we correct the field box_order // If we have renumbered, we correct the field box_order
// This occurs just after an insert. // This occurs just after an insert.
$sql = "SELECT box_order"; $sql = "SELECT box_order";
$sql .= " FROM ".MAIN_DB_PREFIX."boxes"; $sql .= " FROM ".MAIN_DB_PREFIX."boxes";
@ -339,34 +339,34 @@ print "</tr>\n";
foreach ($boxtoadd as $box) foreach ($boxtoadd as $box)
{ {
if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg)) if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg))
{ {
$logo = $box->boximg; $logo = $box->boximg;
} else { } else {
$logo = preg_replace("/^object_/i", "", $box->boximg); $logo = preg_replace("/^object_/i", "", $box->boximg);
} }
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n"; print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
print '<td>'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel); print '<td>'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel);
if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')'; if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
print '</td>'."\n"; print '</td>'."\n";
print '<td>'; print '<td>';
if ($box->note == '(WarningUsingThisBoxSlowDown)') if ($box->note == '(WarningUsingThisBoxSlowDown)')
{ {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("WarningUsingThisBoxSlowDown"); print $langs->trans("WarningUsingThisBoxSlowDown");
} else print ($box->note ? $box->note : '&nbsp;'); } else print ($box->note ? $box->note : '&nbsp;');
print '</td>'."\n"; print '</td>'."\n";
print '<td>'.$box->sourcefile.'</td>'."\n"; print '<td>'.$box->sourcefile.'</td>'."\n";
// For each possible position, an activation link is displayed if the box is not already active for that position // For each possible position, an activation link is displayed if the box is not already active for that position
print '<td class="center">'; print '<td class="center">';
print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, -1, 1, 0, 0, '', 1)."\n"; print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, -1, 1, 0, 0, '', 1)."\n";
print '<input type="hidden" name="boxid['.$box->box_id.'][value]" value="'.$box->box_id.'">'."\n"; print '<input type="hidden" name="boxid['.$box->box_id.'][value]" value="'.$box->box_id.'">'."\n";
print '</td>'; print '</td>';
print '</tr>'."\n"; print '</tr>'."\n";
} }
if (!count($boxtoadd) && count($boxactivated)) if (!count($boxtoadd) && count($boxactivated))
{ {
@ -408,7 +408,7 @@ foreach ($boxactivated as $key => $box)
$logo = preg_replace("/^object_/i", "", $box->boximg); $logo = preg_replace("/^object_/i", "", $box->boximg);
} }
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n"; print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel); print '<td>'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel);
if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')'; if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
@ -465,10 +465,10 @@ print '</tr>';
// Activate FileCache - Developement // Activate FileCache - Developement
if ($conf->global->MAIN_FEATURES_LEVEL == 2 || !empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { if ($conf->global->MAIN_FEATURES_LEVEL == 2 || !empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
print '<tr class="oddeven"><td width="35%">'.$langs->trans("EnableFileCache").'</td><td>'; print '<tr class="oddeven"><td width="35%">'.$langs->trans("EnableFileCache").'</td><td>';
print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1); print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>';

View File

@ -64,11 +64,11 @@ if ($action == 'updateMask')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') } elseif ($action == 'specimen')
{ {
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
@ -81,7 +81,7 @@ if ($action == 'updateMask')
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound = 1; $filefound = 1;
@ -119,7 +119,7 @@ elseif ($action == 'set')
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0)
{ {
if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity); if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity);
} }
} }
@ -153,11 +153,11 @@ elseif ($action == 'setdoc')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_ORDER_FREE_TEXT') } elseif ($action == 'set_ORDER_FREE_TEXT')
{ {
$freetext = GETPOST("ORDER_FREE_TEXT", 'none'); // No alpha here, we want exact string $freetext = GETPOST("ORDER_FREE_TEXT", 'none'); // No alpha here, we want exact string
@ -167,21 +167,21 @@ elseif ($action == 'setdoc')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == "setshippableiconinlist") { } elseif ($action == "setshippableiconinlist") {
// Activate Set Shippable Icon In List // Activate Set Shippable Icon In List
$setshippableiconinlist = GETPOST('value', 'int'); $setshippableiconinlist = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'setribchq') } elseif ($action == 'setribchq')
{ {
$rib = GETPOST('rib', 'alpha'); $rib = GETPOST('rib', 'alpha');
@ -203,31 +203,31 @@ elseif ($action == 'setdoc')
// Activate ask for payment bank // Activate ask for payment bank
elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER')
{ {
$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
// Activate ask for warehouse // Activate ask for warehouse
elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
{ {
$res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
@ -294,13 +294,13 @@ foreach ($dirmodels as $reldir)
print $module->info(); print $module->info();
print '</td>'; print '</td>';
// Show example of numbering model // Show example of numbering model
print '<td class="nowrap">'; print '<td class="nowrap">';
$tmp = $module->getExample(); $tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->COMMANDE_ADDON == $file) if ($conf->global->COMMANDE_ADDON == $file)
@ -321,16 +321,16 @@ foreach ($dirmodels as $reldir)
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$commande->type = 0; $commande->type = 0;
$nextval = $module->getNextValue($mysoc, $commande); $nextval = $module->getNextValue($mysoc, $commande);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
} }
} }
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
@ -389,113 +389,113 @@ clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
foreach (array('', '/doc') as $valdir) foreach (array('', '/doc') as $valdir)
{ {
$realpath = $reldir."core/modules/commande".$valdir; $realpath = $reldir."core/modules/commande".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file)
{ {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{ {
if (file_exists($dir.'/'.$file)) if (file_exists($dir.'/'.$file))
{ {
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified) if ($modulequalified)
{ {
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description; else print $module->description;
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} else { } else {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->COMMANDE_ADDON_PDF == $name) if ($conf->global->COMMANDE_ADDON_PDF == $name)
{ {
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} }
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
//$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); //$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
//$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); //$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>'; print '</td>';
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
} }
} }
} }
} }
} }
} }
print '</table>'; print '</table>';
@ -636,11 +636,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans
$variablename = 'ORDER_FREE_TEXT'; $variablename = 'ORDER_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{ {
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create(); print $doleditor->Create();
} }
print '</td><td class="right">'; print '</td><td class="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';

View File

@ -109,7 +109,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
foreach ($arrayofimages as $varforimage) foreach ($arrayofimages as $varforimage)
{ {
if ($_FILES[$varforimage]["name"] && ! preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported. if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported.
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors'); setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
break; break;

View File

@ -41,7 +41,7 @@ $type = 'contract';
if (empty($conf->global->CONTRACT_ADDON)) if (empty($conf->global->CONTRACT_ADDON))
{ {
$conf->global->CONTRACT_ADDON = 'mod_contract_serpis'; $conf->global->CONTRACT_ADDON = 'mod_contract_serpis';
} }
@ -53,18 +53,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconst = GETPOST('maskconstcontract', 'alpha'); $maskconst = GETPOST('maskconstcontract', 'alpha');
$maskvalue = GETPOST('maskcontract', 'alpha'); $maskvalue = GETPOST('maskcontract', 'alpha');
if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') // For contract } elseif ($action == 'specimen') // For contract
{ {
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
@ -77,7 +77,7 @@ if ($action == 'updateMask')
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound = 1; $filefound = 1;
@ -115,7 +115,7 @@ elseif ($action == 'set')
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0)
{ {
if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity); if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity);
} }
} }
@ -149,17 +149,17 @@ elseif ($action == 'setdoc')
$draft = GETPOST('CONTRACT_DRAFT_WATERMARK', 'alpha'); $draft = GETPOST('CONTRACT_DRAFT_WATERMARK', 'alpha');
$res2 = dolibarr_set_const($db, "CONTRACT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res2 = dolibarr_set_const($db, "CONTRACT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
$value = GETPOST('activate_hideClosedServiceByDefault', 'alpha'); $value = GETPOST('activate_hideClosedServiceByDefault', 'alpha');
$res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity); $res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity);
if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) $error++; if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
@ -251,16 +251,16 @@ foreach ($dirmodels as $reldir)
$htmltooltip = ''; $htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval = $module->getNextValue($mysoc, $contract); $nextval = $module->getNextValue($mysoc, $contract);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
} }
} }
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
@ -319,111 +319,111 @@ clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
foreach (array('', '/doc') as $valdir) foreach (array('', '/doc') as $valdir)
{ {
$realpath = $reldir."core/modules/contract".$valdir; $realpath = $reldir."core/modules/contract".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file)
{ {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{ {
if (file_exists($dir.'/'.$file)) if (file_exists($dir.'/'.$file))
{ {
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified) if ($modulequalified)
{ {
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description; else print $module->description;
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} else { } else {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Defaut // Defaut
print '<td class="center">'; print '<td class="center">';
if ($conf->global->CONTRACT_ADDON_PDF == $name) if ($conf->global->CONTRACT_ADDON_PDF == $name)
{ {
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} }
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>'; print '</td>';
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
} }
} }
} }
} }
} }
} }
print '</table>'; print '</table>';
@ -457,11 +457,11 @@ print '<br>';
$variablename = 'CONTRACT_FREE_TEXT'; $variablename = 'CONTRACT_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{ {
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create(); print $doleditor->Create();
} }
print '</td></tr>'."\n"; print '</td></tr>'."\n";

View File

@ -165,19 +165,19 @@ if (GETPOST('addoperation', 'alpha'))
if ($action == 'updateoperation') if ($action == 'updateoperation')
{ {
$emailcollectoroperation = new EmailCollectorAction($db); $emailcollectoroperation = new EmailCollectorAction($db);
$emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int')); $emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int'));
$emailcollectoroperation->actionparam = GETPOST('operationparam2', 'none'); $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'none');
$result = $emailcollectoroperation->update($user); $result = $emailcollectoroperation->update($user);
if ($result > 0) if ($result > 0)
{ {
$object->fetchActions(); $object->fetchActions();
} else { } else {
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
} }
} }
if ($action == 'deleteoperation') if ($action == 'deleteoperation')
{ {
@ -199,11 +199,11 @@ if ($action == 'confirm_collect')
$res = $object->doCollectOneCollector(); $res = $object->doCollectOneCollector();
if ($res > 0) if ($res > 0)
{ {
$debuginfo = $object->debuginfo; $debuginfo = $object->debuginfo;
setEventMessages($object->lastresult, null, 'mesgs'); setEventMessages($object->lastresult, null, 'mesgs');
} else { } else {
$debuginfo = $object->debuginfo; $debuginfo = $object->debuginfo;
setEventMessages($object->error, null, 'errors'); setEventMessages($object->error, null, 'errors');
} }
$action = ''; $action = '';
@ -475,27 +475,27 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
$arrayoftypes = array( $arrayoftypes = array(
'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')), 'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')),
'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')), 'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')),
'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')), 'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')),
'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')), 'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')),
'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')), 'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')),
'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')), 'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')),
// disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2 // disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2
//'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'), // HEADER key value //'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'), // HEADER key value
//'X1'=>'---', //'X1'=>'---',
//'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'), //'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'),
//'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'), //'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'),
'X2'=>'---', 'X2'=>'---',
'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1), 'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1),
'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1), 'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1),
'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1), 'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1),
'answered'=>array('label'=>'Answered', 'data-noparam'=>1), 'answered'=>array('label'=>'Answered', 'data-noparam'=>1),
'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), 'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')),
'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), 'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')),
'X3'=>'---', 'X3'=>'---',
'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1), 'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1),
'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1), 'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1),
'X4'=>'---', 'X4'=>'---',
'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1), 'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1),
'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1) 'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1)
@ -559,9 +559,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
$arrayoftypes = array( $arrayoftypes = array(
'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")), 'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")), 'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
'recordevent'=>'RecordEvent'); 'recordevent'=>'RecordEvent');
if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty'; if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty';
if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty'; if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty';
if ($conf->recruitment->enabled) $arrayoftypes['candidature'] = 'CreateCandidature'; if ($conf->recruitment->enabled) $arrayoftypes['candidature'] = 'CreateCandidature';
@ -602,7 +602,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print $langs->trans($arrayoftypes[$ruleaction['type']]); print $langs->trans($arrayoftypes[$ruleaction['type']]);
if (in_array($ruleaction['type'], array('recordevent'))) if (in_array($ruleaction['type'], array('recordevent')))
{ {
print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked')); print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked'));
} elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) { } elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) {
print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp')); print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp'));
} }
@ -610,11 +610,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td class="wordbreak">'; print '<td class="wordbreak">';
if ($action == 'editoperation' && $ruleaction['id'] == $operationid) if ($action == 'editoperation' && $ruleaction['id'] == $operationid)
{ {
print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>'; print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>';
print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'"><br>'; print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'"><br>';
print '<input type="submit" class="button" name="saveoperation2" value="'.$langs->trans("Save").'"> <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="saveoperation2" value="'.$langs->trans("Save").'"> <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
} else { } else {
print $ruleaction['actionparam']; print $ruleaction['actionparam'];
} }
print '</td>'; print '</td>';
// Move up/down // Move up/down
@ -641,7 +641,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</div>'; print '</div>';
if (!empty($conf->use_javascript_ajax)) { if (!empty($conf->use_javascript_ajax)) {
$urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id; $urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id;
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
} }
@ -668,7 +668,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Edit").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Edit").'</a></div>';
// Clone // Clone
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a></div>';
// Collect now // Collect now
if (count($object->actions) > 0) { if (count($object->actions) > 0) {
@ -684,7 +684,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (!empty($debuginfo)) if (!empty($debuginfo))
{ {
print info_admin($debuginfo); print info_admin($debuginfo);
} }

View File

@ -48,7 +48,7 @@ $type = 'shipping';
if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
{ {
$conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor'; $conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor';
} }
@ -105,7 +105,7 @@ if ($action == 'updateMask')
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound = 1; $filefound = 1;
@ -143,7 +143,7 @@ elseif ($action == 'set')
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0)
{ {
if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity); if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity);
} }
} }
@ -231,14 +231,14 @@ foreach ($dirmodels as $reldir)
print $module->info(); print $module->info();
print '</td>'; print '</td>';
// Show example of numbering module // Show example of numbering module
print '<td class="nowrap">'; print '<td class="nowrap">';
$tmp = $module->getExample(); $tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file") if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file")
@ -258,16 +258,16 @@ foreach ($dirmodels as $reldir)
$htmltooltip = ''; $htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval = $module->getNextValue($mysoc, $expedition); $nextval = $module->getNextValue($mysoc, $expedition);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
} }
} }
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
@ -328,107 +328,107 @@ clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
foreach (array('', '/doc') as $valdir) foreach (array('', '/doc') as $valdir)
{ {
$dir = dol_buildpath($reldir."core/modules/expedition".$valdir); $dir = dol_buildpath($reldir."core/modules/expedition".$valdir);
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file)
{ {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{ {
if (file_exists($dir.'/'.$file)) if (file_exists($dir.'/'.$file))
{ {
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified) if ($modulequalified)
{ {
print '<tr><td width="100">'; print '<tr><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description; else print $module->description;
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} else { } else {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Defaut // Defaut
print '<td class="center">'; print '<td class="center">';
if ($conf->global->EXPEDITION_ADDON_PDF == $name) if ($conf->global->EXPEDITION_ADDON_PDF == $name)
{ {
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} }
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>'; print '</td>';
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'sending').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'sending').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
} }
} }
} }
} }
} }
} }
print '</table>'; print '</table>';
@ -461,11 +461,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->tr
$variablename = 'SHIPPING_FREE_TEXT'; $variablename = 'SHIPPING_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{ {
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create(); print $doleditor->Create();
} }
print "</td></tr>\n"; print "</td></tr>\n";

View File

@ -53,66 +53,66 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha');
$maskconstreplacement = GETPOST('maskconstreplacement', 'alpha'); $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha');
$maskconstcredit = GETPOST('maskconstcredit', 'alpha'); $maskconstcredit = GETPOST('maskconstcredit', 'alpha');
$maskconstdeposit = GETPOST('maskconstdeposit', 'alpha'); $maskconstdeposit = GETPOST('maskconstdeposit', 'alpha');
$maskinvoice = GETPOST('maskinvoice', 'alpha'); $maskinvoice = GETPOST('maskinvoice', 'alpha');
$maskreplacement = GETPOST('maskreplacement', 'alpha'); $maskreplacement = GETPOST('maskreplacement', 'alpha');
$maskcredit = GETPOST('maskcredit', 'alpha'); $maskcredit = GETPOST('maskcredit', 'alpha');
$maskdeposit = GETPOST('maskdeposit', 'alpha'); $maskdeposit = GETPOST('maskdeposit', 'alpha');
if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity);
if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity);
if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity);
if ($maskconstdeposit) $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); if ($maskconstdeposit) $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') } elseif ($action == 'specimen')
{ {
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$facture = new Facture($db); $facture = new Facture($db);
$facture->initAsSpecimen(); $facture->initAsSpecimen();
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound)
{ {
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($facture, $langs) > 0) if ($module->write_file($facture, $langs) > 0)
{ {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
return; return;
} else { } else {
setEventMessages($module->error, $module->errors, 'errors'); setEventMessages($module->error, $module->errors, 'errors');
dol_syslog($module->error, LOG_ERR); dol_syslog($module->error, LOG_ERR);
} }
} else { } else {
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} }
// Activate a model // Activate a model
elseif ($action == 'set') elseif ($action == 'set')
@ -123,7 +123,7 @@ elseif ($action == 'set')
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0)
{ {
if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity); if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity);
} }
} }
// Set default model // Set default model
@ -144,89 +144,89 @@ elseif ($action == 'setdoc')
} }
} elseif ($action == 'setmod') } elseif ($action == 'setmod')
{ {
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'setribchq') } elseif ($action == 'setribchq')
{ {
$rib = GETPOST('rib', 'alpha'); $rib = GETPOST('rib', 'alpha');
$chq = GETPOST('chq', 'alpha'); $chq = GETPOST('chq', 'alpha');
$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') } elseif ($action == 'set_FACTURE_DRAFT_WATERMARK')
{ {
$draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha'); $draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha');
$res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_INVOICE_FREE_TEXT') } elseif ($action == 'set_INVOICE_FREE_TEXT')
{ {
$freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string $freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'setforcedate') } elseif ($action == 'setforcedate')
{ {
$forcedate = GETPOST('forcedate', 'alpha'); $forcedate = GETPOST('forcedate', 'alpha');
$res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'setDefaultPDFModulesByType') } elseif ($action == 'setDefaultPDFModulesByType')
{ {
$invoicetypemodels = GETPOST('invoicetypemodels'); $invoicetypemodels = GETPOST('invoicetypemodels');
if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) if (!empty($invoicetypemodels) && is_array($invoicetypemodels))
{ {
$error = 0; $error = 0;
foreach ($invoicetypemodels as $type => $value) foreach ($invoicetypemodels as $type => $value)
{ {
$res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
} }
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
} }
@ -267,144 +267,144 @@ clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$dir = dol_buildpath($reldir."core/modules/facture/"); $dir = dol_buildpath($reldir."core/modules/facture/");
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
{ {
$filebis = $file; $filebis = $file;
$classname = preg_replace('/\.php$/', '', $file); $classname = preg_replace('/\.php$/', '', $file);
// For compatibility // For compatibility
if (!is_file($dir.$filebis)) if (!is_file($dir.$filebis))
{ {
$filebis = $file."/".$file.".modules.php"; $filebis = $file."/".$file.".modules.php";
$classname = "mod_facture_".$file; $classname = "mod_facture_".$file;
} }
// Check if there is a filter on country // Check if there is a filter on country
preg_match('/\-(.*)_(.*)$/', $classname, $reg); preg_match('/\-(.*)_(.*)$/', $classname, $reg);
if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
$classname = preg_replace('/\-.*$/', '', $classname); $classname = preg_replace('/\-.*$/', '', $classname);
if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php')
{ {
// Charging the numbering class // Charging the numbering class
require_once $dir.$filebis; require_once $dir.$filebis;
$module = new $classname($db); $module = new $classname($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled()) if ($module->isEnabled())
{ {
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
print "</td><td>\n"; print "</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
// Show example of numbering module // Show example of numbering module
print '<td class="nowrap">'; print '<td class="nowrap">';
$tmp = $module->getExample(); $tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
//print "> ".$conf->global->FACTURE_ADDON." - ".$file; //print "> ".$conf->global->FACTURE_ADDON." - ".$file;
if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file) if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file)
{ {
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
} }
print '</td>'; print '</td>';
$facture = new Facture($db); $facture = new Facture($db);
$facture->initAsSpecimen(); $facture->initAsSpecimen();
// Example for standard invoice // Example for standard invoice
$htmltooltip = ''; $htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type = 0; $facture->type = 0;
$nextval = $module->getNextValue($mysoc, $facture); $nextval = $module->getNextValue($mysoc, $facture);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValueForInvoices").': '; $htmltooltip .= $langs->trans("NextValueForInvoices").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
} }
} }
// Example for remplacement // Example for remplacement
$facture->type = 1; $facture->type = 1;
$nextval = $module->getNextValue($mysoc, $facture); $nextval = $module->getNextValue($mysoc, $facture);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValueForReplacements").': '; $htmltooltip .= $langs->trans("NextValueForReplacements").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
} }
} }
// Example for credit invoice // Example for credit invoice
$facture->type = 2; $facture->type = 2;
$nextval = $module->getNextValue($mysoc, $facture); $nextval = $module->getNextValue($mysoc, $facture);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValueForCreditNotes").': '; $htmltooltip .= $langs->trans("NextValueForCreditNotes").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
} }
} }
// Example for deposit invoice // Example for deposit invoice
$facture->type = 3; $facture->type = 3;
$nextval = $module->getNextValue($mysoc, $facture); $nextval = $module->getNextValue($mysoc, $facture);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValueForDeposit").': '; $htmltooltip .= $langs->trans("NextValueForDeposit").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
$htmltooltip .= $nextval; $htmltooltip .= $nextval;
} else { } else {
$htmltooltip .= $langs->trans($module->error); $htmltooltip .= $langs->trans($module->error);
} }
} }
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
if ($conf->global->FACTURE_ADDON.'.php' == $file) // If module is the one used, we show existing errors if ($conf->global->FACTURE_ADDON.'.php' == $file) // If module is the one used, we show existing errors
{ {
if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
} }
} }
closedir($handle); closedir($handle);
} }
} }
} }
print '</table>'; print '</table>';
@ -426,16 +426,16 @@ $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows)
{ {
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
@ -454,156 +454,156 @@ $activatedModels = array();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
foreach (array('', '/doc') as $valdir) foreach (array('', '/doc') as $valdir)
{ {
$realpath = $reldir."core/modules/facture".$valdir; $realpath = $reldir."core/modules/facture".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file)
{ {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{ {
if (file_exists($dir.'/'.$file)) if (file_exists($dir.'/'.$file))
{ {
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified) if ($modulequalified)
{ {
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description; else print $module->description;
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} else { } else {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("SetAsDefault"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("SetAsDefault"), 'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Defaut // Defaut
print '<td class="center">'; print '<td class="center">';
if ($conf->global->FACTURE_ADDON_PDF == "$name") if ($conf->global->FACTURE_ADDON_PDF == "$name")
{ {
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').'</a>';
} }
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1); $htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1); $htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1); $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>'; print '</td>';
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
} }
} }
} }
} }
} }
} }
print '</table>'; print '</table>';
if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf
{ {
/* /*
* Document templates generators * Document templates generators
*/ */
print '<br>'; print '<br>';
print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', ''); print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'" />'; print '<input type="hidden" name="token" value="'.newToken().'" />';
print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >'; print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >';
print '<table id="default-pdf-modules-by-type-table" class="noborder centpercent">'; print '<table id="default-pdf-modules-by-type-table" class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Type").'</td>'; print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Name").'</td>'; print '<td>'.$langs->trans("Name").'</td>';
print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n"; print "</tr>\n";
$listtype = array( $listtype = array(
Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
); );
if (!empty($conf->global->INVOICE_USE_SITUATION)) if (!empty($conf->global->INVOICE_USE_SITUATION))
{ {
$listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
} }
foreach ($listtype as $type => $trans) foreach ($listtype as $type => $trans)
{ {
$thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
$current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; $current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF;
print '<tr >'; print '<tr >';
print '<td>'.$trans.'</td>'; print '<td>'.$trans.'</td>';
print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'</td>'; print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'</td>';
print "</tr>\n"; print "</tr>\n";
} }
print '</table>'; print '</table>';
print "</form>"; print "</form>";
} }
/* /*
@ -629,37 +629,37 @@ print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
print "<td>"; print "<td>";
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled))
{ {
$sql = "SELECT rowid, label"; $sql = "SELECT rowid, label";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql .= " WHERE clos = 0"; $sql .= " WHERE clos = 0";
$sql .= " AND courant = 1"; $sql .= " AND courant = 1";
$sql .= " AND entity IN (".getEntity('bank_account').")"; $sql .= " AND entity IN (".getEntity('bank_account').")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
if ($num > 0) if ($num > 0)
{ {
print '<select name="rib" class="flat" id="rib">'; print '<select name="rib" class="flat" id="rib">';
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>'; print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
while ($i < $num) while ($i < $num)
{ {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"'; print '<option value="'.$row[0].'"';
print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : ''; print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : '';
print '>'.$row[1].'</option>'; print '>'.$row[1].'</option>';
$i++; $i++;
} }
print "</select>"; print "</select>";
} else { } else {
print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>'; print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
} }
} }
} else { } else {
print $langs->trans("BankModuleNotActive"); print $langs->trans("BankModuleNotActive");
} }
print "</td></tr>"; print "</td></tr>";
@ -679,18 +679,18 @@ $sql .= " AND entity IN (".getEntity('bank_account').")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"'; print '<option value="'.$row[0].'"';
print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : ''; print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>'; print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
$i++; $i++;
} }
} }
print "</select>"; print "</select>";
print "</td></tr>"; print "</td></tr>";
@ -735,11 +735,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->tra
$variablename = 'INVOICE_FREE_TEXT'; $variablename = 'INVOICE_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{ {
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create(); print $doleditor->Create();
} }
print '</td><td class="right">'; print '</td><td class="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';

View File

@ -43,7 +43,7 @@ $type = 'contract';
if (empty($conf->global->HOLIDAY_ADDON)) if (empty($conf->global->HOLIDAY_ADDON))
{ {
$conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna'; $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna';
} }
@ -55,18 +55,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconst = GETPOST('maskconstholiday', 'alpha'); $maskconst = GETPOST('maskconstholiday', 'alpha');
$maskvalue = GETPOST('maskholiday', 'alpha'); $maskvalue = GETPOST('maskholiday', 'alpha');
if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') // For contract } elseif ($action == 'specimen') // For contract
{ {
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
@ -79,7 +79,7 @@ if ($action == 'updateMask')
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound = 1; $filefound = 1;
@ -117,7 +117,7 @@ elseif ($action == 'set')
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0)
{ {
if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity); if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity);
} }
} }
@ -154,11 +154,11 @@ elseif ($action == 'setdoc')
if (!$res1 > 0 || !$res2 > 0) $error++; if (!$res1 > 0 || !$res2 > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
@ -251,16 +251,16 @@ foreach ($dirmodels as $reldir)
$htmltooltip = ''; $htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval = $module->getNextValue($mysoc, $holiday); $nextval = $module->getNextValue($mysoc, $holiday);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
} }
} }
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
@ -282,11 +282,11 @@ print '<br>';
if ($conf->global->MAIN_FEATURES_LEVEL < 2) { if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
dol_fiche_end(); dol_fiche_end();
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();
exit; exit;
} }
/* /*
@ -304,8 +304,8 @@ $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows)
{ {
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
@ -332,111 +332,111 @@ clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
foreach (array('', '/doc') as $valdir) foreach (array('', '/doc') as $valdir)
{ {
$realpath = $reldir."core/modules/holiday".$valdir; $realpath = $reldir."core/modules/holiday".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file)
{ {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{ {
if (file_exists($dir.'/'.$file)) if (file_exists($dir.'/'.$file))
{ {
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified) if ($modulequalified)
{ {
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description; else print $module->description;
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} else { } else {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->HOLIDAY_ADDON_PDF == $name) if ($conf->global->HOLIDAY_ADDON_PDF == $name)
{ {
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} }
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>'; print '</td>';
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
} }
} }
} }
} }
} }
} }
print '</table>'; print '</table>';
@ -473,11 +473,11 @@ print '<br>';
$variablename = 'HOLIDAY_FREE_TEXT'; $variablename = 'HOLIDAY_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{ {
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create(); print $doleditor->Create();
} }
print '</td></tr>'."\n"; print '</td></tr>'."\n";

View File

@ -113,29 +113,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db); $formmail = new FormMail($db);
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{ {
$tmp = FormMail::getAvailableSubstitKey('formemail'); $tmp = FormMail::getAvailableSubstitKey('formemail');
$tmp['__(AnyTranslationKey)__'] = 'Translation'; $tmp['__(AnyTranslationKey)__'] = 'Translation';
$helpsubstit = $langs->trans("AvailableVariables").':<br>'; $helpsubstit = $langs->trans("AvailableVariables").':<br>';
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'; $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
foreach ($tmp as $key => $val) foreach ($tmp as $key => $val)
{ {
$helpsubstit .= $key.' -> '.$val.'<br>'; $helpsubstit .= $key.' -> '.$val.'<br>';
$helpsubstitforlines .= $key.' -> '.$val.'<br>'; $helpsubstitforlines .= $key.' -> '.$val.'<br>';
} }
} else { } else {
$tmp = FormMail::getAvailableSubstitKey('formemailwithlines'); $tmp = FormMail::getAvailableSubstitKey('formemailwithlines');
$tmp['__(AnyTranslationKey)__'] = 'Translation'; $tmp['__(AnyTranslationKey)__'] = 'Translation';
$helpsubstit = $langs->trans("AvailableVariables").':<br>'; $helpsubstit = $langs->trans("AvailableVariables").':<br>';
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'; $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
foreach ($tmp as $key => $val) foreach ($tmp as $key => $val)
{ {
$helpsubstit .= $key.' -> '.$val.'<br>'; $helpsubstit .= $key.' -> '.$val.'<br>';
} }
$tmp = FormMail::getAvailableSubstitKey('formemailforlines'); $tmp = FormMail::getAvailableSubstitKey('formemailforlines');
foreach ($tmp as $key => $val) foreach ($tmp as $key => $val)
{ {
$helpsubstitforlines .= $key.' -> '.$val.'<br>'; $helpsubstitforlines .= $key.' -> '.$val.'<br>';
} }
} }
@ -201,206 +201,206 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{ {
$search_label = ''; $search_label = '';
$search_type_template = ''; $search_type_template = '';
$search_lang = ''; $search_lang = '';
$search_fk_user = ''; $search_fk_user = '';
$search_topic = ''; $search_topic = '';
$toselect = ''; $toselect = '';
$search_array_options = array(); $search_array_options = array();
} }
// Actions add or modify an entry into a dictionary // Actions add or modify an entry into a dictionary
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{ {
$listfield = explode(',', str_replace(' ', '', $tabfield[$id])); $listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert = explode(',', $tabfieldinsert[$id]); $listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify = explode(',', $tabfieldinsert[$id]); $listfieldmodify = explode(',', $tabfieldinsert[$id]);
$listfieldvalue = explode(',', $tabfieldvalue[$id]); $listfieldvalue = explode(',', $tabfieldvalue[$id]);
// Check that all fields are filled // Check that all fields are filled
$ok = 1; $ok = 1;
foreach ($listfield as $f => $value) foreach ($listfield as $f => $value)
{ {
// Not mandatory fields // Not mandatory fields
if ($value == 'joinfiles') continue; if ($value == 'joinfiles') continue;
if ($value == 'content') continue; if ($value == 'content') continue;
if ($value == 'content_lines') continue; if ($value == 'content_lines') continue;
if (GETPOST('actionmodify', 'alpha') && $value == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; if (GETPOST('actionmodify', 'alpha') && $value == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid];
if ((!isset($_POST[$value]) || $_POST[$value] == '' || $_POST[$value] == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') if ((!isset($_POST[$value]) || $_POST[$value] == '' || $_POST[$value] == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position')
{ {
$ok = 0; $ok = 0;
$fieldnamekey = $listfield[$f]; $fieldnamekey = $listfield[$f];
// We take translate key of field // We take translate key of field
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Code'; if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Code';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
if ($fieldnamekey == 'type_template') $fieldnamekey = 'TypeOfTemplate'; if ($fieldnamekey == 'type_template') $fieldnamekey = 'TypeOfTemplate';
if ($fieldnamekey == 'fk_user') $fieldnamekey = 'Owner'; if ($fieldnamekey == 'fk_user') $fieldnamekey = 'Owner';
if ($fieldnamekey == 'private') $fieldnamekey = 'Private'; if ($fieldnamekey == 'private') $fieldnamekey = 'Private';
if ($fieldnamekey == 'position') $fieldnamekey = 'Position'; if ($fieldnamekey == 'position') $fieldnamekey = 'Position';
if ($fieldnamekey == 'topic') $fieldnamekey = 'Topic'; if ($fieldnamekey == 'topic') $fieldnamekey = 'Topic';
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
} }
} }
// Si verif ok et action add, on ajoute la ligne // Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd')) if ($ok && GETPOST('actionadd'))
{ {
// Add new entry // Add new entry
$sql = "INSERT INTO ".$tabname[$id]." ("; $sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields // List of fields
$sql .= $tabfieldinsert[$id]; $sql .= $tabfieldinsert[$id];
$sql .= ",active)"; $sql .= ",active)";
$sql .= " VALUES("; $sql .= " VALUES(";
// List of values // List of values
$i = 0; $i = 0;
foreach ($listfieldinsert as $f => $value) foreach ($listfieldinsert as $f => $value)
{ {
$keycode = $listfieldvalue[$i]; $keycode = $listfieldvalue[$i];
if ($value == 'lang') $keycode = 'langcode'; if ($value == 'lang') $keycode = 'langcode';
if (empty($keycode)) $keycode = $value; if (empty($keycode)) $keycode = $value;
if ($value == 'entity') $_POST[$keycode] = $conf->entity; if ($value == 'entity') $_POST[$keycode] = $conf->entity;
if ($value == 'fk_user' && !($_POST[$keycode] > 0)) $_POST[$keycode] = ''; if ($value == 'fk_user' && !($_POST[$keycode] > 0)) $_POST[$keycode] = '';
if ($value == 'private' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '0'; if ($value == 'private' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '0';
if ($value == 'position' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '1'; if ($value == 'position' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '1';
//var_dump($keycode.' '.$value); //var_dump($keycode.' '.$value);
if ($i) $sql .= ", "; if ($i) $sql .= ", ";
if (GETPOST($keycode) == '' && $keycode != 'langcode') $sql .= "null"; // langcode must be '' if not defined so the unique key that include lang will work if (GETPOST($keycode) == '' && $keycode != 'langcode') $sql .= "null"; // langcode must be '' if not defined so the unique key that include lang will work
elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work
elseif ($keycode == 'content') { elseif ($keycode == 'content') {
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
} elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) { } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) {
$sql .= (int) GETPOST($keycode, 'int'); $sql .= (int) GETPOST($keycode, 'int');
} else { } else {
$sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
} }
$i++; $i++;
} }
$sql .= ", 1)"; $sql .= ", 1)";
dol_syslog("actionadd", LOG_DEBUG); dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) // Add is ok if ($result) // Add is ok
{ {
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST = array('id'=>$id); // Clean $_POST array, we keep only id $_POST = array('id'=>$id); // Clean $_POST array, we keep only id
} else { } else {
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
// Si verif ok et action modify, on modifie la ligne // Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify')) if ($ok && GETPOST('actionmodify'))
{ {
$rowidcol = "rowid"; $rowidcol = "rowid";
// Modify entry // Modify entry
$sql = "UPDATE ".$tabname[$id]." SET "; $sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs // Modifie valeur des champs
$i = 0; $i = 0;
foreach ($listfieldmodify as $field) foreach ($listfieldmodify as $field)
{ {
$keycode = $listfieldvalue[$i]; $keycode = $listfieldvalue[$i];
if ($field == 'lang') $keycode = 'langcode'; if ($field == 'lang') $keycode = 'langcode';
if (empty($keycode)) $keycode = $field; if (empty($keycode)) $keycode = $field;
if ($field == 'fk_user' && !($_POST['fk_user'] > 0)) $_POST['fk_user'] = ''; if ($field == 'fk_user' && !($_POST['fk_user'] > 0)) $_POST['fk_user'] = '';
if ($field == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; if ($field == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid];
if ($field == 'joinfiles') $_POST['joinfiles'] = $_POST['joinfiles-'.$rowid]; if ($field == 'joinfiles') $_POST['joinfiles'] = $_POST['joinfiles-'.$rowid];
if ($field == 'content') $_POST['content'] = $_POST['content-'.$rowid]; if ($field == 'content') $_POST['content'] = $_POST['content-'.$rowid];
if ($field == 'content_lines') $_POST['content_lines'] = $_POST['content_lines-'.$rowid]; if ($field == 'content_lines') $_POST['content_lines'] = $_POST['content_lines-'.$rowid];
if ($field == 'entity') $_POST[$keycode] = $conf->entity; if ($field == 'entity') $_POST[$keycode] = $conf->entity;
if ($i) $sql .= ", "; if ($i) $sql .= ", ";
$sql .= $field."="; $sql .= $field."=";
if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && !GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && !GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work
elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work
elseif ($keycode == 'content') { elseif ($keycode == 'content') {
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
} elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) { } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) {
$sql .= (int) GETPOST($keycode, 'int'); $sql .= (int) GETPOST($keycode, 'int');
} else { } else {
$sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
} }
$i++; $i++;
} }
$sql .= " WHERE ".$rowidcol." = '".$rowid."'"; $sql .= " WHERE ".$rowidcol." = '".$rowid."'";
//print $sql;exit; //print $sql;exit;
dol_syslog("actionmodify", LOG_DEBUG); dol_syslog("actionmodify", LOG_DEBUG);
//print $sql; //print $sql;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
} else { } else {
setEventMessages($db->error(), null, 'errors'); setEventMessages($db->error(), null, 'errors');
} }
} }
} }
if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{ {
$rowidcol = "rowid"; $rowidcol = "rowid";
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
dol_syslog("delete", LOG_DEBUG); dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result)
{ {
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{ {
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
// activate // activate
if ($action == $acts[0]) if ($action == $acts[0])
{ {
$rowidcol = "rowid"; $rowidcol = "rowid";
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result)
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
// disable // disable
if ($action == $acts[1]) if ($action == $acts[1])
{ {
$rowidcol = "rowid"; $rowidcol = "rowid";
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result)
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
@ -428,7 +428,7 @@ dol_fiche_head($head, 'templates', '', -1);
// Confirmation de la suppression de la ligne // Confirmation de la suppression de la ligne
if ($action == 'delete') if ($action == 'delete')
{ {
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
} }
//var_dump($elementList); //var_dump($elementList);
@ -613,90 +613,90 @@ dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$param = '&id='.$id; $param = '&id='.$id;
if ($search_label) $param .= '&search_label='.urlencode($search_label); if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($search_lang > 0) $param .= '&search_lang='.urlencode($search_lang); if ($search_lang > 0) $param .= '&search_lang='.urlencode($search_lang);
if ($search_type_template != '-1') $param .= '&search_type_template='.urlencode($search_type_template); if ($search_type_template != '-1') $param .= '&search_type_template='.urlencode($search_type_template);
if ($search_fk_user > 0) $param .= '&search_fk_user='.urlencode($search_fk_user); if ($search_fk_user > 0) $param .= '&search_fk_user='.urlencode($search_fk_user);
if ($search_topic) $param .= '&search_topic='.urlencode($search_topic); if ($search_topic) $param .= '&search_topic='.urlencode($search_topic);
$paramwithsearch = $param; $paramwithsearch = $param;
if ($sortorder) $paramwithsearch .= '&sortorder='.urlencode($sortorder); if ($sortorder) $paramwithsearch .= '&sortorder='.urlencode($sortorder);
if ($sortfield) $paramwithsearch .= '&sortfield='.urlencode($sortfield); if ($sortfield) $paramwithsearch .= '&sortfield='.urlencode($sortfield);
if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha')); if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha'));
// There is several pages // There is several pages
if ($num > $listlimit) if ($num > $listlimit)
{ {
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">'; print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>'); print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>'; print '</td></tr>';
} }
// Title line with search boxes // Title line with search boxes
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
$filterfound = 0; $filterfound = 0;
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
if ($value == 'label') { if ($value == 'label') {
print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth100" value="'.dol_escape_htmltag($search_label).'"></td>'; print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth100" value="'.dol_escape_htmltag($search_label).'"></td>';
} elseif ($value == 'lang') { } elseif ($value == 'lang') {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100'); print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100');
print '</td>'; print '</td>';
} elseif ($value == 'fk_user') { } elseif ($value == 'fk_user') {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
$restrictid = array(); $restrictid = array();
if (!$user->admin) $restrictid = array($user->id); if (!$user->admin) $restrictid = array($user->id);
//var_dump($restrictid); //var_dump($restrictid);
print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, 'hierarchyme', null, 0, 0, 1, '', 0, '', 'maxwidth100'); print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, 'hierarchyme', null, 0, 0, 1, '', 0, '', 'maxwidth100');
print '</td>'; print '</td>';
} elseif ($value == 'topic') { } elseif ($value == 'topic') {
print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>'; print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
} elseif ($value == 'type_template') { } elseif ($value == 'type_template') {
print '<td class="liste_titre">'.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 maxwidth100onsmartphone').'</td>'; print '<td class="liste_titre">'.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 maxwidth100onsmartphone').'</td>';
} elseif (!in_array($value, array('content', 'content_lines'))) { } elseif (!in_array($value, array('content', 'content_lines'))) {
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
} }
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print '<td class="liste_titre"></td>'; if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print '<td class="liste_titre"></td>';
// Action column // Action column
print '<td class="liste_titre right" width="64">'; print '<td class="liste_titre right" width="64">';
$searchpicto = $form->showFilterButtons(); $searchpicto = $form->showFilterButtons();
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Title of lines // Title of lines
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
$showfield = 1; // By defaut $showfield = 1; // By defaut
$align = "left"; $align = "left";
$sortable = 1; $sortable = 1;
$valuetoshow = ''; $valuetoshow = '';
$forcenowrap = 1; $forcenowrap = 1;
/* /*
$tmparray=getLabelOfField($fieldlist[$field]); $tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield']; $showfield=$tmp['showfield'];
$valuetoshow=$tmp['valuetoshow']; $valuetoshow=$tmp['valuetoshow'];
$align=$tmp['align']; $align=$tmp['align'];
$sortable=$tmp['sortable']; $sortable=$tmp['sortable'];
*/ */
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut $valuetoshow = ucfirst($fieldlist[$field]); // By defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate $valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); }
if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); }
if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); }
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Code"); } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Code"); }
if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); } if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); }
if ($fieldlist[$field] == 'private') { $align = 'center'; } if ($fieldlist[$field] == 'private') { $align = 'center'; }
if ($fieldlist[$field] == 'position') { $align = 'center'; } if ($fieldlist[$field] == 'position') { $align = 'center'; }
@ -704,99 +704,99 @@ if ($resql)
if ($fieldlist[$field] == 'content') { $valuetoshow = $langs->trans("Content"); $showfield = 0; } if ($fieldlist[$field] == 'content') { $valuetoshow = $langs->trans("Content"); $showfield = 0; }
if ($fieldlist[$field] == 'content_lines') { $valuetoshow = $langs->trans("ContentLines"); $showfield = 0; } if ($fieldlist[$field] == 'content_lines') { $valuetoshow = $langs->trans("ContentLines"); $showfield = 0; }
// Show fields // Show fields
if ($showfield) if ($showfield)
{ {
if (!empty($tabhelp[$id][$value])) if (!empty($tabhelp[$id][$value]))
{ {
if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click
else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover
} }
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder); print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder);
} }
} }
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print '</tr>'; print '</tr>';
if ($num) if ($num)
{ {
// Lines with values // Lines with values
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
{ {
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">'; print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
$tmpaction = 'edit'; $tmpaction = 'edit';
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
// Show fields // Show fields
if (empty($reshook)) fieldList($fieldlist, $obj, $tabname[$id], 'edit'); if (empty($reshook)) fieldList($fieldlist, $obj, $tabname[$id], 'edit');
print '<td></td><td></td><td></td>'; print '<td></td><td></td><td></td>';
print '<td class="center">'; print '<td class="center">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">'; print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="submit" class="button buttongen" name="actionmodify" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button buttongen" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>'; print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
print '<input type="submit" class="button buttongen" name="actioncancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button buttongen" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '</td>'; print '</td>';
$fieldsforcontent = array('topic', 'joinfiles', 'content'); $fieldsforcontent = array('topic', 'joinfiles', 'content');
if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{ {
$fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines');
} }
foreach ($fieldsforcontent as $tmpfieldlist) foreach ($fieldsforcontent as $tmpfieldlist)
{ {
$showfield = 1; $showfield = 1;
$align = "left"; $align = "left";
$valuetoshow = $obj->{$tmpfieldlist}; $valuetoshow = $obj->{$tmpfieldlist};
$class = 'tddict'; $class = 'tddict';
// Show value for field // Show value for field
if ($showfield) { if ($showfield) {
// Show line for topic, joinfiles and content // Show line for topic, joinfiles and content
print '</tr><tr class="oddeven" nohover tr-'.$tmpfieldlist.'-'.$rowid.' ">'; print '</tr><tr class="oddeven" nohover tr-'.$tmpfieldlist.'-'.$rowid.' ">';
print '<td colspan="8">'; print '<td colspan="8">';
if ($tmpfieldlist == 'topic') if ($tmpfieldlist == 'topic')
{ {
print '<strong>'.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> '; print '<strong>'.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> ';
print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'">'; print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'">';
} }
if ($tmpfieldlist == 'joinfiles') if ($tmpfieldlist == 'joinfiles')
{ {
print '<strong>'.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> '; print '<strong>'.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> ';
print '<input type="text" class="flat maxwidth50" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'">'; print '<input type="text" class="flat maxwidth50" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'">';
} }
if ($tmpfieldlist == 'content') if ($tmpfieldlist == 'content')
{ {
print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>'; print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
$okforextended = true; $okforextended = true;
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false;
$doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
} }
print '</td>'; print '</td>';
print '<td></td>'; print '<td></td>';
print '<td></td>'; print '<td></td>';
} }
} }
print "</tr>\n"; print "</tr>\n";
} else { } else {
$keyforobj = 'type_template'; $keyforobj = 'type_template';
if (!in_array($obj->$keyforobj, array_keys($elementList))) if (!in_array($obj->$keyforobj, array_keys($elementList)))
{ {
$i++; $i++;
continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled) continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled)
} }
// Test on 'enabled' // Test on 'enabled'
if (!dol_eval($obj->enabled, 1)) if (!dol_eval($obj->enabled, 1))
{ {
@ -804,100 +804,100 @@ if ($resql)
continue; // Email template not qualified continue; // Email template not qualified
} }
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">'; print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
$tmpaction = 'view'; $tmpaction = 'view';
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) if (empty($reshook))
{ {
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
if (in_array($fieldlist[$field], array('content', 'content_lines'))) continue; if (in_array($fieldlist[$field], array('content', 'content_lines'))) continue;
$showfield = 1; $showfield = 1;
$align = "left"; $align = "left";
$valuetoshow = $obj->{$fieldlist[$field]}; $valuetoshow = $obj->{$fieldlist[$field]};
if ($value == 'label' || $value == 'topic') if ($value == 'label' || $value == 'topic')
{ {
$valuetoshow = dol_escape_htmltag($valuetoshow); $valuetoshow = dol_escape_htmltag($valuetoshow);
} }
if ($value == 'type_template') if ($value == 'type_template')
{ {
$valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
} }
if ($value == 'lang' && $valuetoshow) if ($value == 'lang' && $valuetoshow)
{ {
$valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow); $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow);
} }
if ($value == 'fk_user') if ($value == 'fk_user')
{ {
if ($valuetoshow > 0) if ($valuetoshow > 0)
{ {
$fuser = new User($db); $fuser = new User($db);
$fuser->fetch($valuetoshow); $fuser->fetch($valuetoshow);
$valuetoshow = $fuser->getNomUrl(1); $valuetoshow = $fuser->getNomUrl(1);
} }
} }
if ($value == 'private') if ($value == 'private')
{ {
$align = "center"; $align = "center";
if ($valuetoshow) $valuetoshow = yn($valuetoshow); if ($valuetoshow) $valuetoshow = yn($valuetoshow);
else $valuetoshow = ''; else $valuetoshow = '';
} }
if ($value == 'position') if ($value == 'position')
{ {
$align = "center"; $align = "center";
} }
if ($value == 'joinfiles') if ($value == 'joinfiles')
{ {
$align = "center"; $align = "center";
if ($valuetoshow) $valuetoshow = 1; if ($valuetoshow) $valuetoshow = 1;
else $valuetoshow = ''; else $valuetoshow = '';
} }
$class = 'tddict'; $class = 'tddict';
// Show value for field // Show value for field
if ($showfield) if ($showfield)
{ {
print '<!-- '.$fieldlist[$field].' -->'; print '<!-- '.$fieldlist[$field].' -->';
print '<td align="'.$align.'" class="'.$class.'">'.$valuetoshow.'</td>'; print '<td align="'.$align.'" class="'.$class.'">'.$valuetoshow.'</td>';
} }
} }
} }
// Can an entry be erased or disabled ? // Can an entry be erased or disabled ?
$iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
if (!$user->admin && $obj->fk_user != $user->id) if (!$user->admin && $obj->fk_user != $user->id)
{ {
$iserasable = 0; $iserasable = 0;
$canbedisabled = 0; $canbedisabled = 0;
$canbemodified = 0; $canbemodified = 0;
} }
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
if ($param) $url .= '&'.$param; if ($param) $url .= '&'.$param;
$url .= '&'; $url .= '&';
// Status / Active // Status / Active
print '<td class="center nowrap">'; print '<td class="center nowrap">';
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>'; if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
else print '<span class="opacitymedium">'.$actl[$obj->active].'</span>'; else print '<span class="opacitymedium">'.$actl[$obj->active].'</span>';
print "</td>"; print "</td>";
// Modify link / Delete link // Modify link / Delete link
print '<td class="center nowraponall" width="64">'; print '<td class="center nowraponall" width="64">';
if ($canbemodified) print '<a class="reposition editfielda" href="'.$url.'action=edit">'.img_edit().'</a>'; if ($canbemodified) print '<a class="reposition editfielda" href="'.$url.'action=edit">'.img_edit().'</a>';
if ($iserasable) if ($iserasable)
{ {
print '<a class="marginleftonly" href="'.$url.'action=delete">'.img_delete().'</a>'; print '<a class="marginleftonly" href="'.$url.'action=delete">'.img_delete().'</a>';
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
} }
print '</td>'; print '</td>';
/* /*
$fieldsforcontent = array('content'); $fieldsforcontent = array('content');
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{ {
@ -925,15 +925,15 @@ if ($resql)
} }
}*/ }*/
print "</tr>\n"; print "</tr>\n";
} }
$i++; $i++;
} }
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
print '</table>'; print '</table>';

View File

@ -89,7 +89,6 @@ if ($action == 'update')
$result = $menu->fetch(GETPOST('menuId', 'int')); $result = $menu->fetch(GETPOST('menuId', 'int'));
if ($result > 0) if ($result > 0)
{ {
$menu->titre = GETPOST('titre', 'alpha'); // deprecated
$menu->title = GETPOST('titre', 'alpha'); $menu->title = GETPOST('titre', 'alpha');
$menu->leftmenu = GETPOST('leftmenu', 'aZ09'); $menu->leftmenu = GETPOST('leftmenu', 'aZ09');
$menu->url = GETPOST('url', 'alpha'); $menu->url = GETPOST('url', 'alpha');
@ -200,7 +199,6 @@ if ($action == 'add')
$menu = new Menubase($db); $menu = new Menubase($db);
$menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09')); $menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09'));
$menu->type = GETPOST('type', 'alpha'); $menu->type = GETPOST('type', 'alpha');
$menu->titre = GETPOST('titre', 'alpha'); // deprecated
$menu->title = GETPOST('titre', 'alpha'); $menu->title = GETPOST('titre', 'alpha');
$menu->url = GETPOST('url', 'alpha'); $menu->url = GETPOST('url', 'alpha');
$menu->langs = GETPOST('langs', 'alpha'); $menu->langs = GETPOST('langs', 'alpha');
@ -478,7 +476,7 @@ if ($action == 'create')
//print '<tr><td>'.$langs->trans('Level').'</td><td>'.$menu->level.'</td><td>'.$langs->trans('DetailLevel').'</td></tr>'; //print '<tr><td>'.$langs->trans('Level').'</td><td>'.$menu->level.'</td><td>'.$langs->trans('DetailLevel').'</td></tr>';
// Title // Title
print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag($menu->titre ? $menu->titre : $menu->title).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag($menu->title).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
// Url // Url
print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" class="quatrevingtpercent" name="url" value="'.$menu->url.'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" class="quatrevingtpercent" name="url" value="'.$menu->url.'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';

View File

@ -56,11 +56,11 @@ if ($action == 'updateMask')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') } elseif ($action == 'specimen')
{ {
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
@ -73,7 +73,7 @@ if ($action == 'updateMask')
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound = 1; $filefound = 1;
@ -111,7 +111,7 @@ elseif ($action == 'set')
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0)
{ {
if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity); if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity);
} }
} }
@ -145,11 +145,11 @@ elseif ($action == 'setdoc')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_MRP_MO_FREE_TEXT') } elseif ($action == 'set_MRP_MO_FREE_TEXT')
{ {
$freetext = GETPOST("MRP_MO_FREE_TEXT", 'none'); // No alpha here, we want exact string $freetext = GETPOST("MRP_MO_FREE_TEXT", 'none'); // No alpha here, we want exact string
@ -159,11 +159,11 @@ elseif ($action == 'setdoc')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
@ -212,7 +212,7 @@ foreach ($dirmodels as $reldir)
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php') if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{ {
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
@ -230,13 +230,13 @@ foreach ($dirmodels as $reldir)
print $module->info(); print $module->info();
print '</td>'; print '</td>';
// Show example of numbering model // Show example of numbering model
print '<td class="nowrap">'; print '<td class="nowrap">';
$tmp = $module->getExample(); $tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->MRP_MO_ADDON == $file) if ($conf->global->MRP_MO_ADDON == $file)
@ -257,16 +257,16 @@ foreach ($dirmodels as $reldir)
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$mrp->type = 0; $mrp->type = 0;
$nextval = $module->getNextValue($mysoc, $mrp); $nextval = $module->getNextValue($mysoc, $mrp);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
} }
} }
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
@ -325,108 +325,108 @@ clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
foreach (array('', '/doc') as $valdir) foreach (array('', '/doc') as $valdir)
{ {
$realpath = $reldir."core/modules/mrp".$valdir; $realpath = $reldir."core/modules/mrp".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file)
{ {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{ {
if (file_exists($dir.'/'.$file)) if (file_exists($dir.'/'.$file))
{ {
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified) if ($modulequalified)
{ {
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description; else print $module->description;
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} else { } else {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->MRP_MO_ADDON_PDF == $name) if ($conf->global->MRP_MO_ADDON_PDF == $name)
{ {
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} }
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1); $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>'; print '</td>';
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
} }
} }
} }
} }
} }
} }
print '</table>'; print '</table>';
@ -458,11 +458,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("A
$variablename = 'MRP_MO_FREE_TEXT'; $variablename = 'MRP_MO_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{ {
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create(); print $doleditor->Create();
} }
print '</td><td class="right">'; print '</td><td class="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';

View File

@ -45,13 +45,13 @@ $type = 'reception';
if (!empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION)) if (!empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION))
{ {
// This option should always be set to on when module is on. // This option should always be set to on when module is on.
dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity);
} }
if (empty($conf->global->RECEPTION_ADDON_NUMBER)) if (empty($conf->global->RECEPTION_ADDON_NUMBER))
{ {
$conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl'; $conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl';
} }
@ -108,7 +108,7 @@ if ($action == 'updateMask')
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound = 1; $filefound = 1;
@ -146,7 +146,7 @@ elseif ($action == 'set')
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0)
{ {
if ($conf->global->RECEPTION_ADDON_PDF == "$value") dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity); if ($conf->global->RECEPTION_ADDON_PDF == "$value") dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity);
} }
} }
@ -236,14 +236,14 @@ foreach ($dirmodels as $reldir)
print $module->info(); print $module->info();
print '</td>'; print '</td>';
// Show example of numbering module // Show example of numbering module
print '<td class="nowrap">'; print '<td class="nowrap">';
$tmp = $module->getExample(); $tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->RECEPTION_ADDON_NUMBER == "$file") if ($conf->global->RECEPTION_ADDON_NUMBER == "$file")
@ -263,16 +263,16 @@ foreach ($dirmodels as $reldir)
$htmltooltip = ''; $htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval = $module->getNextValue($mysoc, $reception); $nextval = $module->getNextValue($mysoc, $reception);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
} }
} }
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
@ -333,110 +333,110 @@ clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
foreach (array('', '/doc') as $valdir) foreach (array('', '/doc') as $valdir)
{ {
$realpath = $reldir."core/modules/reception".$valdir; $realpath = $reldir."core/modules/reception".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file)
{ {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{ {
if (file_exists($dir.'/'.$file)) if (file_exists($dir.'/'.$file))
{ {
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified) if ($modulequalified)
{ {
print '<tr><td width="100">'; print '<tr><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description; else print $module->description;
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} else { } else {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Defaut // Defaut
print '<td class="center">'; print '<td class="center">';
if ($conf->global->RECEPTION_ADDON_PDF == $name) if ($conf->global->RECEPTION_ADDON_PDF == $name)
{ {
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} }
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>'; print '</td>';
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf')
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'reception').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'reception').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
} }
} }
} }
} }
} }
} }
print '</table>'; print '</table>';

View File

@ -51,42 +51,42 @@ $reg = array();
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
{ {
$code = $reg[1]; $code = $reg[1];
// If constant is for a unique choice, delete other choices // If constant is for a unique choice, delete other choices
if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) { if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) {
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity); dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity); dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity); dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity); dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity);
} }
if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) { if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) {
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity); dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity); dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity); dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity); dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity); dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity);
} }
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
{ {
$code = $reg[1]; $code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0) if (dolibarr_del_const($db, $code, $conf->entity) > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
if ($action == 'warehouse') if ($action == 'warehouse')
@ -224,14 +224,14 @@ print '<td>'.$langs->trans("DeStockOnBill").'</td>';
print '<td class="right">'; print '<td class="right">';
if (!empty($conf->facture->enabled)) if (!empty($conf->facture->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1); print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL); print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL);
} }
} else { } else {
print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")); print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name"));
} }
print "</td>\n</tr>\n"; print "</td>\n</tr>\n";
$found++; $found++;
@ -242,14 +242,14 @@ print '<td>'.$langs->trans("DeStockOnValidateOrder").'</td>';
print '<td class="right">'; print '<td class="right">';
if (!empty($conf->commande->enabled)) if (!empty($conf->commande->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1); print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER); print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER);
} }
} else { } else {
print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")); print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name"));
} }
print "</td>\n</tr>\n"; print "</td>\n</tr>\n";
$found++; $found++;
@ -262,14 +262,14 @@ print '<td>'.$langs->trans("DeStockOnShipment").'</td>';
print '<td class="right">'; print '<td class="right">';
if (!empty($conf->expedition->enabled)) if (!empty($conf->expedition->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1); print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT); print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT);
} }
} else { } else {
print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name"));
} }
print "</td>\n</tr>\n"; print "</td>\n</tr>\n";
$found++; $found++;
@ -280,14 +280,14 @@ print '<td>'.$langs->trans("DeStockOnShipmentOnClosing").'</td>';
print '<td class="right">'; print '<td class="right">';
if (!empty($conf->expedition->enabled)) if (!empty($conf->expedition->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1); print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE); print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE);
} }
} else { } else {
print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name"));
} }
print "</td>\n</tr>\n"; print "</td>\n</tr>\n";
$found++; $found++;
@ -312,14 +312,14 @@ print '<td>'.$langs->trans("ReStockOnBill").'</td>';
print '<td class="right">'; print '<td class="right">';
if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1); print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL); print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL);
} }
} else { } else {
print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
} }
print "</td>\n</tr>\n"; print "</td>\n</tr>\n";
$found++; $found++;
@ -331,14 +331,14 @@ print '<td>'.$langs->trans("ReStockOnValidateOrder").'</td>';
print '<td class="right">'; print '<td class="right">';
if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1); print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER); print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER);
} }
} else { } else {
print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
} }
print "</td>\n</tr>\n"; print "</td>\n</tr>\n";
$found++; $found++;
@ -347,43 +347,43 @@ if (!empty($conf->reception->enabled))
{ {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("StockOnReception").'</td>'; print '<td>'.$langs->trans("StockOnReception").'</td>';
print '<td class="right">'; print '<td class="right">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1); print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION); print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION);
} }
print "</td>\n</tr>\n"; print "</td>\n</tr>\n";
$found++; $found++;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("StockOnReceptionOnClosing").'</td>'; print '<td>'.$langs->trans("StockOnReceptionOnClosing").'</td>';
print '<td class="right">'; print '<td class="right">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1); print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE); print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE);
} }
print "</td>\n</tr>\n"; print "</td>\n</tr>\n";
$found++; $found++;
} else { } else {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("ReStockOnDispatchOrder").'</td>'; print '<td>'.$langs->trans("ReStockOnDispatchOrder").'</td>';
print '<td class="right">'; print '<td class="right">';
if (!empty($conf->fournisseur->enabled)) if (!empty($conf->fournisseur->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1); print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER); print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER);
} }
} else { } else {
print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
} }
@ -406,10 +406,10 @@ print '<tr class="oddeven">';
print '<td>'.$langs->trans("WarehouseAllowNegativeTransfer").'</td>'; print '<td>'.$langs->trans("WarehouseAllowNegativeTransfer").'</td>';
print '<td class="right">'; print '<td class="right">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER'); print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER');
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER); print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER);
} }
print "</td>\n"; print "</td>\n";
print "</tr>\n"; print "</tr>\n";
@ -419,28 +419,28 @@ if ($conf->invoice->enabled)
{ {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("StockMustBeEnoughForInvoice").'</td>'; print '<td>'.$langs->trans("StockMustBeEnoughForInvoice").'</td>';
print '<td class="right">'; print '<td class="right">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE'); print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE');
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE); print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE);
} }
print "</td>\n"; print "</td>\n";
print "</tr>\n"; print "</tr>\n";
} }
if ($conf->order->enabled) if ($conf->order->enabled)
{ {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("StockMustBeEnoughForOrder").'</td>'; print '<td>'.$langs->trans("StockMustBeEnoughForOrder").'</td>';
print '<td class="right">'; print '<td class="right">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER'); print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER');
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER); print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER);
} }
print "</td>\n"; print "</td>\n";
print "</tr>\n"; print "</tr>\n";
} }
@ -449,13 +449,13 @@ if ($conf->expedition->enabled)
{ {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("StockMustBeEnoughForShipment").'</td>'; print '<td>'.$langs->trans("StockMustBeEnoughForShipment").'</td>';
print '<td class="right">'; print '<td class="right">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT'); print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT');
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT); print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT);
} }
print "</td>\n"; print "</td>\n";
print "</tr>\n"; print "</tr>\n";
} }
@ -471,26 +471,26 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
|| !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)
|| !empty($conf->mrp->enabled)) || !empty($conf->mrp->enabled))
{ {
$virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs.
} }
if ($virtualdiffersfromphysical) if ($virtualdiffersfromphysical)
{ {
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print "<td>".$langs->trans("RuleForStockReplenishment")." ".img_help('help', $langs->trans("VirtualDiffersFromPhysical"))."</td>\n"; print "<td>".$langs->trans("RuleForStockReplenishment")." ".img_help('help', $langs->trans("VirtualDiffersFromPhysical"))."</td>\n";
print '<td class="right">'.$langs->trans("Status").'</td>'."\n"; print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
print '</tr>'."\n"; print '</tr>'."\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("UseVirtualStockByDefault").'</td>'; print '<td>'.$langs->trans("UseVirtualStockByDefault").'</td>';
print '<td class="right">'; print '<td class="right">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_USE_VIRTUAL_STOCK'); print ajax_constantonoff('STOCK_USE_VIRTUAL_STOCK');
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_USE_VIRTUAL_STOCK", $arrval, $conf->global->STOCK_USE_VIRTUAL_STOCK); print $form->selectarray("STOCK_USE_VIRTUAL_STOCK", $arrval, $conf->global->STOCK_USE_VIRTUAL_STOCK);
} }
print "</td>\n"; print "</td>\n";
print "</tr>\n"; print "</tr>\n";
print '</table>'; print '</table>';
@ -725,10 +725,10 @@ print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans(
print '</td>'; print '</td>';
print '<td class="right">'; print '<td class="right">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_SUPPORTS_SERVICES'); print ajax_constantonoff('STOCK_SUPPORTS_SERVICES');
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES); print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES);
} }
print "</td>\n"; print "</td>\n";
print "</tr>\n"; print "</tr>\n";
@ -737,10 +737,10 @@ print '<tr class="oddeven">';
print '<td>'.$langs->trans("AllowAddLimitStockByWarehouse").'</td>'; print '<td>'.$langs->trans("AllowAddLimitStockByWarehouse").'</td>';
print '<td class="right">'; print '<td class="right">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE'); print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE');
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", $arrval, $conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE); print $form->selectarray("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", $arrval, $conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE);
} }
print "</td>\n"; print "</td>\n";
print "</tr>\n"; print "</tr>\n";
@ -749,10 +749,10 @@ print '<tr class="oddeven">';
print '<td>'.$langs->trans("AlwaysShowFullArbo").'</td>'; print '<td>'.$langs->trans("AlwaysShowFullArbo").'</td>';
print '<td class="right">'; print '<td class="right">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_ALWAYS_SHOW_FULL_ARBO'); print ajax_constantonoff('STOCK_ALWAYS_SHOW_FULL_ARBO');
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_ALWAYS_SHOW_FULL_ARBO", $arrval, $conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO); print $form->selectarray("STOCK_ALWAYS_SHOW_FULL_ARBO", $arrval, $conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO);
} }
print "</td>\n"; print "</td>\n";
print "</tr>\n"; print "</tr>\n";

View File

@ -61,7 +61,7 @@ $search_all = GETPOST("search_all", 'alpha');
$search = array(); $search = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val)
{ {
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
} }
if (empty($action) && empty($id) && empty($ref)) $action = 'view'; if (empty($action) && empty($id) && empty($ref)) $action = 'view';
@ -92,18 +92,18 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
$error = 0; $error = 0;
$backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php'; $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php';
if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/bom/bom_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); else $backtopage = dol_buildpath('/bom/bom_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
} }
} }
$triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record $triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record
// Actions cancel, add, update, delete or clone // Actions cancel, add, update, delete or clone
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
@ -149,39 +149,39 @@ if (empty($reshook))
} }
if ($object->fk_product == $idprod) { if ($object->fk_product == $idprod) {
setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors'); setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error)
{ {
$lastposition = 0; $lastposition = 0;
$bomline = new BOMLine($db); $bomline = new BOMLine($db);
$bomline->fk_bom = $id; $bomline->fk_bom = $id;
$bomline->fk_product = $idprod; $bomline->fk_product = $idprod;
$bomline->qty = $qty; $bomline->qty = $qty;
$bomline->qty_frozen = (int) $qty_frozen; $bomline->qty_frozen = (int) $qty_frozen;
$bomline->disable_stock_change = (int) $disable_stock_change; $bomline->disable_stock_change = (int) $disable_stock_change;
$bomline->efficiency = $efficiency; $bomline->efficiency = $efficiency;
// Rang to use // Rang to use
$rangmax = $object->line_max(0); $rangmax = $object->line_max(0);
$ranktouse = $rangmax + 1; $ranktouse = $rangmax + 1;
$bomline->position = ($ranktouse + 1); $bomline->position = ($ranktouse + 1);
$result = $bomline->create($user); $result = $bomline->create($user);
if ($result <= 0) if ($result <= 0)
{ {
setEventMessages($bomline->error, $bomline->errors, 'errors'); setEventMessages($bomline->error, $bomline->errors, 'errors');
$action = ''; $action = '';
} else { } else {
unset($_POST['idprod']); unset($_POST['idprod']);
unset($_POST['qty']); unset($_POST['qty']);
unset($_POST['qty_frozen']); unset($_POST['qty_frozen']);
unset($_POST['disable_stock_change']); unset($_POST['disable_stock_change']);
} }
} }
} }
@ -218,9 +218,9 @@ if (empty($reshook))
unset($_POST['idprod']); unset($_POST['idprod']);
unset($_POST['qty']); unset($_POST['qty']);
unset($_POST['qty_frozen']); unset($_POST['qty_frozen']);
unset($_POST['disable_stock_change']); unset($_POST['disable_stock_change']);
$object->fetchLines(); $object->fetchLines();
} }
} }
} }
@ -290,7 +290,7 @@ if (($id || $ref) && $action == 'edit')
print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes'); print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes');
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
@ -321,7 +321,7 @@ if (($id || $ref) && $action == 'edit')
// Part to show record // Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{ {
$res = $object->fetch_optionals(); $res = $object->fetch_optionals();
$head = bomPrepareHead($object); $head = bomPrepareHead($object);
dol_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom'); dol_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom');
@ -331,7 +331,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Confirmation to delete // Confirmation to delete
if ($action == 'delete') if ($action == 'delete')
{ {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1);
} }
// Confirmation to delete line // Confirmation to delete line
if ($action == 'deleteline') if ($action == 'deleteline')
@ -451,7 +451,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$text = $langs->trans('ConfirmSetToDraft', $object->ref); $text = $langs->trans('ConfirmSetToDraft', $object->ref);
$formquestion = array(); $formquestion = array();
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220);
} }
// Call Hook formConfirm // Call Hook formConfirm
@ -543,129 +543,129 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (!empty($object->table_element_line)) if (!empty($object->table_element_line))
{ {
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '').'" method="POST"> print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '').'" method="POST">
<input type="hidden" name="token" value="' . newToken().'"> <input type="hidden" name="token" value="' . newToken().'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'"> <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value=""> <input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id.'"> <input type="hidden" name="id" value="' . $object->id.'">
'; ';
if (!empty($conf->use_javascript_ajax) && $object->status == 0) { if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
} }
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{ {
print '<table id="tablelines" class="noborder noshadow" width="100%">'; print '<table id="tablelines" class="noborder noshadow" width="100%">';
} }
if (!empty($object->lines)) if (!empty($object->lines))
{ {
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl');
} }
// Form to add new line // Form to add new line
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
{ {
if ($action != 'editline') if ($action != 'editline')
{ {
// Add products/services form // Add products/services form
$object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl');
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
} }
} }
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{ {
print '</table>'; print '</table>';
} }
print '</div>'; print '</div>';
print "</form>\n"; print "</form>\n";
} }
// Buttons for actions // Buttons for actions
if ($action != 'presend' && $action != 'editline') { if ($action != 'presend' && $action != 'editline') {
print '<div class="tabsAction">'."\n"; print '<div class="tabsAction">'."\n";
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook))
{ {
// Send // Send
//if (empty($user->socid)) { //if (empty($user->socid)) {
// print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n"; // print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n";
//} //}
// Back to draft // Back to draft
if ($object->status == $object::STATUS_VALIDATED) if ($object->status == $object::STATUS_VALIDATED)
{ {
if ($permissiontoadd) if ($permissiontoadd)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=setdraft">'.$langs->trans("SetToDraft").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=setdraft">'.$langs->trans("SetToDraft").'</a>';
} }
} }
// Modify // Modify
if ($object->status == $object::STATUS_DRAFT) if ($object->status == $object::STATUS_DRAFT)
{ {
if ($permissiontoadd) if ($permissiontoadd)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n"; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
} }
} }
// Validate // Validate
if ($object->status == $object::STATUS_DRAFT) if ($object->status == $object::STATUS_DRAFT)
{ {
if ($permissiontoadd) if ($permissiontoadd)
{ {
if (is_array($object->lines) && count($object->lines) > 0) if (is_array($object->lines) && count($object->lines) > 0)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>';
} else { } else {
$langs->load("errors"); $langs->load("errors");
print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>'; print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
} }
} }
} }
// Close / Cancel // Close / Cancel
if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED) if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close">'.$langs->trans("Disable").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close">'.$langs->trans("Disable").'</a>';
} }
// Re-open // Re-open
if ($permissiontoadd && $object->status == $object::STATUS_CANCELED) if ($permissiontoadd && $object->status == $object::STATUS_CANCELED)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>';
} }
// Create MO // Create MO
if ($conf->mrp->enabled) if ($conf->mrp->enabled)
{ {
if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write)) if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write))
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/mrp/mo_card.php?action=create&fk_bom='.$object->id.'&backtopageforcancel='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("CreateMO").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/mrp/mo_card.php?action=create&fk_bom='.$object->id.'&backtopageforcancel='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("CreateMO").'</a>';
} }
} }
// Clone // Clone
if ($permissiontoadd) if ($permissiontoadd)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&object=bom">'.$langs->trans("ToClone").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&object=bom">'.$langs->trans("ToClone").'</a>';
} }
/* /*
if ($user->rights->bom->write) if ($user->rights->bom->write)
{ {
if ($object->status == 1) if ($object->status == 1)
@ -679,14 +679,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
} }
*/ */
if ($permissiontodelete) if ($permissiontodelete)
{ {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n"; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n"; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
} }
} }
print '</div>'."\n"; print '</div>'."\n";
} }
@ -697,41 +697,41 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($action != 'presend') if ($action != 'presend')
{ {
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
// Documents // Documents
$objref = dol_sanitizeFileName($object->ref); $objref = dol_sanitizeFileName($object->ref);
$relativepath = $objref.'/'.$objref.'.pdf'; $relativepath = $objref.'/'.$objref.'.pdf';
$filedir = $conf->bom->dir_output.'/'.$objref; $filedir = $conf->bom->dir_output.'/'.$objref;
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content $genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content
$delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card $delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card
print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
// Show links to link elements // Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('bom')); $linktoelem = $form->showLinkToObjectBlock($object, null, array('bom'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
$MAXEVENT = 10; $MAXEVENT = 10;
$morehtmlright = '<a href="'.dol_buildpath('/bom/bom_agenda.php', 1).'?id='.$object->id.'">'; $morehtmlright = '<a href="'.dol_buildpath('/bom/bom_agenda.php', 1).'?id='.$object->id.'">';
$morehtmlright .= $langs->trans("SeeAll"); $morehtmlright .= $langs->trans("SeeAll");
$morehtmlright .= '</a>'; $morehtmlright .= '</a>';
// List of actions on element // List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions = new FormActions($db); $formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'bom', $socid, 1, '', $MAXEVENT, '', $morehtmlright); $somethingshown = $formactions->showactions($object, 'bom', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
print '</div></div></div>'; print '</div></div></div>';
} }
//Select mail models is same action as presend //Select mail models is same action as presend
if (GETPOST('modelselected')) $action = 'presend'; if (GETPOST('modelselected')) $action = 'presend';
// Presend form // Presend form
$modelmail = 'bom'; $modelmail = 'bom';

View File

@ -31,8 +31,8 @@
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($object) || !is_object($object)) { if (empty($object) || !is_object($object)) {
print "Error: this template page cannot be called directly as an URL"; print "Error: this template page cannot be called directly as an URL";
exit; exit;
} }
@ -52,34 +52,34 @@ print "<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines); $nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
if ($nolinesbefore) { if ($nolinesbefore) {
print '<tr class="liste_titre nodrag nodrop">'; print '<tr class="liste_titre nodrag nodrop">';
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
print '<td class="linecolnum center"></td>'; print '<td class="linecolnum center"></td>';
} }
print '<td class="linecoldescription minwidth500imp">'; print '<td class="linecoldescription minwidth500imp">';
print '<div id="add"></div><span class="hideonsmartphone">'.$langs->trans('AddNewLine').'</span>'; print '<div id="add"></div><span class="hideonsmartphone">'.$langs->trans('AddNewLine').'</span>';
print '</td>'; print '</td>';
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>'; print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
if ($conf->global->PRODUCT_USE_UNITS) if ($conf->global->PRODUCT_USE_UNITS)
{ {
print '<td class="linecoluseunit left">'; print '<td class="linecoluseunit left">';
print '<span id="title_units">'; print '<span id="title_units">';
print $langs->trans('Unit'); print $langs->trans('Unit');
print '</span></td>'; print '</span></td>';
} }
print '<td class="linecolqtyfrozen right">'.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).'</td>'; print '<td class="linecolqtyfrozen right">'.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).'</td>';
print '<td class="linecoldisablestockchange right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>'; print '<td class="linecoldisablestockchange right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>';
print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>'; print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
print '<td class="linecoledit" colspan="'.$colspan.'">&nbsp;</td>'; print '<td class="linecoledit" colspan="'.$colspan.'">&nbsp;</td>';
print '</tr>'; print '</tr>';
} }
print '<tr class="pair nodrag nodrop nohoverpair'.(($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create').'">'; print '<tr class="pair nodrag nodrop nohoverpair'.(($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create').'">';
$coldisplay = 0; $coldisplay = 0;
// Adds a line numbering column // Adds a line numbering column
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$coldisplay++; $coldisplay++;
echo '<td class="bordertop nobottom linecolnum center"></td>'; echo '<td class="bordertop nobottom linecolnum center"></td>';
} }
$coldisplay++; $coldisplay++;
@ -111,7 +111,7 @@ print '</td>';
if ($conf->global->PRODUCT_USE_UNITS) if ($conf->global->PRODUCT_USE_UNITS)
{ {
$coldisplay++; $coldisplay++;
print '<td class="nobottom linecoluseunit left">'; print '<td class="nobottom linecoluseunit left">';
print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units"); print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units");
print '</td>'; print '</td>';

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -76,7 +76,7 @@ if (!$user->rights->agenda->myactions->read) accessforbidden();
if (!$user->rights->agenda->allactions->read) $canedit = 0; if (!$user->rights->agenda->allactions->read) $canedit = 0;
if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me
{ {
$filtert = $user->id; $filtert = $user->id;
} }
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
@ -91,19 +91,19 @@ $type = GETPOST("search_type", 'aZ09') ?GETPOST("search_type", 'aZ09') : GETPOST
$maxprint = (isset($_GET["maxprint"]) ?GETPOST("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $maxprint = (isset($_GET["maxprint"]) ?GETPOST("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
if ($dateselect > 0) if ($dateselect > 0)
{ {
$day=GETPOST('dateselectday', 'int'); $day = GETPOST('dateselectday', 'int');
$month=GETPOST('dateselectmonth', 'int'); $month = GETPOST('dateselectmonth', 'int');
$year=GETPOST('dateselectyear', 'int'); $year = GETPOST('dateselectyear', 'int');
} }
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
if (GETPOST('search_actioncode', 'array')) if (GETPOST('search_actioncode', 'array'))
{ {
$actioncode = GETPOST('search_actioncode', 'array', 3); $actioncode = GETPOST('search_actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0'; if (!count($actioncode)) $actioncode = '0';
} else { } else {
$actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
} }
@ -119,13 +119,13 @@ if ($action == 'default') // When action is default, we want a calendar view and
$action = (($defaultview != 'show_list') ? $defaultview : 'show_month'); $action = (($defaultview != 'show_list') ? $defaultview : 'show_month');
} }
if (GETPOST('viewcal', 'none') && GETPOST('action', 'alpha') != 'show_day' && GETPOST('action', 'alpha') != 'show_week') { if (GETPOST('viewcal', 'none') && GETPOST('action', 'alpha') != 'show_day' && GETPOST('action', 'alpha') != 'show_week') {
$action = 'show_month'; $day = ''; $action = 'show_month'; $day = '';
} // View by month } // View by month
if (GETPOST('viewweek', 'none') || GETPOST('action', 'alpha') == 'show_week') { if (GETPOST('viewweek', 'none') || GETPOST('action', 'alpha') == 'show_week') {
$action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d"));
} // View by week } // View by week
if (GETPOST('viewday', 'none') || GETPOST('action', 'alpha') == 'show_day') { if (GETPOST('viewday', 'none') || GETPOST('action', 'alpha') == 'show_day') {
$action = 'show_day'; $day = ($day ? $day : date("d")); $action = 'show_day'; $day = ($day ? $day : date("d"));
} // View by day } // View by day
// Load translation files required by the page // Load translation files required by the page
@ -141,46 +141,46 @@ $hookmanager->initHooks(array('agenda'));
if (GETPOST("viewlist", 'alpha') || $action == 'show_list') if (GETPOST("viewlist", 'alpha') || $action == 'show_list')
{ {
$param = ''; $param = '';
if (is_array($_POST)) if (is_array($_POST))
{ {
foreach ($_POST as $key => $val) foreach ($_POST as $key => $val)
{ {
if ($key == 'token') continue; if ($key == 'token') continue;
$param .= '&'.$key.'='.urlencode($val); $param .= '&'.$key.'='.urlencode($val);
} }
} }
if (! preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list'; if (! preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list';
//print $param; //print $param;
header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param); header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param);
exit; exit;
} }
if (GETPOST("viewperuser", 'alpha') || $action == 'show_peruser') if (GETPOST("viewperuser", 'alpha') || $action == 'show_peruser')
{ {
$param = ''; $param = '';
if (is_array($_POST)) if (is_array($_POST))
{ {
foreach ($_POST as $key => $val) foreach ($_POST as $key => $val)
{ {
if ($key == 'token') continue; if ($key == 'token') continue;
$param .= '&'.$key.'='.urlencode($val); $param .= '&'.$key.'='.urlencode($val);
} }
} }
//print $param; //print $param;
header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param); header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param);
exit; exit;
} }
if ($action == 'delete_action') if ($action == 'delete_action')
{ {
$event = new ActionComm($db); $event = new ActionComm($db);
$event->fetch($actionid); $event->fetch($actionid);
$event->fetch_optionals(); $event->fetch_optionals();
$event->fetch_userassigned(); $event->fetch_userassigned();
$event->oldcopy = clone $event; $event->oldcopy = clone $event;
$result = $event->delete(); $result = $event->delete();
} }
@ -226,21 +226,21 @@ $listofextcals = array();
// Define list of external calendars (global admin setup) // Define list of external calendars (global admin setup)
if (empty($conf->global->AGENDA_DISABLE_EXT)) if (empty($conf->global->AGENDA_DISABLE_EXT))
{ {
$i = 0; $i = 0;
while ($i < $MAXAGENDA) while ($i < $MAXAGENDA)
{ {
$i++; $i++;
$source = 'AGENDA_EXT_SRC'.$i; $source = 'AGENDA_EXT_SRC'.$i;
$name = 'AGENDA_EXT_NAME'.$i; $name = 'AGENDA_EXT_NAME'.$i;
$offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i;
$color = 'AGENDA_EXT_COLOR'.$i; $color = 'AGENDA_EXT_COLOR'.$i;
$buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i;
if (!empty($conf->global->$source) && !empty($conf->global->$name)) if (!empty($conf->global->$source) && !empty($conf->global->$name))
{ {
// Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
$listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0)); $listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0));
} }
} }
} }
// Define list of external calendars (user setup) // Define list of external calendars (user setup)
if (empty($user->conf->AGENDA_DISABLE_EXT)) if (empty($user->conf->AGENDA_DISABLE_EXT))
@ -251,7 +251,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT))
$i++; $i++;
$source = 'AGENDA_EXT_SRC_'.$user->id.'_'.$i; $source = 'AGENDA_EXT_SRC_'.$user->id.'_'.$i;
$name = 'AGENDA_EXT_NAME_'.$user->id.'_'.$i; $name = 'AGENDA_EXT_NAME_'.$user->id.'_'.$i;
$offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i;
$color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i; $color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i;
$enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i; $enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i;
$buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i; $buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i;
@ -265,65 +265,65 @@ if (empty($user->conf->AGENDA_DISABLE_EXT))
if (empty($action) || $action == 'show_month') if (empty($action) || $action == 'show_month')
{ {
$prev = dol_get_prev_month($month, $year); $prev = dol_get_prev_month($month, $year);
$prev_year = $prev['year']; $prev_year = $prev['year'];
$prev_month = $prev['month']; $prev_month = $prev['month'];
$next = dol_get_next_month($month, $year); $next = dol_get_next_month($month, $year);
$next_year = $next['year']; $next_year = $next['year'];
$next_month = $next['month']; $next_month = $next['month'];
$max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month
$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month
// tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday)
$tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday
$tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week.
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
$firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year); $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year);
$next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7; $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
if ($next_day < 6) $next_day += 7; if ($next_day < 6) $next_day += 7;
$lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year);
} }
if ($action == 'show_week') if ($action == 'show_week')
{ {
$prev = dol_get_first_day_week($day, $month, $year); $prev = dol_get_first_day_week($day, $month, $year);
$prev_year = $prev['prev_year']; $prev_year = $prev['prev_year'];
$prev_month = $prev['prev_month']; $prev_month = $prev['prev_month'];
$prev_day = $prev['prev_day']; $prev_day = $prev['prev_day'];
$first_day = $prev['first_day']; $first_day = $prev['first_day'];
$first_month = $prev['first_month']; $first_month = $prev['first_month'];
$first_year = $prev['first_year']; $first_year = $prev['first_year'];
$week = $prev['week']; $week = $prev['week'];
$day = (int) $day; $day = (int) $day;
$next = dol_get_next_week($first_day, $week, $first_month, $first_year); $next = dol_get_next_week($first_day, $week, $first_month, $first_year);
$next_year = $next['year']; $next_year = $next['year'];
$next_month = $next['month']; $next_month = $next['month'];
$next_day = $next['day']; $next_day = $next['day'];
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year);
$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd');
$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year));
$tmpday = $first_day; $tmpday = $first_day;
} }
if ($action == 'show_day') if ($action == 'show_day')
{ {
$prev = dol_get_prev_day($day, $month, $year); $prev = dol_get_prev_day($day, $month, $year);
$prev_year = $prev['year']; $prev_year = $prev['year'];
$prev_month = $prev['month']; $prev_month = $prev['month'];
$prev_day = $prev['day']; $prev_day = $prev['day'];
$next = dol_get_next_day($day, $month, $year); $next = dol_get_next_day($day, $month, $year);
$next_year = $next['year']; $next_year = $next['year'];
$next_month = $next['month']; $next_month = $next['month'];
$next_day = $next['day']; $next_day = $next['day'];
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
$firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year); $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year);
$lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year);
} }
//print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day; //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day;
//print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day;
@ -356,30 +356,30 @@ $param .= "&maxprint=".urlencode($maxprint);
// Show navigation bar // Show navigation bar
if (empty($action) || $action == 'show_month') if (empty($action) || $action == 'show_month')
{ {
$nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n"; $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y"); $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y");
$nav .= " </span>\n"; $nav .= " </span>\n";
$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n"; $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth.$param."\">".$langs->trans("Today")."</a> "; $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth.$param."\">".$langs->trans("Today")."</a> ";
$picto = 'calendar'; $picto = 'calendar';
} }
if ($action == 'show_week') if ($action == 'show_week')
{ {
$nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\" title=\"".dol_escape_htmltag($langs->trans("Previous"))."\"></i></a> &nbsp;\n"; $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\" title=\"".dol_escape_htmltag($langs->trans("Previous"))."\"></i></a> &nbsp;\n";
$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week;
$nav .= " </span>\n"; $nav .= " </span>\n";
$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n"; $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n";
$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> "; $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
$picto = 'calendarweek'; $picto = 'calendarweek';
} }
if ($action == 'show_day') if ($action == 'show_day')
{ {
$nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n"; $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort"); $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort");
$nav .= " </span>\n"; $nav .= " </span>\n";
$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n"; $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> "; $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
$picto = 'calendarday'; $picto = 'calendarday';
} }
$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
@ -471,21 +471,21 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on
$s .= 'jQuery(".family_birthday").toggle();'."\n"; $s .= 'jQuery(".family_birthday").toggle();'."\n";
if ($action == "show_week" || $action == "show_month" || empty($action)) if ($action == "show_week" || $action == "show_month" || empty($action))
{ {
// Code to enable drag and drop // Code to enable drag and drop
$s .= 'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n"; $s .= 'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n";
// Code to submit form // Code to submit form
$s .= 'console.log("submit form to record new event");'."\n"; $s .= 'console.log("submit form to record new event");'."\n";
//$s.='console.log(event.target);'; //$s.='console.log(event.target);';
$s .= 'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'."\n"; $s .= 'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'."\n";
$s .= 'console.log("found parent div.dayevent with id = "+newval);'."\n"; $s .= 'console.log("found parent div.dayevent with id = "+newval);'."\n";
$s .= 'var frm=jQuery("#searchFormList");'."\n"; $s .= 'var frm=jQuery("#searchFormList");'."\n";
$s .= 'var newurl = ui.item.find("a.cal_event").attr("href");'."\n"; $s .= 'var newurl = ui.item.find("a.cal_event").attr("href");'."\n";
$s .= 'console.log(newurl);'."\n"; $s .= 'console.log(newurl);'."\n";
$s .= 'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'."\n"; $s .= 'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'."\n";
$s .= '});'."\n"; $s .= '});'."\n";
} }
$s .= '});'."\n"; $s .= '});'."\n";
$s .= '</script>'."\n"; $s .= '</script>'."\n";
// Local calendar // Local calendar
$s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>'; $s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
@ -513,26 +513,26 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on
$s .= '<div class="nowrap inline-block"><input type="checkbox" id="check_birthday" name="check_birthday" class="check_birthday"> <span class="check_birthday_text">'.$langs->trans("AgendaShowBirthdayEvents").'</span> &nbsp; </div>'; $s .= '<div class="nowrap inline-block"><input type="checkbox" id="check_birthday" name="check_birthday" class="check_birthday"> <span class="check_birthday_text">'.$langs->trans("AgendaShowBirthdayEvents").'</span> &nbsp; </div>';
// Calendars from hooks // Calendars from hooks
$parameters = array(); $object = null; $parameters = array(); $object = null;
$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
if (empty($reshook)) if (empty($reshook))
{
$s .= $hookmanager->resPrint;
} elseif ($reshook > 1)
{ {
$s = $hookmanager->resPrint; $s .= $hookmanager->resPrint;
} } elseif ($reshook > 1)
{
$s = $hookmanager->resPrint;
}
} else // If javascript off } else // If javascript off
{ {
$newparam = $param; // newparam is for birthday links $newparam = $param; // newparam is for birthday links
$newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam); $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1'; if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1';
$link = '<a href="'.dol_escape_htmltag($_SERVER['PHP_SELF']); $link = '<a href="'.dol_escape_htmltag($_SERVER['PHP_SELF']);
$link .= '?'.dol_escape_htmltag($newparam); $link .= '?'.dol_escape_htmltag($newparam);
$link .= '">'; $link .= '">';
if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents"); if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents");
else $link .= $langs->trans("AgendaHideBirthdayEvents"); else $link .= $langs->trans("AgendaHideBirthdayEvents");
$link .= '</a>'; $link .= '</a>';
} }
// Load events from database into $eventarray // Load events from database into $eventarray
@ -561,26 +561,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')';
// Condition on actioncode // Condition on actioncode
if (!empty($actioncode)) if (!empty($actioncode))
{ {
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
{ {
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
else { else {
if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'";
if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'";
} }
} else { } else {
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
else { else {
if (is_array($actioncode)) if (is_array($actioncode))
{ {
$sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')";
} else { } else {
$sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
} }
} }
} }
} }
if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid);
@ -590,28 +590,28 @@ if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid;
if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($action == 'show_day') if ($action == 'show_day')
{ {
$sql .= " AND ("; $sql .= " AND (";
$sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
$sql .= " OR "; $sql .= " OR ";
$sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
$sql .= " OR "; $sql .= " OR ";
$sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
$sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
$sql .= ')'; $sql .= ')';
} else { } else {
// To limit array // To limit array
$sql .= " AND ("; $sql .= " AND (";
$sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before
$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31 $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31
$sql .= " OR "; $sql .= " OR ";
$sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
$sql .= " OR "; $sql .= " OR ";
$sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
$sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
$sql .= ')'; $sql .= ')';
} }
if ($type) $sql .= " AND ca.id = ".$type; if ($type) $sql .= " AND ca.id = ".$type;
if ($status == '0') { $sql .= " AND a.percent = 0"; } if ($status == '0') { $sql .= " AND a.percent = 0"; }
@ -622,10 +622,10 @@ if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; }
// We must filter on assignement table // We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) if ($filtert > 0 || $usergroup > 0)
{ {
$sql .= " AND ("; $sql .= " AND (";
if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert;
if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
$sql .= ")"; $sql .= ")";
} }
// Sort on date // Sort on date
$sql .= ' ORDER BY datep'; $sql .= ' ORDER BY datep';
@ -1090,8 +1090,8 @@ if (count($listofextcals))
// Transparency (see https://www.kanzaki.com/docs/ical/transp.html) // Transparency (see https://www.kanzaki.com/docs/ical/transp.html)
if ($icalevent['TRANSP']) if ($icalevent['TRANSP'])
{ {
if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0; // 0 = available / free if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0; // 0 = available / free
if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1; // 1 = busy if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1; // 1 = busy
// TODO: MS outlook states // TODO: MS outlook states
// X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:TRANSPARENT => Available / Free // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:TRANSPARENT => Available / Free
@ -1156,12 +1156,12 @@ if (count($listofextcals))
$parameters = array(); $object = null; $parameters = array(); $object = null;
$reshook = $hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action); $reshook = $hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action);
if (!empty($hookmanager->resArray['eventarray'])) { if (!empty($hookmanager->resArray['eventarray'])) {
foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) { foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) {
if (!isset($eventarray[$keyDate])) { if (!isset($eventarray[$keyDate])) {
$eventarray[$keyDate] = array(); $eventarray[$keyDate] = array();
} }
$eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events); $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
} }
} }
// Sort events // Sort events
@ -1180,7 +1180,7 @@ $cacheusers = array();
$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php";
if (is_readable($color_file)) if (is_readable($color_file))
{ {
include_once $color_file; include_once $color_file;
} }
if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
@ -1384,39 +1384,39 @@ if (empty($action) || $action == 'show_month') // View by month
echo " </div>\n"; echo " </div>\n";
*/ */
echo '</table>'; echo '</table>';
print '</div>'; print '</div>';
/* WIP View per hour */ /* WIP View per hour */
$useviewhour = 0; $useviewhour = 0;
if ($useviewhour) if ($useviewhour)
{ {
print '<div class="div-table-responsive-no-min borderbottom">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '<div class="div-table-responsive-no-min borderbottom">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
$maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file
echo '<div style="max-height: '.$maxheightwin.'px;">'; echo '<div style="max-height: '.$maxheightwin.'px;">';
echo '<div class="tagtable centpercent calendarviewcontainer">'; echo '<div class="tagtable centpercent calendarviewcontainer">';
$maxnbofchar = 80; $maxnbofchar = 80;
$tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS); $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS);
$minhour = round($tmp[0], 0); $minhour = round($tmp[0], 0);
$maxhour = round($tmp[1], 0); $maxhour = round($tmp[1], 0);
if ($minhour > 23) $minhour = 23; if ($minhour > 23) $minhour = 23;
if ($maxhour < 1) $maxhour = 1; if ($maxhour < 1) $maxhour = 1;
if ($maxhour <= $minhour) { $maxhour = $minhour + 1; } if ($maxhour <= $minhour) { $maxhour = $minhour + 1; }
$i = 0; $i = 0;
$j = 0; $j = 0;
while ($i < 24) while ($i < 24)
{ {
echo ' <div class="tagtr calendarviewcontainertr">'."\n"; echo ' <div class="tagtr calendarviewcontainertr">'."\n";
echo ' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600, 'hour', 'gmt').'</div>'; echo ' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600, 'hour', 'gmt').'</div>';
echo ' <div class="tagtd '.$style.' tdtop"></div>'."\n"; echo ' <div class="tagtd '.$style.' tdtop"></div>'."\n";
echo ' </div>'."\n"; echo ' </div>'."\n";
$i++; $i++;
$j++; $j++;
} }
echo '</div></div>'; echo '</div></div>';
@ -1424,13 +1424,13 @@ if (empty($action) || $action == 'show_month') // View by month
show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1); show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1);
print '</div>'; print '</div>';
} else { } else {
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0); show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
print '</div>'; print '</div>';
} }
} }
print "\n".'</form>'; print "\n".'</form>';
@ -1871,11 +1871,11 @@ function dol_color_minus($color, $minus, $minusunit = 16)
$newcolor = $color; $newcolor = $color;
if ($minusunit == 16) if ($minusunit == 16)
{ {
$newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0)); $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
$newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0)); $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
$newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0)); $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
} else { } else {
// Not yet implemented // Not yet implemented
} }
return $newcolor; return $newcolor;
} }
@ -1890,39 +1890,39 @@ function dol_color_minus($color, $minus, $minusunit = 16)
function sort_events_by_date($a, $b) function sort_events_by_date($a, $b)
{ {
// Sort holidays at first // Sort holidays at first
if ($a->type_code === 'HOLIDAY') if ($a->type_code === 'HOLIDAY')
{ {
return -1; return -1;
} }
if ($b->type_code === 'HOLIDAY') if ($b->type_code === 'HOLIDAY')
{ {
return 1; return 1;
} }
// datep => Event start time // datep => Event start time
// datef => Event end time // datef => Event end time
// Events have different start time // Events have different start time
if ($a->datep !== $b->datep) if ($a->datep !== $b->datep)
{ {
return $a->datep - $b->datep; return $a->datep - $b->datep;
} }
// Events have same start time and no end time // Events have same start time and no end time
if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) if ((!is_numeric($b->datef)) || (!is_numeric($a->datef)))
{ {
return sort_events_by_percentage($a, $b); return sort_events_by_percentage($a, $b);
} }
// Events have the same start time and same end time // Events have the same start time and same end time
if ($b->datef === $a->datef) if ($b->datef === $a->datef)
{ {
return sort_events_by_percentage($a, $b); return sort_events_by_percentage($a, $b);
} }
// Events have the same start time, but have different end time -> longest event first // Events have the same start time, but have different end time -> longest event first
return $b->datef - $a->datef; return $b->datef - $a->datef;
} }
/** /**
@ -1934,18 +1934,18 @@ function sort_events_by_date($a, $b)
*/ */
function sort_events_by_percentage($a, $b) function sort_events_by_percentage($a, $b)
{ {
// Sort events with no percentage before each other // Sort events with no percentage before each other
// (usefull to sort holidays, sick days or similar on the top) // (usefull to sort holidays, sick days or similar on the top)
if ($a->percentage < 0) if ($a->percentage < 0)
{ {
return -1; return -1;
} }
if ($b->percentage < 0) if ($b->percentage < 0)
{ {
return 1; return 1;
} }
return $b->percentage - $a->percentage; return $b->percentage - $a->percentage;
} }

View File

@ -160,7 +160,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
if (GETPOST('cancel', 'alpha')) if (GETPOST('cancel', 'alpha'))
{ {
$action='list'; $massaction=''; $action = 'list'; $massaction = '';
} }
if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday"))
@ -708,7 +708,7 @@ if ($resql)
$labeltype = $langs->trans("Message"); $labeltype = $langs->trans("Message");
} else { } else {
if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype];
if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code
} }
print dol_trunc($labeltype, 28); print dol_trunc($labeltype, 28);
print '</td>'; print '</td>';

View File

@ -211,7 +211,6 @@ if (empty($reshook))
$substitutionarray['__OTHER4__'] = $other4; $substitutionarray['__OTHER4__'] = $other4;
$substitutionarray['__OTHER5__'] = $other5; $substitutionarray['__OTHER5__'] = $other5;
$substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
$substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>'; $substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
$substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>'; $substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>';

View File

@ -472,6 +472,8 @@ if ($resql)
'generate_doc'=>$langs->trans("ReGeneratePDF"), 'generate_doc'=>$langs->trans("ReGeneratePDF"),
'builddoc'=>$langs->trans("PDFMerge"), 'builddoc'=>$langs->trans("PDFMerge"),
'presend'=>$langs->trans("SendByMail"), 'presend'=>$langs->trans("SendByMail"),
'prevalidate'=>$langs->trans("Validate"),
'presign'=>$langs->trans("Sign"),
); );
if ($user->rights->propal->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); if ($user->rights->propal->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if ($user->rights->propal->cloturer) $arrayofmassactions['closed'] = $langs->trans("Close"); if ($user->rights->propal->cloturer) $arrayofmassactions['closed'] = $langs->trans("Close");
@ -502,6 +504,16 @@ if ($resql)
$trackid = 'pro'.$object->id; $trackid = 'pro'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($massaction == 'prevalidate')
{
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1);
}
if ($massaction == 'presign')
{
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSignature"), $langs->trans("ConfirmMassSignatureQuestion"), "sign", null, '', 0, 200, 500, 1);
}
if ($sall) if ($sall)
{ {
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
@ -1270,10 +1282,72 @@ if ($resql)
$delallowed = $user->rights->propal->creer; $delallowed = $user->rights->propal->creer;
print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
if ($action == 'validate') {
if (GETPOST('confirm') == 'yes') {
$tmpproposal = new Propal($db);
$db->begin();
$error = 0;
foreach ($toselect as $checked) {
if ($tmpproposal->fetch($checked)) {
if ($tmpproposal->statut == 0) {
if ($tmpproposal->valid($user)){
setEventMessage($tmpproposal->ref . " " . $langs->trans('PassedInOpenStatus'), 'mesgs');
} else {
setEventMessage($langs->trans('CantBeValidated'), 'errors');
$error++;
}
} else {
setEventMessage($tmpproposal->ref . " " . $langs->trans('IsNotADraft'), 'errors');
$error++;
}
}
dol_print_error($db);
$error++;
}
if ($error){
$db->rollback();
} else {
$db->commit();
}
}
}
if ($action == "sign") {
if (GETPOST('confirm') == 'yes') {
$tmpproposal = new Propal($db);
$db->begin();
$error = 0;
foreach ($toselect as $checked) {
if ($tmpproposal->fetch($checked)) {
if ($tmpproposal->statut == 1) {
$tmpproposal->statut = 2;
if ($tmpproposal->update($user)) {
setEventMessage($tmpproposal->ref . " " . $langs->trans('Signed'), 'mesgs');
} else {
dol_print_error($db);
$error++;
}
} else {
setEventMessage($tmpproposal->ref . " " . $langs->trans('CantBeSign'), 'errors');
$error++;
}
} else {
dol_print_error($db);
$error++;
}
}
if ($error){
$db->rollback();
} else {
$db->commit();
}
}
}
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -159,8 +159,8 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
$reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters); $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters);
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
$sql.= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, "; $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, ";
$sql.= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; $sql .= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
// Add Group from hooks // Add Group from hooks
$parameters = array(); $parameters = array();

View File

@ -81,38 +81,38 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
if ($action == 'confirm_delete') if ($action == 'confirm_delete')
{ {
$res = $object->delete($user); $res = $object->delete($user);
if ($res > 0) if ($res > 0)
{ {
if ($object->type == 'bank-transfer') { if ($object->type == 'bank-transfer') {
header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php'); header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php');
} else { } else {
header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php'); header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php');
} }
exit; exit;
} }
} }
// Seems to no be used and replaced with $action == 'infocredit' // Seems to no be used and replaced with $action == 'infocredit'
if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes') if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes')
{ {
$res = $object->set_credite(); $res = $object->set_credite();
if ($res >= 0) if ($res >= 0)
{ {
header("Location: card.php?id=".$id); header("Location: card.php?id=".$id);
exit; exit;
} }
} }
if ($action == 'infotrans' && $user->rights->prelevement->bons->send) if ($action == 'infotrans' && $user->rights->prelevement->bons->send)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
/* /*
if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref) if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref)
{ {
$dir = $conf->prelevement->dir_output.'/receipts'; $dir = $conf->prelevement->dir_output.'/receipts';
@ -133,24 +133,24 @@ if (empty($reshook))
$error = $object->set_infotrans($user, $dt, GETPOST('methode', 'alpha')); $error = $object->set_infotrans($user, $dt, GETPOST('methode', 'alpha'));
if ($error) if ($error)
{ {
header("Location: card.php?id=".$id."&error=$error"); header("Location: card.php?id=".$id."&error=$error");
exit; exit;
} }
} }
// Set direct debit order to credited, create payment and close invoices // Set direct debit order to credited, create payment and close invoices
if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) if ($action == 'infocredit' && $user->rights->prelevement->bons->credit)
{ {
$dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$error = $object->set_infocredit($user, $dt); $error = $object->set_infocredit($user, $dt);
if ($error) if ($error)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }

View File

@ -318,7 +318,7 @@ class BonPrelevement extends CommonObject
$this->type = $obj->type; $this->type = $obj->type;
$this->status = $obj->status; $this->status = $obj->status;
$this->statut = $obj->status; // For backward compatibility $this->statut = $obj->status; // For backward compatibility
$this->fetched = 1; $this->fetched = 1;
@ -510,7 +510,7 @@ class BonPrelevement extends CommonObject
$paiement->num_paiement = $this->ref; // For backward compatibility $paiement->num_paiement = $this->ref; // For backward compatibility
$paiement->id_prelevement = $this->id; $paiement->id_prelevement = $this->id;
$paiement_id = $paiement->create($user); // This use ->paiementid, that is ID of payment mode $paiement_id = $paiement->create($user); // This use ->paiementid, that is ID of payment mode
if ($paiement_id < 0) if ($paiement_id < 0)
{ {
$error++; $error++;
@ -540,7 +540,7 @@ class BonPrelevement extends CommonObject
// Update withdrawal line // Update withdrawal line
// TODO: Translate to ligneprelevement.class.php // TODO: Translate to ligneprelevement.class.php
if (! $error) { if (!$error) {
$sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes"; $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes";
$sql .= " SET statut = 2"; $sql .= " SET statut = 2";
$sql .= " WHERE fk_prelevement_bons = ".$this->id; $sql .= " WHERE fk_prelevement_bons = ".$this->id;
@ -884,7 +884,7 @@ class BonPrelevement extends CommonObject
$sql .= " AND f.rowid = pfd.fk_facture_fourn"; $sql .= " AND f.rowid = pfd.fk_facture_fourn";
} }
$sql .= " AND s.rowid = f.fk_soc"; $sql .= " AND s.rowid = f.fk_soc";
$sql .= " AND f.fk_statut = 1"; // Invoice validated $sql .= " AND f.fk_statut = 1"; // Invoice validated
$sql .= " AND f.paye = 0"; $sql .= " AND f.paye = 0";
$sql .= " AND pfd.traite = 0"; $sql .= " AND pfd.traite = 0";
$sql .= " AND f.total_ttc > 0"; $sql .= " AND f.total_ttc > 0";
@ -1179,7 +1179,7 @@ class BonPrelevement extends CommonObject
/* /*
* Update total defined after generation of file * Update total defined after generation of file
*/ */
if (! $error) { if (!$error) {
$sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
$sql .= " SET amount = ".price2num($this->total); $sql .= " SET amount = ".price2num($this->total);
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
@ -1542,7 +1542,7 @@ class BonPrelevement extends CommonObject
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if (! empty($cachearraytotestduplicate[$obj->idfac])) { if (!empty($cachearraytotestduplicate[$obj->idfac])) {
$this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid); $this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid);
$this->invoice_in_error[$obj->idfac] = $this->error; $this->invoice_in_error[$obj->idfac] = $this->error;
$result = -2; $result = -2;
@ -1657,7 +1657,7 @@ class BonPrelevement extends CommonObject
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if (! empty($cachearraytotestduplicate[$obj->idfac])) { if (!empty($cachearraytotestduplicate[$obj->idfac])) {
$this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid); $this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid);
$this->invoice_in_error[$obj->idfac] = $this->error; $this->invoice_in_error[$obj->idfac] = $this->error;
$result = -2; $result = -2;
@ -2192,7 +2192,7 @@ class BonPrelevement extends CommonObject
$XML_SEPA_INFO .= ' <AdrLine>'.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.'</AdrLine>'.$CrLf; $XML_SEPA_INFO .= ' <AdrLine>'.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.'</AdrLine>'.$CrLf;
$XML_SEPA_INFO .= ' </PstlAdr>'.$CrLf; $XML_SEPA_INFO .= ' </PstlAdr>'.$CrLf;
$XML_SEPA_INFO .= ' </UltmtCdtr>'.$CrLf;*/ $XML_SEPA_INFO .= ' </UltmtCdtr>'.$CrLf;*/
$XML_SEPA_INFO .= ' <ChrgBr>SLEV</ChrgBr>'.$CrLf; // Field "Responsible of fees". Must be SLEV $XML_SEPA_INFO .= ' <ChrgBr>SLEV</ChrgBr>'.$CrLf; // Field "Responsible of fees". Must be SLEV
$XML_SEPA_INFO .= ' <CdtrSchmeId>'.$CrLf; $XML_SEPA_INFO .= ' <CdtrSchmeId>'.$CrLf;
$XML_SEPA_INFO .= ' <Id>'.$CrLf; $XML_SEPA_INFO .= ' <Id>'.$CrLf;
$XML_SEPA_INFO .= ' <PrvtId>'.$CrLf; $XML_SEPA_INFO .= ' <PrvtId>'.$CrLf;
@ -2254,7 +2254,7 @@ class BonPrelevement extends CommonObject
$XML_SEPA_INFO .= ' <AdrLine>'.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.'</AdrLine>'.$CrLf; $XML_SEPA_INFO .= ' <AdrLine>'.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.'</AdrLine>'.$CrLf;
$XML_SEPA_INFO .= ' </PstlAdr>'.$CrLf; $XML_SEPA_INFO .= ' </PstlAdr>'.$CrLf;
$XML_SEPA_INFO .= ' </UltmtCdtr>'.$CrLf;*/ $XML_SEPA_INFO .= ' </UltmtCdtr>'.$CrLf;*/
$XML_SEPA_INFO .= ' <ChrgBr>SLEV</ChrgBr>'.$CrLf; // Field "Responsible of fees". Must be SLEV $XML_SEPA_INFO .= ' <ChrgBr>SLEV</ChrgBr>'.$CrLf; // Field "Responsible of fees". Must be SLEV
/*$XML_SEPA_INFO .= ' <CdtrSchmeId>'.$CrLf; /*$XML_SEPA_INFO .= ' <CdtrSchmeId>'.$CrLf;
$XML_SEPA_INFO .= ' <Id>'.$CrLf; $XML_SEPA_INFO .= ' <Id>'.$CrLf;
$XML_SEPA_INFO .= ' <PrvtId>'.$CrLf; $XML_SEPA_INFO .= ' <PrvtId>'.$CrLf;

View File

@ -84,10 +84,10 @@ if (empty($reshook))
$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS; $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
} }
$bprev = new BonPrelevement($db); $bprev = new BonPrelevement($db);
$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int')); $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int'));
// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore) // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore)
$result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type); $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
if ($result < 0) { if ($result < 0) {
setEventMessages($bprev->error, $bprev->errors, 'errors'); setEventMessages($bprev->error, $bprev->errors, 'errors');
} elseif ($result == 0) { } elseif ($result == 0) {
@ -188,30 +188,30 @@ print '<form action="'.$_SERVER['PHP_SELF'].'?action=create" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="type" value="'.$type.'">'; print '<input type="hidden" name="type" value="'.$type.'">';
if ($nb) { if ($nb) {
if ($pricetowithdraw) { if ($pricetowithdraw) {
print $langs->trans('ExecutionDate').' '; print $langs->trans('ExecutionDate').' ';
$datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
print $form->selectDate($datere, 're'); print $form->selectDate($datere, 're');
if ($mysoc->isInEEC()) { if ($mysoc->isInEEC()) {
$title = $langs->trans("CreateForSepa"); $title = $langs->trans("CreateForSepa");
if ($type == 'bank-transfer') { if ($type == 'bank-transfer') {
$title = $langs->trans("CreateSepaFileForPaymentByBankTransfer"); $title = $langs->trans("CreateSepaFileForPaymentByBankTransfer");
} }
if ($type != 'bank-transfer') { if ($type != 'bank-transfer') {
print '<select name="format">'; print '<select name="format">';
print '<option value="FRST"'.(GETPOST('format', 'aZ09') == 'FRST' ? ' selected="selected"' : '').'>'.$langs->trans('SEPAFRST').'</option>'; print '<option value="FRST"'.(GETPOST('format', 'aZ09') == 'FRST' ? ' selected="selected"' : '').'>'.$langs->trans('SEPAFRST').'</option>';
print '<option value="RCUR"'.(GETPOST('format', 'aZ09') == 'RCUR' ? ' selected="selected"' : '').'>'.$langs->trans('SEPARCUR').'</option>'; print '<option value="RCUR"'.(GETPOST('format', 'aZ09') == 'RCUR' ? ' selected="selected"' : '').'>'.$langs->trans('SEPARCUR').'</option>';
print '</select>'; print '</select>';
} }
print '<input class="butAction" type="submit" value="'.$title.'"/>'; print '<input class="butAction" type="submit" value="'.$title.'"/>';
} else { } else {
$title = $langs->trans("CreateAll"); $title = $langs->trans("CreateAll");
if ($type == 'bank-transfer') { if ($type == 'bank-transfer') {
$title = $langs->trans("CreateFileForPaymentByBankTransfer"); $title = $langs->trans("CreateFileForPaymentByBankTransfer");
} }
print '<a class="butAction" type="submit" href="create.php?action=create&format=ALL&type='.$type.'">'.$title."</a>\n"; print '<a class="butAction" type="submit" href="create.php?action=create&format=ALL&type='.$type.'">'.$title."</a>\n";
} }
} else { } else {
if ($mysoc->isInEEC()) if ($mysoc->isInEEC())
@ -301,12 +301,12 @@ if ($resql)
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$param = ''; $param = '';
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($socid) $param .= '&socid='.urlencode($socid); if ($socid) $param .= '&socid='.urlencode($socid);
if ($option) $param .= "&option=".urlencode($option); if ($option) $param .= "&option=".urlencode($option);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
if (!empty($limit)) { if (!empty($limit)) {
@ -317,12 +317,12 @@ if ($resql)
if ($type == 'bank-transfer') { if ($type == 'bank-transfer') {
$title = $langs->trans("InvoiceWaitingPaymentByBankTransfer"); $title = $langs->trans("InvoiceWaitingPaymentByBankTransfer");
} }
print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit); print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit);
$tradinvoice = "Invoice"; $tradinvoice = "Invoice";
if ($type == 'bank-transfer') { if ($type == 'bank-transfer') {
$tradinvoice = "SupplierInvoice"; $tradinvoice = "SupplierInvoice";
} }
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -82,8 +82,8 @@ llxHeader('', $langs->trans("WithdrawalsReceipts"));
if ($id > 0 || $ref) if ($id > 0 || $ref)
{ {
if ($object->fetch($id, $ref) >= 0) if ($object->fetch($id, $ref) >= 0)
{ {
$head = prelevement_prepare_head($object); $head = prelevement_prepare_head($object);
dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
@ -151,9 +151,9 @@ if ($id > 0 || $ref)
print '</div>'; print '</div>';
dol_fiche_end(); dol_fiche_end();
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
@ -191,13 +191,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$resql = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql); $nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -212,13 +212,13 @@ if ($resql)
// Lines of title fields // Lines of title fields
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';
@ -245,38 +245,38 @@ if ($resql)
$invoicetmpsupplier = new FactureFournisseur($db); $invoicetmpsupplier = new FactureFournisseur($db);
while ($i < min($num, $limit)) while ($i < min($num, $limit))
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj->type == 'bank-transfer') { if ($obj->type == 'bank-transfer') {
$invoicetmp = $invoicetmpsupplier; $invoicetmp = $invoicetmpsupplier;
} else { } else {
$invoicetmp = $invoicetmpcustomer; $invoicetmp = $invoicetmpcustomer;
} }
$invoicetmp->fetch($obj->facid); $invoicetmp->fetch($obj->facid);
$thirdpartytmp->fetch($obj->socid); $thirdpartytmp->fetch($obj->socid);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>"; print "<td>";
print $invoicetmp->getNomUrl(1); print $invoicetmp->getNomUrl(1);
print "</td>\n"; print "</td>\n";
print '<td>'; print '<td>';
print $thirdpartytmp->getNomUrl(1); print $thirdpartytmp->getNomUrl(1);
print "</td>\n"; print "</td>\n";
// Amount of invoice // Amount of invoice
print '<td class="right">'.price($obj->total_ttc)."</td>\n"; print '<td class="right">'.price($obj->total_ttc)."</td>\n";
// Amount requested // Amount requested
print '<td class="right">'.price($obj->amount_requested)."</td>\n"; print '<td class="right">'.price($obj->amount_requested)."</td>\n";
// Status of requests // Status of requests
print '<td class="center">'; print '<td class="center">';
if ($obj->statut == 0) { if ($obj->statut == 0) {
print '-'; print '-';
} elseif ($obj->statut == 2) { } elseif ($obj->statut == 2) {
if ($obj->type == 'bank-transfer') { if ($obj->type == 'bank-transfer') {
@ -288,34 +288,34 @@ if ($resql)
print '<b>'.$langs->trans("StatusRefused").'</b>'; print '<b>'.$langs->trans("StatusRefused").'</b>';
} }
print "</td>"; print "</td>";
print "<td></td>"; print "<td></td>";
print "</tr>\n"; print "</tr>\n";
$totalinvoices += $obj->total_ttc; $totalinvoices += $obj->total_ttc;
$totalamount_requested += $obj->amount_requested; $totalamount_requested += $obj->amount_requested;
$i++; $i++;
} }
if ($num > 0) if ($num > 0)
{ {
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td>'.$langs->trans("Total").'</td>'; print '<td>'.$langs->trans("Total").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td class="right">'; print '<td class="right">';
//if ($totalinvoices != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); // It is normal to have total that differs. For an amount of invoice of 100, request to pay may be 50 only. //if ($totalinvoices != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); // It is normal to have total that differs. For an amount of invoice of 100, request to pay may be 50 only.
if ($totalamount_requested != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); if ($totalamount_requested != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices");
print "</td>\n"; print "</td>\n";
print '<td class="right">'; print '<td class="right">';
print price($totalamount_requested); print price($totalamount_requested);
print "</td>\n"; print "</td>\n";
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
} }
print "</table>"; print "</table>";
print '</div>'; print '</div>';

View File

@ -76,8 +76,8 @@ llxHeader('', $langs->trans("WithdrawalsReceipts"));
if ($prev_id > 0 || $ref) if ($prev_id > 0 || $ref)
{ {
if ($object->fetch($prev_id, $ref) >= 0) if ($object->fetch($prev_id, $ref) >= 0)
{ {
$head = prelevement_prepare_head($object); $head = prelevement_prepare_head($object);
dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
@ -145,9 +145,9 @@ if ($prev_id > 0 || $ref)
print '</div>'; print '</div>';
dol_fiche_end(); dol_fiche_end();
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
@ -205,44 +205,44 @@ if ($resql)
if ($num > 0) if ($num > 0)
{ {
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">'; print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
print img_picto('', 'statut'.$obj->statut).' '; print img_picto('', 'statut'.$obj->statut).' ';
print substr('000000'.$obj->rowid, -6); print substr('000000'.$obj->rowid, -6);
print '</a></td>'; print '</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name."</a></td>\n"; print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name."</a></td>\n";
print '<td class="right">'.price($obj->amount)."</td>\n"; print '<td class="right">'.price($obj->amount)."</td>\n";
print '<td>'.$rej->motifs[$obj->motif].'</td>'; print '<td>'.$rej->motifs[$obj->motif].'</td>';
print '<td class="center">'.yn($obj->afacturer).'</td>'; print '<td class="center">'.yn($obj->afacturer).'</td>';
print '<td class="center">'.$obj->fk_facture.'</td>'; print '<td class="center">'.$obj->fk_facture.'</td>';
print "</tr>\n"; print "</tr>\n";
$total += $obj->amount; $total += $obj->amount;
$i++; $i++;
} }
} else { } else {
print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
} }
if ($num > 0) if ($num > 0)
{ {
print '<tr class="liste_total"><td>&nbsp;</td>'; print '<tr class="liste_total"><td>&nbsp;</td>';
print '<td class="liste_total">'.$langs->trans("Total").'</td>'; print '<td class="liste_total">'.$langs->trans("Total").'</td>';
print '<td class="right">'.price($total)."</td>\n"; print '<td class="right">'.price($total)."</td>\n";
print '<td colspan="3">&nbsp;</td>'; print '<td colspan="3">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
$db->free($resql); $db->free($resql);
} else { } else {

File diff suppressed because it is too large Load Diff

View File

@ -184,7 +184,7 @@ $arrayfields = array(
'p.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'p.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
'p.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), 'p.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
); );
if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
$arrayfields['p.fk_prospectcontactlevel'] = array('label'=>"ProspectLevelShort", 'checked'=>1, 'position'=>210); $arrayfields['p.fk_prospectcontactlevel'] = array('label'=>"ProspectLevelShort", 'checked'=>1, 'position'=>210);
$arrayfields['p.fk_stcommcontact'] = array('label'=>"StatusProsp", 'checked'=>1, 'position'=>215); $arrayfields['p.fk_stcommcontact'] = array('label'=>"StatusProsp", 'checked'=>1, 'position'=>215);
} }
@ -270,8 +270,8 @@ if (empty($reshook))
} }
} }
$search_priv = ""; $search_priv = "";
$search_stcomm=''; $search_stcomm = '';
$search_level=''; $search_level = '';
$search_status = -1; $search_status = -1;
$search_categ = ''; $search_categ = '';
$search_categ_thirdparty = ''; $search_categ_thirdparty = '';
@ -314,7 +314,7 @@ $formother = new FormOther($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
$contactstatic->loadCacheOfProspStatus(); $contactstatic->loadCacheOfProspStatus();
} }
@ -323,17 +323,17 @@ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("C
// Select every potentiels, and note each potentiels which fit in search parameters // Select every potentiels, and note each potentiels which fit in search parameters
$tab_level = array(); $tab_level = array();
$sql = "SELECT code, label, sortorder"; $sql = "SELECT code, label, sortorder";
$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel"; $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel";
$sql.= " WHERE active > 0"; $sql .= " WHERE active > 0";
$sql.= " ORDER BY sortorder"; $sql .= " ORDER BY sortorder";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
while ($obj = $db->fetch_object($resql)) while ($obj = $db->fetch_object($resql))
{ {
// Compute level text // Compute level text
$level=$langs->trans($obj->code); $level = $langs->trans($obj->code);
if ($level == $obj->code) $level=$langs->trans($obj->label); if ($level == $obj->code) $level = $langs->trans($obj->label);
$tab_level[$obj->code] = $level; $tab_level[$obj->code] = $level;
} }
} }
@ -343,7 +343,7 @@ $sql = "SELECT s.rowid as socid, s.nom as name,";
$sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,"; $sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,";
$sql .= " p.socialnetworks, p.photo,"; $sql .= " p.socialnetworks, p.photo,";
$sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,";
$sql.= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,"; $sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,";
$sql .= " co.label as country, co.code as country_code"; $sql .= " co.label as country, co.code as country_code";
// Add fields from extrafields // Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) { if (!empty($extrafields->attributes[$object->table_element]['label'])) {
@ -357,7 +357,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact";
if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ
if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ
if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ
@ -469,7 +469,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if (! $resql) if (!$resql)
{ {
dol_print_error($db); dol_print_error($db);
exit; exit;
@ -515,10 +515,10 @@ if ($search_email != '') $param .= '&amp;search_email='.urlencode($search_email)
if ($search_no_email != '') $param .= '&amp;search_no_email='.urlencode($search_no_email); if ($search_no_email != '') $param .= '&amp;search_no_email='.urlencode($search_no_email);
if ($search_status != '') $param .= '&amp;search_status='.urlencode($search_status); if ($search_status != '') $param .= '&amp;search_status='.urlencode($search_status);
if ($search_priv == '0' || $search_priv == '1') $param .= "&amp;search_priv=".urlencode($search_priv); if ($search_priv == '0' || $search_priv == '1') $param .= "&amp;search_priv=".urlencode($search_priv);
if ($search_stcomm != '') $param.='&search_stcomm='.urlencode($search_stcomm); if ($search_stcomm != '') $param .= '&search_stcomm='.urlencode($search_stcomm);
if (is_array($search_level) && count($search_level)) { if (is_array($search_level) && count($search_level)) {
foreach ($search_level as $slevel) { foreach ($search_level as $slevel) {
$param.='&search_level[]='.urlencode($slevel); $param .= '&search_level[]='.urlencode($slevel);
} }
} }
if ($search_import_key != '') $param .= '&amp;search_import_key='.urlencode($search_import_key); if ($search_import_key != '') $param .= '&amp;search_import_key='.urlencode($search_import_key);
@ -739,20 +739,20 @@ if (!empty($arrayfields['p.priv']['checked']))
print '</td>'; print '</td>';
} }
// Prospect level // Prospect level
if (! empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
{ {
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2); print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
print '</td>'; print '</td>';
} }
// Prospect status // Prospect status
if (! empty($arrayfields['p.fk_stcommcontact']['checked'])) if (!empty($arrayfields['p.fk_stcommcontact']['checked']))
{ {
print '<td class="liste_titre maxwidthonsmartphone center">'; print '<td class="liste_titre maxwidthonsmartphone center">';
$arraystcomm=array(); $arraystcomm = array();
foreach ($contactstatic->cacheprospectstatus as $key => $val) foreach ($contactstatic->cacheprospectstatus as $key => $val)
{ {
$arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
} }
print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', 'nowrap '); print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', 'nowrap ');
print '</td>'; print '</td>';
@ -877,7 +877,7 @@ while ($i < min($num, $limit))
$contactstatic->country_code = $obj->country_code; $contactstatic->country_code = $obj->country_code;
$contactstatic->photo = $obj->photo; $contactstatic->photo = $obj->photo;
$contactstatic->fk_prospectlevel=$obj->fk_prospectcontactlevel; $contactstatic->fk_prospectlevel = $obj->fk_prospectcontactlevel;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -1007,7 +1007,7 @@ while ($i < min($num, $limit))
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
if (! empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
{ {
// Prospect level // Prospect level
print '<td class="center">'; print '<td class="center">';
@ -1016,16 +1016,16 @@ while ($i < min($num, $limit))
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
if (! empty($arrayfields['p.fk_stcommcontact']['checked'])) if (!empty($arrayfields['p.fk_stcommcontact']['checked']))
{ {
// Prospect status // Prospect status
print '<td class="center nowrap"><div class="nowrap">'; print '<td class="center nowrap"><div class="nowrap">';
print '<div class="inline-block">' . $contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); print '<div class="inline-block">'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto);
print '</div> - <div class="inline-block">'; print '</div> - <div class="inline-block">';
foreach ($contactstatic->cacheprospectstatus as $key => $val) { foreach ($contactstatic->cacheprospectstatus as $key => $val) {
$titlealt = 'default'; $titlealt = 'default';
if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label'];
if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="' . $_SERVER["PHP_SELF"] . '?stcommcontactid=' . $obj->rowid . '&stcomm=' . $val['code'] . '&action=setstcomm' . $param . ($page ? '&page=' . urlencode($page) : '') . '">' . img_action($titlealt, $val['code'], $val['picto']) . '</a>'; if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommcontactid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page ? '&page='.urlencode($page) : '').'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
} }
print '</div></div></td>'; print '</div></div></td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;

View File

@ -85,7 +85,7 @@ if ($action == 'add' && !empty($permissiontoadd))
$object->$key = $value; $object->$key = $value;
if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)')
{ {
$object->$key = '(PROV)'; $object->$key = '(PROV)';
} }
if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default']))
{ {
@ -105,7 +105,7 @@ if ($action == 'add' && !empty($permissiontoadd))
$result = $object->create($user); $result = $object->create($user);
if ($result > 0) if ($result > 0)
{ {
// Creation OK // Creation OK
$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
header("Location: ".$urltogo); header("Location: ".$urltogo);
@ -154,7 +154,7 @@ if ($action == 'update' && !empty($permissiontoadd))
$value = ''; $value = '';
} }
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) { } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
$value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
} elseif ($object->fields[$key]['type'] == 'boolean') { } elseif ($object->fields[$key]['type'] == 'boolean') {
$value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0); $value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0);
} else { } else {
@ -223,11 +223,11 @@ if ($action == "update_extras" && !empty($permissiontoadd))
// Action to delete // Action to delete
if ($action == 'confirm_delete' && !empty($permissiontodelete)) if ($action == 'confirm_delete' && !empty($permissiontodelete))
{ {
if (!($object->id > 0)) if (!($object->id > 0))
{ {
dol_print_error('', 'Error, object must be fetched before being deleted'); dol_print_error('', 'Error, object must be fetched before being deleted');
exit; exit;
} }
$result = $object->delete($user); $result = $object->delete($user);
if ($result > 0) if ($result > 0)
@ -246,7 +246,7 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete))
if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd))
{ {
if (method_exists('deleteline', $object)) { if (method_exists('deleteline', $object)) {
$result = $object->deleteline($user, $lineid); // For backward compatibility $result = $object->deleteline($user, $lineid); // For backward compatibility
} else { } else {
$result = $object->deleteLine($user, $lineid); $result = $object->deleteLine($user, $lineid);
} }
@ -385,11 +385,11 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd))
{ {
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
} else { } else {
$objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
//$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
// ... // ...
$result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
if (is_object($result) || $result > 0) if (is_object($result) || $result > 0)
{ {
$newid = 0; $newid = 0;
if (is_object($result)) $newid = $result->id; if (is_object($result)) $newid = $result->id;
@ -397,7 +397,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd))
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
exit; exit;
} else { } else {
setEventMessages($objectutil->error, $objectutil->errors, 'errors'); setEventMessages($objectutil->error, $objectutil->errors, 'errors');
$action = ''; $action = '';
} }
} }

View File

@ -263,12 +263,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
if (dol_strlen($sendto)) if (dol_strlen($sendto))
{ {
// Define $urlwithroot // Define $urlwithroot
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$langs->load("commercial"); $langs->load("commercial");
@ -419,7 +419,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
// Initialisation of datas of object to call trigger // Initialisation of datas of object to call trigger
if (is_object($object)) if (is_object($object))
{ {
if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
$object->socid = $sendtosocid; // To link to a company $object->socid = $sendtosocid; // To link to a company
$object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array. $object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array.
@ -456,7 +456,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
if ($error) { if ($error) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
// End call of triggers // End call of triggers
} }

View File

@ -34,28 +34,28 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!isset($mode) || $mode != 'noajax') // For ajax call if (!isset($mode) || $mode != 'noajax') // For ajax call
{ {
require_once '../../main.inc.php'; require_once '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$file = urldecode(GETPOST('file', 'alpha')); $file = urldecode(GETPOST('file', 'alpha'));
$section = GETPOST("section", 'alpha'); $section = GETPOST("section", 'alpha');
$module = GETPOST("module", 'alpha'); $module = GETPOST("module", 'alpha');
$urlsource = GETPOST("urlsource", 'alpha'); $urlsource = GETPOST("urlsource", 'alpha');
$search_doc_ref = GETPOST('search_doc_ref', 'alpha'); $search_doc_ref = GETPOST('search_doc_ref', 'alpha');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name"; if (!$sortfield) $sortfield = "name";
$rootdirfordoc = $conf->ecm->dir_output; $rootdirfordoc = $conf->ecm->dir_output;
@ -63,30 +63,30 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call
$ecmdir = new EcmDirectory($db); $ecmdir = new EcmDirectory($db);
if ($section > 0) { if ($section > 0) {
$result = $ecmdir->fetch($section); $result = $ecmdir->fetch($section);
if (!$result > 0) if (!$result > 0)
{ {
//dol_print_error($db,$ecmdir->error); //dol_print_error($db,$ecmdir->error);
//exit; //exit;
} }
} }
} else // For no ajax call } else // For no ajax call
{ {
$rootdirfordoc = $conf->ecm->dir_output; $rootdirfordoc = $conf->ecm->dir_output;
$ecmdir = new EcmDirectory($db); $ecmdir = new EcmDirectory($db);
$relativepath = ''; $relativepath = '';
if ($section > 0) if ($section > 0)
{ {
$result = $ecmdir->fetch($section); $result = $ecmdir->fetch($section);
if (!$result > 0) if (!$result > 0)
{ {
dol_print_error($db, $ecmdir->error); dol_print_error($db, $ecmdir->error);
exit; exit;
} }
$relativepath = $ecmdir->getRelativePath(); // Example 'mydir/' $relativepath = $ecmdir->getRelativePath(); // Example 'mydir/'
} elseif (GETPOST('section_dir')) } elseif (GETPOST('section_dir'))
{ {
$relativepath = GETPOST('section_dir'); $relativepath = GETPOST('section_dir');
} }
@ -113,10 +113,10 @@ if ($user->socid > 0) $socid = $user->socid;
// On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers.
if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir))
{ {
dol_syslog("Refused to deliver file ".$upload_dir); dol_syslog("Refused to deliver file ".$upload_dir);
// Do no show plain path in shown error message // Do no show plain path in shown error message
dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir)); dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir));
exit; exit;
} }
// Check permissions // Check permissions
@ -145,10 +145,10 @@ if ($modulepart == 'medias')
if (!isset($mode) || $mode != 'noajax') if (!isset($mode) || $mode != 'noajax')
{ {
// Ajout directives pour resoudre bug IE // Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate'); header('Cache-Control: Public, must-revalidate');
header('Pragma: public'); header('Pragma: public');
top_httphead(); top_httphead();
} }
$type = 'directory'; $type = 'directory';
@ -156,8 +156,8 @@ $type = 'directory';
// This test if file exists should be useless. We keep it to find bug more easily // This test if file exists should be useless. We keep it to find bug more easily
if (!dol_is_dir($upload_dir)) if (!dol_is_dir($upload_dir))
{ {
//dol_mkdir($upload_dir); //dol_mkdir($upload_dir);
/*$langs->load("install"); /*$langs->load("install");
dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir)); dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir));
exit;*/ exit;*/
} }
@ -173,76 +173,76 @@ if (!empty($pageid)) $param .= '&pageid='.urlencode($pageid);
// Dir scan // Dir scan
if ($type == 'directory') if ($type == 'directory')
{ {
$formfile = new FormFile($db); $formfile = new FormFile($db);
$maxlengthname = 40; $maxlengthname = 40;
$excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$'); $excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$');
$sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC); $sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC);
// Right area. If module is defined here, we are in automatic ecm. // Right area. If module is defined here, we are in automatic ecm.
$automodules = array( $automodules = array(
'company', 'company',
'invoice', 'invoice',
'invoice_supplier', 'invoice_supplier',
'propal', 'propal',
'supplier_proposal', 'supplier_proposal',
'order', 'order',
'order_supplier', 'order_supplier',
'contract', 'contract',
'product', 'product',
'tax', 'tax',
'project', 'project',
'fichinter', 'fichinter',
'user', 'user',
'expensereport', 'expensereport',
'holiday', 'holiday',
'recruitment-recruitmentcandidature', 'recruitment-recruitmentcandidature',
'banque', 'banque',
'mrp-mo' 'mrp-mo'
); );
// TODO change for multicompany sharing // TODO change for multicompany sharing
if ($module == 'company') $upload_dir = $conf->societe->dir_output; if ($module == 'company') $upload_dir = $conf->societe->dir_output;
elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output; elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output;
elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output; elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output;
elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output; elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output;
elseif ($module == 'order') $upload_dir = $conf->commande->dir_output; elseif ($module == 'order') $upload_dir = $conf->commande->dir_output;
elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output;
elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output; elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output;
elseif ($module == 'product') $upload_dir = $conf->product->dir_output; elseif ($module == 'product') $upload_dir = $conf->product->dir_output;
elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output; elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output;
elseif ($module == 'project') $upload_dir = $conf->projet->dir_output; elseif ($module == 'project') $upload_dir = $conf->projet->dir_output;
elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output; elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output;
elseif ($module == 'user') $upload_dir = $conf->user->dir_output; elseif ($module == 'user') $upload_dir = $conf->user->dir_output;
elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output; elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output;
elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output; elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output;
elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature'; elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature';
elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output; elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output;
elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo'; elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo';
// Automatic list // Automatic list
if (in_array($module, $automodules)) if (in_array($module, $automodules))
{ {
$param .= '&module='.$module; $param .= '&module='.$module;
if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref); if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref);
$textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound")));
if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty.
$filter = preg_quote($search_doc_ref, '/'); $filter = preg_quote($search_doc_ref, '/');
$filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1);
$perm = $user->rights->ecm->upload; $perm = $user->rights->ecm->upload;
$formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1); $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1);
} }
// Manual list // Manual list
else { else {
if ($module == 'medias') if ($module == 'medias')
{ {
/* /*
$_POST is array like $_POST is array like
'token' => string '062380e11b7dcd009d07318b57b71750' (length=32) 'token' => string '062380e11b7dcd009d07318b57b71750' (length=32)
'action' => string 'file_manager' (length=12) 'action' => string 'file_manager' (length=12)
@ -253,82 +253,82 @@ if ($type == 'directory')
'max_file_size' => string '2097152' (length=7) 'max_file_size' => string '2097152' (length=7)
'sendit' => string 'Envoyer fichier' (length=15) 'sendit' => string 'Envoyer fichier' (length=15)
*/ */
$relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha'); $relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha');
if ($relativepath && $relativepath != '/') $relativepath .= '/'; if ($relativepath && $relativepath != '/') $relativepath .= '/';
$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
{ {
$param .= '&file_manager=1'; $param .= '&file_manager=1';
if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha')); if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha'));
if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int')); if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int'));
//if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
} }
} else { } else {
$relativepath = $ecmdir->getRelativePath(); $relativepath = $ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath; $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
} }
// If $section defined with value 0 // If $section defined with value 0
if (($section === '0' || empty($section)) && ($module != 'medias')) if (($section === '0' || empty($section)) && ($module != 'medias'))
{ {
$filearray = array(); $filearray = array();
} else { } else {
$filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1);
} }
if ($section) if ($section)
{ {
$param .= '&section='.$section; $param .= '&section='.$section;
if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref;
$textifempty = $langs->trans('NoFileFound'); $textifempty = $langs->trans('NoFileFound');
} elseif ($section === '0') } elseif ($section === '0')
{ {
if ($module == 'ecm') $textifempty = '<br><div class="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>'; if ($module == 'ecm') $textifempty = '<br><div class="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
else $textifempty = $langs->trans('NoFileFound'); else $textifempty = $langs->trans('NoFileFound');
} else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); } else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection"));
if ($module == 'medias') if ($module == 'medias')
{ {
$useinecm = 6; $useinecm = 6;
$modulepart = 'medias'; $modulepart = 'medias';
$perm = ($user->rights->website->write || $user->rights->emailing->creer); $perm = ($user->rights->website->write || $user->rights->emailing->creer);
$title = 'none'; $title = 'none';
} elseif ($module == 'ecm') // DMS/ECM -> manual structure } elseif ($module == 'ecm') // DMS/ECM -> manual structure
{ {
if ($user->rights->ecm->read) if ($user->rights->ecm->read)
{ {
// Buttons: Preview // Buttons: Preview
$useinecm = 2; $useinecm = 2;
} }
if ($user->rights->ecm->upload) if ($user->rights->ecm->upload)
{ {
// Buttons: Preview + Delete // Buttons: Preview + Delete
$useinecm = 4; $useinecm = 4;
} }
if ($user->rights->ecm->setup) if ($user->rights->ecm->setup)
{ {
// Buttons: Preview + Delete + Edit // Buttons: Preview + Delete + Edit
$useinecm = 5; $useinecm = 5;
} }
$perm = $user->rights->ecm->upload; $perm = $user->rights->ecm->upload;
$modulepart = 'ecm'; $modulepart = 'ecm';
$title = ''; // Use default $title = ''; // Use default
} else { } else {
$useinecm = 5; $useinecm = 5;
$modulepart = 'ecm'; $modulepart = 'ecm';
$perm = $user->rights->ecm->upload; $perm = $user->rights->ecm->upload;
$title = ''; // Use default $title = ''; // Use default
} }
// When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
// When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
//var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url); //var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url);
$formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm); $formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm);
} }
} }

View File

@ -41,47 +41,47 @@ class CMailFile
public $sendmode; public $sendmode;
public $sendsetup; public $sendsetup;
public $subject; // Topic: Subject of email public $subject; // Topic: Subject of email
public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '<myemail@example.com>' or 'John Doe <myemail@example.com>' or '<myemail+trackingid@example.com>'). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '<myemail@example.com>' or 'John Doe <myemail@example.com>' or '<myemail+trackingid@example.com>'). Note that with gmail smtps, value here is forced by google to account (but not the reply-to).
// Sender: Who send the email ("Sender" has sent emails on behalf of "From"). // Sender: Who send the email ("Sender" has sent emails on behalf of "From").
// Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain. // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain.
// Return-Path: Email where to send bounds. // Return-Path: Email where to send bounds.
public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined)
public $errors_to; // Errors-To: Email where to send errors. public $errors_to; // Errors-To: Email where to send errors.
public $addr_to; public $addr_to;
public $addr_cc; public $addr_cc;
public $addr_bcc; public $addr_bcc;
public $trackid; public $trackid;
public $mixed_boundary; public $mixed_boundary;
public $related_boundary; public $related_boundary;
public $alternative_boundary; public $alternative_boundary;
public $deliveryreceipt; public $deliveryreceipt;
public $eol; public $eol;
public $eol2; public $eol2;
/** /**
* @var string Error code (or message) * @var string Error code (or message)
*/ */
public $error = ''; public $error = '';
public $smtps; // Contains SMTPs object (if this method is used) public $smtps; // Contains SMTPs object (if this method is used)
public $phpmailer; // Contains PHPMailer object (if this method is used) public $phpmailer; // Contains PHPMailer object (if this method is used)
/** /**
* @var string CSS * @var string CSS
*/ */
public $css; public $css;
//! Defined css style for body background //! Defined css style for body background
public $styleCSS; public $styleCSS;
//! Defined background directly in body tag //! Defined background directly in body tag
public $bodyCSS; public $bodyCSS;
public $msgid; public $msgid;
public $headers; public $headers;
public $message; public $message;
/** /**
* @var array fullfilenames list (full path of filename on file system) * @var array fullfilenames list (full path of filename on file system)
*/ */
public $filename_list = array(); public $filename_list = array();
@ -95,21 +95,21 @@ class CMailFile
public $mimefilename_list = array(); public $mimefilename_list = array();
// Image // Image
public $html; public $html;
public $image_boundary; public $image_boundary;
public $atleastoneimage = 0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). public $atleastoneimage = 0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used).
public $html_images = array(); public $html_images = array();
public $images_encoded = array(); public $images_encoded = array();
public $image_types = array( public $image_types = array(
'gif' => 'image/gif', 'gif' => 'image/gif',
'jpg' => 'image/jpeg', 'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg', 'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg', 'jpe' => 'image/jpeg',
'bmp' => 'image/bmp', 'bmp' => 'image/bmp',
'png' => 'image/png', 'png' => 'image/png',
'tif' => 'image/tiff', 'tif' => 'image/tiff',
'tiff' => 'image/tiff', 'tiff' => 'image/tiff',
); );
/** /**
@ -147,7 +147,7 @@ class CMailFile
// Add autocopy to (Note: Adding bcc for specific modules are also done from pages) // Add autocopy to (Note: Adding bcc for specific modules are also done from pages)
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
$this->subject = $subject; $this->subject = $subject;
$this->addr_to = $to; $this->addr_to = $to;
$this->addr_from = $from; $this->addr_from = $from;
$this->msg = $msg; $this->msg = $msg;
@ -210,8 +210,8 @@ class CMailFile
} }
if (empty($msg)) if (empty($msg))
{ {
dol_syslog("CMailFile::CMailfile: Try to send an email with empty body"); dol_syslog("CMailFile::CMailfile: Try to send an email with empty body");
$msg = '.'; // Avoid empty message (with empty message content, you will see a multipart structure) $msg = '.'; // Avoid empty message (with empty message content, you will see a multipart structure)
} }
// Detect if message is HTML (use fast method) // Detect if message is HTML (use fast method)
@ -291,7 +291,7 @@ class CMailFile
// Add autocopy to (Note: Adding bcc for specific modules are also done from pages) // Add autocopy to (Note: Adding bcc for specific modules are also done from pages)
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) { if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
$addr_bcc.=($addr_bcc?', ':'').$conf->global->MAIN_MAIL_AUTOCOPY_TO; $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
} }
// We set all data according to choosed sending method. // We set all data according to choosed sending method.
@ -411,40 +411,40 @@ class CMailFile
$this->smtps = $smtps; $this->smtps = $smtps;
} elseif ($this->sendmode == 'swiftmailer') { } elseif ($this->sendmode == 'swiftmailer') {
// Use Swift Mailer library // Use Swift Mailer library
$host = dol_getprefix('email'); $host = dol_getprefix('email');
require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php'; require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php';
// egulias autoloader lib // egulias autoloader lib
require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/autoload.php'; require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/autoload.php';
require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php';
// Create the message // Create the message
//$this->message = Swift_Message::newInstance(); //$this->message = Swift_Message::newInstance();
$this->message = new Swift_Message(); $this->message = new Swift_Message();
//$this->message = new Swift_SignedMessage(); //$this->message = new Swift_SignedMessage();
// Adding a trackid header to a message // Adding a trackid header to a message
$headers = $this->message->getHeaders(); $headers = $this->message->getHeaders();
$headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host); $headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host);
$this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host; $this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host;
$headerID = $this->msgid; $headerID = $this->msgid;
$msgid = $headers->get('Message-ID'); $msgid = $headers->get('Message-ID');
$msgid->setId($headerID); $msgid->setId($headerID);
$headers->addIdHeader('References', $headerID); $headers->addIdHeader('References', $headerID);
// TODO if (! empty($moreinheader)) ... // TODO if (! empty($moreinheader)) ...
// Give the message a subject // Give the message a subject
try { try {
$result = $this->message->setSubject($this->subject); $result = $this->message->setSubject($this->subject);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }
// Set the From address with an associative array // Set the From address with an associative array
//$this->message->setFrom(array('john@doe.com' => 'John Doe')); //$this->message->setFrom(array('john@doe.com' => 'John Doe'));
if (! empty($this->addr_from)) { if (! empty($this->addr_from)) {
try { try {
if (! empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) { if (! empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) {
// Prevent email spoofing for smtp server with a strict configuration // Prevent email spoofing for smtp server with a strict configuration
$regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string $regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string
@ -459,35 +459,35 @@ class CMailFile
} else { } else {
$result = $this->message->setFrom($this->getArrayAddress($this->addr_from)); $result = $this->message->setFrom($this->getArrayAddress($this->addr_from));
} }
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }
} }
// Set the To addresses with an associative array // Set the To addresses with an associative array
if (! empty($this->addr_to)) { if (! empty($this->addr_to)) {
try { try {
$result = $this->message->setTo($this->getArrayAddress($this->addr_to)); $result = $this->message->setTo($this->getArrayAddress($this->addr_to));
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }
} }
if (! empty($this->reply_to)) { if (! empty($this->reply_to)) {
try { try {
$result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to)); $result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }
} }
try { try {
$result = $this->message->setCharSet($conf->file->character_set_client); $result = $this->message->setCharSet($conf->file->character_set_client);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }
if (!empty($this->html)) { if (!empty($this->html)) {
if (!empty($css)) { if (!empty($css)) {
$this->css = $css; $this->css = $css;
$this->buildCSS(); $this->buildCSS();
@ -578,26 +578,26 @@ class CMailFile
$sendingmode = $this->sendmode; $sendingmode = $this->sendmode;
if ($this->context == 'emailing' && !empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') if ($this->context == 'emailing' && !empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail')
{ {
// List of sending methods // List of sending methods
$listofmethods = array(); $listofmethods = array();
$listofmethods['mail'] = 'PHP mail function'; $listofmethods['mail'] = 'PHP mail function';
//$listofmethods['simplemail']='Simplemail class'; //$listofmethods['simplemail']='Simplemail class';
$listofmethods['smtps'] = 'SMTP/SMTPS socket library'; $listofmethods['smtps'] = 'SMTP/SMTPS socket library';
// EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent. // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent.
// You ensure that every user is using its own SMTP server when using the mass emailing module. // You ensure that every user is using its own SMTP server when using the mass emailing module.
$linktoadminemailbefore = '<a href="'.DOL_URL_ROOT.'/admin/mails.php">'; $linktoadminemailbefore = '<a href="'.DOL_URL_ROOT.'/admin/mails.php">';
$linktoadminemailend = '</a>'; $linktoadminemailend = '</a>';
$this->error = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]); $this->error = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]);
$this->errors[] = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]); $this->errors[] = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]);
$this->error .= '<br>'.$langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']); $this->error .= '<br>'.$langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']);
$this->errors[] = $langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']); $this->errors[] = $langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']);
if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS))
{ {
$this->error .= '<br>'.$langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS); $this->error .= '<br>'.$langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS);
$this->errors[] = $langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS); $this->errors[] = $langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS);
} }
return false; return false;
} }
// Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL // Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL
@ -828,9 +828,9 @@ class CMailFile
} }
} elseif ($this->sendmode == 'swiftmailer') } elseif ($this->sendmode == 'swiftmailer')
{ {
// Use Swift Mailer library // Use Swift Mailer library
// ------------------------------------------ // ------------------------------------------
require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php';
// Clean parameters // Clean parameters
if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver = ini_get('SMTP'); if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver = ini_get('SMTP');
@ -849,22 +849,22 @@ class CMailFile
//$smtps->_msgReplyTo = 'reply@web.com'; //$smtps->_msgReplyTo = 'reply@web.com';
// Switch content encoding to base64 - avoid the doubledot issue with quoted-printable // Switch content encoding to base64 - avoid the doubledot issue with quoted-printable
$contentEncoderBase64 = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); $contentEncoderBase64 = new Swift_Mime_ContentEncoder_Base64ContentEncoder();
$this->message->setEncoder($contentEncoderBase64); $this->message->setEncoder($contentEncoderBase64);
// Create the Mailer using your created Transport // Create the Mailer using your created Transport
$this->mailer = new Swift_Mailer($this->transport); $this->mailer = new Swift_Mailer($this->transport);
// DKIM SIGN // DKIM SIGN
if ($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) { if ($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) {
$privateKey = $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; $privateKey = $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY;
$domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; $domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN;
$selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; $selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR;
$signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector); $signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector);
$this->message->attachSigner($signer->ignoreHeader('Return-Path')); $this->message->attachSigner($signer->ignoreHeader('Return-Path'));
} }
if (!empty($conf->global->MAIN_MAIL_DEBUG)) { if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
// To use the ArrayLogger // To use the ArrayLogger
$this->logger = new Swift_Plugins_Loggers_ArrayLogger(); $this->logger = new Swift_Plugins_Loggers_ArrayLogger();
// Or to use the Echo Logger // Or to use the Echo Logger
@ -924,7 +924,7 @@ class CMailFile
return '=?'.$conf->file->character_set_client.'?B?'.base64_encode($stringtoencode).'?='; return '=?'.$conf->file->character_set_client.'?B?'.base64_encode($stringtoencode).'?=';
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Read a file on disk and return encoded content for emails (mode = 'mail') * Read a file on disk and return encoded content for emails (mode = 'mail')
* *
@ -933,7 +933,7 @@ class CMailFile
*/ */
private function _encode_file($sourcefile) private function _encode_file($sourcefile)
{ {
// phpcs:enable // phpcs:enable
$newsourcefile = dol_osencode($sourcefile); $newsourcefile = dol_osencode($sourcefile);
if (is_readable($newsourcefile)) if (is_readable($newsourcefile))
@ -949,7 +949,7 @@ class CMailFile
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Write content of a SMTP request into a dump file (mode = all) * Write content of a SMTP request into a dump file (mode = all)
* Used for debugging. * Used for debugging.
@ -959,7 +959,7 @@ class CMailFile
*/ */
public function dump_mail() public function dump_mail()
{ {
// phpcs:enable // phpcs:enable
global $conf, $dolibarr_main_data_root; global $conf, $dolibarr_main_data_root;
if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir
@ -1040,7 +1040,7 @@ class CMailFile
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Create SMTP headers (mode = 'mail') * Create SMTP headers (mode = 'mail')
* *
@ -1048,7 +1048,7 @@ class CMailFile
*/ */
public function write_smtpheaders() public function write_smtpheaders()
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$out = ""; $out = "";
@ -1104,7 +1104,7 @@ class CMailFile
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Create header MIME (mode = 'mail') * Create header MIME (mode = 'mail')
* *
@ -1114,7 +1114,7 @@ class CMailFile
*/ */
public function write_mimeheaders($filename_list, $mimefilename_list) public function write_mimeheaders($filename_list, $mimefilename_list)
{ {
// phpcs:enable // phpcs:enable
$mimedone = 0; $mimedone = 0;
$out = ""; $out = "";
@ -1135,7 +1135,7 @@ class CMailFile
return $out; return $out;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return email content (mode = 'mail') * Return email content (mode = 'mail')
* *
@ -1144,7 +1144,7 @@ class CMailFile
*/ */
public function write_body($msgtext) public function write_body($msgtext)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$out = ''; $out = '';
@ -1235,7 +1235,7 @@ class CMailFile
return $out; return $out;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Attach file to email (mode = 'mail') * Attach file to email (mode = 'mail')
* *
@ -1246,7 +1246,7 @@ class CMailFile
*/ */
public function write_files($filename_list, $mimetype_list, $mimefilename_list) public function write_files($filename_list, $mimetype_list, $mimefilename_list)
{ {
// phpcs:enable // phpcs:enable
$out = ''; $out = '';
$filename_list_size = count($filename_list); $filename_list_size = count($filename_list);
@ -1282,7 +1282,7 @@ class CMailFile
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Attach an image to email (mode = 'mail') * Attach an image to email (mode = 'mail')
* *
@ -1291,7 +1291,7 @@ class CMailFile
*/ */
public function write_images($images_list) public function write_images($images_list)
{ {
// phpcs:enable // phpcs:enable
$out = ''; $out = '';
if (is_array($images_list)) if (is_array($images_list))
@ -1315,7 +1315,7 @@ class CMailFile
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Try to create a socket connection * Try to create a socket connection
* *
@ -1325,7 +1325,7 @@ class CMailFile
*/ */
public function check_server_port($host, $port) public function check_server_port($host, $port)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$_retVal = 0; $_retVal = 0;
@ -1356,7 +1356,7 @@ class CMailFile
dol_syslog("Try socket connection to host=".$host." port=".$port); dol_syslog("Try socket connection to host=".$host." port=".$port);
//See if we can connect to the SMTP server //See if we can connect to the SMTP server
if ($socket = @fsockopen( if ($socket = @fsockopen(
$host, // Host to test, IP or domain. Add ssl:// for SSL/TLS. $host, // Host to test, IP or domain. Add ssl:// for SSL/TLS.
$port, // which Port number to use $port, // which Port number to use
$errno, // actual system level error $errno, // actual system level error
@ -1377,7 +1377,7 @@ class CMailFile
return $_retVal; return $_retVal;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* This function has been modified as provided by SirSir to allow multiline responses when * This function has been modified as provided by SirSir to allow multiline responses when
* using SMTP Extensions. * using SMTP Extensions.
@ -1388,7 +1388,7 @@ class CMailFile
*/ */
public function server_parse($socket, $response) public function server_parse($socket, $response)
{ {
// phpcs:enable // phpcs:enable
$_retVal = true; // Indicates if Object was created or not $_retVal = true; // Indicates if Object was created or not
$server_response = ''; $server_response = '';
@ -1512,8 +1512,8 @@ class CMailFile
* If format 2: 'john@doe.com' * If format 2: 'john@doe.com'
* If format 3: '<john@doe.com>' or '"John Doe" <john@doe.com>' or '"=?UTF-8?B?Sm9obiBEb2U=?=" <john@doe.com>' * If format 3: '<john@doe.com>' or '"John Doe" <john@doe.com>' or '"=?UTF-8?B?Sm9obiBEb2U=?=" <john@doe.com>'
* If format 4: 'John Doe' or 'john@doe.com' if no label exists * If format 4: 'John Doe' or 'john@doe.com' if no label exists
* If format 5: <a href="mailto:john@doe.com">John Doe</a> or <a href="mailto:john@doe.com">john@doe.com</a> if no label exists * If format 5: <a href="mailto:john@doe.com">John Doe</a> or <a href="mailto:john@doe.com">john@doe.com</a> if no label exists
* @see getArrayAddress() * @see getArrayAddress()
*/ */
public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0) public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0)
{ {
@ -1541,10 +1541,10 @@ class CMailFile
$i++; $i++;
$newemail = ''; $newemail = '';
if ($format == 5) { if ($format == 5) {
$newemail = $name ? $name : $email; $newemail = $name ? $name : $email;
$newemail = '<a href="mailto:'.$email.'">'.$newemail.'</a>'; $newemail = '<a href="mailto:'.$email.'">'.$newemail.'</a>';
} }
if ($format == 4) if ($format == 4)
{ {
$newemail = $name ? $name : $email; $newemail = $name ? $name : $email;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -29,58 +29,58 @@
*/ */
class FormActions class FormActions
{ {
/** /**
* @var DoliDB Database handler. * @var DoliDB Database handler.
*/ */
public $db; public $db;
/** /**
* @var string Error code (or message) * @var string Error code (or message)
*/ */
public $error = ''; public $error = '';
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show list of action status * Show list of action status
* *
* @param string $formname Name of form where select is included * @param string $formname Name of form where select is included
* @param string $selected Preselected value (-1..100) * @param string $selected Preselected value (-1..100)
* @param int $canedit 1=can edit, 0=read only * @param int $canedit 1=can edit, 0=read only
* @param string $htmlname Name of html prefix for html fields (selectX and valX) * @param string $htmlname Name of html prefix for html fields (selectX and valX)
* @param integer $showempty Show an empty line if select is used * @param integer $showempty Show an empty line if select is used
* @param integer $onlyselect 0=Standard, 1=Hide percent of completion and force usage of a select list, 2=Same than 1 and add "Incomplete (Todo+Running) * @param integer $onlyselect 0=Standard, 1=Hide percent of completion and force usage of a select list, 2=Same than 1 and add "Incomplete (Todo+Running)
* @param string $morecss More css on select field * @param string $morecss More css on select field
* @return void * @return void
*/ */
public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100') public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100')
{ {
// phpcs:enable // phpcs:enable
global $langs, $conf; global $langs, $conf;
$listofstatus = array( $listofstatus = array(
'-1' => $langs->trans("ActionNotApplicable"), '-1' => $langs->trans("ActionNotApplicable"),
'0' => $langs->trans("ActionsToDoShort"), '0' => $langs->trans("ActionsToDoShort"),
'50' => $langs->trans("ActionRunningShort"), '50' => $langs->trans("ActionRunningShort"),
'100' => $langs->trans("ActionDoneShort") '100' => $langs->trans("ActionDoneShort")
); );
// +ActionUncomplete // +ActionUncomplete
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax))
{ {
print "\n"; print "\n";
print "<script type=\"text/javascript\"> print "<script type=\"text/javascript\">
var htmlname = '".$htmlname."'; var htmlname = '".$htmlname."';
$(document).ready(function () { $(document).ready(function () {
@ -124,142 +124,142 @@ class FormActions
} }
} }
</script>\n"; </script>\n";
} }
if (!empty($conf->use_javascript_ajax) || $onlyselect) if (!empty($conf->use_javascript_ajax) || $onlyselect)
{ {
//var_dump($selected); //var_dump($selected);
if ($selected == 'done') $selected = '100'; if ($selected == 'done') $selected = '100';
print '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">'; print '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">';
if ($showempty) print '<option value=""'.($selected == '' ? ' selected' : '').'></option>'; if ($showempty) print '<option value=""'.($selected == '' ? ' selected' : '').'></option>';
foreach ($listofstatus as $key => $val) foreach ($listofstatus as $key => $val)
{
print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>';
if ($key == '50' && $onlyselect == 2)
{
print '<option value="todo"'.($selected == 'todo' ? ' selected' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionsToDoShort")."+".$langs->trans("ActionRunningShort").')</option>';
}
}
print '</select>';
if ($selected == 0 || $selected == 100) $canedit = 0;
if (empty($onlyselect))
{
print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit && ($selected >= 0) ? '' : ' disabled').'>';
print '<span class="hideonsmartphone hideifna">%</span>';
}
} else {
print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit ? '' : ' disabled').'>%';
}
}
/**
* Show list of actions for element
*
* @param Object $object Object
* @param string $typeelement 'invoice', 'propal', 'order', 'invoice_supplier', 'order_supplier', 'fichinter'
* @param int $socid Socid of user
* @param int $forceshowtitle Show title even if there is no actions to show
* @param string $morecss More css on table
* @param int $max Max number of record
* @param string $moreparambacktopage More param for the backtopage
* @param string $morehtmlcenter More html text on center of title line
* @return int <0 if KO, >=0 if OK
*/
public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlcenter = '')
{
global $langs, $conf, $user;
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
$sortfield = 'a.datep,a.id';
$sortorder = 'DESC,DESC';
$listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0));
if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions');
$num = count($listofactions);
if ($num || $forceshowtitle)
{
if ($typeelement == 'invoice') $title = $langs->trans('ActionsOnBill');
elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill');
elseif ($typeelement == 'propal') $title = $langs->trans('ActionsOnPropal');
elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal');
elseif ($typeelement == 'order') $title = $langs->trans('ActionsOnOrder');
elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title = $langs->trans('ActionsOnOrder');
elseif ($typeelement == 'shipping') $title = $langs->trans('ActionsOnShipping');
elseif ($typeelement == 'fichinter') $title = $langs->trans('ActionsOnFicheInter');
elseif ($typeelement == 'project') $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
elseif ($typeelement == 'task') $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
elseif ($typeelement == 'member') $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
else $title = $langs->trans("LatestLinkedEvents", $max ? $max : '');
$urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : '');
$projectid = $object->fk_project;
if ($typeelement == 'project') $projectid = $object->id;
$newcardbutton = '';
if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create))
{ {
$newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage)); print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>';
if ($key == '50' && $onlyselect == 2)
{
print '<option value="todo"'.($selected == 'todo' ? ' selected' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionsToDoShort")."+".$langs->trans("ActionRunningShort").')</option>';
}
}
print '</select>';
if ($selected == 0 || $selected == 100) $canedit = 0;
if (empty($onlyselect))
{
print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit && ($selected >= 0) ? '' : ' disabled').'>';
print '<span class="hideonsmartphone hideifna">%</span>';
}
} else {
print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit ? '' : ' disabled').'>%';
}
}
/**
* Show list of actions for element
*
* @param Object $object Object
* @param string $typeelement 'invoice', 'propal', 'order', 'invoice_supplier', 'order_supplier', 'fichinter'
* @param int $socid Socid of user
* @param int $forceshowtitle Show title even if there is no actions to show
* @param string $morecss More css on table
* @param int $max Max number of record
* @param string $moreparambacktopage More param for the backtopage
* @param string $morehtmlcenter More html text on center of title line
* @return int <0 if KO, >=0 if OK
*/
public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlcenter = '')
{
global $langs, $conf, $user;
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
$sortfield = 'a.datep,a.id';
$sortorder = 'DESC,DESC';
$listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0));
if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions');
$num = count($listofactions);
if ($num || $forceshowtitle)
{
if ($typeelement == 'invoice') $title = $langs->trans('ActionsOnBill');
elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill');
elseif ($typeelement == 'propal') $title = $langs->trans('ActionsOnPropal');
elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal');
elseif ($typeelement == 'order') $title = $langs->trans('ActionsOnOrder');
elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title = $langs->trans('ActionsOnOrder');
elseif ($typeelement == 'shipping') $title = $langs->trans('ActionsOnShipping');
elseif ($typeelement == 'fichinter') $title = $langs->trans('ActionsOnFicheInter');
elseif ($typeelement == 'project') $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
elseif ($typeelement == 'task') $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
elseif ($typeelement == 'member') $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
else $title = $langs->trans("LatestLinkedEvents", $max ? $max : '');
$urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : '');
$projectid = $object->fk_project;
if ($typeelement == 'project') $projectid = $object->id;
$newcardbutton = '';
if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create))
{
$newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage));
} }
print '<!-- formactions->showactions -->'."\n"; print '<!-- formactions->showactions -->'."\n";
print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlcenter); print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlcenter);
$page = 0; $param = ''; $page = 0; $param = '';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="centpercent noborder'.($morecss ? ' '.$morecss : '').'">'; print '<table class="centpercent noborder'.($morecss ? ' '.$morecss : '').'">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1); print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1);
print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1); print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1);
print '</tr>'; print '</tr>';
print "\n"; print "\n";
if (is_array($listofactions) && count($listofactions)) if (is_array($listofactions) && count($listofactions))
{ {
$cacheusers = array(); $cacheusers = array();
$cursorevent = 0; $cursorevent = 0;
foreach ($listofactions as $actioncomm) foreach ($listofactions as $actioncomm)
{ {
if ($max && $cursorevent >= $max) break; if ($max && $cursorevent >= $max) break;
$ref = $actioncomm->getNomUrl(1, -1); $ref = $actioncomm->getNomUrl(1, -1);
$label = $actioncomm->getNomUrl(0, 38); $label = $actioncomm->getNomUrl(0, 38);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Ref // Ref
print '<td class="nowraponall">'.$ref.'</td>'; print '<td class="nowraponall">'.$ref.'</td>';
// Onwer // Onwer
print '<td class="tdoverflowmax150">'; print '<td class="tdoverflowmax150">';
if (!empty($actioncomm->userownerid)) if (!empty($actioncomm->userownerid))
{ {
if (is_object($cacheusers[$actioncomm->userownerid])) if (is_object($cacheusers[$actioncomm->userownerid]))
{ {
$tmpuser = $cacheusers[$actioncomm->userownerid]; $tmpuser = $cacheusers[$actioncomm->userownerid];
} else { } else {
$tmpuser = new User($this->db); $tmpuser = new User($this->db);
$tmpuser->fetch($actioncomm->userownerid); $tmpuser->fetch($actioncomm->userownerid);
$cacheusers[$actioncomm->userownerid] = $tmpuser; $cacheusers[$actioncomm->userownerid] = $tmpuser;
} }
if ($tmpuser->id > 0) if ($tmpuser->id > 0)
{ {
print $tmpuser->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); print $tmpuser->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
} }
} }
print '</td>'; print '</td>';
// Type // Type
print '<td>'; print '<td>';
// TODO Code common with code into comm/action/list.php // TODO Code common with code into comm/action/list.php
$imgpicto = ''; $imgpicto = '';
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
{ {
@ -281,100 +281,100 @@ class FormActions
} else { } else {
print $actioncomm->type_short ? $actioncomm->type_short : $actioncomm->type; print $actioncomm->type_short ? $actioncomm->type_short : $actioncomm->type;
} }
print '</td>'; print '</td>';
// Label // Label
print '<td>'.$label.'</td>'; print '<td>'.$label.'</td>';
// Date // Date
print '<td class="center">'.dol_print_date($actioncomm->datep, 'dayhour', 'tzuserrel'); print '<td class="center">'.dol_print_date($actioncomm->datep, 'dayhour', 'tzuserrel');
if ($actioncomm->datef) if ($actioncomm->datef)
{ {
$tmpa = dol_getdate($actioncomm->datep); $tmpa = dol_getdate($actioncomm->datep);
$tmpb = dol_getdate($actioncomm->datef); $tmpb = dol_getdate($actioncomm->datef);
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year'])
{ {
if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($actioncomm->datef, 'hour', 'tzuserrel'); if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($actioncomm->datef, 'hour', 'tzuserrel');
} else print '-'.dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel'); } else print '-'.dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel');
} }
print '</td>'; print '</td>';
print '<td class="right">'; print '<td class="right">';
print $actioncomm->getLibStatut(3); print $actioncomm->getLibStatut(3);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$cursorevent++; $cursorevent++;
} }
} else { } else {
print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
} }
if ($max && $num > $max) if ($max && $num > $max)
{ {
print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("More").'...</td></tr>'; print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("More").'...</td></tr>';
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
} }
return $num; return $num;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Output html select list of type of event * Output html select list of type of event
* *
* @param array|string $selected Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too. * @param array|string $selected Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too.
* @param string $htmlname Name of select field * @param string $htmlname Name of select field
* @param string $excludetype A type to exclude ('systemauto', 'system', '') * @param string $excludetype A type to exclude ('systemauto', 'system', '')
* @param integer $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual" * @param integer $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual"
* @param int $hideinfohelp 1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value * @param int $hideinfohelp 1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value
* @param int $multiselect 1=Allow multiselect of action type * @param int $multiselect 1=Allow multiselect of action type
* @param int $nooutput 1=No output * @param int $nooutput 1=No output
* @param string $morecss More css to add to SELECT component. * @param string $morecss More css to add to SELECT component.
* @return string * @return string
*/ */
public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = '') public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = '')
{ {
// phpcs:enable // phpcs:enable
global $langs, $user, $form, $conf; global $langs, $user, $form, $conf;
if (!is_object($form)) $form = new Form($this->db); if (!is_object($form)) $form = new Form($this->db);
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$caction = new CActionComm($this->db); $caction = new CActionComm($this->db);
// Suggest a list with manual events or all auto events // Suggest a list with manual events or all auto events
$arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot); $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot);
if (empty($multiselect)) { if (empty($multiselect)) {
// Add empty line at start only if no multiselect // Add empty line at start only if no multiselect
array_unshift($arraylist, '&nbsp;'); array_unshift($arraylist, '&nbsp;');
} }
//asort($arraylist); //asort($arraylist);
if ($selected == 'manual') $selected = 'AC_OTH'; if ($selected == 'manual') $selected = 'AC_OTH';
if ($selected == 'auto') $selected = 'AC_OTH_AUTO'; if ($selected == 'auto') $selected = 'AC_OTH_AUTO';
if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']);
$out = ''; $out = '';
if (!empty($multiselect)) if (!empty($multiselect))
{ {
if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected);
$out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0);
} else { } else {
$out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200'.($morecss ? ' '.$morecss : ''), 1); $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200'.($morecss ? ' '.$morecss : ''), 1);
} }
if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0)
{ {
$out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1);
} }
if ($nooutput) return $out; if ($nooutput) return $out;
else print $out; else print $out;
return ''; return '';
} }
} }

View File

@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
class FormCompany extends Form class FormCompany extends Form
{ {
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of labels (translated) of third parties type * Return list of labels (translated) of third parties type
* *
@ -50,7 +50,7 @@ class FormCompany extends Form
*/ */
public function typent_array($mode = 0, $filter = '') public function typent_array($mode = 0, $filter = '')
{ {
// phpcs:enable // phpcs:enable
global $langs, $mysoc; global $langs, $mysoc;
$effs = array(); $effs = array();
@ -83,7 +83,7 @@ class FormCompany extends Form
return $effs; return $effs;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre) * Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre)
* *
@ -93,7 +93,7 @@ class FormCompany extends Form
*/ */
public function effectif_array($mode = 0, $filter = '') public function effectif_array($mode = 0, $filter = '')
{ {
// phpcs:enable // phpcs:enable
$effs = array(); $effs = array();
$sql = "SELECT id, code, libelle"; $sql = "SELECT id, code, libelle";
@ -123,7 +123,7 @@ class FormCompany extends Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Affiche formulaire de selection des modes de reglement * Affiche formulaire de selection des modes de reglement
* *
@ -135,7 +135,7 @@ class FormCompany extends Form
*/ */
public function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0) public function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0)
{ {
// phpcs:enable // phpcs:enable
global $user, $langs; global $user, $langs;
print '<form method="post" action="'.$page.'">'; print '<form method="post" action="'.$page.'">';
@ -225,12 +225,12 @@ class FormCompany extends Form
print '</form>'; print '</form>';
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country.
* In the case of an all-country list, the display breaks on the country. * In the case of an all-country list, the display breaks on the country.
* The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs).
* Thus the links with the departments are done on a department independently of its name. * Thus the links with the departments are done on a department independently of its name.
* *
* @param string $selected Code state preselected * @param string $selected Code state preselected
* @param int $country_codeid 0=list for all countries, otherwise country code or country rowid to show * @param int $country_codeid 0=list for all countries, otherwise country code or country rowid to show
@ -239,16 +239,16 @@ class FormCompany extends Form
*/ */
public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id')
{ {
// phpcs:enable // phpcs:enable
print $this->select_state($selected, $country_codeid, $htmlname); print $this->select_state($selected, $country_codeid, $htmlname);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country.
* In the case of an all-country list, the display breaks on the country. * In the case of an all-country list, the display breaks on the country.
* The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs).
* Thus the links with the departments are done on a department independently of its name. * Thus the links with the departments are done on a department independently of its name.
* *
* @param int $selected Code state preselected (mus be state id) * @param int $selected Code state preselected (mus be state id)
* @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show * @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show
@ -258,7 +258,7 @@ class FormCompany extends Form
*/ */
public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id') public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id')
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs, $user; global $conf, $langs, $user;
dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid, LOG_DEBUG); dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid, LOG_DEBUG);
@ -349,7 +349,7 @@ class FormCompany extends Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Retourne la liste deroulante des regions actives dont le pays est actif * Retourne la liste deroulante des regions actives dont le pays est actif
* La cle de la liste est le code (il peut y avoir plusieurs entree pour * La cle de la liste est le code (il peut y avoir plusieurs entree pour
@ -362,7 +362,7 @@ class FormCompany extends Form
*/ */
public function select_region($selected = '', $htmlname = 'region_id') public function select_region($selected = '', $htmlname = 'region_id')
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs;
$langs->load("dict"); $langs->load("dict");
@ -412,7 +412,7 @@ class FormCompany extends Form
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return combo list with people title * Return combo list with people title
* *
@ -424,7 +424,7 @@ class FormCompany extends Form
*/ */
public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth150', $addjscombo = 0) public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth150', $addjscombo = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs, $user; global $conf, $langs, $user;
$langs->load("dict"); $langs->load("dict");
@ -473,7 +473,7 @@ class FormCompany extends Form
return $out; return $out;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne.
* Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays. * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays.
@ -487,25 +487,25 @@ class FormCompany extends Form
*/ */
public function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '') public function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '')
{ {
// phpcs:enable // phpcs:enable
print $this->select_juridicalstatus($selected, $country_codeid, $filter); print $this->select_juridicalstatus($selected, $country_codeid, $filter);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne.
* Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays
* *
* @param string $selected Preselected code of juridical type * @param string $selected Preselected code of juridical type
* @param int $country_codeid 0=list for all countries, otherwise list only country requested * @param int $country_codeid 0=list for all countries, otherwise list only country requested
* @param string $filter Add a SQL filter on list * @param string $filter Add a SQL filter on list
* @param string $htmlname HTML name of select * @param string $htmlname HTML name of select
* @param string $morecss More CSS * @param string $morecss More CSS
* @return string String with HTML select * @return string String with HTML select
*/ */
public function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code', $morecss = '') public function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code', $morecss = '')
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs, $user; global $conf, $langs, $user;
$langs->load("dict"); $langs->load("dict");
@ -578,9 +578,9 @@ class FormCompany extends Form
$out .= '</select>'; $out .= '</select>';
if ($user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); if ($user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
// Make select dynamic // Make select dynamic
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
$out .= ajax_combobox($htmlname); $out .= ajax_combobox($htmlname);
$out .= '</div>'; $out .= '</div>';
} else { } else {
@ -600,8 +600,8 @@ class FormCompany extends Form
* @param string $htmlname Name of HTML form * @param string $htmlname Name of HTML form
* @param array $limitto Disable answers that are not id in this array list * @param array $limitto Disable answers that are not id in this array list
* @param int $forceid This is to force another object id than object->id * @param int $forceid This is to force another object id than object->id
* @param string $moreparam String with more param to add into url when noajax search is used. * @param string $moreparam String with more param to add into url when noajax search is used.
* @param string $morecss More CSS on select component * @param string $morecss More CSS on select component
* @return int The selected third party ID * @return int The selected third party ID
*/ */
public function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '') public function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '')
@ -746,21 +746,21 @@ class FormCompany extends Form
} }
} }
/** /**
* Return a select list with types of contacts * Return a select list with types of contacts
* *
* @param object $object Object to use to find type of contact * @param object $object Object to use to find type of contact
* @param string $selected Default selected value * @param string $selected Default selected value
* @param string $htmlname HTML select name * @param string $htmlname HTML select name
* @param string $source Source ('internal' or 'external') * @param string $source Source ('internal' or 'external')
* @param string $sortorder Sort criteria ('position', 'code', ...) * @param string $sortorder Sort criteria ('position', 'code', ...)
* @param int $showempty 1=Add en empty line * @param int $showempty 1=Add en empty line
* @param string $morecss Add more css to select component * @param string $morecss Add more css to select component
* @return void * @return void
*/ */
public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '') public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '')
{ {
global $user, $langs; global $user, $langs;
if (is_object($object) && method_exists($object, 'liste_type_contact')) if (is_object($object) && method_exists($object, 'liste_type_contact'))
{ {
@ -822,7 +822,7 @@ class FormCompany extends Form
return 'ErrorBadValueForParameterRenderMode'; // Should not happened return 'ErrorBadValueForParameterRenderMode'; // Should not happened
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return a select list with zip codes and their town * Return a select list with zip codes and their town
* *
@ -837,7 +837,7 @@ class FormCompany extends Form
*/ */
public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '') public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '')
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$out = ''; $out = '';
@ -855,155 +855,155 @@ class FormCompany extends Form
return $out; return $out;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return HTML string to use as input of professional id into a HTML page (siren, siret, etc...) * Return HTML string to use as input of professional id into a HTML page (siren, siret, etc...)
* *
* @param int $idprof 1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm) * @param int $idprof 1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm)
* @param string $htmlname Name of HTML select * @param string $htmlname Name of HTML select
* @param string $preselected Default value to show * @param string $preselected Default value to show
* @param string $country_code FR, IT, ... * @param string $country_code FR, IT, ...
* @param string $morecss More css * @param string $morecss More css
* @return string HTML string with prof id * @return string HTML string with prof id
*/ */
public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent') public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent')
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs, $hookmanager; global $conf, $langs, $hookmanager;
$formlength = 0; $formlength = 0;
if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) { if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) {
if ($country_code == 'FR') if ($country_code == 'FR')
{ {
if (isset($idprof)) { if (isset($idprof)) {
if ($idprof == 1) $formlength = 9; if ($idprof == 1) $formlength = 9;
elseif ($idprof == 2) $formlength = 14; elseif ($idprof == 2) $formlength = 14;
elseif ($idprof == 3) $formlength = 5; // 4 chiffres et 1 lettre depuis janvier elseif ($idprof == 3) $formlength = 5; // 4 chiffres et 1 lettre depuis janvier
elseif ($idprof == 4) $formlength = 32; // No maximum as we need to include a town name in this id elseif ($idprof == 4) $formlength = 32; // No maximum as we need to include a town name in this id
} }
} elseif ($country_code == 'ES') } elseif ($country_code == 'ES')
{ {
if ($idprof == 1) $formlength = 9; //CIF/NIF/NIE 9 digits if ($idprof == 1) $formlength = 9; //CIF/NIF/NIE 9 digits
if ($idprof == 2) $formlength = 12; //NASS 12 digits without / if ($idprof == 2) $formlength = 12; //NASS 12 digits without /
if ($idprof == 3) $formlength = 5; //CNAE 5 digits if ($idprof == 3) $formlength = 5; //CNAE 5 digits
if ($idprof == 4) $formlength = 32; //depend of college if ($idprof == 4) $formlength = 32; //depend of college
} }
} }
$selected = $preselected; $selected = $preselected;
if (!$selected && isset($idprof)) { if (!$selected && isset($idprof)) {
if ($idprof == 1 && !empty($this->idprof1)) $selected = $this->idprof1; if ($idprof == 1 && !empty($this->idprof1)) $selected = $this->idprof1;
elseif ($idprof == 2 && !empty($this->idprof2)) $selected = $this->idprof2; elseif ($idprof == 2 && !empty($this->idprof2)) $selected = $this->idprof2;
elseif ($idprof == 3 && !empty($this->idprof3)) $selected = $this->idprof3; elseif ($idprof == 3 && !empty($this->idprof3)) $selected = $this->idprof3;
elseif ($idprof == 4 && !empty($this->idprof4)) $selected = $this->idprof4; elseif ($idprof == 4 && !empty($this->idprof4)) $selected = $this->idprof4;
} }
$maxlength = $formlength; $maxlength = $formlength;
if (empty($formlength)) { $formlength = 24; $maxlength = 128; } if (empty($formlength)) { $formlength = 24; $maxlength = 128; }
$out = ''; $out = '';
// Execute hook getInputIdProf to complete or replace $out // Execute hook getInputIdProf to complete or replace $out
$parameters = array('formlength'=>$formlength, 'selected'=>$preselected, 'idprof'=>$idprof, 'htmlname'=>$htmlname, 'country_code'=>$country_code); $parameters = array('formlength'=>$formlength, 'selected'=>$preselected, 'idprof'=>$idprof, 'htmlname'=>$htmlname, 'country_code'=>$country_code);
$reshook = $hookmanager->executeHooks('getInputIdProf', $parameters); $reshook = $hookmanager->executeHooks('getInputIdProf', $parameters);
if (empty($reshook)) if (empty($reshook))
{ {
$out .= '<input type="text" '.($morecss ? 'class="'.$morecss.'" ' : '').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">'; $out .= '<input type="text" '.($morecss ? 'class="'.$morecss.'" ' : '').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">';
} }
$out .= $hookmanager->resPrint; $out .= $hookmanager->resPrint;
return $out; return $out;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return a HTML select with localtax values for thirdparties * Return a HTML select with localtax values for thirdparties
* *
* @param int $local LocalTax * @param int $local LocalTax
* @param int $selected Preselected value * @param int $selected Preselected value
* @param string $htmlname HTML select name * @param string $htmlname HTML select name
* @return void * @return void
*/ */
public function select_localtax($local, $selected, $htmlname) public function select_localtax($local, $selected, $htmlname)
{ {
// phpcs:enable // phpcs:enable
$tax = get_localtax_by_third($local); $tax = get_localtax_by_third($local);
$num = $this->db->num_rows($tax); $num = $this->db->num_rows($tax);
$i = 0; $i = 0;
if ($num) if ($num)
{ {
$valors = explode(":", $tax); $valors = explode(":", $tax);
if (count($valors) > 1) if (count($valors) > 1)
{ {
//montar select //montar select
print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
while ($i <= (count($valors)) - 1) while ($i <= (count($valors)) - 1)
{ {
if ($selected == $valors[$i]) if ($selected == $valors[$i])
{ {
print '<option value="'.$valors[$i].'" selected>'; print '<option value="'.$valors[$i].'" selected>';
} else { } else {
print '<option value="'.$valors[$i].'">'; print '<option value="'.$valors[$i].'">';
} }
print $valors[$i]; print $valors[$i];
print '</option>'; print '</option>';
$i++; $i++;
} }
print'</select>'; print'</select>';
} }
} }
} }
/** /**
* Return a HTML select for thirdparty type * Return a HTML select for thirdparty type
* *
* @param int $selected selected value * @param int $selected selected value
* @param string $htmlname HTML select name * @param string $htmlname HTML select name
* @param string $htmlidname HTML select id * @param string $htmlidname HTML select id
* @param string $typeinput HTML output * @param string $typeinput HTML output
* @param string $morecss More css * @param string $morecss More css
* @return string HTML string * @return string HTML string
*/ */
public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '') public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '')
{ {
global $conf, $langs; global $conf, $langs;
$out = '<select class="flat '.$morecss.'" name="'.$htmlname.'" id="'.$htmlidname.'">'; $out = '<select class="flat '.$morecss.'" name="'.$htmlname.'" id="'.$htmlidname.'">';
if ($typeinput == 'form') { if ($typeinput == 'form') {
if ($selected == '' || $selected == '-1') $out .= '<option value="-1">&nbsp;</option>'; if ($selected == '' || $selected == '-1') $out .= '<option value="-1">&nbsp;</option>';
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
$out .= '<option value="2"'.($selected == 2 ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>'; $out .= '<option value="2"'.($selected == 2 ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>';
} }
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
$out .= '<option value="3"'.($selected == 3 ? ' selected' : '').'>'.$langs->trans('ProspectCustomer').'</option>'; $out .= '<option value="3"'.($selected == 3 ? ' selected' : '').'>'.$langs->trans('ProspectCustomer').'</option>';
} }
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$out .= '<option value="1"'.($selected == 1 ? ' selected' : '').'>'.$langs->trans('Customer').'</option>'; $out .= '<option value="1"'.($selected == 1 ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
} }
$out .= '<option value="0"'.((string) $selected == '0' ? ' selected' : '').'>'.$langs->trans('NorProspectNorCustomer').'</option>'; $out .= '<option value="0"'.((string) $selected == '0' ? ' selected' : '').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
} elseif ($typeinput == 'list') { } elseif ($typeinput == 'list') {
$out .= '<option value="-1"'.(($selected == '' || $selected == '-1') ? ' selected' : '').'>&nbsp;</option>'; $out .= '<option value="-1"'.(($selected == '' || $selected == '-1') ? ' selected' : '').'>&nbsp;</option>';
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
$out .= '<option value="2,3"'.($selected == '2,3' ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>'; $out .= '<option value="2,3"'.($selected == '2,3' ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>';
} }
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$out .= '<option value="1,3"'.($selected == '1,3' ? ' selected' : '').'>'.$langs->trans('Customer').'</option>'; $out .= '<option value="1,3"'.($selected == '1,3' ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
} }
$out .= '<option value="4"'.($selected == '4' ? ' selected' : '').'>'.$langs->trans('Supplier').'</option>'; $out .= '<option value="4"'.($selected == '4' ? ' selected' : '').'>'.$langs->trans('Supplier').'</option>';
$out .= '<option value="0"'.($selected == '0' ? ' selected' : '').'>'.$langs->trans('Other').'</option>'; $out .= '<option value="0"'.($selected == '0' ? ' selected' : '').'>'.$langs->trans('Other').'</option>';
} elseif ($typeinput == 'admin') { } elseif ($typeinput == 'admin') {
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
$out .= '<option value="3"'.($selected == 3 ? ' selected' : '').'>'.$langs->trans('ProspectCustomer').'</option>'; $out .= '<option value="3"'.($selected == 3 ? ' selected' : '').'>'.$langs->trans('ProspectCustomer').'</option>';
} }
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$out .= '<option value="1"'.($selected == 1 ? ' selected' : '').'>'.$langs->trans('Customer').'</option>'; $out .= '<option value="1"'.($selected == 1 ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
} }
} }
$out .= '</select>'; $out .= '</select>';
return $out; return $out;
} }
} }

View File

@ -58,7 +58,7 @@ class FormFile
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show form to upload a new file. * Show form to upload a new file.
* *
@ -70,8 +70,8 @@ class FormFile
* @param int $size Length of input file area. Deprecated. * @param int $size Length of input file area. Deprecated.
* @param Object $object Object to use (when attachment is done on an element) * @param Object $object Object to use (when attachment is done on an element)
* @param string $options Add an option column * @param string $options Add an option column
* @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). * @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option).
* Deprecated 2 should never be used and if 1 is used, option should no be enabled. * Deprecated 2 should never be used and if 1 is used, option should no be enabled.
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
* @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files * @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files
* @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM) * @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM)
@ -83,14 +83,14 @@ class FormFile
*/ */
public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '', $usewithoutform = 0, $capture = 0) public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '', $usewithoutform = 0, $capture = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs, $hookmanager; global $conf, $langs, $hookmanager;
$hookmanager->initHooks(array('formfile')); $hookmanager->initHooks(array('formfile'));
// Deprecation warning // Deprecation warning
if ($useajax == 2) { if ($useajax == 2) {
dol_syslog(__METHOD__.": using 2 for useajax is deprecated and should be not used", LOG_WARNING); dol_syslog(__METHOD__.": using 2 for useajax is deprecated and should be not used", LOG_WARNING);
} }
if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') $useajax = 0; if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') $useajax = 0;
@ -114,12 +114,12 @@ class FormFile
if (empty($usewithoutform)) // Try to avoid this and set instead the form by the caller. if (empty($usewithoutform)) // Try to avoid this and set instead the form by the caller.
{ {
$out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">'; $out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">';
$out .= '<input type="hidden" name="token" value="'.newToken().'">'; $out .= '<input type="hidden" name="token" value="'.newToken().'">';
$out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="'.$sectiondir.'">'; $out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="'.$sectiondir.'">';
$out .= '<input type="hidden" id="'.$htmlname.'_section_id" name="section_id" value="'.$sectionid.'">'; $out .= '<input type="hidden" id="'.$htmlname.'_section_id" name="section_id" value="'.$sectionid.'">';
$out .= '<input type="hidden" name="sortfield" value="'.GETPOST('sortfield', 'alpha').'">'; $out .= '<input type="hidden" name="sortfield" value="'.GETPOST('sortfield', 'alpha').'">';
$out .= '<input type="hidden" name="sortorder" value="'.GETPOST('sortorder', 'aZ09').'">'; $out .= '<input type="hidden" name="sortorder" value="'.GETPOST('sortorder', 'aZ09').'">';
} }
$out .= '<table class="nobordernopadding centpercent">'; $out .= '<table class="nobordernopadding centpercent">';
@ -201,24 +201,24 @@ class FormFile
$out .= "</td></tr>"; $out .= "</td></tr>";
if ($savingdocmask) if ($savingdocmask)
{ {
//add a global variable for disable the auto renaming on upload //add a global variable for disable the auto renaming on upload
$rename = (empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT) ? 'checked' : ''); $rename = (empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT) ? 'checked' : '');
$out .= '<tr>'; $out .= '<tr>';
if (!empty($options)) $out .= '<td>'.$options.'</td>'; if (!empty($options)) $out .= '<td>'.$options.'</td>';
$out .= '<td valign="middle" class="nowrap">'; $out .= '<td valign="middle" class="nowrap">';
$out .= '<input type="checkbox" '.$rename.' class="savingdocmask" name="savingdocmask" value="'.dol_escape_js($savingdocmask).'"> '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/', $langs->transnoentitiesnoconv("OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv("OriginFileName")); $out .= '<input type="checkbox" '.$rename.' class="savingdocmask" name="savingdocmask" value="'.dol_escape_js($savingdocmask).'"> '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/', $langs->transnoentitiesnoconv("OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv("OriginFileName"));
$out .= '</td>'; $out .= '</td>';
$out .= '</tr>'; $out .= '</tr>';
} }
$out .= "</table>"; $out .= "</table>";
if (empty($usewithoutform)) if (empty($usewithoutform))
{ {
$out .= '</form>'; $out .= '</form>';
if (empty($sectionid)) $out .= '<br>'; if (empty($sectionid)) $out .= '<br>';
} }
$out .= "\n</div><!-- End form attach new file -->\n"; $out .= "\n</div><!-- End form attach new file -->\n";
@ -232,10 +232,10 @@ class FormFile
if (empty($usewithoutform)) if (empty($usewithoutform))
{ {
$out .= '<form name="'.$htmlname.'_link" id="'.$htmlname.'_link" action="'.$url.'" method="POST">'."\n"; $out .= '<form name="'.$htmlname.'_link" id="'.$htmlname.'_link" action="'.$url.'" method="POST">'."\n";
$out .= '<input type="hidden" name="token" value="'.newToken().'">'."\n"; $out .= '<input type="hidden" name="token" value="'.newToken().'">'."\n";
$out .= '<input type="hidden" id="'.$htmlname.'_link_section_dir" name="link_section_dir" value="">'."\n"; $out .= '<input type="hidden" id="'.$htmlname.'_link_section_dir" name="link_section_dir" value="">'."\n";
$out .= '<input type="hidden" id="'.$htmlname.'_link_section_id" name="link_section_id" value="'.$sectionid.'">'."\n"; $out .= '<input type="hidden" id="'.$htmlname.'_link_section_id" name="link_section_id" value="'.$sectionid.'">'."\n";
} }
$out .= '<div class="valignmiddle">'; $out .= '<div class="valignmiddle">';
@ -257,8 +257,8 @@ class FormFile
$out .= '</div>'; $out .= '</div>';
if (empty($usewithoutform)) if (empty($usewithoutform))
{ {
$out .= '<div class="clearboth"></div>'; $out .= '<div class="clearboth"></div>';
$out .= '</form><br>'; $out .= '</form><br>';
} }
$out .= "\n</div><!-- End form link new url -->\n"; $out .= "\n</div><!-- End form link new url -->\n";
@ -268,7 +268,7 @@ class FormFile
$res = $hookmanager->executeHooks('formattachOptions', $parameters, $object); $res = $hookmanager->executeHooks('formattachOptions', $parameters, $object);
if (empty($res)) if (empty($res))
{ {
print '<div class="'.($usewithoutform ? 'inline-block valignmiddle' : 'attacharea attacharea'.$htmlname).'">'; print '<div class="'.($usewithoutform ? 'inline-block valignmiddle' : 'attacharea attacharea'.$htmlname).'">';
print $out; print $out;
print '</div>'; print '</div>';
} }
@ -278,7 +278,7 @@ class FormFile
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show the box with list of available documents for object * Show the box with list of available documents for object
* *
@ -303,7 +303,7 @@ class FormFile
*/ */
public function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '') public function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '')
{ {
// phpcs:enable // phpcs:enable
$this->numoffiles = 0; $this->numoffiles = 0;
print $this->showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang); print $this->showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang);
return $this->numoffiles; return $this->numoffiles;
@ -454,13 +454,13 @@ class FormFile
$modellist = ModelePDFExpedition::liste_modeles($this->db); $modellist = ModelePDFExpedition::liste_modeles($this->db);
} }
} elseif ($modulepart == 'reception') } elseif ($modulepart == 'reception')
{ {
if (is_array($genallowed)) $modellist = $genallowed; if (is_array($genallowed)) $modellist = $genallowed;
else { else {
include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php';
$modellist = ModelePdfReception::liste_modeles($this->db); $modellist = ModelePdfReception::liste_modeles($this->db);
} }
} elseif ($modulepart == 'livraison') } elseif ($modulepart == 'livraison')
{ {
if (is_array($genallowed)) $modellist = $genallowed; if (is_array($genallowed)) $modellist = $genallowed;
else { else {
@ -611,16 +611,16 @@ class FormFile
$modellist = ModelePDFUserGroup::liste_modeles($this->db); $modellist = ModelePDFUserGroup::liste_modeles($this->db);
} }
} else { } else {
$submodulepart = $modulepart; $submodulepart = $modulepart;
// modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject' // modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject'
$tmp = explode(':', $modulepart); $tmp = explode(':', $modulepart);
if (!empty($tmp[1])) { if (!empty($tmp[1])) {
$modulepart = $tmp[0]; $modulepart = $tmp[0];
$submodulepart = $tmp[1]; $submodulepart = $tmp[1];
} }
// For normalized standard modules // For normalized standard modules
$file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0); $file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0);
if (file_exists($file)) if (file_exists($file))
{ {
@ -628,7 +628,7 @@ class FormFile
} }
// For normalized external modules. // For normalized external modules.
else { else {
$file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0); $file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0);
$res = include_once $file; $res = include_once $file;
} }
@ -992,7 +992,7 @@ class FormFile
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show list of documents in $filearray (may be they are all in same directory but may not) * Show list of documents in $filearray (may be they are all in same directory but may not)
* This also sync database if $upload_dir is defined. * This also sync database if $upload_dir is defined.
@ -1027,7 +1027,7 @@ class FormFile
*/ */
public function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0, $disablecrop = -1) public function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0, $disablecrop = -1)
{ {
// phpcs:enable // phpcs:enable
global $user, $conf, $langs, $hookmanager; global $user, $conf, $langs, $hookmanager;
global $sortfield, $sortorder, $maxheightmini; global $sortfield, $sortorder, $maxheightmini;
global $dolibarr_main_url_root; global $dolibarr_main_url_root;
@ -1049,7 +1049,7 @@ class FormFile
// For backward compatiblity, we detect file stored into an old path // For backward compatiblity, we detect file stored into an old path
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos') if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos')
{ {
$relativepath = preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/'; $relativepath = preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/';
} }
// Defined relative dir to DOL_DATA_ROOT // Defined relative dir to DOL_DATA_ROOT
$relativedir = ''; $relativedir = '';
@ -1233,13 +1233,13 @@ class FormFile
print '<td class="center">'; print '<td class="center">';
if (image_format_supported($file['name']) >= 0) if (image_format_supported($file['name']) >= 0)
{ {
if ($useinecm == 5 || $useinecm == 6) if ($useinecm == 5 || $useinecm == 6)
{ {
$smallfile = getImageFileNameForSize($file['name'], ''); // There is no thumb for ECM module and Media filemanager, so we use true image. TODO Change this it is slow on image dir. $smallfile = getImageFileNameForSize($file['name'], ''); // There is no thumb for ECM module and Media filemanager, so we use true image. TODO Change this it is slow on image dir.
} else { } else {
$smallfile = getImageFileNameForSize($file['name'], '_small'); // For new thumbs using same ext (in lower case however) than original $smallfile = getImageFileNameForSize($file['name'], '_small'); // For new thumbs using same ext (in lower case however) than original
} }
if (!dol_is_file($file['path'].'/'.$smallfile)) $smallfile = getImageFileNameForSize($file['name'], '_small', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension if (!dol_is_file($file['path'].'/'.$smallfile)) $smallfile = getImageFileNameForSize($file['name'], '_small', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension
//print $file['path'].'/'.$smallfile.'<br>'; //print $file['path'].'/'.$smallfile.'<br>';
$urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
@ -1353,7 +1353,7 @@ class FormFile
print '<td'.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>'; print '<td'.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>';
print '</td>'; print '</td>';
} }
} }
} else { } else {
print '<td class="right">'; print '<td class="right">';
print '<input type="hidden" name="ecmfileid" value="'.$filearray[$key]['rowid'].'">'; print '<input type="hidden" name="ecmfileid" value="'.$filearray[$key]['rowid'].'">';
@ -1398,7 +1398,7 @@ class FormFile
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show list of documents in a directory * Show list of documents in a directory
* *
@ -1419,7 +1419,7 @@ class FormFile
*/ */
public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permissiontodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '', $addfilterfields = 0) public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permissiontodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '', $addfilterfields = 0)
{ {
// phpcs:enable // phpcs:enable
global $user, $conf, $langs, $form; global $user, $conf, $langs, $form;
global $sortfield, $sortorder; global $sortfield, $sortorder;
global $search_doc_ref; global $search_doc_ref;
@ -1532,8 +1532,8 @@ class FormFile
$object_instance = new RecruitmentCandidature($this->db); $object_instance = new RecruitmentCandidature($this->db);
} elseif ($modulepart == 'banque') } elseif ($modulepart == 'banque')
{ {
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$object_instance = new Account($this->db); $object_instance = new Account($this->db);
} elseif ($modulepart == 'mrp-mo') } elseif ($modulepart == 'mrp-mo')
{ {
include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
@ -1574,7 +1574,7 @@ class FormFile
'banque'))) { 'banque'))) {
preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : '');
} else { } else {
//print 'Error: Value for modulepart = '.$modulepart.' is not yet implemented in function list_of_autoecmfiles'."\n"; //print 'Error: Value for modulepart = '.$modulepart.' is not yet implemented in function list_of_autoecmfiles'."\n";
} }
if (!$id && !$ref) continue; if (!$id && !$ref) continue;
@ -1733,7 +1733,7 @@ class FormFile
print '<table width="100%" class="liste noborder nobottom">'; print '<table width="100%" class="liste noborder nobottom">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre( print_liste_field_titre(
$langs->trans("Links"), $langs->trans("Links"),
$_SERVER['PHP_SELF'], $_SERVER['PHP_SELF'],
"name", "name",
@ -1742,20 +1742,20 @@ class FormFile
'', '',
$sortfield, $sortfield,
$sortorder, $sortorder,
'' ''
); );
print_liste_field_titre( print_liste_field_titre(
"", "",
"", "",
"", "",
"", "",
"", "",
'', '',
'', '',
'', '',
'right ' 'right '
); );
print_liste_field_titre( print_liste_field_titre(
$langs->trans("Date"), $langs->trans("Date"),
$_SERVER['PHP_SELF'], $_SERVER['PHP_SELF'],
"date", "date",
@ -1764,18 +1764,18 @@ class FormFile
'', '',
$sortfield, $sortfield,
$sortorder, $sortorder,
'center ' 'center '
); );
print_liste_field_titre( print_liste_field_titre(
'', '',
$_SERVER['PHP_SELF'], $_SERVER['PHP_SELF'],
"", "",
"", "",
$param, $param,
'', '',
'', '',
'', '',
'center ' 'center '
); );
print_liste_field_titre('', '', ''); print_liste_field_titre('', '', '');
print '</tr>'; print '</tr>';

View File

@ -37,75 +37,75 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
class FormMail extends Form class FormMail extends Form
{ {
/** /**
* @var DoliDB Database handler. * @var DoliDB Database handler.
*/ */
public $db; public $db;
/** /**
* @var int 1 = Include HTML form tag and show submit button * @var int 1 = Include HTML form tag and show submit button
* 0 = Do not include form tag and submit button * 0 = Do not include form tag and submit button
* -1 = Do not include form tag but include submit button * -1 = Do not include form tag but include submit button
*/ */
public $withform; public $withform;
/** /**
* @var string name from * @var string name from
*/ */
public $fromname; public $fromname;
/** /**
* @var string email from * @var string email from
*/ */
public $frommail; public $frommail;
/** /**
* @var string user, company, robot * @var string user, company, robot
*/ */
public $fromtype; public $fromtype;
/** /**
* @var int from ID * @var int from ID
*/ */
public $fromid; public $fromid;
/** /**
* @var int also from robot * @var int also from robot
*/ */
public $fromalsorobot; public $fromalsorobot;
/** /**
* @var string thirdparty etc * @var string thirdparty etc
*/ */
public $totype; public $totype;
/** /**
* @var int ID * @var int ID
*/ */
public $toid; public $toid;
/** /**
* @var string replyto name * @var string replyto name
*/ */
public $replytoname; public $replytoname;
/** /**
* @var string replyto email * @var string replyto email
*/ */
public $replytomail; public $replytomail;
/** /**
* @var string to name * @var string to name
*/ */
public $toname; public $toname;
/** /**
* @var string to email * @var string to email
*/ */
public $tomail; public $tomail;
/** /**
* @var string trackid * @var string trackid
*/ */
public $trackid; public $trackid;
public $withsubstit; // Show substitution array public $withsubstit; // Show substitution array
@ -180,7 +180,7 @@ class FormMail extends Form
$this->withfckeditor = -1; // -1 = Auto $this->withfckeditor = -1; // -1 = Auto
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Clear list of attached files in send mail form (also stored in session) * Clear list of attached files in send mail form (also stored in session)
* *
@ -188,7 +188,7 @@ class FormMail extends Form
*/ */
public function clear_attached_files() public function clear_attached_files()
{ {
// phpcs:enable // phpcs:enable
global $conf, $user; global $conf, $user;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -203,7 +203,7 @@ class FormMail extends Form
unset($_SESSION["listofmimes".$keytoavoidconflict]); unset($_SESSION["listofmimes".$keytoavoidconflict]);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Add a file into the list of attached files (stored in SECTION array) * Add a file into the list of attached files (stored in SECTION array)
* *
@ -214,7 +214,7 @@ class FormMail extends Form
*/ */
public function add_attached_files($path, $file = '', $type = '') public function add_attached_files($path, $file = '', $type = '')
{ {
// phpcs:enable // phpcs:enable
$listofpaths = array(); $listofpaths = array();
$listofnames = array(); $listofnames = array();
$listofmimes = array(); $listofmimes = array();
@ -237,7 +237,7 @@ class FormMail extends Form
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Remove a file from the list of attached files (stored in SECTION array) * Remove a file from the list of attached files (stored in SECTION array)
* *
@ -246,7 +246,7 @@ class FormMail extends Form
*/ */
public function remove_attached_files($keytodelete) public function remove_attached_files($keytodelete)
{ {
// phpcs:enable // phpcs:enable
$listofpaths = array(); $listofpaths = array();
$listofnames = array(); $listofnames = array();
$listofmimes = array(); $listofmimes = array();
@ -267,7 +267,7 @@ class FormMail extends Form
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of attached files (stored in SECTION array) * Return list of attached files (stored in SECTION array)
* *
@ -275,7 +275,7 @@ class FormMail extends Form
*/ */
public function get_attached_files() public function get_attached_files()
{ {
// phpcs:enable // phpcs:enable
$listofpaths = array(); $listofpaths = array();
$listofnames = array(); $listofnames = array();
$listofmimes = array(); $listofmimes = array();
@ -287,7 +287,7 @@ class FormMail extends Form
return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes); return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show the form to input an email * Show the form to input an email
* this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
@ -299,11 +299,11 @@ class FormMail extends Form
*/ */
public function show_form($addfileaction = 'addfile', $removefileaction = 'removefile') public function show_form($addfileaction = 'addfile', $removefileaction = 'removefile')
{ {
// phpcs:enable // phpcs:enable
print $this->get_form($addfileaction, $removefileaction); print $this->get_form($addfileaction, $removefileaction);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Get the form to input an email * Get the form to input an email
* this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
@ -316,17 +316,17 @@ class FormMail extends Form
*/ */
public function get_form($addfileaction = 'addfile', $removefileaction = 'removefile') public function get_form($addfileaction = 'addfile', $removefileaction = 'removefile')
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs, $user, $hookmanager, $form; global $conf, $langs, $user, $hookmanager, $form;
// Required to show preview of mail attachments // Required to show preview of mail attachments
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new Formfile($this->db); $formfile = new Formfile($this->db);
if (!is_object($form)) $form = new Form($this->db); if (!is_object($form)) $form = new Form($this->db);
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('other', 'mails')); $langs->loadLangs(array('other', 'mails'));
// Clear temp files. Must be done at beginning, before call of triggers // Clear temp files. Must be done at beginning, before call of triggers
if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
@ -464,7 +464,7 @@ class FormMail extends Form
'propal_send', 'order_send', 'facture_send', 'propal_send', 'order_send', 'facture_send',
'shipping_send', 'fichinter_send', 'supplier_proposal_send', 'order_supplier_send', 'shipping_send', 'fichinter_send', 'supplier_proposal_send', 'order_supplier_send',
'invoice_supplier_send', 'thirdparty', 'contract', 'user', 'recruitmentcandidature_send', 'all' 'invoice_supplier_send', 'thirdparty', 'contract', 'user', 'recruitmentcandidature_send', 'all'
))) )))
{ {
// If list of template is empty // If list of template is empty
$out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n"; $out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n";
@ -486,7 +486,7 @@ class FormMail extends Form
if (is_array($this->substit) && count($this->substit)) $helpforsubstitution .= $langs->trans('AvailableVariables').' :<br>'."\n"; if (is_array($this->substit) && count($this->substit)) $helpforsubstitution .= $langs->trans('AvailableVariables').' :<br>'."\n";
foreach ($this->substit as $key => $val) foreach ($this->substit as $key => $val)
{ {
$helpforsubstitution .= $key.' -> '.$langs->trans(dol_string_nohtmltag($val)).'<br>'; $helpforsubstitution .= $key.' -> '.$langs->trans(dol_string_nohtmltag(dolGetFirstLineOfText($val))).'<br>';
} }
if (!empty($this->withsubstit)) // Unset or set ->withsubstit=0 to disable this. if (!empty($this->withsubstit)) // Unset or set ->withsubstit=0 to disable this.
{ {
@ -733,7 +733,7 @@ class FormMail extends Form
{ {
$out .= (!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : ""; $out .= (!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : "";
} else { } else {
$out .= '<input class="minwidth200" id="sendtocc" name="sendtocc" value="'.(GETPOST("sendtocc", "alpha") ? GETPOST("sendtocc", "alpha") : ((!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />'; $out .= '<input class="minwidth200" id="sendtocc" name="sendtocc" value="'.(GETPOST("sendtocc", "alpha") ? GETPOST("sendtocc", "alpha") : ((!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />';
if (!empty($this->withtocc) && is_array($this->withtocc)) if (!empty($this->withtocc) && is_array($this->withtocc))
{ {
$out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; $out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
@ -854,10 +854,10 @@ class FormMail extends Form
foreach ($listofpaths as $key => $val) foreach ($listofpaths as $key => $val)
{ {
$out .= '<div id="attachfile_'.$key.'">'; $out .= '<div id="attachfile_'.$key.'">';
// Preview of attachment // Preview of attachment
preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT)-strlen($val))), $formfile_params); preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT)-strlen($val))), $formfile_params);
$out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; $out .= img_mime($listofnames[$key]).' '.$listofnames[$key];
$out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]); $out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]);
if (!$this->withfilereadonly) if (!$this->withfilereadonly)
{ {
$out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />'; $out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
@ -1060,7 +1060,7 @@ class FormMail extends Form
if (!empty($this->withtocccreadonly)) { if (!empty($this->withtocccreadonly)) {
$out .= (!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : ""; $out .= (!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : "";
} else { } else {
$out .= '<input class="minwidth200" id="sendtoccc" name="sendtoccc" value="'.(GETPOST("sendtoccc", "alpha") ? GETPOST("sendtoccc", "alpha") : ((!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />'; $out .= '<input class="minwidth200" id="sendtoccc" name="sendtoccc" value="'.(GETPOST("sendtoccc", "alpha") ? GETPOST("sendtoccc", "alpha") : ((!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />';
if (!empty($this->withtoccc) && is_array($this->withtoccc)) { if (!empty($this->withtoccc) && is_array($this->withtoccc)) {
$out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; $out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
@ -1185,7 +1185,7 @@ class FormMail extends Form
*/ */
public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '') public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '')
{ {
$ret = new ModelMail(); $ret = new ModelMail();
if ($id == -2 && empty($label)) { if ($id == -2 && empty($label)) {
$this->error = 'LabelIsMandatoryWhenIdIs-2'; $this->error = 'LabelIsMandatoryWhenIdIs-2';
@ -1513,9 +1513,9 @@ class ModelMail
public $id; public $id;
/** /**
* @var string Model mail label * @var string Model mail label
*/ */
public $label; public $label;
public $topic; public $topic;
public $content; public $content;

View File

@ -993,9 +993,9 @@ class FormTicket
$defaultmessage = str_replace('\n', "\n", $defaultmessage); $defaultmessage = str_replace('\n', "\n", $defaultmessage);
// Deal with format differences between message and signature (text / HTML) // Deal with format differences between message and signature (text / HTML)
if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__SIGNATURE__'])) { if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
$this->substit['__SIGNATURE__'] = dol_nl2br($this->substit['__SIGNATURE__']); $this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']);
} elseif (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__SIGNATURE__'])) { } elseif (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
$defaultmessage = dol_nl2br($defaultmessage); $defaultmessage = dol_nl2br($defaultmessage);
} }
if (isset($_POST["message"]) && !$_POST['modelselected']) { if (isset($_POST["message"]) && !$_POST['modelselected']) {

View File

@ -184,7 +184,7 @@ class Menubase
$this->position = (int) $this->position; $this->position = (int) $this->position;
$this->url = trim($this->url); $this->url = trim($this->url);
$this->target = trim($this->target); $this->target = trim($this->target);
$this->titre = trim($this->titre); $this->title = trim($this->title);
$this->langs = trim($this->langs); $this->langs = trim($this->langs);
$this->perms = trim($this->perms); $this->perms = trim($this->perms);
$this->enabled = trim($this->enabled); $this->enabled = trim($this->enabled);
@ -264,7 +264,7 @@ class Menubase
$sql .= " ".((int) $this->position).","; $sql .= " ".((int) $this->position).",";
$sql .= " '".$this->db->escape($this->url)."',"; $sql .= " '".$this->db->escape($this->url)."',";
$sql .= " '".$this->db->escape($this->target)."',"; $sql .= " '".$this->db->escape($this->target)."',";
$sql .= " '".$this->db->escape($this->titre)."',"; $sql .= " '".$this->db->escape($this->title)."',";
$sql .= " '".$this->db->escape($this->langs)."',"; $sql .= " '".$this->db->escape($this->langs)."',";
$sql .= " '".$this->db->escape($this->perms)."',"; $sql .= " '".$this->db->escape($this->perms)."',";
$sql .= " '".$this->db->escape($this->enabled)."',"; $sql .= " '".$this->db->escape($this->enabled)."',";
@ -317,7 +317,7 @@ class Menubase
$this->position = (int) $this->position; $this->position = (int) $this->position;
$this->url = trim($this->url); $this->url = trim($this->url);
$this->target = trim($this->target); $this->target = trim($this->target);
$this->titre = trim($this->titre); $this->title = trim($this->title);
$this->langs = trim($this->langs); $this->langs = trim($this->langs);
$this->perms = trim($this->perms); $this->perms = trim($this->perms);
$this->enabled = trim($this->enabled); $this->enabled = trim($this->enabled);
@ -339,7 +339,7 @@ class Menubase
$sql .= " position=".($this->position > 0 ? $this->position : 0).","; $sql .= " position=".($this->position > 0 ? $this->position : 0).",";
$sql .= " url='".$this->db->escape($this->url)."',"; $sql .= " url='".$this->db->escape($this->url)."',";
$sql .= " target='".$this->db->escape($this->target)."',"; $sql .= " target='".$this->db->escape($this->target)."',";
$sql .= " titre='".$this->db->escape($this->titre)."',"; $sql .= " titre='".$this->db->escape($this->title)."',";
$sql .= " langs='".$this->db->escape($this->langs)."',"; $sql .= " langs='".$this->db->escape($this->langs)."',";
$sql .= " perms='".$this->db->escape($this->perms)."',"; $sql .= " perms='".$this->db->escape($this->perms)."',";
$sql .= " enabled='".$this->db->escape($this->enabled)."',"; $sql .= " enabled='".$this->db->escape($this->enabled)."',";
@ -383,7 +383,7 @@ class Menubase
$sql .= " t.position,"; $sql .= " t.position,";
$sql .= " t.url,"; $sql .= " t.url,";
$sql .= " t.target,"; $sql .= " t.target,";
$sql .= " t.titre,"; $sql .= " t.titre as title,";
$sql .= " t.langs,"; $sql .= " t.langs,";
$sql .= " t.perms,"; $sql .= " t.perms,";
$sql .= " t.enabled,"; $sql .= " t.enabled,";
@ -414,7 +414,7 @@ class Menubase
$this->position = $obj->position; $this->position = $obj->position;
$this->url = $obj->url; $this->url = $obj->url;
$this->target = $obj->target; $this->target = $obj->target;
$this->titre = $obj->titre; $this->title = $obj->title;
$this->langs = $obj->langs; $this->langs = $obj->langs;
$this->perms = $obj->perms; $this->perms = $obj->perms;
$this->enabled = str_replace("\"", "'", $obj->enabled); $this->enabled = str_replace("\"", "'", $obj->enabled);
@ -475,10 +475,8 @@ class Menubase
$this->position = ''; $this->position = '';
$this->url = 'http://dummy'; $this->url = 'http://dummy';
$this->target = ''; $this->target = '';
$this->titre = 'Specimen menu'; // deprecated
$this->title = 'Specimen menu'; $this->title = 'Specimen menu';
$this->langs = ''; $this->langs = '';
$this->level = '';
$this->leftmenu = ''; $this->leftmenu = '';
$this->perms = ''; $this->perms = '';
$this->enabled = ''; $this->enabled = '';

View File

@ -46,16 +46,16 @@
*/ */
function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLength = 2, $autoselect = 0, $ajaxoptions = array(), $moreparams = '') function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLength = 2, $autoselect = 0, $ajaxoptions = array(), $moreparams = '')
{ {
if (empty($minLength)) $minLength = 1; if (empty($minLength)) $minLength = 1;
$dataforrenderITem = 'ui-autocomplete'; $dataforrenderITem = 'ui-autocomplete';
$dataforitem = 'ui-autocomplete-item'; $dataforitem = 'ui-autocomplete-item';
// Allow two constant to use other values for backward compatibility // Allow two constant to use other values for backward compatibility
if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem = constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM'); if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem = constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
if (defined('JS_QUERY_AUTOCOMPLETE_ITEM')) $dataforitem = constant('JS_QUERY_AUTOCOMPLETE_ITEM'); if (defined('JS_QUERY_AUTOCOMPLETE_ITEM')) $dataforitem = constant('JS_QUERY_AUTOCOMPLETE_ITEM');
// Input search_htmlname is original field // Input search_htmlname is original field
// Input htmlname is a second input field used when using ajax autocomplete. // Input htmlname is a second input field used when using ajax autocomplete.
$script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" '.($moreparams ? $moreparams : '').' />'; $script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" '.($moreparams ? $moreparams : '').' />';
$script .= '<!-- Javascript code for autocomplete of field '.$htmlname.' -->'."\n"; $script .= '<!-- Javascript code for autocomplete of field '.$htmlname.' -->'."\n";
@ -348,7 +348,7 @@ function ajax_dialog($title, $message, $w = 350, $h = 150)
$msg = '<div id="dialog-info" title="'.dol_escape_htmltag($newtitle).'">'; $msg = '<div id="dialog-info" title="'.dol_escape_htmltag($newtitle).'">';
$msg .= $message; $msg .= $message;
$msg .= '</div>'."\n"; $msg .= '</div>'."\n";
$msg .= '<script> $msg .= '<script>
jQuery(function() { jQuery(function() {
jQuery("#dialog-info").dialog({ jQuery("#dialog-info").dialog({
resizable: false, resizable: false,
@ -364,9 +364,9 @@ function ajax_dialog($title, $message, $w = 350, $h = 150)
}); });
</script>'; </script>';
$msg .= "\n"; $msg .= "\n";
return $msg; return $msg;
} }
@ -397,8 +397,8 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete =
if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete = 0; if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete = 0;
$tmpplugin = 'select2'; $tmpplugin = 'select2';
$msg = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' --> $msg = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$(\''.(preg_match('/^\./', $htmlname) ? $htmlname : '#'.$htmlname).'\').'.$tmpplugin.'({ $(\''.(preg_match('/^\./', $htmlname) ? $htmlname : '#'.$htmlname).'\').'.$tmpplugin.'({
@ -477,9 +477,9 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete =
} }
$msg .= '});'."\n"; $msg .= '});'."\n";
$msg .= "</script>\n"; $msg .= "</script>\n";
return $msg; return $msg;
} }
/** /**
@ -500,7 +500,7 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
global $conf, $langs, $user; global $conf, $langs, $user;
$entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity); $entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity);
if (! isset($input)) $input = array(); if (!isset($input)) $input = array();
if (empty($conf->use_javascript_ajax) || $forcenoajax) if (empty($conf->use_javascript_ajax) || $forcenoajax)
{ {
@ -566,9 +566,9 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
*/ */
function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array()) function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array())
{ {
global $langs; global $langs;
$out = '<script> $out = '<script>
$(function() { $(function() {
var input = '.json_encode($input).'; var input = '.json_encode($input).';
@ -633,8 +633,8 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input =
}); });
}); });
</script>'; </script>';
$out .= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? 'hideobject' : '').'">'.img_picto($langs->trans($text_off), 'switch_off').'</span>'; $out .= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? 'hideobject' : '').'">'.img_picto($langs->trans($text_off), 'switch_off').'</span>';
$out .= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? '' : 'hideobject').'">'.img_picto($langs->trans($text_on), 'switch_on').'</span>'; $out .= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? '' : 'hideobject').'">'.img_picto($langs->trans($text_on), 'switch_on').'</span>';
return $out; return $out;
} }

File diff suppressed because it is too large Load Diff

View File

@ -60,9 +60,9 @@ function expedition_prepare_head(Expedition $object)
complete_head_from_modules($conf, $langs, $object, $head, $h, 'order'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'order');
complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove');
return $head; return $head;
} }
/** /**
@ -95,18 +95,18 @@ function expedition_admin_prepare_head()
if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
{ {
$head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields"); $head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes_shipment'; $head[$h][2] = 'attributes_shipment';
$h++; $h++;
} }
if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
{ {
$head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsLines"); $head[$h][1] = $langs->trans("ExtraFieldsLines");
$head[$h][2] = 'attributeslines_shipment'; $head[$h][2] = 'attributeslines_shipment';
$h++; $h++;
} }
if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON))

View File

@ -958,11 +958,11 @@ function dolCheckVirus($src_file)
if (!class_exists('AntiVir')) { if (!class_exists('AntiVir')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/antivir.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/antivir.class.php';
} }
$antivir=new AntiVir($db); $antivir = new AntiVir($db);
$result = $antivir->dol_avscan_file($src_file); $result = $antivir->dol_avscan_file($src_file);
if ($result < 0) // If virus or error, we stop here if ($result < 0) // If virus or error, we stop here
{ {
$reterrors=$antivir->errors; $reterrors = $antivir->errors;
return $reterrors; return $reterrors;
} }
} }
@ -1049,7 +1049,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
{ {
// $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too. // $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too.
$publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity]; $publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity];
if (! preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash.='/'; if (!preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash .= '/';
if (strpos($upload_dir, $publicmediasdirwithslash) !== 0) { // We never add .noexe on files into media directory if (strpos($upload_dir, $publicmediasdirwithslash) !== 0) { // We never add .noexe on files into media directory
$file_name .= '.noexe'; $file_name .= '.noexe';
@ -2771,7 +2771,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
if (preg_match('/^specimen/i', $original_file)) $accessallowed = 1; // If link to a file called specimen. Test must be done before changing $original_file int full path. if (preg_match('/^specimen/i', $original_file)) $accessallowed = 1; // If link to a file called specimen. Test must be done before changing $original_file int full path.
if ($fuser->admin) $accessallowed = 1; // If user is admin if ($fuser->admin) $accessallowed = 1; // If user is admin
$tmpmodulepart = explode('-', $modulepart); $tmpmodulepart = explode('-', $modulepart);
if (! empty($tmpmodulepart[1])) { if (!empty($tmpmodulepart[1])) {
$modulepart = $tmpmodulepart[0]; $modulepart = $tmpmodulepart[0];
$original_file = $tmpmodulepart[1].'/'.$original_file; $original_file = $tmpmodulepart[1].'/'.$original_file;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -259,7 +259,7 @@ function hundreds2text($hundreds, $tens, $units)
$decenas = array("", "", "TREINTA ", "CUARENTA ", "CINCUENTA ", "SESENTA ", "SETENTA ", "OCHENTA ", "NOVENTA "); $decenas = array("", "", "TREINTA ", "CUARENTA ", "CINCUENTA ", "SESENTA ", "SETENTA ", "OCHENTA ", "NOVENTA ");
$veintis = array("VEINTE", "VEINTIUN", "VEINTID&OacuteS", "VEINTITR&EacuteS", "VEINTICUATRO", "VEINTICINCO", "VEINTIS&EacuteIS", "VEINTISIETE", "VEINTIOCHO", "VEINTINUEVE"); $veintis = array("VEINTE", "VEINTIUN", "VEINTID&OacuteS", "VEINTITR&EacuteS", "VEINTICUATRO", "VEINTICINCO", "VEINTIS&EacuteIS", "VEINTISIETE", "VEINTIOCHO", "VEINTINUEVE");
$diecis = array("DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE", "DIECIS&EacuteIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE"); $diecis = array("DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE", "DIECIS&EacuteIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE");
$unidades = array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE"); $unidades = array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE");
$entexto = ""; $entexto = "";
if ($hundreds != 0) { if ($hundreds != 0) {
$entexto .= $centenas[$hundreds - 1]; $entexto .= $centenas[$hundreds - 1];

View File

@ -43,8 +43,8 @@ function establishment_prepare_head($object)
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab // $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'establishment'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'establishment');
$head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/info.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/info.php?id='.$object->id;
@ -64,30 +64,30 @@ function establishment_prepare_head($object)
*/ */
function hrm_admin_prepare_head() function hrm_admin_prepare_head()
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
$langs->load('hrm'); $langs->load('hrm');
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_hrm.php'; $head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_hrm.php';
$head[$h][1] = $langs->trans("Parameters"); $head[$h][1] = $langs->trans("Parameters");
$head[$h][2] = 'parameters'; $head[$h][2] = 'parameters';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_establishment.php'; $head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_establishment.php';
$head[$h][1] = $langs->trans("Establishments"); $head[$h][1] = $langs->trans("Establishments");
$head[$h][2] = 'establishments'; $head[$h][2] = 'establishments';
$h++; $h++;
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin'); complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin');
complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin', 'remove'); complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin', 'remove');
return $head; return $head;
} }

View File

@ -40,39 +40,39 @@ function image_format_supported($file, $acceptsvg = 0)
{ {
global $conf; global $conf;
$regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php
if ($acceptsvg || ! empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) { if ($acceptsvg || ! empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
$regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript $regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript
} }
// Case filename is not a format image // Case filename is not a format image
$reg = array(); $reg = array();
if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1; if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1;
// Case filename is a format image but not supported by this PHP // Case filename is a format image but not supported by this PHP
$imgfonction = ''; $imgfonction = '';
if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif'; if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif';
if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg'; if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg';
if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg'; if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg';
if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng'; if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng';
if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp'; if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp';
if (strtolower($reg[1]) == '.webp') $imgfonction = 'imagecreatefromwebp'; if (strtolower($reg[1]) == '.webp') $imgfonction = 'imagecreatefromwebp';
if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm'; if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm';
if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm'; if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm';
if (strtolower($reg[1]) == '.svg') $imgfonction = 'imagecreatefromsvg'; // Never available if (strtolower($reg[1]) == '.svg') $imgfonction = 'imagecreatefromsvg'; // Never available
if ($imgfonction) if ($imgfonction)
{ {
if (!function_exists($imgfonction)) if (!function_exists($imgfonction))
{ {
// Fonctions of conversion not available in this PHP // Fonctions of conversion not available in this PHP
return 0; return 0;
} }
// Filename is a format image and supported for conversion by this PHP // Filename is a format image and supported for conversion by this PHP
return 1; return 1;
} }
return 0; return 0;
} }
@ -97,9 +97,9 @@ function dol_getImageSize($file, $url = false)
if ($filetoread) if ($filetoread)
{ {
$infoImg = getimagesize($filetoread); // Recuperation des infos de l'image $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
$ret['width'] = $infoImg[0]; // Largeur de l'image $ret['width'] = $infoImg[0]; // Largeur de l'image
$ret['height'] = $infoImg[1]; // Hauteur de l'image $ret['height'] = $infoImg[1]; // Hauteur de l'image
} }
return $ret; return $ret;
@ -305,7 +305,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0,
if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
// Free memory. This does not delete image. // Free memory. This does not delete image.
imagedestroy($img); imagedestroy($img);
imagedestroy($imgThumb); imagedestroy($imgThumb);
clearstatcache(); // File was replaced by a modified one, so we clear file caches. clearstatcache(); // File was replaced by a modified one, so we clear file caches.
@ -441,20 +441,20 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
} elseif (!file_exists($file)) } elseif (!file_exists($file))
{ {
// Si le fichier passe en parametre n'existe pas // Si le fichier passe en parametre n'existe pas
dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR); dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR);
return $langs->trans("ErrorFileNotFound", $file); return $langs->trans("ErrorFileNotFound", $file);
} elseif (image_format_supported($file) < 0) } elseif (image_format_supported($file) < 0)
{ {
dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING); dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING);
return 'ErrorBadImageFormat'; return 'ErrorBadImageFormat';
} elseif (!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) { } elseif (!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) {
// Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
dol_syslog('Wrong value for parameter maxWidth', LOG_ERR); dol_syslog('Wrong value for parameter maxWidth', LOG_ERR);
return 'Error: Wrong value for parameter maxWidth'; return 'Error: Wrong value for parameter maxWidth';
} elseif (!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) { } elseif (!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) {
// Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
dol_syslog('Wrong value for parameter maxHeight', LOG_ERR); dol_syslog('Wrong value for parameter maxHeight', LOG_ERR);
return 'Error: Wrong value for parameter maxHeight'; return 'Error: Wrong value for parameter maxHeight';
} }
$filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image
@ -495,7 +495,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
$imgfonction = 'imagecreatefrompng'; $imgfonction = 'imagecreatefrompng';
break; break;
case IMAGETYPE_BMP: // 6 case IMAGETYPE_BMP: // 6
// Not supported by PHP GD // Not supported by PHP GD
break; break;
case IMAGETYPE_WBMP: // 15 case IMAGETYPE_WBMP: // 15
$imgfonction = 'imagecreatefromwbmp'; $imgfonction = 'imagecreatefromwbmp';
@ -531,7 +531,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
$extImg = '.png'; $extImg = '.png';
break; break;
case IMAGETYPE_BMP: // 6 case IMAGETYPE_BMP: // 6
// Not supported by PHP GD // Not supported by PHP GD
$extImg = '.bmp'; $extImg = '.bmp';
break; break;
case IMAGETYPE_WBMP: // 15 case IMAGETYPE_WBMP: // 15
@ -540,14 +540,14 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
break; break;
} }
if (!is_resource($img)) if (!is_resource($img))
{ {
dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING);
return 0; return 0;
} }
$exifAngle = false; $exifAngle = false;
if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) { if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) {
switch ($ort) switch ($ort)
{ {
case 3: // 180 rotate left case 3: // 180 rotate left
@ -568,12 +568,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
} }
} }
if ($exifAngle) if ($exifAngle)
{ {
$rotated = false; $rotated = false;
if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case
{ {
imagealphablending($img, false); imagealphablending($img, false);
imagesavealpha($img, true); imagesavealpha($img, true);
$rotated = imagerotate($img, $exifAngle, imageColorAllocateAlpha($img, 0, 0, 0, 127)); $rotated = imagerotate($img, $exifAngle, imageColorAllocateAlpha($img, 0, 0, 0, 127));
@ -583,9 +583,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
$rotated = imagerotate($img, $exifAngle, 0); $rotated = imagerotate($img, $exifAngle, 0);
} }
// replace image with good orientation // replace image with good orientation
if (!empty($rotated)) { if (!empty($rotated)) {
$img = $rotated; $img = $rotated;
$imgWidth = $trueImgWidth; $imgWidth = $trueImgWidth;
$imgHeight = $trueImgHeight; $imgHeight = $trueImgHeight;
} }
@ -612,8 +612,8 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
$thumbHeight = round($thumbHeight); $thumbHeight = round($thumbHeight);
$thumbWidth = round($thumbWidth); $thumbWidth = round($thumbWidth);
// Define target format // Define target format
if (empty($targetformat)) $targetformat = $infoImg[2]; if (empty($targetformat)) $targetformat = $infoImg[2];
// Create empty image // Create empty image
if ($targetformat == IMAGETYPE_GIF) if ($targetformat == IMAGETYPE_GIF)
@ -643,31 +643,31 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
case IMAGETYPE_GIF: // 1 case IMAGETYPE_GIF: // 1
$trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF
imagecolortransparent($imgThumb, $trans_colour); imagecolortransparent($imgThumb, $trans_colour);
$extImgTarget = '.gif'; $extImgTarget = '.gif';
$newquality = 'NU'; $newquality = 'NU';
break; break;
case IMAGETYPE_JPEG: // 2 case IMAGETYPE_JPEG: // 2
$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
$extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg'); $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg');
$newquality = $quality; $newquality = $quality;
break; break;
case IMAGETYPE_PNG: // 3 case IMAGETYPE_PNG: // 3
imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme
$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel
$extImgTarget = '.png'; $extImgTarget = '.png';
$newquality = $quality - 100; $newquality = $quality - 100;
$newquality = round(abs($quality - 100) * 9 / 100); $newquality = round(abs($quality - 100) * 9 / 100);
break; break;
case IMAGETYPE_BMP: // 6 case IMAGETYPE_BMP: // 6
// Not supported by PHP GD // Not supported by PHP GD
$extImgTarget = '.bmp'; $extImgTarget = '.bmp';
$newquality = 'NU'; $newquality = 'NU';
break; break;
case IMAGETYPE_WBMP: // 15 case IMAGETYPE_WBMP: // 15
$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
$extImgTarget = '.bmp'; $extImgTarget = '.bmp';
$newquality = 'NU'; $newquality = 'NU';
break; break;
} }
if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour);
@ -698,7 +698,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
imagepng($imgThumb, $imgThumbName, $newquality); imagepng($imgThumb, $imgThumbName, $newquality);
break; break;
case IMAGETYPE_BMP: // 6 case IMAGETYPE_BMP: // 6
// Not supported by PHP GD // Not supported by PHP GD
break; break;
case IMAGETYPE_WBMP: // 15 case IMAGETYPE_WBMP: // 15
imagewbmp($imgThumb, $imgThumbName); imagewbmp($imgThumb, $imgThumbName);
@ -708,9 +708,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
// Set permissions on file // Set permissions on file
if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
// Free memory. This does not delete image. // Free memory. This does not delete image.
imagedestroy($img); imagedestroy($img);
imagedestroy($imgThumb); imagedestroy($imgThumb);
return $imgThumbName; return $imgThumbName;
} }

View File

@ -63,46 +63,46 @@ function member_prepare_head(Adherent $object)
$h++; $h++;
} }
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'member'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'member');
$nbNote = 0; $nbNote = 0;
if (!empty($object->note)) $nbNote++; if (!empty($object->note)) $nbNote++;
if (!empty($object->note_private)) $nbNote++; if (!empty($object->note_private)) $nbNote++;
if (!empty($object->note_public)) $nbNote++; if (!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Note"); $head[$h][1] = $langs->trans("Note");
$head[$h][2] = 'note'; $head[$h][2] = 'note';
if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>'; if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
$h++; $h++;
// Attachments // Attachments
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member'); $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member');
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $object->element, $object->id); $nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents'); $head[$h][1] = $langs->trans('Documents');
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
$head[$h][2] = 'document'; $head[$h][2] = 'document';
$h++; $h++;
// Show agenda tab // Show agenda tab
if (!empty($conf->agenda->enabled)) if (!empty($conf->agenda->enabled))
{ {
$head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id; $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
$head[$h][1] = $langs->trans("Events"); $head[$h][1] = $langs->trans("Events");
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
{ {
$head[$h][1] .= '/'; $head[$h][1] .= '/';
$head[$h][1] .= $langs->trans("Agenda"); $head[$h][1] .= $langs->trans("Agenda");
} }
$head[$h][2] = 'agenda'; $head[$h][2] = 'agenda';
$h++; $h++;
} }
complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove');
@ -148,11 +148,11 @@ function member_type_prepare_head(AdherentType $object)
$h++; $h++;
} }
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype');
complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype', 'remove'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype', 'remove');
@ -166,45 +166,45 @@ function member_type_prepare_head(AdherentType $object)
*/ */
function member_admin_prepare_head() function member_admin_prepare_head()
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php'; $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php';
$head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][1] = $langs->trans("Miscellaneous");
$head[$h][2] = 'general'; $head[$h][2] = 'general';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php'; $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php';
$head[$h][1] = $langs->trans("EMails"); $head[$h][1] = $langs->trans("EMails");
$head[$h][2] = 'emails'; $head[$h][2] = 'emails';
$h++; $h++;
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin'); complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin');
$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsMember"); $head[$h][1] = $langs->trans("ExtraFieldsMember");
$head[$h][2] = 'attributes'; $head[$h][2] = 'attributes';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsMemberType"); $head[$h][1] = $langs->trans("ExtraFieldsMemberType");
$head[$h][2] = 'attributes_type'; $head[$h][2] = 'attributes_type';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php'; $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php';
$head[$h][1] = $langs->trans("BlankSubscriptionForm"); $head[$h][1] = $langs->trans("BlankSubscriptionForm");
$head[$h][2] = 'website'; $head[$h][2] = 'website';
$h++; $h++;
complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin', 'remove'); complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin', 'remove');
return $head; return $head;
} }
@ -216,50 +216,50 @@ function member_admin_prepare_head()
*/ */
function member_stats_prepare_head($object) function member_stats_prepare_head($object)
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php'; $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
$head[$h][1] = $langs->trans("Subscriptions"); $head[$h][1] = $langs->trans("Subscriptions");
$head[$h][2] = 'statssubscription'; $head[$h][2] = 'statssubscription';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry'; $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
$head[$h][1] = $langs->trans("Country"); $head[$h][1] = $langs->trans("Country");
$head[$h][2] = 'statscountry'; $head[$h][2] = 'statscountry';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion'; $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
$head[$h][1] = $langs->trans("Region"); $head[$h][1] = $langs->trans("Region");
$head[$h][2] = 'statsregion'; $head[$h][2] = 'statsregion';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate'; $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
$head[$h][1] = $langs->trans("State"); $head[$h][1] = $langs->trans("State");
$head[$h][2] = 'statsstate'; $head[$h][2] = 'statsstate';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown'; $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
$head[$h][1] = $langs->trans('Town'); $head[$h][1] = $langs->trans('Town');
$head[$h][2] = 'statstown'; $head[$h][2] = 'statstown';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php'; $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
$head[$h][1] = $langs->trans('ByProperties'); $head[$h][1] = $langs->trans('ByProperties');
$head[$h][2] = 'statsbyproperties'; $head[$h][2] = 'statsbyproperties';
$h++; $h++;
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab // $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats');
complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove');
return $head; return $head;
} }
/** /**

View File

@ -30,21 +30,21 @@
*/ */
function multicurrencyAdminPrepareHead() function multicurrencyAdminPrepareHead()
{ {
global $langs, $conf; global $langs, $conf;
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = dol_buildpath("/admin/multicurrency.php", 1); $head[$h][0] = dol_buildpath("/admin/multicurrency.php", 1);
$head[$h][1] = $langs->trans("Parameters"); $head[$h][1] = $langs->trans("Parameters");
$head[$h][2] = 'settings'; $head[$h][2] = 'settings';
$h++; $h++;
complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency'); complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency');
complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency', 'remove'); complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency', 'remove');
return $head; return $head;
} }
/** /**

View File

@ -49,18 +49,18 @@ function reception_prepare_head(Reception $object)
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
$objectsrc = $object; $objectsrc = $object;
if ($object->origin == 'commande' && $object->origin_id > 0) if ($object->origin == 'commande' && $object->origin_id > 0)
{ {
$objectsrc = new Commande($db); $objectsrc = new Commande($db);
$objectsrc->fetch($object->origin_id); $objectsrc->fetch($object->origin_id);
} }
$nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
$head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
$head[$h][1] = $langs->trans("ContactsAddresses"); $head[$h][1] = $langs->trans("ContactsAddresses");
if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>'; if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $h++;
} }
// Show more tabs from modules // Show more tabs from modules
@ -69,18 +69,18 @@ function reception_prepare_head(Reception $object)
// $this->tabs = array('entity:-tabname); to remove a tab // $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception');
$nbNote = 0; $nbNote = 0;
if (!empty($object->note_private)) $nbNote++; if (!empty($object->note_private)) $nbNote++;
if (!empty($object->note_public)) $nbNote++; if (!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id; $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
$head[$h][1] = $langs->trans("Notes"); $head[$h][1] = $langs->trans("Notes");
if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>'; if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'remove'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'remove');
return $head; return $head;
} }
/** /**
@ -105,18 +105,18 @@ function reception_admin_prepare_head()
if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION))
{ {
$head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields"); $head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes_reception'; $head[$h][2] = 'attributes_reception';
$h++; $h++;
} }
if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION))
{ {
$head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsLines"); $head[$h][1] = $langs->trans("ExtraFieldsLines");
$head[$h][2] = 'attributeslines_reception'; $head[$h][2] = 'attributeslines_reception';
$h++; $h++;
} }
complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin', 'remove'); complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin', 'remove');

View File

@ -37,13 +37,13 @@ function resource_prepare_head($object)
$head[$h][0] = dol_buildpath('/resource/card.php', 1).'?id='.$object->id; $head[$h][0] = dol_buildpath('/resource/card.php', 1).'?id='.$object->id;
$head[$h][1] = $langs->trans("ResourceCard"); $head[$h][1] = $langs->trans("ResourceCard");
$head[$h][2] = 'resource'; $head[$h][2] = 'resource';
$h++; $h++;
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && (empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER) || empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY))) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && (empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER) || empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY)))
{ {
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
$head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][1] = $langs->trans('ContactsAddresses');
if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>'; if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';

View File

@ -27,41 +27,41 @@
*/ */
function salaries_prepare_head($object) function salaries_prepare_head($object)
{ {
global $db, $langs, $conf; global $db, $langs, $conf;
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("SalaryPayment"); $head[$h][1] = $langs->trans("SalaryPayment");
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab // $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries');
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref); $upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $object->element, $object->id); $nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents'); $head[$h][1] = $langs->trans('Documents');
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge ">'.($nbFiles + $nbLinks).'</span>'; if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge ">'.($nbFiles + $nbLinks).'</span>';
$head[$h][2] = 'documents'; $head[$h][2] = 'documents';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
$head[$h][1] = $langs->trans("Info"); $head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info'; $head[$h][2] = 'info';
$h++; $h++;
complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
return $head; return $head;
} }
/** /**
@ -71,28 +71,28 @@ function salaries_prepare_head($object)
*/ */
function salaries_admin_prepare_head() function salaries_admin_prepare_head()
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php'; $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
$head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][1] = $langs->trans("Miscellaneous");
$head[$h][2] = 'general'; $head[$h][2] = 'general';
$h++; $h++;
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin'); complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin');
$head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsSalaries"); $head[$h][1] = $langs->trans("ExtraFieldsSalaries");
$head[$h][2] = 'attributes'; $head[$h][2] = 'attributes';
$h++; $h++;
complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove'); complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove');
return $head; return $head;
} }

View File

@ -309,7 +309,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
break; break;
} }
} }
} elseif (!empty($feature)) { // This is for permissions on 2 levels ('creer' or 'write') } elseif (!empty($feature)) { // This is for permissions on 2 levels ('creer' or 'write')
//print '<br>feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; exit; //print '<br>feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; exit;
if (empty($user->rights->$feature->creer) if (empty($user->rights->$feature->creer)
&& empty($user->rights->$feature->write) && empty($user->rights->$feature->write)
@ -541,7 +541,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
if ($feature == 'agenda')// Also check owner or attendee for users without allactions->read if ($feature == 'agenda')// Also check owner or attendee for users without allactions->read
{ {
if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) { if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) {
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
$action = new ActionComm($db); $action = new ActionComm($db);
$action->fetch($objectid); $action->fetch($objectid);
if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) { if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) {

View File

@ -71,5 +71,5 @@ function takepos_admin_prepare_head()
complete_head_from_modules($conf, $langs, null, $head, $h, 'takepos_admin', 'remove'); complete_head_from_modules($conf, $langs, null, $head, $h, 'takepos_admin', 'remove');
return $head; return $head;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1867,7 +1867,6 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$menu->type = $this->menu[$key]['type']; $menu->type = $this->menu[$key]['type'];
$menu->mainmenu = isset($this->menu[$key]['mainmenu']) ? $this->menu[$key]['mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu : ''); $menu->mainmenu = isset($this->menu[$key]['mainmenu']) ? $this->menu[$key]['mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu : '');
$menu->leftmenu = isset($this->menu[$key]['leftmenu']) ? $this->menu[$key]['leftmenu'] : ''; $menu->leftmenu = isset($this->menu[$key]['leftmenu']) ? $this->menu[$key]['leftmenu'] : '';
$menu->titre = $this->menu[$key]['titre']; // deprecated
$menu->title = $this->menu[$key]['titre']; $menu->title = $this->menu[$key]['titre'];
$menu->url = $this->menu[$key]['url']; $menu->url = $this->menu[$key]['url'];
$menu->langs = $this->menu[$key]['langs']; $menu->langs = $this->menu[$key]['langs'];

View File

@ -41,8 +41,8 @@ class pdf_ban extends ModeleBankAccountDoc
public $emetteur; public $emetteur;
/** /**
* @var string Dolibarr version of the loaded document * @var string Dolibarr version of the loaded document
*/ */
public $version = 'development'; public $version = 'development';
/** /**
@ -50,12 +50,12 @@ class pdf_ban extends ModeleBankAccountDoc
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
global $conf, $langs, $mysoc; global $conf, $langs, $mysoc;
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("main", "bank", "withdrawals", "companies")); $langs->loadLangs(array("main", "bank", "withdrawals", "companies"));
$this->db = $db; $this->db = $db;
$this->name = "ban"; $this->name = "ban";
@ -89,7 +89,7 @@ class pdf_ban extends ModeleBankAccountDoc
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Fonction generant le projet sur le disque * Fonction generant le projet sur le disque
* *
@ -97,9 +97,9 @@ class pdf_ban extends ModeleBankAccountDoc
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @return int 1 if OK, <=0 if KO * @return int 1 if OK, <=0 if KO
*/ */
public function write_file($object, $outputlangs) public function write_file($object, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf, $hookmanager, $langs, $user; global $conf, $hookmanager, $langs, $user;
if (!is_object($outputlangs)) $outputlangs = $langs; if (!is_object($outputlangs)) $outputlangs = $langs;
@ -113,16 +113,16 @@ class pdf_ban extends ModeleBankAccountDoc
{ {
//$nblines = count($object->lines); // This is set later with array of tasks //$nblines = count($object->lines); // This is set later with array of tasks
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) if ($object->specimen)
{ {
$dir = $conf->bank->dir_output; $dir = $conf->bank->dir_output;
$file = $dir."/SPECIMEN.pdf"; $file = $dir."/SPECIMEN.pdf";
} else { } else {
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->bank->dir_output."/".$objectref; $dir = $conf->bank->dir_output."/".$objectref;
$file = $dir."/".$objectref.".pdf"; $file = $dir."/".$objectref.".pdf";
} }
if (!file_exists($dir)) if (!file_exists($dir))
{ {
@ -146,20 +146,20 @@ class pdf_ban extends ModeleBankAccountDoc
global $action; global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$pdf = pdf_getInstance($this->format); $pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part $heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
$pdf->Open(); $pdf->Open();
$pagenb = 0; $pagenb = 0;
@ -185,7 +185,7 @@ class pdf_ban extends ModeleBankAccountDoc
$tab_top = 50; $tab_top = 50;
$tab_height = 200; $tab_height = 200;
$tab_top_newpage = 40; $tab_top_newpage = 40;
$tab_height_newpage = 210; $tab_height_newpage = 210;
// Affiche notes // Affiche notes
if (!empty($object->note_public)) if (!empty($object->note_public))
@ -246,8 +246,8 @@ class pdf_ban extends ModeleBankAccountDoc
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -280,12 +280,12 @@ class pdf_ban extends ModeleBankAccountDoc
* @param int $hidebottom Hide bottom bar of array * @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf, $mysoc; global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@ -310,7 +310,7 @@ class pdf_ban extends ModeleBankAccountDoc
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetFont('', 'B', $default_font_size + 3);
$posx = $this->page_largeur - $this->marge_droite - 100; $posx = $this->page_largeur - $this->marge_droite - 100;
$posy = $this->marge_haute; $posy = $this->marge_haute;
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
@ -321,8 +321,8 @@ class pdf_ban extends ModeleBankAccountDoc
{ {
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -376,7 +376,7 @@ class pdf_ban extends ModeleBankAccountDoc
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Project $object Object to show * @param Project $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output

View File

@ -43,9 +43,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc
public $emetteur; public $emetteur;
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/** /**
@ -53,7 +53,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
global $conf, $langs, $mysoc; global $conf, $langs, $mysoc;
@ -88,22 +88,22 @@ class pdf_sepamandate extends ModeleBankAccountDoc
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Fonction generant le projet sur le disque * Fonction generant le projet sur le disque
* *
* @param Project $object Object project a generer * @param Project $object Object project a generer
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details (not used for this template) * @param int $hidedetails Do not show line details (not used for this template)
* @param int $hidedesc Do not show desc (not used for this template) * @param int $hidedesc Do not show desc (not used for this template)
* @param int $hideref Do not show ref (not used for this template) * @param int $hideref Do not show ref (not used for this template)
* @param null|array $moreparams More parameters * @param null|array $moreparams More parameters
* @return int 1 if OK, <=0 if KO * @return int 1 if OK, <=0 if KO
*/ */
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
{ {
// phpcs:enable // phpcs:enable
global $conf, $hookmanager, $langs, $user, $mysoc; global $conf, $hookmanager, $langs, $user, $mysoc;
if (!is_object($outputlangs)) $outputlangs = $langs; if (!is_object($outputlangs)) $outputlangs = $langs;
@ -117,18 +117,18 @@ class pdf_sepamandate extends ModeleBankAccountDoc
{ {
//$nblines = count($object->lines); // This is set later with array of tasks //$nblines = count($object->lines); // This is set later with array of tasks
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) if ($object->specimen)
{ {
if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
else $dir = $conf->bank->dir_output; else $dir = $conf->bank->dir_output;
$file = $dir."/SPECIMEN.pdf"; $file = $dir."/SPECIMEN.pdf";
} else { } else {
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
else $dir = $conf->bank->dir_output."/".$objectref; else $dir = $conf->bank->dir_output."/".$objectref;
$file = $dir."/".$langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref."-".dol_sanitizeFileName($object->rum).".pdf"; $file = $dir."/".$langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref."-".dol_sanitizeFileName($object->rum).".pdf";
} }
if (!file_exists($dir)) if (!file_exists($dir))
{ {
@ -152,20 +152,20 @@ class pdf_sepamandate extends ModeleBankAccountDoc
global $action; global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$pdf = pdf_getInstance($this->format); $pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part $heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
$pdf->Open(); $pdf->Open();
$pagenb = 0; $pagenb = 0;
@ -191,7 +191,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$tab_top = 50; $tab_top = 50;
$tab_height = 200; $tab_height = 200;
$tab_top_newpage = 40; $tab_top_newpage = 40;
$tab_height_newpage = 210; $tab_height_newpage = 210;
// Show notes // Show notes
if (!empty($object->note_public)) if (!empty($object->note_public))
@ -271,7 +271,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$sepaname = '______________________________________________'; $sepaname = '______________________________________________';
if ($thirdparty->id > 0) if ($thirdparty->id > 0)
{ {
$sepaname = $thirdparty->name.($object->account_owner ? ' ('.$object->account_owner.')' : ''); $sepaname = $thirdparty->name.($object->account_owner ? ' ('.$object->account_owner.')' : '');
} }
$posY = $pdf->GetY(); $posY = $pdf->GetY();
$posY += 3; $posY += 3;
@ -292,7 +292,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$address = '______________________________________________'; $address = '______________________________________________';
if ($thirdparty->id > 0) if ($thirdparty->id > 0)
{ {
$address = $thirdparty->getFullAddress(); $address = $thirdparty->getFullAddress();
} }
$posY = $pdf->GetY(); $posY = $pdf->GetY();
$posY += 1; $posY += 1;
@ -302,9 +302,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
if (preg_match('/_____/', $address)) if (preg_match('/_____/', $address))
{ {
$posY += 6; $posY += 6;
$pdf->SetXY(80, $posY); $pdf->SetXY(80, $posY);
$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
} }
$ban = '__________________________________________________'; $ban = '__________________________________________________';
@ -346,10 +346,10 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
if (empty($object->frstrecur)) if (empty($object->frstrecur))
{ {
$posY += 6; $posY += 6;
$pdf->SetXY(80, $posY); $pdf->SetXY(80, $posY);
$txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')'; $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')';
$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
} }
$posY = $pdf->GetY(); $posY = $pdf->GetY();
@ -399,8 +399,8 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -433,12 +433,12 @@ class pdf_sepamandate extends ModeleBankAccountDoc
* @param int $hidebottom Hide bottom bar of array * @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf, $mysoc; global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
} }
@ -455,27 +455,27 @@ class pdf_sepamandate extends ModeleBankAccountDoc
*/ */
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf, $mysoc; global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 1 : $conf->global->PDF_DIFFSIZE_TITLE); $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 1 : $conf->global->PDF_DIFFSIZE_TITLE);
$posy += $this->_signature_area($pdf, $object, $posy, $outputlangs); $posy += $this->_signature_area($pdf, $object, $posy, $outputlangs);
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size); $pdf->SetFont('', '', $default_font_size);
$pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0);
$posy = $pdf->GetY() + 2; $posy = $pdf->GetY() + 2;
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0); $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0);
$pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0); $pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0);
$posy = $pdf->GetY() + 2; $posy = $pdf->GetY() + 2;
return $posy; return $posy;
} }
@ -493,33 +493,33 @@ class pdf_sepamandate extends ModeleBankAccountDoc
*/ */
protected function _signature_area(&$pdf, $object, $posy, $outputlangs) protected function _signature_area(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$tab_top = $posy + 4; $tab_top = $posy + 4;
$tab_hl = 4; $tab_hl = 4;
$posx = $this->marge_gauche; $posx = $this->marge_gauche;
$pdf->SetXY($posx, $tab_top + 0); $pdf->SetXY($posx, $tab_top + 0);
$pdf->SetFont('', '', $default_font_size - 2); $pdf->SetFont('', '', $default_font_size - 2);
$pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0);
$pdf->MultiCell(100, 3, ' '); $pdf->MultiCell(100, 3, ' ');
$pdf->MultiCell(100, 3, '______________________', 0, 'L', 0); $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0);
$posx = 120; $posx = 120;
$largcol = ($this->page_largeur - $this->marge_droite - $posx); $largcol = ($this->page_largeur - $this->marge_droite - $posx);
$useborder = 0; $useborder = 0;
$index = 0; $index = 0;
// Total HT // Total HT
$pdf->SetFillColor(255, 255, 255); $pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($posx, $tab_top + 0); $pdf->SetXY($posx, $tab_top + 0);
$pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1); $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1);
$pdf->SetXY($posx, $tab_top + $tab_hl); $pdf->SetXY($posx, $tab_top + $tab_hl);
$pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R'); $pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
return ($tab_hl * 7); return ($tab_hl * 7);
} }
@ -545,7 +545,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetFont('', 'B', $default_font_size + 3);
$posx = $this->page_largeur - $this->marge_droite - 100; $posx = $this->page_largeur - $this->marge_droite - 100;
$posy = $this->marge_haute; $posy = $this->marge_haute;
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
@ -556,8 +556,8 @@ class pdf_sepamandate extends ModeleBankAccountDoc
{ {
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -578,7 +578,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$daterum = '__________________'; $daterum = '__________________';
if (!empty($object->date_rum)) if (!empty($object->date_rum))
{ {
$daterum = dol_print_date($object->date_rum, 'day', false, $outputlangs, true); $daterum = dol_print_date($object->date_rum, 'day', false, $outputlangs, true);
} else $daterum = dol_print_date($object->datec, 'day', false, $outputlangs, true); // For old record, the date_rum was not saved. } else $daterum = dol_print_date($object->datec, 'day', false, $outputlangs, true); // For old record, the date_rum was not saved.
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".$daterum, '', 'R'); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".$daterum, '', 'R');
/*$posy+=6; /*$posy+=6;
@ -616,7 +616,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Project $object Object to show * @param Project $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output

View File

@ -68,17 +68,17 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
// Retrieves transmitter // Retrieves transmitter
$this->emetteur = $mysoc; $this->emetteur = $mysoc;
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
// Define column position // Define column position
$this->line_height = 5; $this->line_height = 5;
$this->line_per_page = 40; $this->line_per_page = 40;
$this->tab_height = 200; //$this->line_height * $this->line_per_page; $this->tab_height = 200; //$this->line_height * $this->line_per_page;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Fonction to generate document on disk * Fonction to generate document on disk
* *
@ -86,19 +86,19 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
* @param string $_dir Directory * @param string $_dir Directory
* @param string $number Number * @param string $number Number
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @return int 1=ok, 0=ko * @return int 1=ok, 0=ko
*/ */
public function write_file($object, $_dir, $number, $outputlangs) public function write_file($object, $_dir, $number, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $user, $conf, $langs, $hookmanager; global $user, $conf, $langs, $hookmanager;
if (!is_object($outputlangs)) $outputlangs = $langs; if (!is_object($outputlangs)) $outputlangs = $langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
$sav_charset_output = $outputlangs->charset_output; $sav_charset_output = $outputlangs->charset_output;
if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
// Load traductions files required by page // Load traductions files required by page
$outputlangs->loadLangs(array("main", "companies", "bills", "products", "compta")); $outputlangs->loadLangs(array("main", "companies", "bills", "products", "compta"));
$dir = $_dir."/".get_exdir($number, 0, 1, 0, $object, 'cheque').$number; $dir = $_dir."/".get_exdir($number, 0, 1, 0, $object, 'cheque').$number;
@ -128,19 +128,19 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Create PDF instance // Create PDF instance
$pdf = pdf_getInstance($this->format); $pdf = pdf_getInstance($this->format);
$heightforinfotot = 50; // Height reserved to output the info and total part $heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
$pdf->Open(); $pdf->Open();
$pagenb = 0; $pagenb = 0;
@ -170,7 +170,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
} }
$pdf->AddPage(); $pdf->AddPage();
$pagenb++; $pagenb++;
$this->Header($pdf, $pagenb, $pages, $outputlangs); $this->Header($pdf, $pagenb, $pages, $outputlangs);
$this->Body($pdf, $pagenb, $pages, $outputlangs); $this->Body($pdf, $pagenb, $pages, $outputlangs);
@ -195,8 +195,8 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -204,12 +204,12 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$this->result = array('fullpath'=>$file); $this->result = array('fullpath'=>$file);
$outputlangs->charset_output = $sav_charset_output; $outputlangs->charset_output = $sav_charset_output;
return 1; // No error return 1; // No error
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Generate Header * Generate Header
* *
@ -221,7 +221,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
*/ */
public function Header(&$pdf, $page, $pages, $outputlangs) public function Header(&$pdf, $page, $pages, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -230,47 +230,47 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$title = $outputlangs->transnoentities("CheckReceipt"); $title = $outputlangs->transnoentities("CheckReceipt");
$pdf->SetFont('', 'B', $default_font_size); $pdf->SetFont('', 'B', $default_font_size);
$pdf->SetXY(10, 8); $pdf->SetXY(10, 8);
$pdf->MultiCell(0, 2, $title, 0, 'L'); $pdf->MultiCell(0, 2, $title, 0, 'L');
$pdf->SetFont('', '', $default_font_size); $pdf->SetFont('', '', $default_font_size);
$pdf->SetXY(10, 15); $pdf->SetXY(10, 15);
$pdf->MultiCell(22, 2, $outputlangs->transnoentities("Ref"), 0, 'L'); $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Ref"), 0, 'L');
$pdf->SetXY(32, 15); $pdf->SetXY(32, 15);
$pdf->SetFont('', '', $default_font_size); $pdf->SetFont('', '', $default_font_size);
$pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ? " - ".$this->ref_ext : '')), 0, 'L'); $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ? " - ".$this->ref_ext : '')), 0, 'L');
$pdf->SetFont('', '', $default_font_size); $pdf->SetFont('', '', $default_font_size);
$pdf->SetXY(10, 20); $pdf->SetXY(10, 20);
$pdf->MultiCell(22, 2, $outputlangs->transnoentities("Date"), 0, 'L'); $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Date"), 0, 'L');
$pdf->SetXY(32, 20); $pdf->SetXY(32, 20);
$pdf->SetFont('', '', $default_font_size); $pdf->SetFont('', '', $default_font_size);
$pdf->MultiCell(60, 2, dol_print_date($this->date, "day", false, $outputlangs)); $pdf->MultiCell(60, 2, dol_print_date($this->date, "day", false, $outputlangs));
$pdf->SetFont('', '', $default_font_size); $pdf->SetFont('', '', $default_font_size);
$pdf->SetXY(10, 26); $pdf->SetXY(10, 26);
$pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L'); $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L');
$pdf->SetFont('', '', $default_font_size); $pdf->SetFont('', '', $default_font_size);
$pdf->SetXY(32, 26); $pdf->SetXY(32, 26);
$pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L'); $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L');
$pdf->SetFont('', '', $default_font_size); $pdf->SetFont('', '', $default_font_size);
$pdf->SetXY(10, 32); $pdf->SetXY(10, 32);
$pdf->MultiCell(0, 2, $outputlangs->transnoentities("Account"), 0, 'L'); $pdf->MultiCell(0, 2, $outputlangs->transnoentities("Account"), 0, 'L');
pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1); pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1);
$pdf->SetFont('', '', $default_font_size); $pdf->SetFont('', '', $default_font_size);
$pdf->SetXY(114, 15); $pdf->SetXY(114, 15);
$pdf->MultiCell(40, 2, $outputlangs->transnoentities("Signature"), 0, 'L'); $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Signature"), 0, 'L');
$pdf->Rect(9, 14, 192, 35); $pdf->Rect(9, 14, 192, 35);
$pdf->line(9, 19, 112, 19); $pdf->line(9, 19, 112, 19);
$pdf->line(9, 25, 112, 25); $pdf->line(9, 25, 112, 25);
//$pdf->line(9, 31, 201, 31); //$pdf->line(9, 31, 201, 31);
$pdf->line(9, 31, 112, 31); $pdf->line(9, 31, 112, 31);
$pdf->line(30, 14, 30, 49); $pdf->line(30, 14, 30, 49);
$pdf->line(112, 14, 112, 49); $pdf->line(112, 14, 112, 49);
// Number of cheques // Number of cheques
$posy = 51; $posy = 51;
@ -284,11 +284,11 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$pdf->MultiCell(40, 2, $outputlangs->transnoentities("NumberOfCheques"), 0, 'L'); $pdf->MultiCell(40, 2, $outputlangs->transnoentities("NumberOfCheques"), 0, 'L');
$pdf->SetFont('', 'B', $default_font_size); $pdf->SetFont('', 'B', $default_font_size);
$pdf->SetXY(57, $posy + 1); $pdf->SetXY(57, $posy + 1);
$pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L'); $pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L');
$pdf->SetFont('', '', $default_font_size); $pdf->SetFont('', '', $default_font_size);
$pdf->SetXY(148, $posy + 1); $pdf->SetXY(148, $posy + 1);
$pdf->MultiCell(40, 2, $langs->trans("Total")); $pdf->MultiCell(40, 2, $langs->trans("Total"));
$pdf->SetFont('', 'B', $default_font_size); $pdf->SetFont('', 'B', $default_font_size);
@ -302,11 +302,11 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10); $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10);
$pdf->SetXY(41, $this->tab_top + 2); $pdf->SetXY(41, $this->tab_top + 2);
$pdf->MultiCell(40, 2, $outputlangs->transnoentities("Bank"), 0, 'L'); $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Bank"), 0, 'L');
$pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10); $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10);
$pdf->SetXY(101, $this->tab_top + 2); $pdf->SetXY(101, $this->tab_top + 2);
$pdf->MultiCell(40, 2, $outputlangs->transnoentities("CheckTransmitter"), 0, 'L'); $pdf->MultiCell(40, 2, $outputlangs->transnoentities("CheckTransmitter"), 0, 'L');
$pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10); $pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10);
$pdf->SetXY(180, $this->tab_top + 2); $pdf->SetXY(180, $this->tab_top + 2);
@ -317,7 +317,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Output array * Output array
* *
@ -329,7 +329,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
*/ */
public function Body(&$pdf, $pagenb, $pages, $outputlangs) public function Body(&$pdf, $pagenb, $pages, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
// x=10 - Num // x=10 - Num
// x=30 - Banque // x=30 - Banque
// x=100 - Emetteur // x=100 - Emetteur
@ -342,30 +342,30 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$num = count($this->lines); $num = count($this->lines);
for ($j = 0; $j < $num; $j++) for ($j = 0; $j < $num; $j++)
{ {
// Dynamic max line heigh calculation // Dynamic max line heigh calculation
$dynamic_line_height = array(); $dynamic_line_height = array();
$dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq)); $dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq));
$dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq)); $dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq));
$max_line_height = max($dynamic_line_height); $max_line_height = max($dynamic_line_height);
// Calculate number of line used function of estimated line size // Calculate number of line used function of estimated line size
if ($max_line_height > $this->line_height) $nb_lines = floor($max_line_height / $this->line_height) + 1; if ($max_line_height > $this->line_height) $nb_lines = floor($max_line_height / $this->line_height) + 1;
else $nb_lines = 1; else $nb_lines = 1;
// Add page break if we do not have space to add current line // Add page break if we do not have space to add current line
if ($lineinpage >= ($this->line_per_page - 1)) if ($lineinpage >= ($this->line_per_page - 1))
{ {
$lineinpage = 0; $yp = 0; $lineinpage = 0; $yp = 0;
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
$pagenb++; $pagenb++;
$this->Header($pdf, $pagenb, $pages, $outputlangs); $this->Header($pdf, $pagenb, $pages, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
} }
$lineinpage += $nb_lines; $lineinpage += $nb_lines;
$pdf->SetXY(1, $this->tab_top + 10 + $yp); $pdf->SetXY(1, $this->tab_top + 10 + $yp);
$pdf->MultiCell(8, $this->line_height, $j + 1, 0, 'R', 0); $pdf->MultiCell(8, $this->line_height, $j + 1, 0, 'R', 0);
@ -382,14 +382,14 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$pdf->SetXY(180, $this->tab_top + 10 + $yp); $pdf->SetXY(180, $this->tab_top + 10 + $yp);
$pdf->MultiCell(20, $this->line_height, price($this->lines[$j]->amount_chq), 0, 'R', 0); $pdf->MultiCell(20, $this->line_height, price($this->lines[$j]->amount_chq), 0, 'R', 0);
$yp = $yp + ($this->line_height * $nb_lines); $yp = $yp + ($this->line_height * $nb_lines);
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
@ -410,7 +410,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$paramfreetext = 'BANK_CHEQUERECEIPT_FREE_TEXT'; $paramfreetext = 'BANK_CHEQUERECEIPT_FREE_TEXT';
if (!empty($conf->global->$paramfreetext)) if (!empty($conf->global->$paramfreetext))
{ {
$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
} }
return pdf_pagefoot($pdf, $outputlangs, $newfreetext, $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); return pdf_pagefoot($pdf, $outputlangs, $newfreetext, $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);

View File

@ -41,70 +41,70 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
class pdf_strato extends ModelePDFContract class pdf_strato extends ModelePDFContract
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
*/ */
public $db; public $db;
/** /**
* @var string model name * @var string model name
*/ */
public $name; public $name;
/** /**
* @var string model description (short text) * @var string model description (short text)
*/ */
public $description; public $description;
/** /**
* @var string document type * @var string document type
*/ */
public $type; public $type;
/** /**
* @var array Minimum version of PHP required by module. * @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.6 = array(5, 6) * e.g.: PHP ≥ 5.6 = array(5, 6)
*/ */
public $phpmin = array(5, 6); public $phpmin = array(5, 6);
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/** /**
* @var int page_largeur * @var int page_largeur
*/ */
public $page_largeur; public $page_largeur;
/** /**
* @var int page_hauteur * @var int page_hauteur
*/ */
public $page_hauteur; public $page_hauteur;
/** /**
* @var array format * @var array format
*/ */
public $format; public $format;
/** /**
* @var int marge_gauche * @var int marge_gauche
*/ */
public $marge_gauche; public $marge_gauche;
/** /**
* @var int marge_droite * @var int marge_droite
*/ */
public $marge_droite; public $marge_droite;
/** /**
* @var int marge_haute * @var int marge_haute
*/ */
public $marge_haute; public $marge_haute;
/** /**
* @var int marge_basse * @var int marge_basse
*/ */
public $marge_basse; public $marge_basse;
/** /**
@ -160,21 +160,21 @@ class pdf_strato extends ModelePDFContract
$this->posxdesc = $this->marge_gauche + 1; $this->posxdesc = $this->marge_gauche + 1;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Function to build pdf onto disk * Function to build pdf onto disk
* *
* @param CommonObject $object Id of object to generate * @param CommonObject $object Id of object to generate
* @param object $outputlangs Lang output object * @param object $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
// phpcs:enable // phpcs:enable
global $user, $langs, $conf, $hookmanager, $mysoc; global $user, $langs, $conf, $hookmanager, $mysoc;
if (!is_object($outputlangs)) $outputlangs = $langs; if (!is_object($outputlangs)) $outputlangs = $langs;
@ -186,7 +186,7 @@ class pdf_strato extends ModelePDFContract
if ($conf->contrat->dir_output) if ($conf->contrat->dir_output)
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) if ($object->specimen)
@ -221,26 +221,26 @@ class pdf_strato extends ModelePDFContract
global $action; global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$pdf = pdf_getInstance($this->format); $pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part $heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
$pdf->Open(); $pdf->Open();
$pagenb = 0; $pagenb = 0;
@ -341,12 +341,12 @@ class pdf_strato extends ModelePDFContract
} }
$txtpredefinedservice = ''; $txtpredefinedservice = '';
$txtpredefinedservice = $objectligne->product_label; $txtpredefinedservice = $objectligne->product_label;
if ($objectligne->product_label) if ($objectligne->product_label)
{ {
$txtpredefinedservice .= ' - '; $txtpredefinedservice .= ' - ';
$txtpredefinedservice .= $objectligne->product_label; $txtpredefinedservice .= $objectligne->product_label;
} }
$desc = dol_htmlentitiesbr($objectligne->desc, 1); // Desc (not empty for free lines) $desc = dol_htmlentitiesbr($objectligne->desc, 1); // Desc (not empty for free lines)
$txt = ''; $txt = '';
@ -359,7 +359,7 @@ class pdf_strato extends ModelePDFContract
if (empty($conf->global->CONTRACT_HIDE_REAL_DATE_ON_PDF)) if (empty($conf->global->CONTRACT_HIDE_REAL_DATE_ON_PDF))
{ {
$txt .= '<br>'; $txt .= '<br>';
$txt .= $outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>'; $txt .= $outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>';
if ($objectligne->date_cloture) $txt .= " - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>'; if ($objectligne->date_cloture) $txt .= " - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>';
} }
@ -476,8 +476,8 @@ class pdf_strato extends ModelePDFContract
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -518,7 +518,7 @@ class pdf_strato extends ModelePDFContract
if ($hidetop) $hidetop = -1; if ($hidetop) $hidetop = -1;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
/* /*
$pdf->SetXY($this->marge_gauche, $tab_top); $pdf->SetXY($this->marge_gauche, $tab_top);
$pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0); $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
$pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8); $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
@ -548,16 +548,16 @@ class pdf_strato extends ModelePDFContract
$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 3); // Rect takes a length in 3rd parameter and 4th parameter $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 3); // Rect takes a length in 3rd parameter and 4th parameter
} }
/** /**
* Show footer signature of page * Show footer signature of page
* @param TCPDF $pdf Object PDF * @param TCPDF $pdf Object PDF
* @param int $tab_top tab height position * @param int $tab_top tab height position
* @param int $tab_height tab height * @param int $tab_height tab height
* @param Translate $outputlangs Object language for output * @param Translate $outputlangs Object language for output
* @return void * @return void
*/ */
protected function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs) protected function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs)
{ {
$pdf->SetDrawColor(128, 128, 128); $pdf->SetDrawColor(128, 128, 128);
$posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2); $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2);
$posy = $tab_top + $tab_height + 3 + 3; $posy = $tab_top + $tab_height + 3 + 3;
@ -573,20 +573,20 @@ class pdf_strato extends ModelePDFContract
$pdf->SetXY($posmiddle + 5, $posy + 5); $pdf->SetXY($posmiddle + 5, $posy + 5);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $posmiddle - 5, 20, '', 1); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posmiddle - 5, 20, '', 1);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show top header of page. * Show top header of page.
* *
* @param TCPDF $pdf Object PDF * @param TCPDF $pdf Object PDF
* @param CommonObject $object Object to show * @param CommonObject $object Object to show
* @param int $showaddress 0=no, 1=yes * @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @return void * @return void
*/ */
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{ {
global $conf, $langs; global $conf, $langs;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -617,8 +617,8 @@ class pdf_strato extends ModelePDFContract
{ {
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -754,7 +754,7 @@ class pdf_strato extends ModelePDFContract
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param PDF $pdf PDF * @param PDF $pdf PDF
* @param CommonObject $object Object to show * @param CommonObject $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output

View File

@ -36,71 +36,71 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
*/ */
class pdf_espadon extends ModelePdfExpedition class pdf_espadon extends ModelePdfExpedition
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
*/ */
public $db; public $db;
/**
* @var string model name
*/
public $name;
/**
* @var string model description (short text)
*/
public $description;
/** /**
* @var string document type * @var string model name
*/ */
public $type; public $name;
/** /**
* @var array Minimum version of PHP required by module. * @var string model description (short text)
* e.g.: PHP ≥ 5.6 = array(5, 6) */
*/ public $description;
/**
* @var string document type
*/
public $type;
/**
* @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.6 = array(5, 6)
*/
public $phpmin = array(5, 6); public $phpmin = array(5, 6);
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/** /**
* @var int page_largeur * @var int page_largeur
*/ */
public $page_largeur; public $page_largeur;
/** /**
* @var int page_hauteur * @var int page_hauteur
*/ */
public $page_hauteur; public $page_hauteur;
/** /**
* @var array format * @var array format
*/ */
public $format; public $format;
/** /**
* @var int marge_gauche * @var int marge_gauche
*/ */
public $marge_gauche; public $marge_gauche;
/** /**
* @var int marge_droite * @var int marge_droite
*/ */
public $marge_droite; public $marge_droite;
/** /**
* @var int marge_haute * @var int marge_haute
*/ */
public $marge_haute; public $marge_haute;
/** /**
* @var int marge_basse * @var int marge_basse
*/ */
public $marge_basse; public $marge_basse;
/** /**
@ -148,11 +148,11 @@ class pdf_espadon extends ModelePdfExpedition
* *
* @param Object $object Object expedition to generate (or id if old method) * @param Object $object Object expedition to generate (or id if old method)
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
@ -177,16 +177,16 @@ class pdf_espadon extends ModelePdfExpedition
$nblines = count($object->lines); $nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show // Loop on each lines to detect if there is at least one image to show
$realpatharray = array(); $realpatharray = array();
$this->atleastonephoto = false; $this->atleastonephoto = false;
if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
{ {
$objphoto = new Product($this->db); $objphoto = new Product($this->db);
for ($i = 0; $i < $nblines; $i++) for ($i = 0; $i < $nblines; $i++)
{ {
if (empty($object->lines[$i]->fk_product)) continue; if (empty($object->lines[$i]->fk_product)) continue;
$objphoto = new Product($this->db); $objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product); $objphoto->fetch($object->lines[$i]->fk_product);
@ -202,34 +202,34 @@ class pdf_espadon extends ModelePdfExpedition
$realpath = ''; $realpath = '';
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
{ {
if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
{ {
if ($obj['photo_vignette']) if ($obj['photo_vignette'])
{ {
$filename = $obj['photo_vignette']; $filename = $obj['photo_vignette'];
} else { } else {
$filename = $obj['photo']; $filename = $obj['photo'];
} }
} else { } else {
$filename = $obj['photo']; $filename = $obj['photo'];
} }
$realpath = $dir.$filename; $realpath = $dir.$filename;
$this->atleastonephoto = true; $this->atleastonephoto = true;
break; break;
} }
if ($realpath) $realpatharray[$i] = $realpath; if ($realpath) $realpatharray[$i] = $realpath;
} }
} }
if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol; if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
if ($conf->expedition->dir_output) if ($conf->expedition->dir_output)
{ {
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) if ($object->specimen)
{ {
$dir = $conf->expedition->dir_output."/sending"; $dir = $conf->expedition->dir_output."/sending";
@ -268,23 +268,23 @@ class pdf_espadon extends ModelePdfExpedition
$pdf = pdf_getInstance($this->format); $pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$heightforinfotot = 8; // Height reserved to output the info and total part $heightforinfotot = 8; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
$pdf->Open(); $pdf->Open();
$pagenb = 0; $pagenb = 0;
@ -315,7 +315,7 @@ class pdf_espadon extends ModelePdfExpedition
$tab_height = 130; $tab_height = 130;
$tab_height_newpage = 150; $tab_height_newpage = 150;
$this->posxdesc = $this->marge_gauche + 1; $this->posxdesc = $this->marge_gauche + 1;
// Incoterm // Incoterm
$height_incoterms = 0; $height_incoterms = 0;
@ -340,15 +340,15 @@ class pdf_espadon extends ModelePdfExpedition
} }
} }
// display note // display note
$notetoshow = empty($object->note_public) ? '' : $object->note_public; $notetoshow = empty($object->note_public) ? '' : $object->note_public;
// Extrafields in note // Extrafields in note
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs); $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
if (!empty($extranote)) if (!empty($extranote))
{ {
$notetoshow = dol_concatdesc($notetoshow, $extranote); $notetoshow = dol_concatdesc($notetoshow, $extranote);
} }
if (!empty($notetoshow) || !empty($object->tracking_number)) if (!empty($notetoshow) || !empty($object->tracking_number))
{ {
@ -391,7 +391,7 @@ class pdf_espadon extends ModelePdfExpedition
// Notes // Notes
if (!empty($notetoshow)) if (!empty($notetoshow))
{ {
$pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($notetoshow), 0, 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($notetoshow), 0, 1);
} }
@ -441,69 +441,69 @@ class pdf_espadon extends ModelePdfExpedition
if ($this->getColumnStatus('photo')) if ($this->getColumnStatus('photo'))
{ {
// We start with Photo of product line // We start with Photo of product line
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page
{ {
$pdf->AddPage('', '', true); $pdf->AddPage('', '', true);
if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (!empty($tplidx)) $pdf->useTemplate($tplidx);
//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pageposbefore + 1); $pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage; $curY = $tab_top_newpage;
// Allows data in the first page if description is long enough to break in multiples pages // Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1; $showpricebeforepagebreak = 1;
else $showpricebeforepagebreak = 0; else $showpricebeforepagebreak = 0;
} }
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
{ {
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually // $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height']; $posYAfterImage = $curY + $imglinesize['height'];
} }
} }
// Description of product line // Description of product line
if ($this->getColumnStatus('desc')) if ($this->getColumnStatus('desc'))
{ {
$pdf->startTransaction(); $pdf->startTransaction();
$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak if ($pageposafter > $pageposbefore) // There is a pagebreak
{ {
$pdf->rollbackTransaction(true); $pdf->rollbackTransaction(true);
$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY(); $posyafter = $pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // There is no space left for total+free text if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // There is no space left for total+free text
{ {
if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{ {
$pdf->AddPage('', '', true); $pdf->AddPage('', '', true);
if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (!empty($tplidx)) $pdf->useTemplate($tplidx);
//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pageposafter + 1); $pdf->setPage($pageposafter + 1);
} }
} else { } else {
// We found a page break // We found a page break
// Allows data in the first page if description is long enough to break in multiples pages // Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1; $showpricebeforepagebreak = 1;
else $showpricebeforepagebreak = 0; else $showpricebeforepagebreak = 0;
} }
} else // No pagebreak } else // No pagebreak
{ {
$pdf->commitTransaction(); $pdf->commitTransaction();
} }
$posYAfterDescription = $pdf->GetY(); $posYAfterDescription = $pdf->GetY();
} }
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -541,39 +541,39 @@ class pdf_espadon extends ModelePdfExpedition
if ($this->getColumnStatus('weight')) if ($this->getColumnStatus('weight'))
{ {
$this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, array('html'=>1)); $this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, array('html'=>1));
$nexY = max($pdf->GetY(), $nexY); $nexY = max($pdf->GetY(), $nexY);
} }
if ($this->getColumnStatus('qty_asked')) if ($this->getColumnStatus('qty_asked'))
{ {
$this->printStdColumnContent($pdf, $curY, 'qty_asked', $object->lines[$i]->qty_asked); $this->printStdColumnContent($pdf, $curY, 'qty_asked', $object->lines[$i]->qty_asked);
$nexY = max($pdf->GetY(), $nexY); $nexY = max($pdf->GetY(), $nexY);
} }
if ($this->getColumnStatus('qty_shipped')) if ($this->getColumnStatus('qty_shipped'))
{ {
$this->printStdColumnContent($pdf, $curY, 'qty_shipped', $object->lines[$i]->qty_shipped); $this->printStdColumnContent($pdf, $curY, 'qty_shipped', $object->lines[$i]->qty_shipped);
$nexY = max($pdf->GetY(), $nexY); $nexY = max($pdf->GetY(), $nexY);
} }
if ($this->getColumnStatus('subprice')) if ($this->getColumnStatus('subprice'))
{ {
$this->printStdColumnContent($pdf, $curY, 'subprice', price($object->lines[$i]->subprice, 0, $outputlangs)); $this->printStdColumnContent($pdf, $curY, 'subprice', price($object->lines[$i]->subprice, 0, $outputlangs));
$nexY = max($pdf->GetY(), $nexY); $nexY = max($pdf->GetY(), $nexY);
} }
// Extrafields // Extrafields
if (!empty($object->lines[$i]->array_options)) { if (!empty($object->lines[$i]->array_options)) {
foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) { foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
if ($this->getColumnStatus($extrafieldColKey)) if ($this->getColumnStatus($extrafieldColKey))
{ {
$extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey); $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
$this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue); $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
$nexY = max($pdf->GetY(), $nexY); $nexY = max($pdf->GetY(), $nexY);
} }
} }
} }
// Add line // Add line
if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
@ -646,8 +646,8 @@ class pdf_espadon extends ModelePdfExpedition
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -683,9 +683,9 @@ class pdf_espadon extends ModelePdfExpedition
// phpcs:enable // phpcs:enable
global $conf, $mysoc; global $conf, $mysoc;
$sign = 1; $sign = 1;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$tab2_top = $posy; $tab2_top = $posy;
$tab2_hl = 4; $tab2_hl = 4;
@ -715,8 +715,8 @@ class pdf_espadon extends ModelePdfExpedition
// Set trueVolume and volume_units not currently stored into database // Set trueVolume and volume_units not currently stored into database
if ($object->trueWidth && $object->trueHeight && $object->trueDepth) if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
{ {
$object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
$object->volume_units = $object->size_units * 3; $object->volume_units = $object->size_units * 3;
} }
if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
@ -727,40 +727,40 @@ class pdf_espadon extends ModelePdfExpedition
if ($this->getColumnStatus('desc')) if ($this->getColumnStatus('desc'))
{ {
$this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total")); $this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total"));
} }
if ($this->getColumnStatus('weight')) if ($this->getColumnStatus('weight'))
{ {
if ($totalWeighttoshow) if ($totalWeighttoshow)
{ {
$this->printStdColumnContent($pdf, $tab2_top, 'weight', $totalWeighttoshow); $this->printStdColumnContent($pdf, $tab2_top, 'weight', $totalWeighttoshow);
$index++; $index++;
} }
if ($totalVolumetoshow) if ($totalVolumetoshow)
{ {
$y = $tab2_top + ($tab2_hl * $index); $y = $tab2_top + ($tab2_hl * $index);
$this->printStdColumnContent($pdf, $y, 'weight', $totalVolumetoshow); $this->printStdColumnContent($pdf, $y, 'weight', $totalVolumetoshow);
} }
} }
if ($this->getColumnStatus('qty_asked') && $totalOrdered) if ($this->getColumnStatus('qty_asked') && $totalOrdered)
{ {
$this->printStdColumnContent($pdf, $tab2_top, 'qty_asked', $totalOrdered); $this->printStdColumnContent($pdf, $tab2_top, 'qty_asked', $totalOrdered);
} }
if ($this->getColumnStatus('qty_shipped') && $totalToShip) if ($this->getColumnStatus('qty_shipped') && $totalToShip)
{ {
$this->printStdColumnContent($pdf, $tab2_top, 'qty_shipped', $totalToShip); $this->printStdColumnContent($pdf, $tab2_top, 'qty_shipped', $totalToShip);
} }
if ($this->getColumnStatus('subprice')) if ($this->getColumnStatus('subprice'))
{ {
$this->printStdColumnContent($pdf, $tab2_top, 'subprice', price($object->total_ht, 0, $outputlangs)); $this->printStdColumnContent($pdf, $tab2_top, 'subprice', price($object->total_ht, 0, $outputlangs));
} }
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
@ -814,7 +814,7 @@ class pdf_espadon extends ModelePdfExpedition
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
} }
} }
@ -841,7 +841,7 @@ class pdf_espadon extends ModelePdfExpedition
// Show Draft Watermark // Show Draft Watermark
if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK)))
{ {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
} }
//Prepare next //Prepare next
@ -861,8 +861,8 @@ class pdf_espadon extends ModelePdfExpedition
{ {
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -918,10 +918,10 @@ class pdf_espadon extends ModelePdfExpedition
// Date planned delivery // Date planned delivery
if (!empty($object->date_delivery)) if (!empty($object->date_delivery))
{ {
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R'); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
} }
if (!empty($object->thirdparty->code_client)) if (!empty($object->thirdparty->code_client))
@ -940,7 +940,7 @@ class pdf_espadon extends ModelePdfExpedition
$origin = $object->origin; $origin = $object->origin;
$origin_id = $object->origin_id; $origin_id = $object->origin_id;
// TODO move to external function // TODO move to external function
if (!empty($conf->$origin->enabled)) // commonly $origin='commande' if (!empty($conf->$origin->enabled)) // commonly $origin='commande'
{ {
$outputlangs->load('orders'); $outputlangs->load('orders');
@ -950,7 +950,7 @@ class pdf_espadon extends ModelePdfExpedition
$result = $linkedobject->fetch($origin_id); $result = $linkedobject->fetch($origin_id);
if ($result >= 0) if ($result >= 0)
{ {
//$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
$pdf->SetFont('', '', $default_font_size - 2); $pdf->SetFont('', '', $default_font_size - 2);
$text = $linkedobject->ref; $text = $linkedobject->ref;
@ -1064,7 +1064,7 @@ class pdf_espadon extends ModelePdfExpedition
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
@ -1090,21 +1090,21 @@ class pdf_espadon extends ModelePdfExpedition
*/ */
public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
global $conf, $hookmanager; global $conf, $hookmanager;
// Default field style for content // Default field style for content
$this->defaultContentsFieldsStyle = array( $this->defaultContentsFieldsStyle = array(
'align' => 'R', // R,C,L 'align' => 'R', // R,C,L
'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
); );
// Default field style for content // Default field style for content
$this->defaultTitlesFieldsStyle = array( $this->defaultTitlesFieldsStyle = array(
'align' => 'C', // R,C,L 'align' => 'C', // R,C,L
'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
); );
/* /*
* For exemple * For exemple
$this->cols['theColKey'] = array( $this->cols['theColKey'] = array(
'rank' => $rank, // int : use for ordering columns 'rank' => $rank, // int : use for ordering columns
@ -1122,128 +1122,128 @@ class pdf_espadon extends ModelePdfExpedition
); );
*/ */
$rank = 0; // do not use negative rank $rank = 0; // do not use negative rank
$this->cols['desc'] = array( $this->cols['desc'] = array(
'rank' => $rank, 'rank' => $rank,
'width' => false, // only for desc 'width' => false, // only for desc
'status' => true, 'status' => true,
'title' => array( 'title' => array(
'textkey' => 'Designation', // use lang key is usefull in somme case with module 'textkey' => 'Designation', // use lang key is usefull in somme case with module
'align' => 'L', 'align' => 'L',
// 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
// 'label' => ' ', // the final label // 'label' => ' ', // the final label
'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
), ),
'content' => array( 'content' => array(
'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
), ),
); );
$rank = $rank + 10; $rank = $rank + 10;
$this->cols['photo'] = array( $this->cols['photo'] = array(
'rank' => $rank, 'rank' => $rank,
'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
'status' => false, 'status' => false,
'title' => array( 'title' => array(
'textkey' => 'Photo', 'textkey' => 'Photo',
'label' => ' ' 'label' => ' '
), ),
'content' => array( 'content' => array(
'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
), ),
'border-left' => false, // remove left line separator 'border-left' => false, // remove left line separator
); );
if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE) && !empty($this->atleastonephoto)) if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE) && !empty($this->atleastonephoto))
{ {
$this->cols['photo']['status'] = true; $this->cols['photo']['status'] = true;
} }
$rank = $rank + 10; $rank = $rank + 10;
$this->cols['weight'] = array( $this->cols['weight'] = array(
'rank' => $rank, 'rank' => $rank,
'width' => 30, // in mm 'width' => 30, // in mm
'status' => true, 'status' => true,
'title' => array( 'title' => array(
'textkey' => 'WeightVolShort' 'textkey' => 'WeightVolShort'
), ),
'border-left' => true, // add left line separator 'border-left' => true, // add left line separator
); );
$rank = $rank + 10; $rank = $rank + 10;
$this->cols['subprice'] = array( $this->cols['subprice'] = array(
'rank' => $rank, 'rank' => $rank,
'width' => 19, // in mm 'width' => 19, // in mm
'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0, 'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
'title' => array( 'title' => array(
'textkey' => 'PriceUHT' 'textkey' => 'PriceUHT'
), ),
'border-left' => true, // add left line separator 'border-left' => true, // add left line separator
); );
$rank = $rank + 10; $rank = $rank + 10;
$this->cols['totalexcltax'] = array( $this->cols['totalexcltax'] = array(
'rank' => $rank, 'rank' => $rank,
'width' => 26, // in mm 'width' => 26, // in mm
'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0, 'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
'title' => array( 'title' => array(
'textkey' => 'TotalHT' 'textkey' => 'TotalHT'
), ),
'border-left' => true, // add left line separator 'border-left' => true, // add left line separator
); );
$rank = $rank + 10; $rank = $rank + 10;
$this->cols['qty_asked'] = array( $this->cols['qty_asked'] = array(
'rank' => $rank, 'rank' => $rank,
'width' => 30, // in mm 'width' => 30, // in mm
'status' => empty($conf->global->SHIPPING_PDF_HIDE_ORDERED) ? 1 : 0, 'status' => empty($conf->global->SHIPPING_PDF_HIDE_ORDERED) ? 1 : 0,
'title' => array( 'title' => array(
'textkey' => 'QtyOrdered' 'textkey' => 'QtyOrdered'
), ),
'border-left' => true, // add left line separator 'border-left' => true, // add left line separator
'content' => array( 'content' => array(
'align' => 'C', 'align' => 'C',
), ),
); );
$rank = $rank + 10; $rank = $rank + 10;
$this->cols['qty_shipped'] = array( $this->cols['qty_shipped'] = array(
'rank' => $rank, 'rank' => $rank,
'width' => 30, // in mm 'width' => 30, // in mm
'status' => true, 'status' => true,
'title' => array( 'title' => array(
'textkey' => 'QtyToShip' 'textkey' => 'QtyToShip'
), ),
'border-left' => true, // add left line separator 'border-left' => true, // add left line separator
'content' => array( 'content' => array(
'align' => 'C', 'align' => 'C',
), ),
); );
// Add extrafields cols // Add extrafields cols
if (!empty($object->lines)) { if (!empty($object->lines)) {
$line = reset($object->lines); $line = reset($object->lines);
$this->defineColumnExtrafield($line, $outputlangs, $hidedetails); $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
} }
$parameters = array( $parameters = array(
'object' => $object, 'object' => $object,
'outputlangs' => $outputlangs, 'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails, 'hidedetails' => $hidedetails,
'hidedesc' => $hidedesc, 'hidedesc' => $hidedesc,
'hideref' => $hideref 'hideref' => $hideref
); );
$reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
if ($reshook < 0) if ($reshook < 0)
{ {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
} elseif (empty($reshook)) } elseif (empty($reshook))
{ {
$this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
} else { } else {
$this->cols = $hookmanager->resArray; $this->cols = $hookmanager->resArray;
} }
} }
} }

View File

@ -37,71 +37,71 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
*/ */
class pdf_merou extends ModelePdfExpedition class pdf_merou extends ModelePdfExpedition
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
*/ */
public $db; public $db;
/** /**
* @var string model name * @var string model name
*/ */
public $name; public $name;
/** /**
* @var string model description (short text) * @var string model description (short text)
*/ */
public $description; public $description;
/** /**
* @var string document type * @var string document type
*/ */
public $type; public $type;
/** /**
* @var array Minimum version of PHP required by module. * @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.6 = array(5, 6) * e.g.: PHP ≥ 5.6 = array(5, 6)
*/ */
public $phpmin = array(5, 6); public $phpmin = array(5, 6);
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/** /**
* @var int page_largeur * @var int page_largeur
*/ */
public $page_largeur; public $page_largeur;
/** /**
* @var int page_hauteur * @var int page_hauteur
*/ */
public $page_hauteur; public $page_hauteur;
/** /**
* @var array format * @var array format
*/ */
public $format; public $format;
/** /**
* @var int marge_gauche * @var int marge_gauche
*/ */
public $marge_gauche; public $marge_gauche;
/** /**
* @var int marge_droite * @var int marge_droite
*/ */
public $marge_droite; public $marge_droite;
/** /**
* @var int marge_haute * @var int marge_haute
*/ */
public $marge_haute; public $marge_haute;
/** /**
* @var int marge_basse * @var int marge_basse
*/ */
public $marge_basse; public $marge_basse;
/** /**
@ -142,21 +142,21 @@ class pdf_merou extends ModelePdfExpedition
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Function to build pdf onto disk * Function to build pdf onto disk
* *
* @param Object $object Object expedition to generate (or id if old method) * @param Object $object Object expedition to generate (or id if old method)
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
public function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
// phpcs:enable // phpcs:enable
global $user, $conf, $langs, $mysoc, $hookmanager; global $user, $conf, $langs, $mysoc, $hookmanager;
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@ -179,7 +179,7 @@ class pdf_merou extends ModelePdfExpedition
//Create recipient //Create recipient
$idcontact = $object->$origin->getIdContact('external', 'SHIPPING'); $idcontact = $object->$origin->getIdContact('external', 'SHIPPING');
$this->destinataire = new Contact($this->db); $this->destinataire = new Contact($this->db);
if (!empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]); if (!empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
//Create deliverer //Create deliverer
@ -225,23 +225,23 @@ class pdf_merou extends ModelePdfExpedition
$pdf = pdf_getInstance($this->format, 'mm', 'l'); $pdf = pdf_getInstance($this->format, 'mm', 'l');
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$heightforinfotot = 0; // Height reserved to output the info and total part $heightforinfotot = 0; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
$pdf->Open(); $pdf->Open();
$pagenb = 0; $pagenb = 0;
@ -414,12 +414,12 @@ class pdf_merou extends ModelePdfExpedition
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK)); @chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file); $this->result = array('fullpath'=>$file);
@ -479,7 +479,7 @@ class pdf_merou extends ModelePdfExpedition
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
@ -498,11 +498,11 @@ class pdf_merou extends ModelePdfExpedition
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C');
// Show page nb only on iso languages (so default Helvetica font) // Show page nb only on iso languages (so default Helvetica font)
//if (pdf_getPDFFont($outputlangs) == 'Helvetica') //if (pdf_getPDFFont($outputlangs) == 'Helvetica')
//{ //{
// $pdf->SetXY(-10,-10); // $pdf->SetXY(-10,-10);
// $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); // $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
//} //}
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@ -526,11 +526,11 @@ class pdf_merou extends ModelePdfExpedition
//Affiche le filigrane brouillon - Print Draft Watermark //Affiche le filigrane brouillon - Print Draft Watermark
if ($object->statut == 0 && (!empty($conf->global->SENDING_DRAFT_WATERMARK))) if ($object->statut == 0 && (!empty($conf->global->SENDING_DRAFT_WATERMARK)))
{ {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK); pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK);
} }
$posy = $this->marge_haute; $posy = $this->marge_haute;
$posx = $this->page_largeur - $this->marge_droite - 100; $posx = $this->page_largeur - $this->marge_droite - 100;
$Xoff = 90; $Xoff = 90;
$Yoff = 0; $Yoff = 0;
@ -547,8 +547,8 @@ class pdf_merou extends ModelePdfExpedition
{ {
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto) $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);

View File

@ -37,71 +37,71 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
*/ */
class pdf_rouget extends ModelePdfExpedition class pdf_rouget extends ModelePdfExpedition
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
*/ */
public $db; public $db;
/**
* @var string model name
*/
public $name;
/**
* @var string model description (short text)
*/
public $description;
/** /**
* @var string document type * @var string model name
*/ */
public $type; public $name;
/** /**
* @var array Minimum version of PHP required by module. * @var string model description (short text)
* e.g.: PHP ≥ 5.6 = array(5, 6) */
*/ public $description;
/**
* @var string document type
*/
public $type;
/**
* @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.6 = array(5, 6)
*/
public $phpmin = array(5, 6); public $phpmin = array(5, 6);
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/** /**
* @var int page_largeur * @var int page_largeur
*/ */
public $page_largeur; public $page_largeur;
/** /**
* @var int page_hauteur * @var int page_hauteur
*/ */
public $page_hauteur; public $page_hauteur;
/** /**
* @var array format * @var array format
*/ */
public $format; public $format;
/** /**
* @var int marge_gauche * @var int marge_gauche
*/ */
public $marge_gauche; public $marge_gauche;
/** /**
* @var int marge_droite * @var int marge_droite
*/ */
public $marge_droite; public $marge_droite;
/** /**
* @var int marge_haute * @var int marge_haute
*/ */
public $marge_haute; public $marge_haute;
/** /**
* @var int marge_basse * @var int marge_basse
*/ */
public $marge_basse; public $marge_basse;
/** /**
@ -159,18 +159,18 @@ class pdf_rouget extends ModelePdfExpedition
$this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
// To work with US executive format // To work with US executive format
if ($this->page_largeur < 210) { if ($this->page_largeur < 210) {
$this->posxweightvol -= 20; $this->posxweightvol -= 20;
$this->posxpicture -= 20; $this->posxpicture -= 20;
$this->posxqtyordered -= 20; $this->posxqtyordered -= 20;
$this->posxqtytoship -= 20; $this->posxqtytoship -= 20;
} }
if (!empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { if (!empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
$this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
$this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
$this->posxqtyordered = $this->posxqtytoship; $this->posxqtyordered = $this->posxqtytoship;
} }
} }
@ -180,11 +180,11 @@ class pdf_rouget extends ModelePdfExpedition
* *
* @param Object $object Object expedition to generate (or id if old method) * @param Object $object Object expedition to generate (or id if old method)
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
@ -202,15 +202,15 @@ class pdf_rouget extends ModelePdfExpedition
$nblines = count($object->lines); $nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show // Loop on each lines to detect if there is at least one image to show
$realpatharray = array(); $realpatharray = array();
if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
{ {
$objphoto = new Product($this->db); $objphoto = new Product($this->db);
for ($i = 0; $i < $nblines; $i++) for ($i = 0; $i < $nblines; $i++)
{ {
if (empty($object->lines[$i]->fk_product)) continue; if (empty($object->lines[$i]->fk_product)) continue;
$objphoto = new Product($this->db); $objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product); $objphoto->fetch($object->lines[$i]->fk_product);
@ -225,28 +225,28 @@ class pdf_rouget extends ModelePdfExpedition
$realpath = ''; $realpath = '';
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
if ($obj['photo_vignette']) if ($obj['photo_vignette'])
{ {
$filename = $obj['photo_vignette']; $filename = $obj['photo_vignette'];
} else { } else {
$filename = $obj['photo']; $filename = $obj['photo'];
} }
} else { } else {
$filename = $obj['photo']; $filename = $obj['photo'];
} }
$realpath = $dir.$filename; $realpath = $dir.$filename;
break; break;
} }
if ($realpath) $realpatharray[$i] = $realpath; if ($realpath) $realpatharray[$i] = $realpath;
} }
} }
if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol; if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
if ($conf->expedition->dir_output) if ($conf->expedition->dir_output)
{ {
@ -289,23 +289,23 @@ class pdf_rouget extends ModelePdfExpedition
$pdf = pdf_getInstance($this->format); $pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$heightforinfotot = 8; // Height reserved to output the info and total part $heightforinfotot = 8; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
$pdf->Open(); $pdf->Open();
$pagenb = 0; $pagenb = 0;
@ -544,8 +544,8 @@ class pdf_rouget extends ModelePdfExpedition
if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{ {
$pdf->SetXY($this->posxqtyordered, $curY); $pdf->SetXY($this->posxqtyordered, $curY);
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C'); $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
} }
if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
@ -637,8 +637,8 @@ class pdf_rouget extends ModelePdfExpedition
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -674,9 +674,9 @@ class pdf_rouget extends ModelePdfExpedition
// phpcs:enable // phpcs:enable
global $conf, $mysoc; global $conf, $mysoc;
$sign = 1; $sign = 1;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$tab2_top = $posy; $tab2_top = $posy;
$tab2_hl = 4; $tab2_hl = 4;
@ -706,8 +706,8 @@ class pdf_rouget extends ModelePdfExpedition
// Set trueVolume and volume_units not currently stored into database // Set trueVolume and volume_units not currently stored into database
if ($object->trueWidth && $object->trueHeight && $object->trueDepth) if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
{ {
$object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
$object->volume_units = $object->size_units * 3; $object->volume_units = $object->size_units * 3;
} }
if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
@ -715,29 +715,29 @@ class pdf_rouget extends ModelePdfExpedition
if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
$pdf->SetFillColor(255, 255, 255); $pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{ {
$pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1); $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
} }
if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
{ {
$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
} }
if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT))
{ {
$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
} }
if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
@ -745,17 +745,17 @@ class pdf_rouget extends ModelePdfExpedition
// Total Weight // Total Weight
if ($totalWeighttoshow) if ($totalWeighttoshow)
{ {
$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
$index++; $index++;
} }
if ($totalVolumetoshow) if ($totalVolumetoshow)
{ {
$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
$index++; $index++;
} }
if (!$totalWeighttoshow && !$totalVolumetoshow) $index++; if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
} }
@ -816,25 +816,25 @@ class pdf_rouget extends ModelePdfExpedition
} }
} }
if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{ {
$pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height); $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
if (empty($hidetop)) if (empty($hidetop))
{ {
$pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1); $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C'); $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
} }
} }
if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
{ {
$pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height); $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
if (empty($hidetop)) if (empty($hidetop))
{ {
$pdf->SetXY($this->posxqtytoship, $tab_top + 1); $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"), '', 'C'); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"), '', 'C');
} }
} }
if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) { if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
$pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height); $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
@ -876,7 +876,7 @@ class pdf_rouget extends ModelePdfExpedition
// Show Draft Watermark // Show Draft Watermark
if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK)))
{ {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
} }
//Prepare la suite //Prepare la suite
@ -896,8 +896,8 @@ class pdf_rouget extends ModelePdfExpedition
{ {
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -953,10 +953,10 @@ class pdf_rouget extends ModelePdfExpedition
// Date planned delivery // Date planned delivery
if (!empty($object->date_delivery)) if (!empty($object->date_delivery))
{ {
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R'); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
} }
if (!empty($object->thirdparty->code_client)) if (!empty($object->thirdparty->code_client))
@ -975,7 +975,7 @@ class pdf_rouget extends ModelePdfExpedition
$origin = $object->origin; $origin = $object->origin;
$origin_id = $object->origin_id; $origin_id = $object->origin_id;
// TODO move to external function // TODO move to external function
if (!empty($conf->$origin->enabled)) // commonly $origin='commande' if (!empty($conf->$origin->enabled)) // commonly $origin='commande'
{ {
$outputlangs->load('orders'); $outputlangs->load('orders');
@ -985,7 +985,7 @@ class pdf_rouget extends ModelePdfExpedition
$result = $linkedobject->fetch($origin_id); $result = $linkedobject->fetch($origin_id);
if ($result >= 0) if ($result >= 0)
{ {
//$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
$pdf->SetFont('', '', $default_font_size - 2); $pdf->SetFont('', '', $default_font_size - 2);
$text = $linkedobject->ref; $text = $linkedobject->ref;
@ -1099,7 +1099,7 @@ class pdf_rouget extends ModelePdfExpedition
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output

View File

@ -44,71 +44,71 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php';
*/ */
class pdf_standard extends ModeleExpenseReport class pdf_standard extends ModeleExpenseReport
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
*/ */
public $db; public $db;
/** /**
* @var string model name * @var string model name
*/ */
public $name; public $name;
/** /**
* @var string model description (short text) * @var string model description (short text)
*/ */
public $description; public $description;
/** /**
* @var string document type * @var string document type
*/ */
public $type; public $type;
/** /**
* @var array Minimum version of PHP required by module. * @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.6 = array(5, 6) * e.g.: PHP ≥ 5.6 = array(5, 6)
*/ */
public $phpmin = array(5, 6); public $phpmin = array(5, 6);
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/** /**
* @var int page_largeur * @var int page_largeur
*/ */
public $page_largeur; public $page_largeur;
/** /**
* @var int page_hauteur * @var int page_hauteur
*/ */
public $page_hauteur; public $page_hauteur;
/** /**
* @var array format * @var array format
*/ */
public $format; public $format;
/** /**
* @var int marge_gauche * @var int marge_gauche
*/ */
public $marge_gauche; public $marge_gauche;
/** /**
* @var int marge_droite * @var int marge_droite
*/ */
public $marge_droite; public $marge_droite;
/** /**
* @var int marge_haute * @var int marge_haute
*/ */
public $marge_haute; public $marge_haute;
/** /**
* @var int marge_basse * @var int marge_basse
*/ */
public $marge_basse; public $marge_basse;
/** /**
@ -209,7 +209,7 @@ class pdf_standard extends ModeleExpenseReport
*/ */
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
// phpcs:enable // phpcs:enable
global $user, $langs, $conf, $mysoc, $db, $hookmanager; global $user, $langs, $conf, $mysoc, $db, $hookmanager;
if (!is_object($outputlangs)) $outputlangs = $langs; if (!is_object($outputlangs)) $outputlangs = $langs;
@ -258,24 +258,24 @@ class pdf_standard extends ModeleExpenseReport
$pdf = pdf_getInstance($this->format); $pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 40; // Height reserved to output the info and total part $heightforinfotot = 40; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
$pdf->Open(); $pdf->Open();
$pagenb = 0; $pagenb = 0;
@ -417,15 +417,15 @@ class pdf_standard extends ModeleExpenseReport
$pdf->commitTransaction(); $pdf->commitTransaction();
} }
$i++; $i++;
//nexY //nexY
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore); $pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute); $pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
//$nblineFollowComment = 1; //$nblineFollowComment = 1;
// Search number of lines coming to know if there is enough room // Search number of lines coming to know if there is enough room
// if ($i < ($nblines - 1)) // If it's not last line // if ($i < ($nblines - 1)) // If it's not last line
// { // {
// //Fetch current description to know on which line the next one should be placed // //Fetch current description to know on which line the next one should be placed
@ -436,11 +436,11 @@ class pdf_standard extends ModeleExpenseReport
// $nbLineCommentNeed = dol_nboflines_bis($follow_comment,52,$outputlangs->charset_output); // $nbLineCommentNeed = dol_nboflines_bis($follow_comment,52,$outputlangs->charset_output);
// $nbLineTypeNeed = dol_nboflines_bis($follow_type,4,$outputlangs->charset_output); // $nbLineTypeNeed = dol_nboflines_bis($follow_type,4,$outputlangs->charset_output);
// $nblineFollowComment = max($nbLineCommentNeed, $nbLineTypeNeed); // $nblineFollowComment = max($nbLineCommentNeed, $nbLineTypeNeed);
// } // }
//$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Add space between lines //$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Add space between lines
$nexY += ($pdf->getFontSize() * 1.3); // Add space between lines $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages // Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter) while ($pagenb < $pageposafter)
@ -487,7 +487,7 @@ class pdf_standard extends ModeleExpenseReport
$pdf->SetFont('', '', 10); $pdf->SetFont('', '', 10);
// Show total area box // Show total area box
$posy = $bottomlasttab + 5; $posy = $bottomlasttab + 5;
$posy_start_of_totals = $posy; $posy_start_of_totals = $posy;
$pdf->SetXY(130, $posy); $pdf->SetXY(130, $posy);
@ -498,7 +498,7 @@ class pdf_standard extends ModeleExpenseReport
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
// TODO Show vat amout per tax level // TODO Show vat amout per tax level
$posy += 5; $posy += 5;
$pdf->SetXY(130, $posy); $pdf->SetXY(130, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -536,8 +536,8 @@ class pdf_standard extends ModeleExpenseReport
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -568,78 +568,78 @@ class pdf_standard extends ModeleExpenseReport
*/ */
protected function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0) protected function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
{ {
global $conf; global $conf;
$pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFont('', '', $default_font_size - 1);
// Accountancy piece // Accountancy piece
$pdf->SetXY($this->posxpiece, $curY); $pdf->SetXY($this->posxpiece, $curY);
$pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1); $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1);
// Date // Date
//$pdf->SetXY($this->posxdate -1, $curY); //$pdf->SetXY($this->posxdate -1, $curY);
//$pdf->MultiCell($this->posxtype-$this->posxdate-0.8, 4, dol_print_date($object->lines[$linenumber]->date,"day",false,$outputlangs), 0, 'C'); //$pdf->MultiCell($this->posxtype-$this->posxdate-0.8, 4, dol_print_date($object->lines[$linenumber]->date,"day",false,$outputlangs), 0, 'C');
// Type // Type
$pdf->SetXY($this->posxtype - 1, $curY); $pdf->SetXY($this->posxtype - 1, $curY);
$nextColumnPosX = $this->posxup; $nextColumnPosX = $this->posxup;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
$nextColumnPosX = $this->posxtva; $nextColumnPosX = $this->posxtva;
} }
if (!empty($conf->projet->enabled)) { if (!empty($conf->projet->enabled)) {
$nextColumnPosX = $this->posxprojet; $nextColumnPosX = $this->posxprojet;
} }
$expensereporttypecode = $object->lines[$linenumber]->type_fees_code; $expensereporttypecode = $object->lines[$linenumber]->type_fees_code;
$expensereporttypecodetoshow = ($outputlangs->trans(($expensereporttypecode)) == $expensereporttypecode ? $object->lines[$linenumber]->type_fees_libelle : $outputlangs->trans($expensereporttypecode)); $expensereporttypecodetoshow = ($outputlangs->trans(($expensereporttypecode)) == $expensereporttypecode ? $object->lines[$linenumber]->type_fees_libelle : $outputlangs->trans($expensereporttypecode));
if ($expensereporttypecodetoshow == $expensereporttypecode) { if ($expensereporttypecodetoshow == $expensereporttypecode) {
$expensereporttypecodetoshow = preg_replace('/^(EX_|TF_)/', '', $expensereporttypecodetoshow); $expensereporttypecodetoshow = preg_replace('/^(EX_|TF_)/', '', $expensereporttypecodetoshow);
} }
//$expensereporttypecodetoshow = dol_trunc($expensereporttypecodetoshow, 9); //$expensereporttypecodetoshow = dol_trunc($expensereporttypecodetoshow, 9);
//$pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, $expensereporttypecodetoshow, 0, 'C'); //$pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, $expensereporttypecodetoshow, 0, 'C');
// Project // Project
//if (! empty($conf->projet->enabled)) //if (! empty($conf->projet->enabled))
//{ //{
// $pdf->SetFont('','', $default_font_size - 1); // $pdf->SetFont('','', $default_font_size - 1);
// $pdf->SetXY($this->posxprojet, $curY); // $pdf->SetXY($this->posxprojet, $curY);
// $pdf->MultiCell($this->posxtva-$this->posxprojet-0.8, 4, $object->lines[$linenumber]->projet_ref, 0, 'C'); // $pdf->MultiCell($this->posxtva-$this->posxprojet-0.8, 4, $object->lines[$linenumber]->projet_ref, 0, 'C');
//} //}
// VAT Rate // VAT Rate
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
$vat_rate = pdf_getlinevatrate($object, $linenumber, $outputlangs, $hidedetails); $vat_rate = pdf_getlinevatrate($object, $linenumber, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxtva, $curY); $pdf->SetXY($this->posxtva, $curY);
$pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0, 'R'); $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0, 'R');
} }
// Unit price // Unit price
$pdf->SetXY($this->posxup, $curY); $pdf->SetXY($this->posxup, $curY);
$pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4, price($object->lines[$linenumber]->value_unit), 0, 'R'); $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4, price($object->lines[$linenumber]->value_unit), 0, 'R');
// Quantity // Quantity
$pdf->SetXY($this->posxqty, $curY); $pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->postotalttc - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0, 'R'); $pdf->MultiCell($this->postotalttc - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0, 'R');
// Total with all taxes // Total with all taxes
$pdf->SetXY($this->postotalttc - 1, $curY); $pdf->SetXY($this->postotalttc - 1, $curY);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R'); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R');
// Comments // Comments
$pdf->SetXY($this->posxcomment, $curY); $pdf->SetXY($this->posxcomment, $curY);
$comment = $outputlangs->trans("Date").':'.dol_print_date($object->lines[$linenumber]->date, "day", false, $outputlangs).' '; $comment = $outputlangs->trans("Date").':'.dol_print_date($object->lines[$linenumber]->date, "day", false, $outputlangs).' ';
$comment .= $outputlangs->trans("Type").':'.$expensereporttypecodetoshow.'<br>'; $comment .= $outputlangs->trans("Type").':'.$expensereporttypecodetoshow.'<br>';
if (!empty($object->lines[$linenumber]->projet_ref)) { if (!empty($object->lines[$linenumber]->projet_ref)) {
$comment .= $outputlangs->trans("Project").':'.$object->lines[$linenumber]->projet_ref.'<br>'; $comment .= $outputlangs->trans("Project").':'.$object->lines[$linenumber]->projet_ref.'<br>';
} }
$comment .= $object->lines[$linenumber]->comments; $comment .= $object->lines[$linenumber]->comments;
$pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1); $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show top header of page. * Show top header of page.
* *
* @param TCPDF $pdf Object PDF * @param TCPDF $pdf Object PDF
@ -666,7 +666,7 @@ class pdf_standard extends ModeleExpenseReport
pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
*/ */
// Draft watermark // Draft watermark
if ($object->fk_statut == 0 && !empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) { if ($object->fk_statut == 0 && !empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK); pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK);
} }
@ -683,8 +683,8 @@ class pdf_standard extends ModeleExpenseReport
$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo) { if ($this->emetteur->logo) {
if (is_readable($logo)) { if (is_readable($logo)) {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -933,15 +933,15 @@ class pdf_standard extends ModeleExpenseReport
// $pdf->MultiCell($this->posxprojet-$this->posxtype - 1, 2, $outputlangs->transnoentities("Type"), '', 'C'); // $pdf->MultiCell($this->posxprojet-$this->posxtype - 1, 2, $outputlangs->transnoentities("Type"), '', 'C');
//} //}
//if (!empty($conf->projet->enabled)) //if (!empty($conf->projet->enabled))
//{ //{
// // Project // // Project
// $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height); // $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height);
// if (empty($hidetop)) { // if (empty($hidetop)) {
// $pdf->SetXY($this->posxprojet - 1, $tab_top + 1); // $pdf->SetXY($this->posxprojet - 1, $tab_top + 1);
// $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 2, $outputlangs->transnoentities("Project"), '', 'C'); // $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 2, $outputlangs->transnoentities("Project"), '', 'C');
// } // }
//} //}
// VAT // VAT
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
@ -952,7 +952,7 @@ class pdf_standard extends ModeleExpenseReport
} }
} }
// Unit price // Unit price
$pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height); $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxup - 1, $tab_top + 1); $pdf->SetXY($this->posxup - 1, $tab_top + 1);
@ -1090,7 +1090,7 @@ class pdf_standard extends ModeleExpenseReport
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output

View File

@ -43,76 +43,76 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
*/ */
class pdf_crabe extends ModelePDFFactures class pdf_crabe extends ModelePDFFactures
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
*/ */
public $db; public $db;
/** /**
* @var string model name * @var string model name
*/ */
public $name; public $name;
/** /**
* @var string model description (short text) * @var string model description (short text)
*/ */
public $description; public $description;
/**
* @var int Save the name of generated file as the main doc when generating a doc with this template
*/
public $update_main_doc_field;
/** /**
* @var string document type * @var int Save the name of generated file as the main doc when generating a doc with this template
*/ */
public $type; public $update_main_doc_field;
/** /**
* @var array Minimum version of PHP required by module. * @var string document type
* e.g.: PHP ≥ 5.6 = array(5, 6) */
*/ public $type;
/**
* @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.6 = array(5, 6)
*/
public $phpmin = array(5, 6); public $phpmin = array(5, 6);
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/** /**
* @var int page_largeur * @var int page_largeur
*/ */
public $page_largeur; public $page_largeur;
/** /**
* @var int page_hauteur * @var int page_hauteur
*/ */
public $page_hauteur; public $page_hauteur;
/** /**
* @var array format * @var array format
*/ */
public $format; public $format;
/** /**
* @var int marge_gauche * @var int marge_gauche
*/ */
public $marge_gauche; public $marge_gauche;
/** /**
* @var int marge_droite * @var int marge_droite
*/ */
public $marge_droite; public $marge_droite;
/** /**
* @var int marge_haute * @var int marge_haute
*/ */
public $marge_haute; public $marge_haute;
/** /**
* @var int marge_basse * @var int marge_basse
*/ */
public $marge_basse; public $marge_basse;
/** /**
@ -197,14 +197,14 @@ class pdf_crabe extends ModelePDFFactures
$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format
{ {
$this->posxpicture -= 20; $this->posxpicture -= 20;
$this->posxtva -= 20; $this->posxtva -= 20;
$this->posxup -= 20; $this->posxup -= 20;
$this->posxqty -= 20; $this->posxqty -= 20;
$this->posxunit -= 20; $this->posxunit -= 20;
$this->posxdiscount -= 20; $this->posxdiscount -= 20;
$this->posxprogress -= 20; $this->posxprogress -= 20;
$this->postotalht -= 20; $this->postotalht -= 20;
} }
$this->tva = array(); $this->tva = array();
@ -216,21 +216,21 @@ class pdf_crabe extends ModelePDFFactures
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Function to build pdf onto disk * Function to build pdf onto disk
* *
* @param Object $object Object to generate * @param Object $object Object to generate
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
// phpcs:enable // phpcs:enable
global $user, $langs, $conf, $mysoc, $hookmanager, $nblines; global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
@ -318,27 +318,27 @@ class pdf_crabe extends ModelePDFFactures
// Create pdf instance // Create pdf instance
$pdf = pdf_getInstance($this->format); $pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
$heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
$pdf->Open(); $pdf->Open();
$pagenb = 0; $pagenb = 0;
@ -380,14 +380,14 @@ class pdf_crabe extends ModelePDFFactures
} }
if (empty($this->atleastonediscount)) // retreive space not used by discount if (empty($this->atleastonediscount)) // retreive space not used by discount
{ {
$delta = ($this->posxprogress - $this->posxdiscount); $delta = ($this->posxprogress - $this->posxdiscount);
$this->posxpicture += $delta; $this->posxpicture += $delta;
$this->posxtva += $delta; $this->posxtva += $delta;
$this->posxup += $delta; $this->posxup += $delta;
$this->posxqty += $delta; $this->posxqty += $delta;
$this->posxunit += $delta; $this->posxunit += $delta;
$this->posxdiscount += $delta; $this->posxdiscount += $delta;
// post of fields after are not modified, stay at same position // post of fields after are not modified, stay at same position
} }
$progress_width = 0; $progress_width = 0;
@ -452,11 +452,11 @@ class pdf_crabe extends ModelePDFFactures
if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
} }
} }
// Extrafields in note // Extrafields in note
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs); $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
if (!empty($extranote)) { if (!empty($extranote)) {
$notetoshow = dol_concatdesc($notetoshow, $extranote); $notetoshow = dol_concatdesc($notetoshow, $extranote);
} }
if ($notetoshow) if ($notetoshow)
{ {
$tab_top -= 2; $tab_top -= 2;
@ -606,17 +606,17 @@ class pdf_crabe extends ModelePDFFactures
// Discount on line // Discount on line
if ($object->lines[$i]->remise_percent) if ($object->lines[$i]->remise_percent)
{ {
$pdf->SetXY($this->posxdiscount - 2, $curY); $pdf->SetXY($this->posxdiscount - 2, $curY);
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
$pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R'); $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
} }
// Situation progress // Situation progress
if ($this->situationinvoice) if ($this->situationinvoice)
{ {
$progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails); $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxprogress, $curY); $pdf->SetXY($this->posxprogress, $curY);
$pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R'); $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R');
} }
// Total HT line // Total HT line
@ -660,7 +660,7 @@ class pdf_crabe extends ModelePDFFactures
$localtax2_type = $localtaxtmp_array[2]; $localtax2_type = $localtaxtmp_array[2];
} }
// retrieve global local tax // retrieve global local tax
if ($localtax1_type && $localtax1ligne != 0) if ($localtax1_type && $localtax1ligne != 0)
$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
if ($localtax2_type && $localtax2ligne != 0) if ($localtax2_type && $localtax2ligne != 0)
@ -754,8 +754,8 @@ class pdf_crabe extends ModelePDFFactures
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -780,23 +780,23 @@ class pdf_crabe extends ModelePDFFactures
/** /**
* Show payments table * Show payments table
* *
* @param TCPDF $pdf Object PDF * @param TCPDF $pdf Object PDF
* @param Object $object Object invoice * @param Object $object Object invoice
* @param int $posy Position y in PDF * @param int $posy Position y in PDF
* @param Translate $outputlangs Object langs for output * @param Translate $outputlangs Object langs for output
* @param int $heightforfooter height for footer * @param int $heightforfooter height for footer
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter = 0) protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$sign = 1; $sign = 1;
if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
$current_page = $pdf->getPage(); $current_page = $pdf->getPage();
$tab3_posx = 120; $tab3_posx = 120;
$tab3_top = $posy + 8; $tab3_top = $posy + 8;
$tab3_width = 80; $tab3_width = 80;
$tab3_height = 4; $tab3_height = 4;
@ -937,8 +937,8 @@ class pdf_crabe extends ModelePDFFactures
*/ */
protected function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height) protected function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height)
{ {
// phpcs:enable // phpcs:enable
$title = $outputlangs->transnoentities("PaymentsAlreadyDone"); $title = $outputlangs->transnoentities("PaymentsAlreadyDone");
if ($object->type == 2) $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone"); if ($object->type == 2) $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
$pdf->SetFont('', '', $default_font_size - 3); $pdf->SetFont('', '', $default_font_size - 3);
@ -973,7 +973,7 @@ class pdf_crabe extends ModelePDFFactures
*/ */
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf, $mysoc; global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -1085,13 +1085,13 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
$posy = $pdf->GetY() + 1; $posy = $pdf->GetY() + 1;
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
{ {
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
$posy = $pdf->GetY() + 2; $posy = $pdf->GetY() + 2;
} }
} }
if ($conf->global->FACTURE_CHQ_NUMBER == -1) if ($conf->global->FACTURE_CHQ_NUMBER == -1)
{ {
@ -1100,13 +1100,13 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
$posy = $pdf->GetY() + 1; $posy = $pdf->GetY() + 1;
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
{ {
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
$posy = $pdf->GetY() + 2; $posy = $pdf->GetY() + 2;
} }
} }
} }
} }
@ -1148,13 +1148,13 @@ class pdf_crabe extends ModelePDFFactures
*/ */
protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf, $mysoc; global $conf, $mysoc;
$sign = 1; $sign = 1;
if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$tab2_top = $posy; $tab2_top = $posy;
$tab2_hl = 4; $tab2_hl = 4;
@ -1193,7 +1193,7 @@ class pdf_crabe extends ModelePDFFactures
{ {
// Nothing to do // Nothing to do
} else { } else {
// FIXME amount of vat not supported with multicurrency // FIXME amount of vat not supported with multicurrency
//Local tax 1 before VAT //Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
@ -1227,7 +1227,7 @@ class pdf_crabe extends ModelePDFFactures
} }
} }
} }
//} //}
//Local tax 2 before VAT //Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{ //{
@ -1262,7 +1262,7 @@ class pdf_crabe extends ModelePDFFactures
} }
} }
//} //}
// VAT // VAT
foreach ($this->tva as $tvakey => $tvaval) foreach ($this->tva as $tvakey => $tvaval)
@ -1319,7 +1319,7 @@ class pdf_crabe extends ModelePDFFactures
} }
} }
} }
//} //}
//Local tax 2 after VAT //Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{ //{
@ -1558,23 +1558,23 @@ class pdf_crabe extends ModelePDFFactures
if ($this->atleastonediscount) if ($this->atleastonediscount)
{ {
$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height); $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
if (empty($hidetop)) if (empty($hidetop))
{ {
$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1); $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
$pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
} }
} }
if ($this->situationinvoice) { if ($this->situationinvoice) {
$pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height); $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxprogress, $tab_top + 1); $pdf->SetXY($this->posxprogress, $tab_top + 1);
$pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities("ProgressShort"), '', 'C'); $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities("ProgressShort"), '', 'C');
} }
} }
$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
if (empty($hidetop)) if (empty($hidetop))
{ {
$pdf->SetXY($this->postotalht - 1, $tab_top + 1); $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
@ -1605,9 +1605,9 @@ class pdf_crabe extends ModelePDFFactures
// Show Draft Watermark // Show Draft Watermark
if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
{ {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK); pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
} }
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetFont('', 'B', $default_font_size + 3);
@ -1615,7 +1615,7 @@ class pdf_crabe extends ModelePDFFactures
$w = 110; $w = 110;
$posy = $this->marge_haute; $posy = $this->marge_haute;
$posx = $this->page_largeur - $this->marge_droite - $w; $posx = $this->page_largeur - $this->marge_droite - $w;
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
@ -1634,7 +1634,7 @@ class pdf_crabe extends ModelePDFFactures
} }
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
@ -1771,16 +1771,16 @@ class pdf_crabe extends ModelePDFFactures
// Get contact // Get contact
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
{ {
$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
if (count($arrayidcontact) > 0) if (count($arrayidcontact) > 0)
{ {
$usertmp = new User($this->db); $usertmp = new User($this->db);
$usertmp->fetch($arrayidcontact[0]); $usertmp->fetch($arrayidcontact[0]);
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
} }
} }
$posy += 1; $posy += 1;
@ -1888,7 +1888,7 @@ class pdf_crabe extends ModelePDFFactures
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output

File diff suppressed because it is too large Load Diff

View File

@ -39,70 +39,70 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
class pdf_typhon extends ModelePDFDeliveryOrder class pdf_typhon extends ModelePDFDeliveryOrder
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
*/ */
public $db; public $db;
/** /**
* @var string model name * @var string model name
*/ */
public $name; public $name;
/** /**
* @var string model description (short text) * @var string model description (short text)
*/ */
public $description; public $description;
/** /**
* @var string document type * @var string document type
*/ */
public $type; public $type;
/** /**
* @var array Minimum version of PHP required by module. * @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.6 = array(5, 6) * e.g.: PHP ≥ 5.6 = array(5, 6)
*/ */
public $phpmin = array(5, 6); public $phpmin = array(5, 6);
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/** /**
* @var int page_largeur * @var int page_largeur
*/ */
public $page_largeur; public $page_largeur;
/** /**
* @var int page_hauteur * @var int page_hauteur
*/ */
public $page_hauteur; public $page_hauteur;
/** /**
* @var array format * @var array format
*/ */
public $format; public $format;
/** /**
* @var int marge_gauche * @var int marge_gauche
*/ */
public $marge_gauche; public $marge_gauche;
/** /**
* @var int marge_droite * @var int marge_droite
*/ */
public $marge_droite; public $marge_droite;
/** /**
* @var int marge_haute * @var int marge_haute
*/ */
public $marge_haute; public $marge_haute;
/** /**
* @var int marge_basse * @var int marge_basse
*/ */
public $marge_basse; public $marge_basse;
/** /**
@ -171,21 +171,21 @@ class pdf_typhon extends ModelePDFDeliveryOrder
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Function to build pdf onto disk * Function to build pdf onto disk
* *
* @param Object $object Object to generate * @param Object $object Object to generate
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
// phpcs:enable // phpcs:enable
global $user, $langs, $conf, $mysoc, $hookmanager; global $user, $langs, $conf, $mysoc, $hookmanager;
if (!is_object($outputlangs)) $outputlangs = $langs; if (!is_object($outputlangs)) $outputlangs = $langs;
@ -236,25 +236,25 @@ class pdf_typhon extends ModelePDFDeliveryOrder
// Create pdf instance // Create pdf instance
$pdf = pdf_getInstance($this->format); $pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 30; // Height reserved to output the info and total part $heightforinfotot = 30; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
// We get the shipment that is the origin of delivery receipt // We get the shipment that is the origin of delivery receipt
$expedition = new Expedition($this->db); $expedition = new Expedition($this->db);
@ -377,42 +377,42 @@ class pdf_typhon extends ModelePDFDeliveryOrder
// Description of product line // Description of product line
$curX = $this->posxdesc - 1; $curX = $this->posxdesc - 1;
$showpricebeforepagebreak = 1; $showpricebeforepagebreak = 1;
$pdf->startTransaction(); $pdf->startTransaction();
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 3, $curX, $curY, $hideref, $hidedesc); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 3, $curX, $curY, $hideref, $hidedesc);
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak if ($pageposafter > $pageposbefore) // There is a pagebreak
{ {
$pdf->rollbackTransaction(true); $pdf->rollbackTransaction(true);
$pageposafter = $pageposbefore; $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit; //print $pageposafter.'-'.$pageposbefore;exit;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 4, $curX, $curY, $hideref, $hidedesc); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 4, $curX, $curY, $hideref, $hidedesc);
$posyafter = $pdf->GetY(); $posyafter = $pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
{ {
if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{ {
$pdf->AddPage('', '', true); $pdf->AddPage('', '', true);
if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pageposafter + 1); $pdf->setPage($pageposafter + 1);
} }
} else { } else {
// We found a page break // We found a page break
// Allows data in the first page if description is long enough to break in multiples pages // Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1; $showpricebeforepagebreak = 1;
else $showpricebeforepagebreak = 0; else $showpricebeforepagebreak = 0;
} }
} else // No pagebreak } else // No pagebreak
{ {
$pdf->commitTransaction(); $pdf->commitTransaction();
} }
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore); $pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute); $pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
@ -602,8 +602,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -623,7 +623,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show miscellaneous information (payment mode, payment term, ...) * Show miscellaneous information (payment mode, payment term, ...)
* *
@ -635,7 +635,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
*/ */
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf, $mysoc; global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -756,8 +756,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder
{ {
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -895,7 +895,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
@ -903,9 +903,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder
* @return int Return height of bottom margin including footer text * @return int Return height of bottom margin including footer text
*/ */
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{ {
global $conf; global $conf;
$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); return pdf_pagefoot($pdf, $outputlangs, 'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
} }
} }

View File

@ -132,26 +132,26 @@ class modProduct extends DolibarrModules
$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'supprimer'; $this->rights[$r][4] = 'supprimer';
$r++; $r++;
$this->rights[$r][0] = 38; // Must be same permission than in service module $this->rights[$r][0] = 38; // Must be same permission than in service module
$this->rights[$r][1] = 'Export products'; $this->rights[$r][1] = 'Export products';
$this->rights[$r][2] = 'r'; $this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'export'; $this->rights[$r][4] = 'export';
$r++; $r++;
$this->rights[$r][0] = 39; $this->rights[$r][0] = 39;
$this->rights[$r][1] = 'Ignore minimum price'; $this->rights[$r][1] = 'Ignore minimum price';
$this->rights[$r][2] = 'r'; $this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'ignore_price_min_advance'; $this->rights[$r][4] = 'ignore_price_min_advance';
$r++; $r++;
// Menus // Menus
//------- //-------
$this->menu = 1; // This module adds menu entries. They are coded into menu manager. $this->menu = 1; // This module adds menu entries. They are coded into menu manager.
/* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts /* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts
$r=0; $r=0;
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
@ -278,90 +278,90 @@ class modProduct extends DolibarrModules
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES))
{ {
// Exports product multiprice // Exports product multiprice
$r++; $r++;
$this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_permission[$r] = array(array("produit", "export")); $this->export_permission[$r] = array(array("produit", "export"));
$this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref",
's.nom'=>'ThirdParty', 's.nom'=>'ThirdParty',
'pr.price_base_type'=>"PriceBase", 'pr.price_base_type'=>"PriceBase",
'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC", 'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC",
'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", 'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC",
'pr.tva_tx'=>'PriceVATRate', 'pr.tva_tx'=>'PriceVATRate',
'pr.default_vat_code'=>'PriceVATCode', 'pr.default_vat_code'=>'PriceVATCode',
'pr.datec'=>'DateCreation'); 'pr.datec'=>'DateCreation');
if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
$this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product",
's.nom'=>'company', 's.nom'=>'company',
'pr.price_base_type'=>"product", 'pr.price'=>"product", 'pr.price_base_type'=>"product", 'pr.price'=>"product",
'pr.price_ttc'=>"product", 'pr.price_ttc'=>"product",
'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product",
'pr.tva_tx'=>'product', 'pr.tva_tx'=>'product',
'pr.default_vat_code'=>'product', 'pr.default_vat_code'=>'product',
'pr.recuperableonly'=>'product', 'pr.recuperableonly'=>'product',
'pr.datec'=>"product"); 'pr.datec'=>"product");
$this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid';
$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
} }
if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) if (!empty($conf->global->PRODUIT_SOUSPRODUITS))
{ {
// Exports virtual products // Exports virtual products
$r++; $r++;
$this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_permission[$r] = array(array("produit", "export")); $this->export_permission[$r] = array(array("produit", "export"));
$this->export_fields_array[$r] = array( $this->export_fields_array[$r] = array(
'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl",
'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",
'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",
'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode",
'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic',
'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode',
'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell",
'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' 'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification'
); );
if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));
if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock'));
$this->export_TypeFields_array[$r] = array( $this->export_TypeFields_array[$r] = array(
'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text",
'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text",
'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text",
'p.note'=>"Text", 'p.note_public'=>"Text", 'p.note'=>"Text", 'p.note_public'=>"Text",
'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text',
'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean",
'p.datec'=>'Date', 'p.tms'=>'Date' 'p.datec'=>'Date', 'p.tms'=>'Date'
); );
if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));
if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric'));
$this->export_entities_array[$r] = array( $this->export_entities_array[$r] = array(
'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct",
'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct', 'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct',
'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct', 'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct',
'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct",
'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct',
'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct",
'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct" 'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct"
); );
if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct')); if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct'));
if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct'));
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct'));
$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description"));
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct"));
$this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,';
$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2';
$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
$this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';
} }
// Imports // Imports
@ -378,34 +378,34 @@ class modProduct extends DolibarrModules
$this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields'); $this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields');
$this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id $this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id
$this->import_fields_array[$r] = array( $this->import_fields_array[$r] = array(
'p.ref' => "Ref*", 'p.ref' => "Ref*",
'p.label' => "Label*", 'p.label' => "Label*",
'p.fk_product_type' => "Type*", 'p.fk_product_type' => "Type*",
'p.tosell' => "OnSell*", 'p.tosell' => "OnSell*",
'p.tobuy' => "OnBuy*", 'p.tobuy' => "OnBuy*",
'p.description' => "Description", 'p.description' => "Description",
'p.url' => "PublicUrl", 'p.url' => "PublicUrl",
'p.customcode' => 'CustomCode', 'p.customcode' => 'CustomCode',
'p.fk_country' => 'CountryCode', 'p.fk_country' => 'CountryCode',
'p.accountancy_code_sell' => "ProductAccountancySellCode", 'p.accountancy_code_sell' => "ProductAccountancySellCode",
'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode", 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",
'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode", 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode",
'p.accountancy_code_buy' => "ProductAccountancyBuyCode", 'p.accountancy_code_buy' => "ProductAccountancyBuyCode",
'p.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode",
'p.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode", 'p.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode",
'p.note_public' => "NotePublic", 'p.note_public' => "NotePublic",
'p.note' => "NotePrivate", 'p.note' => "NotePrivate",
'p.weight' => "Weight", 'p.weight' => "Weight",
'p.weight_units' => "WeightUnits", 'p.weight_units' => "WeightUnits",
'p.length' => "Length", 'p.length' => "Length",
'p.length_units' => "LengthUnits", 'p.length_units' => "LengthUnits",
'p.width' => "Width", 'p.width' => "Width",
'p.width_units' => "WidthUnits", 'p.width_units' => "WidthUnits",
'p.height' => "Height", 'p.height' => "Height",
'p.height_units' => "HeightUnits", 'p.height_units' => "HeightUnits",
'p.surface' => "Surface", 'p.surface' => "Surface",
'p.surface_units' => "SurfaceUnits", 'p.surface_units' => "SurfaceUnits",
'p.volume' => "Volume", 'p.volume' => "Volume",
'p.volume_units' => "VolumeUnits", 'p.volume_units' => "VolumeUnits",
'p.duration' => "Duration", //duration of service 'p.duration' => "Duration", //duration of service
'p.finished' => 'Nature', 'p.finished' => 'Nature',
@ -419,9 +419,9 @@ class modProduct extends DolibarrModules
'p.cost_price' => "CostPrice", 'p.cost_price' => "CostPrice",
); );
$this->import_convertvalue_array[$r] = array( $this->import_convertvalue_array[$r] = array(
'p.weight_units' => array( 'p.weight_units' => array(
'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
'classfile' => '/core/class/cunits.class.php', 'classfile' => '/core/class/cunits.class.php',
'class' => 'CUnits', 'class' => 'CUnits',
'method' => 'fetch', 'method' => 'fetch',
@ -468,38 +468,38 @@ class modProduct extends DolibarrModules
'units' => 'volume', 'units' => 'volume',
'dict' => 'DictionaryMeasuringUnits' 'dict' => 'DictionaryMeasuringUnits'
), ),
'p.fk_country' => array( 'p.fk_country' => array(
'rule' => 'fetchidfromcodeid', 'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/ccountry.class.php', 'classfile' => '/core/class/ccountry.class.php',
'class' => 'Ccountry', 'class' => 'Ccountry',
'method' => 'fetch', 'method' => 'fetch',
'dict' => 'DictionaryCountry' 'dict' => 'DictionaryCountry'
) )
); );
$this->import_regex_array[$r] = array( $this->import_regex_array[$r] = array(
'p.ref' => '[^ ]', 'p.ref' => '[^ ]',
'p.price_base_type' => '\AHT\z|\ATTC\z', 'p.price_base_type' => '\AHT\z|\ATTC\z',
'p.tosell' => '^[0|1]$', 'p.tosell' => '^[0|1]$',
'p.tobuy' => '^[0|1]$', 'p.tobuy' => '^[0|1]$',
'p.fk_product_type' => '^[0|1]$', 'p.fk_product_type' => '^[0|1]$',
'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
'p.recuperableonly' => '^[0|1]$', 'p.recuperableonly' => '^[0|1]$',
'p.finished' => '^[0|1]$' 'p.finished' => '^[0|1]$'
); );
if (!empty($conf->stock->enabled)) {//if Stock module enabled if (!empty($conf->stock->enabled)) {//if Stock module enabled
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.fk_default_warehouse'=>'DefaultWarehouse', 'p.fk_default_warehouse'=>'DefaultWarehouse',
'p.tobatch'=>'ManageLotSerial', 'p.tobatch'=>'ManageLotSerial',
'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning
'p.pmp' => 'PMPValue', //weighted average price 'p.pmp' => 'PMPValue', //weighted average price
'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature
)); ));
$this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array( $this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array(
'p.tobatch' => '^[0|1]$' 'p.tobatch' => '^[0|1]$'
)); ));
$this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
'p.fk_default_warehouse' => array( 'p.fk_default_warehouse' => array(
@ -510,7 +510,7 @@ class modProduct extends DolibarrModules
'element'=> 'Warehouse' 'element'=> 'Warehouse'
) )
)); ));
} }
if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice'));
if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR'));
@ -525,77 +525,77 @@ class modProduct extends DolibarrModules
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example) if ($resql) // This can fail when class is used on old database (during migration for example)
{ {
while ($obj = $this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql))
{ {
$fieldname = 'extra.'.$obj->name; $fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label); $fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
$import_extrafield_sample[$fieldname] = $fieldlabel; $import_extrafield_sample[$fieldname] = $fieldlabel;
} }
} }
// End add extra fields // End add extra fields
$this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
// field order as per structure of table llx_product // field order as per structure of table llx_product
$import_sample = array( $import_sample = array(
'p.ref' => "PREF123456", 'p.ref' => "PREF123456",
'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'), 'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'),
'p.label' => "Product name in default language", 'p.label' => "Product name in default language",
'p.description' => "Product description in default language", 'p.description' => "Product description in default language",
'p.note_public' => "a public note (free text)", 'p.note_public' => "a public note (free text)",
'p.note' => "a private note (free text)", 'p.note' => "a private note (free text)",
'p.customcode' => 'customs code', 'p.customcode' => 'customs code',
'p.fk_country' => 'FR', 'p.fk_country' => 'FR',
'p.price' => "100", 'p.price' => "100",
'p.price_min' => "100", 'p.price_min' => "100",
'p.price_ttc' => "110", 'p.price_ttc' => "110",
'p.price_min_ttc' => "110", 'p.price_min_ttc' => "110",
'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)",
'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country'
'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)",
'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)", 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",
'p.fk_product_type' => "0 (product) / 1 (service)", 'p.fk_product_type' => "0 (product) / 1 (service)",
'p.duration' => "eg. 365d/12m/1y", 'p.duration' => "eg. 365d/12m/1y",
'p.url' => 'link to product (no https)', 'p.url' => 'link to product (no https)',
'p.accountancy_code_sell' => "", 'p.accountancy_code_sell' => "",
'p.accountancy_code_sell_intra' => "", 'p.accountancy_code_sell_intra' => "",
'p.accountancy_code_sell_export' => "", 'p.accountancy_code_sell_export' => "",
'p.accountancy_code_buy' => "", 'p.accountancy_code_buy' => "",
'p.accountancy_code_buy_intra' => "", 'p.accountancy_code_buy_intra' => "",
'p.accountancy_code_buy_export' => "", 'p.accountancy_code_buy_export' => "",
'p.weight' => "", 'p.weight' => "",
'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units',
'p.length' => "", 'p.length' => "",
'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',
'p.width' => "", 'p.width' => "",
'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',
'p.height' => "", 'p.height' => "",
'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',
'p.surface' => "", 'p.surface' => "",
'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units',
'p.volume' => "", 'p.volume' => "",
'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units',
'p.finished' => '0 (raw material) / 1 (finished goods)' 'p.finished' => '0 (raw material) / 1 (finished goods)'
); );
//clauses copied from import_fields_array //clauses copied from import_fields_array
if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array( if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array(
'p.tobatch'=>"0 (don't use) / 1 (use batch/serial number)", 'p.tobatch'=>"0 (don't use) / 1 (use batch/serial number)",
'p.seuil_stock_alerte' => '', 'p.seuil_stock_alerte' => '',
'p.pmp' => '0', 'p.pmp' => '0',
'p.desiredstock' => '' 'p.desiredstock' => ''
)); ));
if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90')); if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90'));
if (is_object($mysoc) && $mysoc->useNPR()) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0')); if (is_object($mysoc) && $mysoc->useNPR()) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0'));
if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>''));
if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>''));
if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>'')); if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>''));
if (!empty($conf->global->PRODUCT_USE_UNITS)) { if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$import_sample = array_merge( $import_sample = array_merge(
$import_sample, $import_sample,
array( array(
'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"' 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"'
) )
); );
$this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
'p.fk_unit' => array( 'p.fk_unit' => array(
@ -608,8 +608,8 @@ class modProduct extends DolibarrModules
)); ));
} }
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref');
if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled
if (!empty($conf->fournisseur->enabled)) if (!empty($conf->fournisseur->enabled))
{ {
@ -622,34 +622,34 @@ class modProduct extends DolibarrModules
$this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); $this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price');
$this->import_tables_creator_array[$r] = array('sp'=>'fk_user'); $this->import_tables_creator_array[$r] = array('sp'=>'fk_user');
$this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields
'sp.fk_product'=>"ProductOrService*", 'sp.fk_product'=>"ProductOrService*",
'sp.fk_soc' => "Supplier*", 'sp.fk_soc' => "Supplier*",
'sp.ref_fourn' => 'SupplierRef*', 'sp.ref_fourn' => 'SupplierRef*',
'sp.quantity' => "QtyMin*", 'sp.quantity' => "QtyMin*",
'sp.tva_tx' => 'VATRate', 'sp.tva_tx' => 'VATRate',
'sp.default_vat_code' => 'VATCode', 'sp.default_vat_code' => 'VATCode',
'sp.delivery_time_days' => 'DeliveryDelay', 'sp.delivery_time_days' => 'DeliveryDelay',
'sp.supplier_reputation' => 'SupplierReputation' 'sp.supplier_reputation' => 'SupplierReputation'
); );
if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR'));
if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'sp.price'=>"PriceQtyMinHT*", 'sp.price'=>"PriceQtyMinHT*",
'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty
'sp.remise_percent'=>'DiscountQtyMin' 'sp.remise_percent'=>'DiscountQtyMin'
)); ));
if ($conf->multicurrency->enabled) if ($conf->multicurrency->enabled)
{ {
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line 'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line
'sp.multicurrency_code'=>'CurrencyCode', 'sp.multicurrency_code'=>'CurrencyCode',
'sp.multicurrency_tx'=>'CurrencyRate', 'sp.multicurrency_tx'=>'CurrencyRate',
'sp.multicurrency_unitprice'=>'CurrencyUnitPrice', 'sp.multicurrency_unitprice'=>'CurrencyUnitPrice',
'sp.multicurrency_price'=>'CurrencyPrice', 'sp.multicurrency_price'=>'CurrencyPrice',
)); ));
} }
$this->import_convertvalue_array[$r] = array( $this->import_convertvalue_array[$r] = array(
'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'), 'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'),
@ -657,38 +657,38 @@ class modProduct extends DolibarrModules
); );
$this->import_examplevalues_array[$r] = array( $this->import_examplevalues_array[$r] = array(
'sp.fk_product' => "PRODUCT_REF or id:123456", 'sp.fk_product' => "PRODUCT_REF or id:123456",
'sp.fk_soc' => "My Supplier", 'sp.fk_soc' => "My Supplier",
'sp.ref_fourn' => "XYZ-F123456", 'sp.ref_fourn' => "XYZ-F123456",
'sp.quantity' => "5", 'sp.quantity' => "5",
'sp.tva_tx' => '10', 'sp.tva_tx' => '10',
'sp.price'=>"50", 'sp.price'=>"50",
'sp.unitprice'=>'50', 'sp.unitprice'=>'50',
'sp.remise_percent'=>'0', 'sp.remise_percent'=>'0',
'sp.default_vat_code' => '', 'sp.default_vat_code' => '',
'sp.delivery_time_days' => '5', 'sp.delivery_time_days' => '5',
'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER'
); );
if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>''));
if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.price' => "50.00", 'sp.price' => "50.00",
'sp.unitprice' => '10', 'sp.unitprice' => '10',
// TODO Make this field not required and calculate it from price and qty // TODO Make this field not required and calculate it from price and qty
'sp.remise_percent' => '20' 'sp.remise_percent' => '20'
)); ));
if ($conf->multicurrency->enabled) if ($conf->multicurrency->enabled)
{ {
$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency',
'sp.multicurrency_code'=>'GBP', 'sp.multicurrency_code'=>'GBP',
'sp.multicurrency_tx'=>'1.12345', 'sp.multicurrency_tx'=>'1.12345',
'sp.multicurrency_unitprice'=>'', 'sp.multicurrency_unitprice'=>'',
// TODO Make this field not required and calculate it from price and qty // TODO Make this field not required and calculate it from price and qty
'sp.multicurrency_price'=>'' 'sp.multicurrency_price'=>''
)); ));
} }
$this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier'); $this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier');
} }
@ -712,26 +712,26 @@ class modProduct extends DolibarrModules
if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR'));
$this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'pr.recuperableonly'=>'^[0|1]$'); $this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'pr.recuperableonly'=>'^[0|1]$');
$this->import_convertvalue_array[$r] = array( $this->import_convertvalue_array[$r] = array(
'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') 'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
); );
$this->import_examplevalues_array[$r] = array('pr.fk_product'=>"PRODUCT_REF or id:123456", $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"PRODUCT_REF or id:123456",
'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1", 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1",
'pr.price'=>"100", 'pr.price_ttc'=>"110", 'pr.price'=>"100", 'pr.price_ttc'=>"110",
'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110",
'pr.tva_tx'=>'20', 'pr.tva_tx'=>'20',
'pr.recuperableonly'=>'0', 'pr.recuperableonly'=>'0',
'pr.date_price'=>'2013-04-10'); 'pr.date_price'=>'2013-04-10');
} }
if (!empty($conf->global->MAIN_MULTILANGS)) if (!empty($conf->global->MAIN_MULTILANGS))
{ {
// Import translations of product names and descriptions // Import translations of product names and descriptions
$r++; $r++;
$this->import_code[$r] = $this->rights_class.'_languages'; $this->import_code[$r] = $this->rights_class.'_languages';
$this->import_label[$r] = "ProductsOrServicesTranslations"; $this->import_label[$r] = "ProductsOrServicesTranslations";
$this->import_icon[$r] = $this->picto; $this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang'); $this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang');
// multiline translation, one line per translation // multiline translation, one line per translation
$this->import_fields_array[$r] = array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); $this->import_fields_array[$r] = array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription');
//$this->import_fields_array[$r]['l.note']='TranslatedNote'; //$this->import_fields_array[$r]['l.note']='TranslatedNote';
@ -744,20 +744,20 @@ class modProduct extends DolibarrModules
} }
/** /**
* Function called when module is enabled. * Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories * It also creates data directories
* *
* @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes')
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
public function init($options = '') public function init($options = '')
{ {
$this->remove($options); $this->remove($options);
$sql = array(); $sql = array();
return $this->_init($sql, $options); return $this->_init($sql, $options);
} }
} }

View File

@ -266,75 +266,75 @@ class modRecruitment extends DolibarrModules
/* BEGIN MODULEBUILDER TOPMENU */ /* BEGIN MODULEBUILDER TOPMENU */
/* END MODULEBUILDER TOPMENU */ /* END MODULEBUILDER TOPMENU */
/* BEGIN MODULEBUILDER LEFTMENU RECRUITMENTJOBPOSITION */ /* BEGIN MODULEBUILDER LEFTMENU RECRUITMENTJOBPOSITION */
$this->menu[$r++]=array( $this->menu[$r++] = array(
'fk_menu'=>'fk_mainmenu=hrm', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'fk_menu'=>'fk_mainmenu=hrm', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Top menu entry 'type'=>'left', // This is a Top menu entry
'titre'=>'Recruitment', 'titre'=>'Recruitment',
'mainmenu'=>'hrm', 'mainmenu'=>'hrm',
'leftmenu'=>'recruitmentjobposition', 'leftmenu'=>'recruitmentjobposition',
'url'=>'/recruitment/recruitmentindex.php', 'url'=>'/recruitment/recruitmentindex.php',
'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r, 'position'=>1000 + $r,
'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled.
'perms'=>'$user->rights->recruitment->recruitmentjobposition->read', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules 'perms'=>'$user->rights->recruitment->recruitmentjobposition->read', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
); );
$this->menu[$r++]=array( $this->menu[$r++] = array(
'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry 'type'=>'left', // This is a Left menu entry
'titre'=>'NewPositionToBeFilled', 'titre'=>'NewPositionToBeFilled',
'mainmenu'=>'hrm', 'mainmenu'=>'hrm',
'leftmenu'=>'recruitment_recruitmentjobposition_new', 'leftmenu'=>'recruitment_recruitmentjobposition_new',
'url'=>'/recruitment/recruitmentjobposition_card.php?action=create', 'url'=>'/recruitment/recruitmentjobposition_card.php?action=create',
'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r, 'position'=>1000 + $r,
'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'$user->rights->recruitment->recruitmentjobposition->write', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules 'perms'=>'$user->rights->recruitment->recruitmentjobposition->write', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
); );
$this->menu[$r++]=array( $this->menu[$r++] = array(
'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry 'type'=>'left', // This is a Left menu entry
'titre'=>'ListOfPositionsToBeFilled', 'titre'=>'ListOfPositionsToBeFilled',
'mainmenu'=>'hrm', 'mainmenu'=>'hrm',
'leftmenu'=>'recruitment_recruitmentjobposition_list', 'leftmenu'=>'recruitment_recruitmentjobposition_list',
'url'=>'/recruitment/recruitmentjobposition_list.php', 'url'=>'/recruitment/recruitmentjobposition_list.php',
'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r, 'position'=>1000 + $r,
'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'$user->rights->recruitment->recruitmentjobposition->read', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules 'perms'=>'$user->rights->recruitment->recruitmentjobposition->read', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
); );
$this->menu[$r++]=array( $this->menu[$r++] = array(
'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry 'type'=>'left', // This is a Left menu entry
'titre'=>'NewCandidature', 'titre'=>'NewCandidature',
'mainmenu'=>'hrm', 'mainmenu'=>'hrm',
'leftmenu'=>'recruitment_recruitmentcandidature_new', 'leftmenu'=>'recruitment_recruitmentcandidature_new',
'url'=>'/recruitment/recruitmentcandidature_card.php?action=create', 'url'=>'/recruitment/recruitmentcandidature_card.php?action=create',
'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r, 'position'=>1000 + $r,
'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'$user->rights->recruitment->recruitmentjobposition->write', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules 'perms'=>'$user->rights->recruitment->recruitmentjobposition->write', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
); );
$this->menu[$r++]=array( $this->menu[$r++] = array(
'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry 'type'=>'left', // This is a Left menu entry
'titre'=>'ListOfCandidatures', 'titre'=>'ListOfCandidatures',
'mainmenu'=>'hrm', 'mainmenu'=>'hrm',
'leftmenu'=>'recruitment_recruitmentcandidature_list', 'leftmenu'=>'recruitment_recruitmentcandidature_list',
'url'=>'/recruitment/recruitmentcandidature_list.php', 'url'=>'/recruitment/recruitmentcandidature_list.php',
'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r, 'position'=>1000 + $r,
'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'$user->rights->recruitment->recruitmentjobposition->read', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules 'perms'=>'$user->rights->recruitment->recruitmentjobposition->read', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
); );
/* END MODULEBUILDER LEFTMENU RECRUITMENTJOBPOSITION */ /* END MODULEBUILDER LEFTMENU RECRUITMENTJOBPOSITION */
@ -422,24 +422,24 @@ class modRecruitment extends DolibarrModules
// Document template // Document template
$moduledir = 'mymodule'; $moduledir = 'mymodule';
$myTmpObjects = array(); $myTmpObjects = array();
$myTmpObjects['RecruitmentJobPosition']=array('includerefgeneration'=>1, 'includedocgeneration'=>1); $myTmpObjects['RecruitmentJobPosition'] = array('includerefgeneration'=>1, 'includedocgeneration'=>1);
foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
if ($myTmpObjectKey == 'MyObject') continue; if ($myTmpObjectKey == 'MyObject') continue;
if ($myTmpObjectArray['includerefgeneration']) { if ($myTmpObjectArray['includerefgeneration']) {
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt'; $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/mymodule'; $dirodt = DOL_DATA_ROOT.'/doctemplates/mymodule';
$dest=$dirodt.'/template_myobjects.odt'; $dest = $dirodt.'/template_myobjects.odt';
if (file_exists($src) && ! file_exists($dest)) if (file_exists($src) && !file_exists($dest))
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt); dol_mkdir($dirodt);
$result=dol_copy($src, $dest, 0, 0); $result = dol_copy($src, $dest, 0, 0);
if ($result < 0) if ($result < 0)
{ {
$langs->load("errors"); $langs->load("errors");
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0; return 0;
} }
} }

View File

@ -31,57 +31,57 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
class modSocialNetworks extends DolibarrModules class modSocialNetworks extends DolibarrModules
{ {
/** /**
* Constructor. Define names, constants, directories, boxes, permissions * Constructor. Define names, constants, directories, boxes, permissions
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
global $langs, $conf; global $langs, $conf;
$this->db = $db; $this->db = $db;
$this->numero = 3400; $this->numero = 3400;
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page // It is used to group modules in module setup page
$this->family = "interface"; $this->family = "interface";
// Module position in the family on 2 digits ('01', '10', '20', ...) // Module position in the family on 2 digits ('01', '10', '20', ...)
$this->module_position = '20'; $this->module_position = '20';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this)); $this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)"; $this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'dolibarr'; $this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Name of image file used for this module. // Name of image file used for this module.
$this->picto = 'share-alt'; $this->picto = 'share-alt';
// Data directories to create when module is enabled // Data directories to create when module is enabled
$this->dirs = array(); $this->dirs = array();
// Config pages // Config pages
$this->config_page_url = array(DOL_URL_ROOT.'/admin/dict.php?id=38'); $this->config_page_url = array(DOL_URL_ROOT.'/admin/dict.php?id=38');
// Dependencies // Dependencies
$this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module $this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module
$this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled $this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled
$this->requiredby = array(); // List of module ids to disable if this one is disabled $this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->phpmin = array(5, 4); // Minimum version of PHP required by module $this->phpmin = array(5, 4); // Minimum version of PHP required by module
$this->langfiles = array(); $this->langfiles = array();
// Constants // Constants
// New pages on tabs // New pages on tabs
$this->tabs = array(); $this->tabs = array();
// Boxes // Boxes
$this->boxes = array(); $this->boxes = array();
// Main menu entries // Main menu entries
$this->menu = array(); $this->menu = array();
} }
} }

View File

@ -37,74 +37,74 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
*/ */
class pdf_stdandard extends ModelePDFMovement class pdf_stdandard extends ModelePDFMovement
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
*/ */
public $db; public $db;
/** /**
* @var string model name * @var string model name
*/ */
public $name; public $name;
/** /**
* @var string model description (short text) * @var string model description (short text)
*/ */
public $description; public $description;
/** /**
* @var string document type * @var string document type
*/ */
public $type; public $type;
/** /**
* @var array Minimum version of PHP required by module. * @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.6 = array(5, 6) * e.g.: PHP ≥ 5.6 = array(5, 6)
*/ */
public $phpmin = array(5, 6); public $phpmin = array(5, 6);
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/** /**
* @var int page_largeur * @var int page_largeur
*/ */
public $page_largeur; public $page_largeur;
/**
* @var int page_hauteur
*/
public $page_hauteur;
/**
* @var array format
*/
public $format;
/** /**
* @var int marge_gauche * @var int page_hauteur
*/ */
public $page_hauteur;
/**
* @var array format
*/
public $format;
/**
* @var int marge_gauche
*/
public $marge_gauche; public $marge_gauche;
/** /**
* @var int marge_droite * @var int marge_droite
*/ */
public $marge_droite; public $marge_droite;
/** /**
* @var int marge_haute * @var int marge_haute
*/ */
public $marge_haute; public $marge_haute;
/** /**
* @var int marge_basse * @var int marge_basse
*/ */
public $marge_basse; public $marge_basse;
/** /**
* @var Societe Issuer * @var Societe Issuer
*/ */
public $emetteur; public $emetteur;
@ -179,7 +179,7 @@ class pdf_stdandard extends ModelePDFMovement
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Function to build a document on disk using the generic odt module. * Function to build a document on disk using the generic odt module.
* *
@ -193,7 +193,7 @@ class pdf_stdandard extends ModelePDFMovement
*/ */
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
// phpcs:enable // phpcs:enable
global $user, $langs, $conf, $mysoc, $db, $hookmanager; global $user, $langs, $conf, $mysoc, $db, $hookmanager;
if (!is_object($outputlangs)) $outputlangs = $langs; if (!is_object($outputlangs)) $outputlangs = $langs;
@ -203,9 +203,9 @@ class pdf_stdandard extends ModelePDFMovement
// Load traductions files required by page // Load traductions files required by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries")); $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
/** /**
* TODO: get from object * TODO: get from object
*/ */
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
@ -328,7 +328,7 @@ class pdf_stdandard extends ModelePDFMovement
$resql = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
/* /*
* END TODO * END TODO
**/ **/
@ -414,21 +414,21 @@ class pdf_stdandard extends ModelePDFMovement
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
$heightforinfotot = 40; // Height reserved to output the info and total part $heightforinfotot = 40; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
$pdf->Open(); $pdf->Open();
$pagenb = 0; $pagenb = 0;
@ -773,8 +773,8 @@ class pdf_stdandard extends ModelePDFMovement
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -809,34 +809,34 @@ class pdf_stdandard extends ModelePDFMovement
*/ */
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
{ {
global $conf; global $conf;
// Force to disable hidetop and hidebottom // Force to disable hidetop and hidebottom
$hidebottom = 0; $hidebottom = 0;
if ($hidetop) $hidetop = -1; if ($hidetop) $hidetop = -1;
$currency = !empty($currency) ? $currency : $conf->currency; $currency = !empty($currency) ? $currency : $conf->currency;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
// Amount in (at tab_top - 1) // Amount in (at tab_top - 1)
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2); $pdf->SetFont('', '', $default_font_size - 2);
if (empty($hidetop)) if (empty($hidetop))
{ {
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
} }
$pdf->SetDrawColor(128, 128, 128); $pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetFont('', 'B', $default_font_size - 3);
// Output Rect // Output Rect
//$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26))); $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
$pdf->SetDrawColor(220, 26, 26); $pdf->SetDrawColor(220, 26, 26);
@ -846,12 +846,12 @@ class pdf_stdandard extends ModelePDFMovement
$pdf->SetTextColor(0, 0, 120); $pdf->SetTextColor(0, 0, 120);
//Ref mouv //Ref mouv
if (empty($hidetop)) if (empty($hidetop))
{ {
//$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter
$pdf->SetXY($this->posxidref, $tab_top + 1); $pdf->SetXY($this->posxidref, $tab_top + 1);
$pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L'); $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L');
} }
//Date mouv //Date mouv
//$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height); //$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height);
@ -862,20 +862,20 @@ class pdf_stdandard extends ModelePDFMovement
} }
//Ref Product //Ref Product
//$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
if (empty($hidetop)) if (empty($hidetop))
{ {
$pdf->SetXY($this->posxdesc - 1, $tab_top + 1); $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
$pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities("Ref. Product"), '', 'C'); $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities("Ref. Product"), '', 'C');
} }
//Label Product //Label Product
//$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
if (empty($hidetop)) if (empty($hidetop))
{ {
$pdf->SetXY($this->posxlabel - 1, $tab_top + 1); $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
$pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities("Label"), '', 'C'); $pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities("Label"), '', 'C');
} }
//Lot/serie Product //Lot/serie Product
//$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); //$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
@ -886,36 +886,36 @@ class pdf_stdandard extends ModelePDFMovement
} }
//Code Inv //Code Inv
//$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
if (empty($hidetop)) if (empty($hidetop))
{ {
$pdf->SetXY($this->posxup - 1, $tab_top + 1); $pdf->SetXY($this->posxup - 1, $tab_top + 1);
$pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities("Inventory Code"), '', 'C'); $pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities("Inventory Code"), '', 'C');
} }
//Label mouvement //Label mouvement
//$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height); //$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height);
if (empty($hidetop)) if (empty($hidetop))
{ {
$pdf->SetXY($this->posxunit, $tab_top + 1); $pdf->SetXY($this->posxunit, $tab_top + 1);
$pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities("Label Mouvement"), '', 'C'); $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities("Label Mouvement"), '', 'C');
} }
//Origin //Origin
//$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
if (empty($hidetop)) if (empty($hidetop))
{ {
$pdf->SetXY($this->posxdiscount + 2, $tab_top + 1); $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
$pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities("Origin"), '', 'C'); $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities("Origin"), '', 'C');
} }
//Qty //Qty
//$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
if (empty($hidetop)) if (empty($hidetop))
{ {
$pdf->SetXY($this->postotalht + 2, $tab_top + 1); $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("Qty"), '', 'C'); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("Qty"), '', 'C');
} }
$pdf->SetDrawColor(220, 26, 26); $pdf->SetDrawColor(220, 26, 26);
$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26))); $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
@ -936,70 +936,70 @@ class pdf_stdandard extends ModelePDFMovement
*/ */
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "")
{ {
global $conf, $langs, $db, $hookmanager; global $conf, $langs, $db, $hookmanager;
// Load traductions files required by page // Load traductions files required by page
$outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks")); $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks"));
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
if ($object->type == 1) $titlekey = 'ServiceSheet'; if ($object->type == 1) $titlekey = 'ServiceSheet';
else $titlekey = 'StockSheet'; else $titlekey = 'StockSheet';
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark // Show Draft Watermark
if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
{ {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK); pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
} }
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetFont('', 'B', $default_font_size + 3);
$posy = $this->marge_haute; $posy = $this->marge_haute;
$posx = $this->page_largeur - $this->marge_droite - 100; $posx = $this->page_largeur - $this->marge_droite - 100;
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
// Logo // Logo
$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
} }
} else { } else {
$text = $this->emetteur->name; $text = $this->emetteur->name;
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
} }
$pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetFont('', 'B', $default_font_size + 3);
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$title = $outputlangs->transnoentities("Warehouse");
$pdf->MultiCell(100, 3, $title, '', 'R');
$pdf->SetFont('', 'B', $default_font_size);
$posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->label), '', 'R');
$posy += 5;
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R'); $title = $outputlangs->transnoentities("Warehouse");
$pdf->MultiCell(100, 3, $title, '', 'R');
$pdf->SetFont('', 'B', $default_font_size);
$posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->label), '', 'R');
$posy += 5;
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R');
$posy += 4; $posy += 4;
$pdf->SetXY($posx - 50, $posy); $pdf->SetXY($posx - 50, $posy);
@ -1070,7 +1070,7 @@ class pdf_stdandard extends ModelePDFMovement
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
/*if ($object->ref_client) /*if ($object->ref_client)
{ {
$posy+=5; $posy+=5;
$pdf->SetXY($posx,$posy); $pdf->SetXY($posx,$posy);
@ -1078,14 +1078,14 @@ class pdf_stdandard extends ModelePDFMovement
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}*/ }*/
/*$posy+=4; /*$posy+=4;
$pdf->SetXY($posx,$posy); $pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
*/ */
// Get contact // Get contact
/* /*
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
{ {
$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
@ -1100,14 +1100,14 @@ class pdf_stdandard extends ModelePDFMovement
} }
}*/ }*/
$posy += 2; $posy += 2;
// Show list of linked objects // Show list of linked objects
//$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); //$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
if ($showaddress) if ($showaddress)
{ {
/* /*
// Sender properties // Sender properties
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
@ -1138,9 +1138,9 @@ class pdf_stdandard extends ModelePDFMovement
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
*/ */
} }
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@ -1155,8 +1155,8 @@ class pdf_stdandard extends ModelePDFMovement
*/ */
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{ {
global $conf; global $conf;
$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
} }
} }

View File

@ -36,17 +36,17 @@ abstract class ModelePDFMovement extends CommonDocGenerator
public $error = ''; public $error = '';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of active generation modules * Return list of active generation modules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show * @param integer $maxfilenamelength Max length of value to show
* @return array List of templates * @return array List of templates
*/ */
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$type = 'movement'; $type = 'movement';

View File

@ -39,70 +39,70 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
class pdf_baleine extends ModelePDFProjects class pdf_baleine extends ModelePDFProjects
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
*/ */
public $db; public $db;
/** /**
* @var string model name * @var string model name
*/ */
public $name; public $name;
/** /**
* @var string model description (short text) * @var string model description (short text)
*/ */
public $description; public $description;
/** /**
* @var string document type * @var string document type
*/ */
public $type; public $type;
/** /**
* @var array Minimum version of PHP required by module. * @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.6 = array(5, 6) * e.g.: PHP ≥ 5.6 = array(5, 6)
*/ */
public $phpmin = array(5, 6); public $phpmin = array(5, 6);
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/** /**
* @var int page_largeur * @var int page_largeur
*/ */
public $page_largeur; public $page_largeur;
/** /**
* @var int page_hauteur * @var int page_hauteur
*/ */
public $page_hauteur; public $page_hauteur;
/** /**
* @var array format * @var array format
*/ */
public $format; public $format;
/** /**
* @var int marge_gauche * @var int marge_gauche
*/ */
public $marge_gauche; public $marge_gauche;
/** /**
* @var int marge_droite * @var int marge_droite
*/ */
public $marge_droite; public $marge_droite;
/** /**
* @var int marge_haute * @var int marge_haute
*/ */
public $marge_haute; public $marge_haute;
/** /**
* @var int marge_basse * @var int marge_basse
*/ */
public $marge_basse; public $marge_basse;
/** /**
@ -165,7 +165,7 @@ class pdf_baleine extends ModelePDFProjects
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Function to build pdf project onto disk * Function to build pdf project onto disk
* *
@ -175,7 +175,7 @@ class pdf_baleine extends ModelePDFProjects
*/ */
public function write_file($object, $outputlangs) public function write_file($object, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf, $hookmanager, $langs, $user; global $conf, $hookmanager, $langs, $user;
if (!is_object($outputlangs)) $outputlangs = $langs; if (!is_object($outputlangs)) $outputlangs = $langs;
@ -222,22 +222,22 @@ class pdf_baleine extends ModelePDFProjects
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
$heightforinfotot = 40; // Height reserved to output the info and total part $heightforinfotot = 40; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
// Complete object by loading several other informations // Complete object by loading several other informations
$task = new Task($this->db); $task = new Task($this->db);
@ -492,8 +492,8 @@ class pdf_baleine extends ModelePDFProjects
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -584,7 +584,7 @@ class pdf_baleine extends ModelePDFProjects
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetFont('', 'B', $default_font_size + 3);
$posx = $this->page_largeur - $this->marge_droite - 100; $posx = $this->page_largeur - $this->marge_droite - 100;
$posy = $this->marge_haute; $posy = $this->marge_haute;
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
@ -595,8 +595,8 @@ class pdf_baleine extends ModelePDFProjects
{ {
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -657,7 +657,7 @@ class pdf_baleine extends ModelePDFProjects
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Project $object Object to show * @param Project $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output

View File

@ -54,11 +54,11 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
class pdf_beluga extends ModelePDFProjects class pdf_beluga extends ModelePDFProjects
{ {
/** /**
* Page orientation * Page orientation
* @var string 'P' or 'Portait' (default), 'L' or 'Landscape' * @var string 'P' or 'Portait' (default), 'L' or 'Landscape'
*/ */
private $orientation = ''; private $orientation = '';
/** /**
* Issuer * Issuer
@ -85,14 +85,14 @@ class pdf_beluga extends ModelePDFProjects
// Page size for A4 format // Page size for A4 format
$this->type = 'pdf'; $this->type = 'pdf';
$formatarray = pdf_getFormat(); $formatarray = pdf_getFormat();
$this->orientation = 'L'; $this->orientation = 'L';
if ($this->orientation == 'L' || $this->orientation == 'Landscape') { if ($this->orientation == 'L' || $this->orientation == 'Landscape') {
$this->page_largeur = $formatarray['height']; $this->page_largeur = $formatarray['height'];
$this->page_hauteur = $formatarray['width']; $this->page_hauteur = $formatarray['width'];
} else { } else {
$this->page_largeur = $formatarray['width']; $this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height']; $this->page_hauteur = $formatarray['height'];
} }
$this->format = array($this->page_largeur, $this->page_hauteur); $this->format = array($this->page_largeur, $this->page_hauteur);
$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
@ -107,22 +107,22 @@ class pdf_beluga extends ModelePDFProjects
$this->emetteur = $mysoc; $this->emetteur = $mysoc;
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
// Define position of columns // Define position of columns
if ($this->orientation == 'L' || $this->orientation == 'Landscape') { if ($this->orientation == 'L' || $this->orientation == 'Landscape') {
$this->posxref = $this->marge_gauche + 1; $this->posxref = $this->marge_gauche + 1;
$this->posxdate = $this->marge_gauche + 105; $this->posxdate = $this->marge_gauche + 105;
$this->posxsociety = $this->marge_gauche + 125; $this->posxsociety = $this->marge_gauche + 125;
$this->posxamountht = $this->marge_gauche + 190; $this->posxamountht = $this->marge_gauche + 190;
$this->posxamountttc = $this->marge_gauche + 215; $this->posxamountttc = $this->marge_gauche + 215;
$this->posxstatut = $this->marge_gauche + 245; $this->posxstatut = $this->marge_gauche + 245;
} else { } else {
$this->posxref = $this->marge_gauche + 1; $this->posxref = $this->marge_gauche + 1;
$this->posxdate = $this->marge_gauche + 25; $this->posxdate = $this->marge_gauche + 25;
$this->posxsociety = $this->marge_gauche + 45; $this->posxsociety = $this->marge_gauche + 45;
$this->posxamountht = $this->marge_gauche + 110; $this->posxamountht = $this->marge_gauche + 110;
$this->posxamountttc = $this->marge_gauche + 135; $this->posxamountttc = $this->marge_gauche + 135;
$this->posxstatut = $this->marge_gauche + 165; $this->posxstatut = $this->marge_gauche + 165;
} }
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format
{ {
$this->posxref -= 20; $this->posxref -= 20;
@ -135,7 +135,7 @@ class pdf_beluga extends ModelePDFProjects
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Fonction generant le projet sur le disque * Fonction generant le projet sur le disque
* *
@ -145,10 +145,10 @@ class pdf_beluga extends ModelePDFProjects
*/ */
public function write_file($object, $outputlangs) public function write_file($object, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf, $hookmanager, $langs, $user; global $conf, $hookmanager, $langs, $user;
$formproject = new FormProjets($this->db); $formproject = new FormProjets($this->db);
if (!is_object($outputlangs)) $outputlangs = $langs; if (!is_object($outputlangs)) $outputlangs = $langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@ -194,22 +194,22 @@ class pdf_beluga extends ModelePDFProjects
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
$heightforinfotot = 40; // Height reserved to output the info and total part $heightforinfotot = 40; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
// Complete object by loading several other informations // Complete object by loading several other informations
$task = new Task($this->db); $task = new Task($this->db);
@ -282,363 +282,363 @@ class pdf_beluga extends ModelePDFProjects
$curY = $tab_top + $heightoftitleline + 1; $curY = $tab_top + $heightoftitleline + 1;
$nexY = $tab_top + $heightoftitleline + 1; $nexY = $tab_top + $heightoftitleline + 1;
$listofreferent = array( $listofreferent = array(
'propal'=>array( 'propal'=>array(
'name'=>"Proposals", 'name'=>"Proposals",
'title'=>"ListProposalsAssociatedProject", 'title'=>"ListProposalsAssociatedProject",
'class'=>'Propal', 'class'=>'Propal',
'table'=>'propal', 'table'=>'propal',
'datefieldname'=>'datep', 'datefieldname'=>'datep',
'test'=>$conf->propal->enabled && $user->rights->propale->lire, 'test'=>$conf->propal->enabled && $user->rights->propale->lire,
'lang'=>'propal'), 'lang'=>'propal'),
'order'=>array( 'order'=>array(
'name'=>"CustomersOrders", 'name'=>"CustomersOrders",
'title'=>"ListOrdersAssociatedProject", 'title'=>"ListOrdersAssociatedProject",
'class'=>'Commande', 'class'=>'Commande',
'table'=>'commande', 'table'=>'commande',
'datefieldname'=>'date_commande', 'datefieldname'=>'date_commande',
'test'=>$conf->commande->enabled && $user->rights->commande->lire, 'test'=>$conf->commande->enabled && $user->rights->commande->lire,
'lang'=>'orders'), 'lang'=>'orders'),
'invoice'=>array( 'invoice'=>array(
'name'=>"CustomersInvoices", 'name'=>"CustomersInvoices",
'title'=>"ListInvoicesAssociatedProject", 'title'=>"ListInvoicesAssociatedProject",
'class'=>'Facture', 'class'=>'Facture',
'margin'=>'add', 'margin'=>'add',
'table'=>'facture', 'table'=>'facture',
'datefieldname'=>'datef', 'datefieldname'=>'datef',
'test'=>$conf->facture->enabled && $user->rights->facture->lire, 'test'=>$conf->facture->enabled && $user->rights->facture->lire,
'lang'=>'bills'), 'lang'=>'bills'),
'invoice_predefined'=>array( 'invoice_predefined'=>array(
'name'=>"PredefinedInvoices", 'name'=>"PredefinedInvoices",
'title'=>"ListPredefinedInvoicesAssociatedProject", 'title'=>"ListPredefinedInvoicesAssociatedProject",
'class'=>'FactureRec', 'class'=>'FactureRec',
'table'=>'facture_rec', 'table'=>'facture_rec',
'datefieldname'=>'datec', 'datefieldname'=>'datec',
'test'=>$conf->facture->enabled && $user->rights->facture->lire, 'test'=>$conf->facture->enabled && $user->rights->facture->lire,
'lang'=>'bills'), 'lang'=>'bills'),
'order_supplier'=>array( 'order_supplier'=>array(
'name'=>"SuppliersOrders", 'name'=>"SuppliersOrders",
'title'=>"ListSupplierOrdersAssociatedProject", 'title'=>"ListSupplierOrdersAssociatedProject",
'class'=>'CommandeFournisseur', 'class'=>'CommandeFournisseur',
'table'=>'commande_fournisseur', 'table'=>'commande_fournisseur',
'datefieldname'=>'date_commande', 'datefieldname'=>'date_commande',
'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire, 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire,
'lang'=>'orders'), 'lang'=>'orders'),
'invoice_supplier'=>array( 'invoice_supplier'=>array(
'name'=>"BillsSuppliers", 'name'=>"BillsSuppliers",
'title'=>"ListSupplierInvoicesAssociatedProject", 'title'=>"ListSupplierInvoicesAssociatedProject",
'class'=>'FactureFournisseur', 'class'=>'FactureFournisseur',
'margin'=>'minus', 'margin'=>'minus',
'table'=>'facture_fourn', 'table'=>'facture_fourn',
'datefieldname'=>'datef', 'datefieldname'=>'datef',
'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire, 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire,
'lang'=>'bills'), 'lang'=>'bills'),
'contract'=>array( 'contract'=>array(
'name'=>"Contracts", 'name'=>"Contracts",
'title'=>"ListContractAssociatedProject", 'title'=>"ListContractAssociatedProject",
'class'=>'Contrat', 'class'=>'Contrat',
'table'=>'contrat', 'table'=>'contrat',
'datefieldname'=>'date_contrat', 'datefieldname'=>'date_contrat',
'test'=>$conf->contrat->enabled && $user->rights->contrat->lire, 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire,
'lang'=>'contract'), 'lang'=>'contract'),
'intervention'=>array( 'intervention'=>array(
'name'=>"Interventions", 'name'=>"Interventions",
'title'=>"ListFichinterAssociatedProject", 'title'=>"ListFichinterAssociatedProject",
'class'=>'Fichinter', 'class'=>'Fichinter',
'table'=>'fichinter', 'table'=>'fichinter',
'datefieldname'=>'date_valid', 'datefieldname'=>'date_valid',
'disableamount'=>1, 'disableamount'=>1,
'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire, 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire,
'lang'=>'interventions'), 'lang'=>'interventions'),
'trip'=>array( 'trip'=>array(
'name'=>"TripsAndExpenses", 'name'=>"TripsAndExpenses",
'title'=>"ListExpenseReportsAssociatedProject", 'title'=>"ListExpenseReportsAssociatedProject",
'class'=>'Deplacement', 'class'=>'Deplacement',
'table'=>'deplacement', 'table'=>'deplacement',
'datefieldname'=>'dated', 'datefieldname'=>'dated',
'margin'=>'minus', 'margin'=>'minus',
'disableamount'=>1, 'disableamount'=>1,
'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire, 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire,
'lang'=>'trip'), 'lang'=>'trip'),
'expensereport'=>array( 'expensereport'=>array(
'name'=>"ExpensesReports", 'name'=>"ExpensesReports",
'title'=>"ListExpenseReportsAssociatedProject", 'title'=>"ListExpenseReportsAssociatedProject",
'class'=>'ExpenseReport', 'class'=>'ExpenseReport',
'table'=>'expensereport', 'table'=>'expensereport',
'datefieldname'=>'dated', 'datefieldname'=>'dated',
'margin'=>'minus', 'margin'=>'minus',
'disableamount'=>1, 'disableamount'=>1,
'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire, 'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire,
'lang'=>'trip'), 'lang'=>'trip'),
'agenda'=>array( 'agenda'=>array(
'name'=>"Agenda", 'name'=>"Agenda",
'title'=>"ListActionsAssociatedProject", 'title'=>"ListActionsAssociatedProject",
'class'=>'ActionComm', 'class'=>'ActionComm',
'table'=>'actioncomm', 'table'=>'actioncomm',
'datefieldname'=>'datep', 'datefieldname'=>'datep',
'disableamount'=>1, 'disableamount'=>1,
'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read, 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read,
'lang'=>'agenda') 'lang'=>'agenda')
); );
$hookmanager->initHooks(array('completeListOfReferent')); $hookmanager->initHooks(array('completeListOfReferent'));
$hookmanager->executeHooks('completeListOfReferent', ['listofreferent'=>$listofreferent], $object, $action); $hookmanager->executeHooks('completeListOfReferent', ['listofreferent'=>$listofreferent], $object, $action);
if (!empty($hookmanager->resArray)) { if (!empty($hookmanager->resArray)) {
$listofreferent = array_merge($listofreferent, $hookmanager->resArray); $listofreferent = array_merge($listofreferent, $hookmanager->resArray);
} }
foreach ($listofreferent as $key => $value) foreach ($listofreferent as $key => $value)
{ {
$title = $value['title']; $title = $value['title'];
$classname = $value['class']; $classname = $value['class'];
$tablename = $value['table']; $tablename = $value['table'];
$datefieldname = $value['datefieldname']; $datefieldname = $value['datefieldname'];
$qualified = $value['test']; $qualified = $value['test'];
$langstoload = $value['lang']; $langstoload = $value['lang'];
$projectField = isset($value['project_field']) ? $value['project_field'] : 'fk_projet'; $projectField = isset($value['project_field']) ? $value['project_field'] : 'fk_projet';
$langs->load($langstoload); $langs->load($langstoload);
if (!$qualified) continue; if (!$qualified) continue;
//var_dump("$key, $tablename, $datefieldname, $dates, $datee"); //var_dump("$key, $tablename, $datefieldname, $dates, $datee");
$elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, $projectField); $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, $projectField);
$num = count($elementarray); $num = count($elementarray);
if ($num >= 0) if ($num >= 0)
{ {
$nexY = $pdf->GetY() + 5; $nexY = $pdf->GetY() + 5;
$curY = $nexY; $curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
$pdf->SetXY($this->posxref, $curY); $pdf->SetXY($this->posxref, $curY);
$pdf->MultiCell($this->posxstatut - $this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L'); $pdf->MultiCell($this->posxstatut - $this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L');
$selectList = $formproject->select_element($tablename, $project->thirdparty->id, '', -2, $projectField); $selectList = $formproject->select_element($tablename, $project->thirdparty->id, '', -2, $projectField);
$nexY = $pdf->GetY() + 1; $nexY = $pdf->GetY() + 1;
$curY = $nexY; $curY = $nexY;
$pdf->SetXY($this->posxref, $curY); $pdf->SetXY($this->posxref, $curY);
$pdf->MultiCell($this->posxdate - $this->posxref, 3, $outputlangs->transnoentities("Ref"), 1, 'L'); $pdf->MultiCell($this->posxdate - $this->posxref, 3, $outputlangs->transnoentities("Ref"), 1, 'L');
$pdf->SetXY($this->posxdate, $curY); $pdf->SetXY($this->posxdate, $curY);
$pdf->MultiCell($this->posxsociety - $this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C'); $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C');
$pdf->SetXY($this->posxsociety, $curY); $pdf->SetXY($this->posxsociety, $curY);
$titlethirdparty = $outputlangs->transnoentities("ThirdParty"); $titlethirdparty = $outputlangs->transnoentities("ThirdParty");
if ($classname == 'ExpenseReport') $titlethirdparty = $langs->trans("User"); if ($classname == 'ExpenseReport') $titlethirdparty = $langs->trans("User");
$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $titlethirdparty, 1, 'L'); $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $titlethirdparty, 1, 'L');
if (empty($value['disableamount'])) { if (empty($value['disableamount'])) {
$pdf->SetXY($this->posxamountht, $curY); $pdf->SetXY($this->posxamountht, $curY);
$pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHTShort"), 1, 'R'); $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHTShort"), 1, 'R');
$pdf->SetXY($this->posxamountttc, $curY); $pdf->SetXY($this->posxamountttc, $curY);
$pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTCShort"), 1, 'R'); $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTCShort"), 1, 'R');
} else { } else {
$pdf->SetXY($this->posxamountht, $curY); $pdf->SetXY($this->posxamountht, $curY);
$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
} }
$pdf->SetXY($this->posxstatut, $curY); $pdf->SetXY($this->posxstatut, $curY);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Status"), 1, 'R'); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Status"), 1, 'R');
if (is_array($elementarray) && count($elementarray) > 0) if (is_array($elementarray) && count($elementarray) > 0)
{ {
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$total_ht = 0; $total_ht = 0;
$total_ttc = 0; $total_ttc = 0;
$num = count($elementarray); $num = count($elementarray);
// Loop on each lines // Loop on each lines
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++)
{ {
$curY = $nexY; $curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
$pdf->setTopMargin($tab_top_newpage); $pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation($this->orientation, 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation($this->orientation, 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore = $pdf->getPage(); $pageposbefore = $pdf->getPage();
// Description of line // Description of line
$idofelement = $elementarray[$i]; $idofelement = $elementarray[$i];
if ($classname == 'ExpenseReport') if ($classname == 'ExpenseReport')
{ {
// We get id of expense report // We get id of expense report
$expensereportline = new ExpenseReportLine($this->db); $expensereportline = new ExpenseReportLine($this->db);
$expensereportline->fetch($idofelement); $expensereportline->fetch($idofelement);
$idofelement = $expensereportline->fk_expensereport; $idofelement = $expensereportline->fk_expensereport;
} }
$element = new $classname($this->db); $element = new $classname($this->db);
$element->fetch($idofelement); $element->fetch($idofelement);
$element->fetch_thirdparty(); $element->fetch_thirdparty();
// print $classname; // print $classname;
$qualifiedfortotal = true; $qualifiedfortotal = true;
if ($key == 'invoice') { if ($key == 'invoice') {
if ($element->close_code == 'replaced') if ($element->close_code == 'replaced')
$qualifiedfortotal = false; // Replacement invoice $qualifiedfortotal = false; // Replacement invoice
} }
$showpricebeforepagebreak = 1; $showpricebeforepagebreak = 1;
$pdf->startTransaction(); $pdf->startTransaction();
// Label // Label
$pdf->SetXY($this->posxref, $curY); $pdf->SetXY($this->posxref, $curY);
$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak if ($pageposafter > $pageposbefore) // There is a pagebreak
{ {
$pdf->rollbackTransaction(true); $pdf->rollbackTransaction(true);
$pageposafter = $pageposbefore; $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit; //print $pageposafter.'-'.$pageposbefore;exit;
$pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
// Label // Label
$pdf->SetXY($this->posxref, $curY); $pdf->SetXY($this->posxref, $curY);
$posybefore = $pdf->GetY(); $posybefore = $pdf->GetY();
$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY(); $posyafter = $pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
{ {
if ($i == ($num - 1)) // No more lines, and no space left to show total, so we create a new page if ($i == ($num - 1)) // No more lines, and no space left to show total, so we create a new page
{ {
$pdf->AddPage($this->orientation, '', true); $pdf->AddPage($this->orientation, '', true);
if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pageposafter + 1); $pdf->setPage($pageposafter + 1);
} }
} else { } else {
// We found a page break // We found a page break
// Allows data in the first page if description is long enough to break in multiples pages // Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1; $showpricebeforepagebreak = 1;
else $showpricebeforepagebreak = 0; else $showpricebeforepagebreak = 0;
$forcedesconsamepage = 1; $forcedesconsamepage = 1;
if ($forcedesconsamepage) if ($forcedesconsamepage)
{ {
$pdf->rollbackTransaction(true); $pdf->rollbackTransaction(true);
$pageposafter = $pageposbefore; $pageposafter = $pageposbefore;
$pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
$pdf->AddPage($this->orientation, '', true); $pdf->AddPage($this->orientation, '', true);
if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pageposafter + 1); $pdf->setPage($pageposafter + 1);
$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
$pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
$pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
$curY = $tab_top_newpage + $heightoftitleline + 1; $curY = $tab_top_newpage + $heightoftitleline + 1;
// Label // Label
$pdf->SetXY($this->posxref, $curY); $pdf->SetXY($this->posxref, $curY);
$posybefore = $pdf->GetY(); $posybefore = $pdf->GetY();
$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY(); $posyafter = $pdf->GetY();
} }
} }
//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
} else // No pagebreak } else // No pagebreak
{ {
$pdf->commitTransaction(); $pdf->commitTransaction();
} }
$posYAfterDescription = $pdf->GetY(); $posYAfterDescription = $pdf->GetY();
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore); $pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute); $pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation($this->orientation, 1, 0); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation($this->orientation, 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description is moved completely on next page // We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
//var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
} }
$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
// Date // Date
if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order')
$date = $element->date_commande; $date = $element->date_commande;
else { else {
$date = $element->date; $date = $element->date;
if (empty($date)) if (empty($date))
$date = $element->datep; $date = $element->datep;
if (empty($date)) if (empty($date))
$date = $element->date_contrat; $date = $element->date_contrat;
if (empty($date)) if (empty($date))
$date = $element->datev; // Fiche inter $date = $element->datev; // Fiche inter
} }
$pdf->SetXY($this->posxdate, $curY); $pdf->SetXY($this->posxdate, $curY);
$pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C'); $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C');
$pdf->SetXY($this->posxsociety, $curY); $pdf->SetXY($this->posxsociety, $curY);
if ($classname == 'ExpenseReport') if ($classname == 'ExpenseReport')
{ {
$fuser = new User($this->db); $fuser = new User($this->db);
$fuser->fetch($element->fk_user_author); $fuser->fetch($element->fk_user_author);
$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L'); $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L');
} else { } else {
$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty) ? $element->thirdparty->name : ''), 1, 'L'); $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty) ? $element->thirdparty->name : ''), 1, 'L');
} }
// Amount without tax // Amount without tax
if (empty($value['disableamount'])) { if (empty($value['disableamount'])) {
$pdf->SetXY($this->posxamountht, $curY); $pdf->SetXY($this->posxamountht, $curY);
$pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($element->total_ht) : ''), 1, 'R'); $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($element->total_ht) : ''), 1, 'R');
$pdf->SetXY($this->posxamountttc, $curY); $pdf->SetXY($this->posxamountttc, $curY);
$pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($element->total_ttc) : ''), 1, 'R'); $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($element->total_ttc) : ''), 1, 'R');
} else { } else {
$pdf->SetXY($this->posxamountht, $curY); $pdf->SetXY($this->posxamountht, $curY);
if ($key == 'agenda') if ($key == 'agenda')
{ {
$textforamount = dol_trunc($element->label, 26); $textforamount = dol_trunc($element->label, 26);
$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, $textforamount, 1, 'L'); $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, $textforamount, 1, 'L');
} else { } else {
$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
} }
} }
// Status // Status
if ($element instanceof CommonInvoice) { if ($element instanceof CommonInvoice) {
// This applies for Facture and FactureFournisseur // This applies for Facture and FactureFournisseur
$outputstatut = $element->getLibStatut(1, $element->getSommePaiement()); $outputstatut = $element->getLibStatut(1, $element->getSommePaiement());
} else { } else {
$outputstatut = $element->getLibStatut(1); $outputstatut = $element->getLibStatut(1);
} }
$pdf->SetXY($this->posxstatut, $curY); $pdf->SetXY($this->posxstatut, $curY);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputstatut, 1, 'R', false, 1, '', '', true, 0, true); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputstatut, 1, 'R', false, 1, '', '', true, 0, true);
if ($qualifiedfortotal) { if ($qualifiedfortotal) {
$total_ht = $total_ht + $element->total_ht; $total_ht = $total_ht + $element->total_ht;
$total_ttc = $total_ttc + $element->total_ttc; $total_ttc = $total_ttc + $element->total_ttc;
} }
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$curY = $nexY; $curY = $nexY;
} }
if (empty($value['disableamount'])) { if (empty($value['disableamount'])) {
$curY = $nexY; $curY = $nexY;
$pdf->SetXY($this->posxref, $curY); $pdf->SetXY($this->posxref, $curY);
$pdf->MultiCell($this->posxamountttc - $this->posxref, 3, "TOTAL", 1, 'L'); $pdf->MultiCell($this->posxamountttc - $this->posxref, 3, "TOTAL", 1, 'L');
$pdf->SetXY($this->posxamountht, $curY); $pdf->SetXY($this->posxamountht, $curY);
$pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($total_ht) : ''), 1, 'R'); $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($total_ht) : ''), 1, 'R');
$pdf->SetXY($this->posxamountttc, $curY); $pdf->SetXY($this->posxamountttc, $curY);
$pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($total_ttc) : ''), 1, 'R'); $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($total_ttc) : ''), 1, 'R');
$pdf->SetXY($this->posxstatut, $curY); $pdf->SetXY($this->posxstatut, $curY);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Nb")." ".$num, 1, 'L'); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Nb")." ".$num, 1, 'L');
} }
$nexY = $pdf->GetY() + 5; $nexY = $pdf->GetY() + 5;
$curY = $nexY; $curY = $nexY;
} }
} }
$nexY += 2; // Add space between lines $nexY += 2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages // Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter) while ($pagenb < $pageposafter)
@ -667,8 +667,8 @@ class pdf_beluga extends ModelePDFProjects
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -759,7 +759,7 @@ class pdf_beluga extends ModelePDFProjects
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetFont('', 'B', $default_font_size + 3);
$posx = $this->page_largeur - $this->marge_droite - 100; $posx = $this->page_largeur - $this->marge_droite - 100;
$posy = $this->marge_haute; $posy = $this->marge_haute;
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
@ -770,8 +770,8 @@ class pdf_beluga extends ModelePDFProjects
{ {
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -808,7 +808,7 @@ class pdf_beluga extends ModelePDFProjects
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Project $object Object to show * @param Project $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output

View File

@ -97,7 +97,7 @@ class pdf_timespent extends ModelePDFProjects
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Fonction generant le projet sur le disque * Fonction generant le projet sur le disque
* *
@ -107,7 +107,7 @@ class pdf_timespent extends ModelePDFProjects
*/ */
public function write_file($object, $outputlangs) public function write_file($object, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf, $hookmanager, $langs, $user; global $conf, $hookmanager, $langs, $user;
if (!is_object($outputlangs)) $outputlangs = $langs; if (!is_object($outputlangs)) $outputlangs = $langs;
@ -154,30 +154,30 @@ class pdf_timespent extends ModelePDFProjects
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
$heightforinfotot = 40; // Height reserved to output the info and total part $heightforinfotot = 40; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
// Complete object by loading several other informations // Complete object by loading several other informations
$task = new Task($this->db); $task = new Task($this->db);
$tasksarray = $task->getTasksArray(0, 0, $object->id); $tasksarray = $task->getTasksArray(0, 0, $object->id);
if (!$object->id > 0) // Special case when used with object = specimen, we may return all lines if (!$object->id > 0) // Special case when used with object = specimen, we may return all lines
{ {
$tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray))); $tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
} }
$object->lines = $tasksarray; $object->lines = $tasksarray;
$nblines = count($object->lines); $nblines = count($object->lines);
@ -423,8 +423,8 @@ class pdf_timespent extends ModelePDFProjects
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -462,7 +462,7 @@ class pdf_timespent extends ModelePDFProjects
$heightoftitleline = 10; $heightoftitleline = 10;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetDrawColor(128, 128, 128); $pdf->SetDrawColor(128, 128, 128);
@ -515,7 +515,7 @@ class pdf_timespent extends ModelePDFProjects
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetFont('', 'B', $default_font_size + 3);
$posx = $this->page_largeur - $this->marge_droite - 100; $posx = $this->page_largeur - $this->marge_droite - 100;
$posy = $this->marge_haute; $posy = $this->marge_haute;
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
@ -526,8 +526,8 @@ class pdf_timespent extends ModelePDFProjects
{ {
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -586,19 +586,19 @@ class pdf_timespent extends ModelePDFProjects
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Project $object Object to show * @param Project $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @param int $hidefreetext 1=Hide free text * @param int $hidefreetext 1=Hide free text
* @return integer * @return integer
*/ */
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{ {
global $conf; global $conf;
$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
} }
} }

View File

@ -43,75 +43,75 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
class pdf_azur extends ModelePDFPropales class pdf_azur extends ModelePDFPropales
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
*/ */
public $db; public $db;
/** /**
* @var string model name * @var string model name
*/ */
public $name; public $name;
/** /**
* @var string model description (short text) * @var string model description (short text)
*/ */
public $description; public $description;
/** /**
* @var string Save the name of generated file as the main doc when generating a doc with this template * @var string Save the name of generated file as the main doc when generating a doc with this template
*/ */
public $update_main_doc_field; public $update_main_doc_field;
/** /**
* @var string document type * @var string document type
*/ */
public $type; public $type;
/** /**
* @var array Minimum version of PHP required by module. * @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.6 = array(5, 6) * e.g.: PHP ≥ 5.6 = array(5, 6)
*/ */
public $phpmin = array(5, 6); public $phpmin = array(5, 6);
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/** /**
* @var int page_largeur * @var int page_largeur
*/ */
public $page_largeur; public $page_largeur;
/** /**
* @var int page_hauteur * @var int page_hauteur
*/ */
public $page_hauteur; public $page_hauteur;
/** /**
* @var array format * @var array format
*/ */
public $format; public $format;
/** /**
* @var int marge_gauche * @var int marge_gauche
*/ */
public $marge_gauche; public $marge_gauche;
/** /**
* @var int marge_droite * @var int marge_droite
*/ */
public $marge_droite; public $marge_droite;
/** /**
* @var int marge_haute * @var int marge_haute
*/ */
public $marge_haute; public $marge_haute;
/** /**
* @var int marge_basse * @var int marge_basse
*/ */
public $marge_basse; public $marge_basse;
/** /**
@ -200,21 +200,21 @@ class pdf_azur extends ModelePDFPropales
$this->atleastonediscount = 0; $this->atleastonediscount = 0;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Function to build pdf onto disk * Function to build pdf onto disk
* *
* @param Object $object Object to generate * @param Object $object Object to generate
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
// phpcs:enable // phpcs:enable
global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines; global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
if (!is_object($outputlangs)) $outputlangs = $langs; if (!is_object($outputlangs)) $outputlangs = $langs;
@ -237,7 +237,7 @@ class pdf_azur extends ModelePDFPropales
if (empty($object->lines[$i]->fk_product)) continue; if (empty($object->lines[$i]->fk_product)) continue;
$objphoto->fetch($object->lines[$i]->fk_product); $objphoto->fetch($object->lines[$i]->fk_product);
//var_dump($objphoto->ref);exit; //var_dump($objphoto->ref);exit;
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{ {
$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
@ -324,22 +324,22 @@ class pdf_azur extends ModelePDFPropales
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Create pdf instance // Create pdf instance
$pdf = pdf_getInstance($this->format); $pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
$pdf->Open(); $pdf->Open();
$pagenb = 0; $pagenb = 0;
@ -364,14 +364,14 @@ class pdf_azur extends ModelePDFPropales
} }
if (empty($this->atleastonediscount)) if (empty($this->atleastonediscount))
{ {
$delta = ($this->postotalht - $this->posxdiscount); $delta = ($this->postotalht - $this->posxdiscount);
$this->posxpicture += $delta; $this->posxpicture += $delta;
$this->posxtva += $delta; $this->posxtva += $delta;
$this->posxup += $delta; $this->posxup += $delta;
$this->posxqty += $delta; $this->posxqty += $delta;
$this->posxunit += $delta; $this->posxunit += $delta;
$this->posxdiscount += $delta; $this->posxdiscount += $delta;
// post of fields after are not modified, stay at same position // post of fields after are not modified, stay at same position
} }
// New page // New page
@ -379,12 +379,12 @@ class pdf_azur extends ModelePDFPropales
if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
$heightforinfotot = 40; // Height reserved to output the info and total part $heightforinfotot = 40; // Height reserved to output the info and total part
$heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0; $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
//print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit; //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFont('', '', $default_font_size - 1);
@ -392,7 +392,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
$tab_top = 90 + $top_shift; $tab_top = 90 + $top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
// Incoterm // Incoterm
@ -429,18 +429,18 @@ class pdf_azur extends ModelePDFPropales
if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
} }
} }
// Extrafields in note // Extrafields in note
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs); $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
if (!empty($extranote)) { if (!empty($extranote)) {
$notetoshow = dol_concatdesc($notetoshow, $extranote); $notetoshow = dol_concatdesc($notetoshow, $extranote);
} }
if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0) if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
{ {
$tmpuser = new User($this->db); $tmpuser = new User($this->db);
$tmpuser->fetch($object->user_author_id); $tmpuser->fetch($object->user_author_id);
$notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs); $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email; if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email;
if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone; if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
} }
if ($notetoshow) if ($notetoshow)
{ {
@ -630,7 +630,7 @@ class pdf_azur extends ModelePDFPropales
$localtax2_type = $localtaxtmp_array[2]; $localtax2_type = $localtaxtmp_array[2];
} }
// retrieve global local tax // retrieve global local tax
if ($localtax1_type && $localtax1ligne != 0) if ($localtax1_type && $localtax1ligne != 0)
$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
if ($localtax2_type && $localtax2ligne != 0) if ($localtax2_type && $localtax2ligne != 0)
@ -714,7 +714,7 @@ class pdf_azur extends ModelePDFPropales
// Customer signature area // Customer signature area
if (empty($conf->global->PROPAL_DISABLE_SIGNATURE)) if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
{ {
$posy = $this->_signature_area($pdf, $object, $posy, $outputlangs); $posy = $this->_signature_area($pdf, $object, $posy, $outputlangs);
} }
// Pied de page // Pied de page
@ -802,8 +802,8 @@ class pdf_azur extends ModelePDFPropales
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -823,23 +823,23 @@ class pdf_azur extends ModelePDFPropales
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show payments table * Show payments table
* *
* @param TCPDF $pdf Object PDF * @param TCPDF $pdf Object PDF
* @param Object $object Object proposal * @param Object $object Object proposal
* @param int $posy Position y in PDF * @param int $posy Position y in PDF
* @param Translate $outputlangs Object langs for output * @param Translate $outputlangs Object langs for output
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs) protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show miscellaneous information (payment mode, payment term, ...) * Show miscellaneous information (payment mode, payment term, ...)
* *
@ -851,7 +851,7 @@ class pdf_azur extends ModelePDFPropales
*/ */
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf, $mysoc; global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -869,10 +869,10 @@ class pdf_azur extends ModelePDFPropales
$posxval = 52; $posxval = 52;
// Show shipping date // Show shipping date
if (!empty($object->date_livraison)) if (!empty($object->date_livraison))
{ {
$outputlangs->load("sendings"); $outputlangs->load("sendings");
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
@ -882,7 +882,7 @@ class pdf_azur extends ModelePDFPropales
$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true); $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
$pdf->MultiCell(80, 4, $dlp, 0, 'L'); $pdf->MultiCell(80, 4, $dlp, 0, 'L');
$posy = $pdf->GetY() + 1; $posy = $pdf->GetY() + 1;
} elseif ($object->availability_code || $object->availability) // Show availability conditions } elseif ($object->availability_code || $object->availability) // Show availability conditions
{ {
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -969,13 +969,13 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
$posy = $pdf->GetY() + 1; $posy = $pdf->GetY() + 1;
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
{ {
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
$posy = $pdf->GetY() + 2; $posy = $pdf->GetY() + 2;
} }
} }
if ($conf->global->FACTURE_CHQ_NUMBER == -1) if ($conf->global->FACTURE_CHQ_NUMBER == -1)
{ {
@ -984,13 +984,13 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
$posy = $pdf->GetY() + 1; $posy = $pdf->GetY() + 1;
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
{ {
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
$posy = $pdf->GetY() + 2; $posy = $pdf->GetY() + 2;
} }
} }
} }
} }
@ -1019,7 +1019,7 @@ class pdf_azur extends ModelePDFPropales
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show total to pay * Show total to pay
* *
@ -1032,7 +1032,7 @@ class pdf_azur extends ModelePDFPropales
*/ */
protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf, $mysoc; global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -1104,7 +1104,7 @@ class pdf_azur extends ModelePDFPropales
} }
} }
} }
//} //}
//Local tax 2 before VAT //Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{ //{
@ -1195,7 +1195,7 @@ class pdf_azur extends ModelePDFPropales
} }
} }
} }
//} //}
//Local tax 2 after VAT //Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{ //{
@ -1205,7 +1205,7 @@ class pdf_azur extends ModelePDFPropales
foreach ($localtax_rate as $tvakey => $tvaval) foreach ($localtax_rate as $tvakey => $tvaval)
{ {
// retrieve global local tax // retrieve global local tax
if ($tvakey != 0) // On affiche pas taux 0 if ($tvakey != 0) // On affiche pas taux 0
{ {
//$this->atleastoneratenotnull++; //$this->atleastoneratenotnull++;
@ -1434,7 +1434,7 @@ class pdf_azur extends ModelePDFPropales
// Show Draft Watermark // Show Draft Watermark
if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK))) if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK)))
{ {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK); pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
} }
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -1460,8 +1460,8 @@ class pdf_azur extends ModelePDFPropales
} }
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -1543,16 +1543,16 @@ class pdf_azur extends ModelePDFPropales
// Get contact // Get contact
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
{ {
$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
if (count($arrayidcontact) > 0) if (count($arrayidcontact) > 0)
{ {
$usertmp = new User($this->db); $usertmp = new User($this->db);
$usertmp->fetch($arrayidcontact[0]); $usertmp->fetch($arrayidcontact[0]);
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
} }
} }
$posy += 2; $posy += 2;
@ -1664,7 +1664,7 @@ class pdf_azur extends ModelePDFPropales
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
@ -1679,7 +1679,7 @@ class pdf_azur extends ModelePDFPropales
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show area for the customer to sign * Show area for the customer to sign
* *
@ -1691,7 +1691,7 @@ class pdf_azur extends ModelePDFPropales
*/ */
protected function _signature_area(&$pdf, $object, $posy, $outputlangs) protected function _signature_area(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$tab_top = $posy + 4; $tab_top = $posy + 4;

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
*/ */
class pdf_squille extends ModelePdfReception class pdf_squille extends ModelePdfReception
{ {
public $emetteur; // Objet societe qui emet public $emetteur; // Objet societe qui emet
/** /**
@ -83,17 +83,17 @@ class pdf_squille extends ModelePdfReception
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format
{ {
$this->posxweightvol -= 20; $this->posxweightvol -= 20;
$this->posxpicture -= 20; $this->posxpicture -= 20;
$this->posxqtyordered -= 20; $this->posxqtyordered -= 20;
$this->posxqtytoship -= 20; $this->posxqtytoship -= 20;
} }
if (!empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) if (!empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
{ {
$this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
$this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
$this->posxqtyordered = $this->posxqtytoship; $this->posxqtyordered = $this->posxqtytoship;
} }
} }
@ -103,11 +103,11 @@ class pdf_squille extends ModelePdfReception
* *
* @param Object $object Object reception to generate (or id if old method) * @param Object $object Object reception to generate (or id if old method)
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
@ -124,15 +124,15 @@ class pdf_squille extends ModelePdfReception
$nblines = count($object->lines); $nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show // Loop on each lines to detect if there is at least one image to show
$realpatharray = array(); $realpatharray = array();
if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
{ {
$objphoto = new Product($this->db); $objphoto = new Product($this->db);
for ($i = 0; $i < $nblines; $i++) for ($i = 0; $i < $nblines; $i++)
{ {
if (empty($object->lines[$i]->fk_product)) continue; if (empty($object->lines[$i]->fk_product)) continue;
$objphoto = new Product($this->db); $objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product); $objphoto->fetch($object->lines[$i]->fk_product);
@ -142,28 +142,28 @@ class pdf_squille extends ModelePdfReception
$realpath = ''; $realpath = '';
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
if ($obj['photo_vignette']) if ($obj['photo_vignette'])
{ {
$filename = $obj['photo_vignette']; $filename = $obj['photo_vignette'];
} else { } else {
$filename = $obj['photo']; $filename = $obj['photo'];
} }
} else { } else {
$filename = $obj['photo']; $filename = $obj['photo'];
} }
$realpath = $dir.$filename; $realpath = $dir.$filename;
break; break;
} }
if ($realpath) $realpatharray[$i] = $realpath; if ($realpath) $realpatharray[$i] = $realpath;
} }
} }
if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol; if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
if ($conf->reception->dir_output) if ($conf->reception->dir_output)
{ {
@ -206,22 +206,22 @@ class pdf_squille extends ModelePdfReception
$pdf = pdf_getInstance($this->format); $pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$heightforinfotot = 8; // Height reserved to output the info and total part $heightforinfotot = 8; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // Set path to the background PDF File
if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
$pdf->Open(); $pdf->Open();
$pagenb = 0; $pagenb = 0;
@ -458,12 +458,12 @@ class pdf_squille extends ModelePdfReception
//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C'); //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) { if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
$pdf->SetXY($this->posxqtyordered, $curY); $pdf->SetXY($this->posxqtyordered, $curY);
if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) { if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) {
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C'); $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
$totalOrdered += $object->lines[$i]->qty_asked; $totalOrdered += $object->lines[$i]->qty_asked;
} }
$fk_commandefourndet = $object->lines[$i]->fk_commandefourndet; $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
} }
$pdf->SetXY($this->posxqtytoship, $curY); $pdf->SetXY($this->posxqtytoship, $curY);
@ -550,8 +550,8 @@ class pdf_squille extends ModelePdfReception
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0)
{ {
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
if (!empty($conf->global->MAIN_UMASK)) if (!empty($conf->global->MAIN_UMASK))
@ -586,9 +586,9 @@ class pdf_squille extends ModelePdfReception
// phpcs:enable // phpcs:enable
global $conf, $mysoc; global $conf, $mysoc;
$sign = 1; $sign = 1;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$tab2_top = $posy; $tab2_top = $posy;
$tab2_hl = 4; $tab2_hl = 4;
@ -619,8 +619,8 @@ class pdf_squille extends ModelePdfReception
// Set trueVolume and volume_units not currently stored into database // Set trueVolume and volume_units not currently stored into database
if ($object->trueWidth && $object->trueHeight && $object->trueDepth) if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
{ {
$object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
$object->volume_units = $object->size_units * 3; $object->volume_units = $object->size_units * 3;
} }
if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
@ -628,41 +628,41 @@ class pdf_squille extends ModelePdfReception
if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
$pdf->SetFillColor(255, 255, 255); $pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
{ {
$pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1); $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
} }
$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
} }
// Total Weight // Total Weight
if ($totalWeighttoshow) if ($totalWeighttoshow)
{ {
$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
$index++; $index++;
} }
if ($totalVolumetoshow) if ($totalVolumetoshow)
{ {
$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
$index++; $index++;
} }
if (!$totalWeighttoshow && !$totalVolumetoshow) $index++; if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
@ -719,15 +719,15 @@ class pdf_squille extends ModelePdfReception
$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C'); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C');
} }
if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
{ {
$pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height); $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
if (empty($hidetop)) if (empty($hidetop))
{ {
$pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1); $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C'); $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
} }
} }
$pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height); $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
if (empty($hidetop)) if (empty($hidetop))
@ -776,7 +776,7 @@ class pdf_squille extends ModelePdfReception
// Show Draft Watermark // Show Draft Watermark
if ($object->statut == 0 && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK))) if ($object->statut == 0 && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK)))
{ {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->RECEPTION_DRAFT_WATERMARK); pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->RECEPTION_DRAFT_WATERMARK);
} }
//Prepare la suite //Prepare la suite
@ -796,8 +796,8 @@ class pdf_squille extends ModelePdfReception
{ {
if (is_readable($logo)) if (is_readable($logo))
{ {
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { } else {
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
@ -853,10 +853,10 @@ class pdf_squille extends ModelePdfReception
// Date planned delivery // Date planned delivery
if (!empty($object->date_delivery)) if (!empty($object->date_delivery))
{ {
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R'); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
} }
if (!empty($object->thirdparty->code_fournisseur)) if (!empty($object->thirdparty->code_fournisseur))
@ -875,7 +875,7 @@ class pdf_squille extends ModelePdfReception
$origin = $object->origin; $origin = $object->origin;
$origin_id = $object->origin_id; $origin_id = $object->origin_id;
// TODO move to external function // TODO move to external function
if (!empty($conf->fournisseur->enabled)) // commonly $origin='commande' if (!empty($conf->fournisseur->enabled)) // commonly $origin='commande'
{ {
$outputlangs->load('orders'); $outputlangs->load('orders');
@ -885,7 +885,7 @@ class pdf_squille extends ModelePdfReception
$result = $linkedobject->fetch($origin_id); $result = $linkedobject->fetch($origin_id);
if ($result >= 0) if ($result >= 0)
{ {
//$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
$pdf->SetFont('', '', $default_font_size - 2); $pdf->SetFont('', '', $default_font_size - 2);
$text = $linkedobject->ref; $text = $linkedobject->ref;
@ -1002,7 +1002,7 @@ class pdf_squille extends ModelePdfReception
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param TCPDF $pdf PDF * @param TCPDF $pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output

Some files were not shown because too many files have changed in this diff Show More