Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Regis Houssin 2023-03-23 11:06:31 +01:00
commit 8bc0e46e87
163 changed files with 2387 additions and 1223 deletions

View File

@ -72,10 +72,6 @@ jobs:
if: type = pull_request OR type = push if: type = pull_request OR type = push
php: '8.1' php: '8.1'
env: DB=mysql env: DB=mysql
- stage: PHP Dev
if: type = push AND branch = develop
php: nightly
env: DB=mysql
- stage: PHP Dev - stage: PHP Dev
if: type = push AND branch = 17.0 if: type = push AND branch = 17.0
php: nightly php: nightly

View File

@ -31,7 +31,7 @@ NuSoap 0.9.5 LGPL 2.1+ Yes
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency
ParseDown 1.6 MIT License Yes Markdown parser ParseDown 1.6 MIT License Yes Markdown parser
PCLZip 2.8.4 LGPL-3+ Yes Library to zip/unzip files PCLZip 2.8.4 LGPL-3+ Yes Library to zip/unzip files
PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers PHPDebugBar 1.18.2 MIT License Yes Used only by the module "debugbar" for developers
PHP-Imap 2.7.2 MIT License Yes Library to use IMAP with OAuth PHP-Imap 2.7.2 MIT License Yes Library to use IMAP with OAuth
PHPSpreadSheet 1.8.2 LGPL-2.1+ Yes Read/Write XLS files, read ODS files PHPSpreadSheet 1.8.2 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
php-iban 4.1.1 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP php-iban 4.1.1 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP

View File

@ -4,7 +4,6 @@
* Copyright (C) 2013-2022 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2013-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2022 Waël Almoman <info@almoman.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -45,7 +44,7 @@ $cancel = GETPOST('cancel', 'aZ09');
$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')
$id = GETPOST('id', 'int'); // id of record $id = GETPOST('id', 'int'); // id of record
$mode = $mode = $action == 'create' ? "_tmp" : GETPOST('mode', 'aZ09'); // '' or '_tmp' $mode = GETPOST('mode', 'aZ09'); // '' or '_tmp'
$piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id) $piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id)
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
@ -55,15 +54,10 @@ $accountingaccount_number = GETPOST('accountingaccount_number', 'alphanohtml');
$accountingaccount->fetch(null, $accountingaccount_number, true); $accountingaccount->fetch(null, $accountingaccount_number, true);
$accountingaccount_label = $accountingaccount->label; $accountingaccount_label = $accountingaccount->label;
$journal_code = GETPOST('code_journal', 'alpha') ? GETPOST('code_journal', 'alpha') : "NULL"; $journal_code = GETPOST('code_journal', 'alpha');
$accountingjournal->fetch(null, $journal_code); $accountingjournal->fetch(null, $journal_code);
$journal_label = $accountingjournal->label; $journal_label = $accountingjournal->label;
$next_num_mvt = (int) GETPOST('next_num_mvt', 'alpha');
$doc_ref = (string) GETPOST('doc_ref', 'alpha');
$doc_date = (string) GETPOST('doc_date', 'alpha');
$doc_date = $doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
$subledger_account = GETPOST('subledger_account', 'alphanohtml'); $subledger_account = GETPOST('subledger_account', 'alphanohtml');
if ($subledger_account == -1) { if ($subledger_account == -1) {
$subledger_account = null; $subledger_account = null;
@ -78,10 +72,6 @@ $save = GETPOST('save', 'alpha');
if (!empty($save)) { if (!empty($save)) {
$action = 'add'; $action = 'add';
} }
$valid = GETPOST('validate', 'alpha');
if (!empty($valid)) {
$action = 'valid';
}
$update = GETPOST('update', 'alpha'); $update = GETPOST('update', 'alpha');
if (!empty($update)) { if (!empty($update)) {
$action = 'confirm_update'; $action = 'confirm_update';
@ -166,79 +156,64 @@ if ($action == "confirm_update") {
} }
} }
} }
} elseif ($action == 'add' || $action == 'valid') { } elseif ($action == "add") {
$error = 0; $error = 0;
if (array_sum($debit) != array_sum($credit)) { if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) {
$action = 'add'; $error++;
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$action = '';
}
if (empty($accountingaccount_number) || $accountingaccount_number == '-1') {
$error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
$action = '';
} }
foreach ($accountingaccount_number as $key => $value) { if (!$error) {
$accountingaccount->fetch(null, $accountingaccount_number[$key], true); $object = new BookKeeping($db);
$accountingaccount_label[$key] = $accountingaccount->label[$key];
// if one added row is empty remove it before continue $object->numero_compte = $accountingaccount_number;
if ($key < 1 && (empty($accountingaccount_number[$key]) || $accountingaccount_number[$key] == '-1') || (floatval($debit[$key]) == 0.0) && (floatval($credit[$key]) == 0.0)) { $object->subledger_account = $subledger_account;
continue; $object->subledger_label = $subledger_label;
$object->label_compte = $accountingaccount_label;
$object->label_operation = $label_operation;
$object->debit = $debit;
$object->credit = $credit;
$object->doc_date = (string) GETPOST('doc_date', 'alpha');
$object->doc_type = (string) GETPOST('doc_type', 'alpha');
$object->piece_num = $piece_num;
$object->doc_ref = (string) GETPOST('doc_ref', 'alpha');
$object->code_journal = $journal_code;
$object->journal_label = $journal_label;
$object->fk_doc = GETPOSTINT('fk_doc');
$object->fk_docdet = GETPOSTINT('fk_docdet');
if (floatval($debit) != 0.0) {
$object->montant = $debit; // deprecated
$object->amount = $debit;
$object->sens = 'D';
} }
if ((floatval($debit[$key]) != 0.0) && (floatval($credit[$key]) != 0.0)) { if (floatval($credit) != 0.0) {
$error++; $object->montant = $credit; // deprecated
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); $object->amount = $credit;
$object->sens = 'C';
}
$result = $object->createStd($user, false, $mode);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
if ($mode != '_tmp') {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
}
$debit = 0;
$credit = 0;
$action = ''; $action = '';
} }
if (empty($accountingaccount_number[$key]) || $accountingaccount_number[$key] == '-1') {
$error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
$action = '';
}
if (!$error) {
$object = new BookKeeping($db);
$object->numero_compte = $accountingaccount_number[$key];
$object->subledger_account = $subledger_account[$key];
$object->subledger_label = $subledger_label[$key];
$object->label_compte = $accountingaccount_label[$key];
$object->label_operation = $label_operation[$key];
$object->debit = price2num($debit[$key]);
$object->credit = price2num($credit[$key]);
$object->doc_date = $doc_date;
$object->doc_type = (string) GETPOST('doc_type', 'alpha');
$object->piece_num = $piece_num;
$object->doc_ref = $doc_ref;
$object->code_journal = $journal_code;
$object->journal_label = $journal_label;
$object->fk_doc = GETPOSTINT('fk_doc');
$object->fk_docdet = GETPOSTINT('fk_docdet');
if (floatval($debit[$key]) != 0.0) {
$object->montant = $object->debit; // deprecated
$object->amount = $object->debit;
$object->sens = 'D';
}
if (floatval($credit[$key]) != 0.0) {
$object->montant = $object->credit; // deprecated
$object->amount = $object->credit;
$object->sens = 'C';
}
$result = $object->createStd($user, false, $mode);
if ($result < 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
if (empty($error)) {
if ($mode != '_tmp') {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
}
$debit = 0;
$credit = 0;
$action = $action == 'add' ? '' : $action ; // stay in valid mode when not adding line
} }
} elseif ($action == "confirm_delete") { } elseif ($action == "confirm_delete") {
$object = new BookKeeping($db); $object = new BookKeeping($db);
@ -255,28 +230,17 @@ if ($action == "confirm_update") {
} }
} }
$action = ''; $action = '';
} elseif ($action == 'create') { } elseif ($action == "confirm_create") {
$error = 0; $error = 0;
$object = new BookKeeping($db); $object = new BookKeeping($db);
$next_num_mvt = !empty($next_num_mvt) ? $next_num_mvt : $object->getNextNumMvt('_tmp');
$doc_ref = !empty($doc_ref) ? $doc_ref : $next_num_mvt;
if (empty($doc_date)) {
$tmp_date = dol_getdate(dol_now());
$_POST['doc_dateday'] = $tmp_date['mday'];
$_POST['doc_datemonth'] = $tmp_date['mon'];
$_POST['doc_dateyear'] = $tmp_date['year'];
unset($tmp_date);
}
if (!$journal_code || $journal_code == '-1') { if (!$journal_code || $journal_code == '-1') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (empty($doc_ref)) { if (!GETPOST('doc_ref', 'alpha')) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Piece")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Piece")), null, 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
@ -288,8 +252,8 @@ if ($action == "confirm_update") {
$object->credit = 0; $object->credit = 0;
$object->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $object->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
$object->doc_type = GETPOST('doc_type', 'alpha'); $object->doc_type = GETPOST('doc_type', 'alpha');
$object->piece_num = $next_num_mvt; $object->piece_num = GETPOST('next_num_mvt', 'alpha');
$object->doc_ref = $doc_ref; $object->doc_ref = GETPOST('doc_ref', 'alpha');
$object->code_journal = $journal_code; $object->code_journal = $journal_code;
$object->journal_label = $journal_label; $object->journal_label = $journal_label;
$object->fk_doc = 0; $object->fk_doc = 0;
@ -338,7 +302,7 @@ if ($action == 'setjournal') {
} }
if ($action == 'setdocref') { if ($action == 'setdocref') {
$refdoc = $doc_ref; $refdoc = GETPOST('doc_ref', 'alpha');
$result = $object->updateByMvt($piece_num, 'doc_ref', $refdoc, $mode); $result = $object->updateByMvt($piece_num, 'doc_ref', $refdoc, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -369,7 +333,7 @@ if ($action == 'valid') {
$html = new Form($db); $html = new Form($db);
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
$title = $langs->trans($mode =="_tmp" ? "CreateMvts": "UpdateMvts"); $title = $langs->trans("CreateMvts");
llxHeader('', $title); llxHeader('', $title);
@ -379,37 +343,28 @@ if ($action == 'delete') {
print $formconfirm; print $formconfirm;
} }
if ($action == 'create') {
print load_fiche_titre($title);
$object = new BookKeeping($db); $object = new BookKeeping($db);
$result = $object->fetchPerMvt($piece_num, $mode); $next_num_mvt = $object->getNextNumMvt('_tmp');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
if (!empty($object->piece_num)) { if (empty($next_num_mvt)) {
$backlink = '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">'.$langs->trans('BackToList').'</a>'; dol_print_error('', 'Failed to get next piece number');
print load_fiche_titre($langs->trans($mode =="_tmp" ? "CreateMvts": "UpdateMvts"), $backlink);
print '<form action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'" />';
} }
$head = array();
$h = 0;
$head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode ? '&mode='.$mode : '');
$head[$h][1] = $langs->trans("Transaction");
$head[$h][2] = 'transaction';
$h++;
print dol_get_fiche_head($head, 'transaction', '', -1); print '<form action="'.$_SERVER["PHP_SELF"].'" name="create_mvt" method="POST">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="confirm_create">'."\n";
print '<input type="hidden" name="next_num_mvt" value="'.$next_num_mvt.'">'."\n";
print '<input type="hidden" name="mode" value="_tmp">'."\n";
//dol_banner_tab($object, '', $backlink); print dol_get_fiche_head();
print '<div class="fichecenter">'; print '<table class="border centpercent">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
/*print '<tr>'; /*print '<tr>';
print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("NumPiece") . '</td>'; print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("NumPiece") . '</td>';
@ -419,7 +374,7 @@ if (!empty($object->piece_num)) {
print '<tr>'; print '<tr>';
print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("Docdate").'</td>'; print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("Docdate").'</td>';
print '<td>'; print '<td>';
print $html->selectDate($doc_date, 'doc_date', '', '', '', "create_mvt", 1, 1); print $html->selectDate('', 'doc_date', '', '', '', "create_mvt", 1, 1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -430,218 +385,298 @@ if (!empty($object->piece_num)) {
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("Piece").'</td>'; print '<td class="fieldrequired">'.$langs->trans("Piece").'</td>';
print '<td><input type="text" class="minwidth200" name="doc_ref" value="'.$doc_ref.'" /></td>'; print '<td><input type="text" class="minwidth200" name="doc_ref" value="'.GETPOST('doc_ref', 'alpha').'"></td>';
print '</tr>'; print '</tr>';
/* /*
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans("Doctype") . '</td>'; print '<td>' . $langs->trans("Doctype") . '</td>';
print '<td><input type="text" class="minwidth200 name="doc_type" value="" /></td>'; print '<td><input type="text" class="minwidth200 name="doc_type" value=""/></td>';
print '</tr>'; print '</tr>';
*/ */
print '</table>'; print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield centpercent">';
// Doc type
if (!empty($object->doc_type)) {
print '<tr>';
print '<td class="titlefield">'.$langs->trans("Doctype").'</td>';
print '<td>'.$object->doc_type.'</td>';
print '</tr>';
}
// Date document creation
print '<tr>';
print '<td class="titlefield">'.$langs->trans("DateCreation").'</td>';
print '<td>';
print $object->date_creation ? dol_print_date($object->date_creation, 'day') : '&nbsp;';
print '</td>';
print '</tr>';
// Don't show in tmp mode, inevitably empty
if ($mode != "_tmp") {
// Date document export
print '<tr>';
print '<td class="titlefield">'.$langs->trans("DateExport").'</td>';
print '<td>';
print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : '&nbsp;';
print '</td>';
print '</tr>';
// Date document validation
print '<tr>';
print '<td class="titlefield">'.$langs->trans("DateValidation").'</td>';
print '<td>';
print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : '&nbsp;';
print '</td>';
print '</tr>';
}
// Validate
/*
print '<tr>';
print '<td class="titlefield">' . $langs->trans("Status") . '</td>';
print '<td>';
if (empty($object->validated)) {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=enable&token='.newToken().'">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
} else {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=disable&token='.newToken().'">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>';
}
print '</td>';
print '</tr>';
*/
// check data
/*
print '<tr>';
print '<td class="titlefield">' . $langs->trans("Control") . '</td>';
if ($object->doc_type == 'customer_invoice') {
$sqlmid = 'SELECT rowid as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac";
$sqlmid .= " WHERE fac.rowid=" . ((int) $object->fk_doc);
dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$invoicestatic = new Facture($db);
$invoicestatic->fetch($objmid->ref);
$ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1);
} else {
dol_print_error($db);
}
}
print '<td>' . $ref .'</td>';
print '</tr>';
*/
print "</table>\n";
print dol_get_fiche_end(); print dol_get_fiche_end();
print '<div class="clearboth"></div>'; print $form->buttonsSaveCancel("Create");
print '<br>'; print '</form>';
} else {
$result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt $object = new BookKeeping($db);
$result = $object->fetchPerMvt($piece_num, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { }
// List of movements
print load_fiche_titre($langs->trans("ListeMvts"), '', '');
if ($optioncss != '') { if (!empty($object->piece_num)) {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'" />'; $backlink = '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">'.$langs->trans('BackToList').'</a>';
if ($mode == '_tmp') {
print load_fiche_titre($langs->trans("CreateMvts"), $backlink);
} else {
print load_fiche_titre($langs->trans("UpdateMvts"), $backlink);
} }
print '<input type="hidden" name="token" value="'.newToken().'" />'; $head = array();
print '<input type="hidden" name="doc_type" value="'.$object->doc_type.'" />'."\n"; $h = 0;
print '<input type="hidden" name="fk_doc" value="'.$object->fk_doc.'" />'."\n"; $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode ? '&mode='.$mode : '');
print '<input type="hidden" name="fk_docdet" value="'.$object->fk_docdet.'" />'."\n"; $head[$h][1] = $langs->trans("Transaction");
print '<input type="hidden" name="mode" value="'.$mode.'" />'."\n"; $head[$h][2] = 'transaction';
$h++;
if (count($object->linesmvt) > 0) { print dol_get_fiche_head($head, 'transaction', '', -1);
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
$total_debit = 0; //dol_banner_tab($object, '', $backlink);
$total_credit = 0;
// Don't show in tmp mode, inevitably empty print '<div class="fichecenter">';
if ($mode != "_tmp") { print '<div class="fichehalfleft">';
// Date document export
print '<tr>';
print '<td class="titlefield">' . $langs->trans("DateExport") . '</td>';
print '<td>';
print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : '&nbsp;';
print '</td>';
print '</tr>';
// Date document validation print '<div class="underbanner clearboth"></div>';
print '<tr>'; print '<table class="border tableforfield" width="100%">';
print '<td class="titlefield">' . $langs->trans("DateValidation") . '</td>';
print '<td>'; // Account movement
print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : '&nbsp;'; print '<tr>';
print '</td>'; print '<td class="titlefield">'.$langs->trans("NumMvts").'</td>';
print '</tr>'; print '<td>'.($mode == '_tmp' ? '<span class="opacitymedium" title="Id tmp '.$object->piece_num.'">'.$langs->trans("Draft").'</span>' : $object->piece_num).'</td>';
print '</tr>';
// Date
print '<tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('Docdate');
print '</td>';
if ($action != 'editdate') {
print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editdate&token='.newToken().'&piece_num='.urlencode($object->piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdate') {
print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
} }
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate");
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
print $object->doc_date ? dol_print_date($object->doc_date, 'day') : '&nbsp;';
}
print '</td>';
print '</tr>';
print '<tr class="liste_titre">'; // Journal
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Codejournal');
print '</td>';
if ($action != 'editjournal') {
print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editjournal&token='.newToken().'&piece_num='.urlencode($object->piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
if ($action == 'editjournal') {
print '<form name="setjournal" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setjournal">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1);
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
print $object->code_journal;
}
print '</td>';
print '</tr>';
print_liste_field_titre("AccountAccountingShort"); // Ref document
print_liste_field_titre("SubledgerAccount"); print '<tr><td>';
print_liste_field_titre("LabelOperation"); print '<table class="nobordernopadding" width="100%"><tr><td>';
print_liste_field_titre("AccountingDebit", "", "", "", "", 'class="right"'); print $langs->trans('Piece');
print_liste_field_titre("AccountingCredit", "", "", "", "", 'class="right"'); print '</td>';
if (empty($object->date_validation)) { if ($action != 'editdocref') {
print_liste_field_titre("Action", "", "", "", "", 'width="60"', "", "", 'center '); print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editdocref&token='.newToken().'&piece_num='.urlencode($object->piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
if ($action == 'editdocref') {
print '<form name="setdocref" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setdocref">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print '<input type="text" size="20" name="doc_ref" value="'.dol_escape_htmltag($object->doc_ref).'">';
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
print $object->doc_ref;
}
print '</td>';
print '</tr>';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield centpercent">';
// Doc type
if (!empty($object->doc_type)) {
print '<tr>';
print '<td class="titlefield">'.$langs->trans("Doctype").'</td>';
print '<td>'.$object->doc_type.'</td>';
print '</tr>';
}
// Date document creation
print '<tr>';
print '<td class="titlefield">'.$langs->trans("DateCreation").'</td>';
print '<td>';
print $object->date_creation ? dol_print_date($object->date_creation, 'day') : '&nbsp;';
print '</td>';
print '</tr>';
// Don't show in tmp mode, inevitably empty
if ($mode != "_tmp") {
// Date document export
print '<tr>';
print '<td class="titlefield">' . $langs->trans("DateExport") . '</td>';
print '<td>';
print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : '&nbsp;';
print '</td>';
print '</tr>';
// Date document validation
print '<tr>';
print '<td class="titlefield">' . $langs->trans("DateValidation") . '</td>';
print '<td>';
print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : '&nbsp;';
print '</td>';
print '</tr>';
}
// Validate
/*
print '<tr>';
print '<td class="titlefield">' . $langs->trans("Status") . '</td>';
print '<td>';
if (empty($object->validated)) {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=enable&token='.newToken().'">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
} else { } else {
print_liste_field_titre(""); print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=disable&token='.newToken().'">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>';
} }
print '</td>';
print '</tr>';
*/
print "</tr>\n"; // check data
/*
// In _tmp mode the first line is empty so we remove it print '<tr>';
if ($mode == "_tmp") { print '<td class="titlefield">' . $langs->trans("Control") . '</td>';
array_shift($object->linesmvt); if ($object->doc_type == 'customer_invoice')
{
$sqlmid = 'SELECT rowid as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac";
$sqlmid .= " WHERE fac.rowid=" . ((int) $object->fk_doc);
dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$invoicestatic = new Facture($db);
$invoicestatic->fetch($objmid->ref);
$ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1);
} }
else dol_print_error($db);
}
print '<td>' . $ref .'</td>';
print '</tr>';
*/
print "</table>\n";
// Add an empty line at the end to be able to add transaction print '</div>';
$line = new BookKeepingLine();
$object->linesmvt[] = $line;
// Add a second line empty line if there is not yet print dol_get_fiche_end();
if (empty($object->linesmvt[1])) {
$line = new BookKeepingLine(); print '<div class="clearboth"></div>';
$object->linesmvt[] = $line;
print '<br>';
$result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
// List of movements
print load_fiche_titre($langs->trans("ListeMvts"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
} }
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="doc_date" value="'.$object->doc_date.'">'."\n";
print '<input type="hidden" name="doc_type" value="'.$object->doc_type.'">'."\n";
print '<input type="hidden" name="doc_ref" value="'.$object->doc_ref.'">'."\n";
print '<input type="hidden" name="code_journal" value="'.$object->code_journal.'">'."\n";
print '<input type="hidden" name="fk_doc" value="'.$object->fk_doc.'">'."\n";
print '<input type="hidden" name="fk_docdet" value="'.$object->fk_docdet.'">'."\n";
print '<input type="hidden" name="mode" value="'.$mode.'">'."\n";
$count_line = count($object->linesmvt); if (count($object->linesmvt) > 0) {
$num_line = 0; print '<div class="div-table-responsive-no-min">';
foreach ($object->linesmvt as $key => $line) { print '<table class="noborder centpercent">';
$num_line++;
print '<tr class="oddeven" data-lineid="'.((int) $line->id).'">';
$total_debit += $line->debit;
$total_credit += $line->credit;
if ($action == 'update' && $line->id == $id) { $total_debit = 0;
print '<!-- td columns in edit mode -->'; $total_credit = 0;
print '<td>';
print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, ''); print '<tr class="liste_titre">';
print '</td>';
print '<td>'; print_liste_field_titre("AccountAccountingShort");
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: print_liste_field_titre("SubledgerAccount");
// It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. print_liste_field_titre("LabelOperation");
// Also, it is not possible to use a value that is not in the list. print_liste_field_titre("AccountingDebit", "", "", "", "", 'class="right"');
// Also, the label is not automatically filled when a value is selected. print_liste_field_titre("AccountingCredit", "", "", "", "", 'class="right"');
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { if (empty($object->date_validation)) {
print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); print_liste_field_titre("Action", "", "", "", "", 'width="60"', "", "", 'center ');
} else { } else {
print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'" />'; print_liste_field_titre("");
}
print "</tr>\n";
// Add an empty line if there is not yet
if (!empty($object->linesmvt[0])) {
$tmpline = $object->linesmvt[0];
if (!empty($tmpline->numero_compte)) {
$line = new BookKeepingLine();
$object->linesmvt[] = $line;
} }
// Add also input for subledger label }
print '<br><input type="text" class="maxwidth150" name="subledger_label" value="'.(GETPOSTISSET("subledger_label") ? GETPOST("subledger_label", "alpha") : $line->subledger_label).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'" />';
print '</td>'; foreach ($object->linesmvt as $line) {
print '<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation).'" /></td>'; print '<tr class="oddeven" data-lineid="'.((int) $line->id).'">';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value="'.(GETPOSTISSET("debit") ? GETPOST("debit", "alpha") : price($line->debit)).'" /></td>'; $total_debit += $line->debit;
print '<td class="right"><input type="text" size="6" class="right" name="credit" value="'.(GETPOSTISSET("credit") ? GETPOST("credit", "alpha") : price($line->credit)).'" /></td>'; $total_credit += $line->credit;
print '<td>';
print '<input type="hidden" name="id" value="'.$line->id.'" />'."\n"; if ($action == 'update' && $line->id == $id) {
print '<input type="submit" class="button" name="update" value="'.$langs->trans("Update").'" />'; print '<!-- td columns in edit mode -->';
print '</td>';
} elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) {
if ($action == "" || $action == 'add') {
print '<!-- td columns in add mode -->';
print '<td>'; print '<td>';
print $formaccounting->select_account((is_array($accountingaccount_number) ? $accountingaccount_number[$key] : $accountingaccount_number ), 'accountingaccount_number['.$key.']', 1, array(), 1, 1, ''); print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because:
@ -649,102 +684,124 @@ if (!empty($object->piece_num)) {
// Also, it is not possible to use a value that is not in the list. // Also, it is not possible to use a value that is not in the list.
// Also, the label is not automatically filled when a value is selected. // Also, the label is not automatically filled when a value is selected.
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print $formaccounting->select_auxaccount((is_array($subledger_account) ? $subledger_account[$key] : $subledger_account ), 'subledger_account['.$key.']', 1, 'maxwidth250', '', 'subledger_label'); print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
} else { } else {
print '<input type="text" class="maxwidth150" name="subledger_account['.$key.']" value="' . (is_array($subledger_account) ? $subledger_account[$key] : $subledger_account ) . '" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccount")) . '" />'; print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">';
} }
print '<br><input type="text" class="maxwidth150" name="subledger_label['.$key.']" value="' . (is_array($subledger_label) ? $subledger_label[$key] : $subledger_label ) . '" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccountLabel")) . '" />'; // Add also input for subledger label
print '<br><input type="text" class="maxwidth150" name="subledger_label" value="'.(GETPOSTISSET("subledger_label") ? GETPOST("subledger_label", "alpha") : $line->subledger_label).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'">';
print '</td>'; print '</td>';
print '<td><input type="text" class="minwidth200" name="label_operation['.$key.']" value="' . (is_array($label_operation) ? $label_operation[$key] : $label_operation ) . '"/></td>'; print '<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation).'"></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit['.$key.']" value="' . (is_array($debit) ? $debit[$key] : $debit ) . '" /></td>'; print '<td class="right"><input type="text" size="6" class="right" name="debit" value="'.(GETPOSTISSET("debit") ? GETPOST("debit", "alpha") : price($line->debit)).'"></td>';
print '<td class="right"><input type="text" size="6" class="right" name="credit['.$key.']" value="' . (is_array($credit) ? $credit[$key] : $credit ) . '" /></td>'; print '<td class="right"><input type="text" size="6" class="right" name="credit" value="'.(GETPOSTISSET("credit") ? GETPOST("credit", "alpha") : price($line->credit)).'"></td>';
// Add button should not appear twice print '<td>';
if ($num_line === $count_line) { print '<input type="hidden" name="id" value="'.$line->id.'">'."\n";
print '<td><input type="submit" class="button small" name="save" value="' . $langs->trans("Add") . '" /></td>'; print '<input type="submit" class="button" name="update" value="'.$langs->trans("Update").'">';
print '</td>';
} elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) {
if ($action == "" || $action == 'add') {
print '<!-- td columns in add mode -->';
print '<td>';
print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500');
print '</td>';
print '<td>';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because:
// It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases.
// Also, it is not possible to use a value that is not in the list.
// Also, the label is not automatically filled when a value is selected.
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
} else {
print '<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccount")) . '">';
}
print '<br><input type="text" class="maxwidth150" name="subledger_label" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccountLabel")) . '">';
print '</td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="' . $label_operation . '"/></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value=""/></td>';
print '<td class="right"><input type="text" size="6" class="right" name="credit" value=""/></td>';
print '<td class="center"><input type="submit" class="button small" name="save" value="' . $langs->trans("Add") . '"></td>';
}
} else {
print '<!-- td columns in display mode -->';
$resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true);
print '<td>';
if ($resultfetch > 0) {
print $accountingaccount->getNomUrl(0, 1, 1, '', 0);
} else { } else {
print '<td class="right"></td>'; print $line->numero_compte.' <span class="warning">('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')</span>';
} }
} print '</td>';
} else { print '<td>'.length_accounta($line->subledger_account);
print '<!-- td columns in display mode -->'; if ($line->subledger_label) {
$resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true); print ' - <span class="opacitymedium">'.$line->subledger_label.'</span>';
print '<td>'; }
if ($resultfetch > 0) { print '</td>';
print $accountingaccount->getNomUrl(0, 1, 1, '', 0); print '<td>'.$line->label_operation.'</td>';
} else { print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
print $line->numero_compte.' <span class="warning">('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')</span>'; print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
}
print '</td>';
print '<td>'.length_accounta($line->subledger_account);
if ($line->subledger_label) {
print ' - <span class="opacitymedium">'.$line->subledger_label.'</span>';
}
print '</td>';
print '<td>'.$line->label_operation.'</td>';
print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
print '<td class="center nowraponall">'; print '<td class="center nowraponall">';
if (empty($line->date_export) && empty($line->date_validation)) { if (empty($line->date_export) && empty($line->date_validation)) {
print '<a class="editfielda reposition" href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $line->id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; print '<a class="editfielda reposition" href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $line->id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">';
print img_edit('', 0, 'class="marginrightonly"'); print img_edit('', 0, 'class="marginrightonly"');
print '</a> &nbsp;'; print '</a> &nbsp;';
} else { } else {
print '<a class="editfielda nohover cursornotallowed reposition disabled" href="#" title="'.dol_escape_htmltag($langs->trans("ForbiddenTransactionAlreadyExported")).'">'; print '<a class="editfielda nohover cursornotallowed reposition disabled" href="#" title="'.dol_escape_htmltag($langs->trans("ForbiddenTransactionAlreadyExported")).'">';
print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"'); print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"');
print '</a> &nbsp;'; print '</a> &nbsp;';
}
if (empty($line->date_validation)) {
$actiontodelete = 'delete';
if ($mode == '_tmp' || $action != 'delmouv') {
$actiontodelete = 'confirm_delete';
} }
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=' . $actiontodelete . '&id=' . $line->id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; if (empty($line->date_validation)) {
print img_delete(); $actiontodelete = 'delete';
print '</a>'; if ($mode == '_tmp' || $action != 'delmouv') {
$actiontodelete = 'confirm_delete';
}
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=' . $actiontodelete . '&id=' . $line->id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">';
print img_delete();
print '</a>';
} else {
print '<a class="editfielda nohover cursornotallowed disabled" href="#" title="'.dol_escape_htmltag($langs->trans("ForbiddenTransactionAlreadyExported")).'">';
print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated"));
print '</a>';
}
print '</td>';
}
print "</tr>\n";
}
$total_debit = price2num($total_debit, 'MT');
$total_credit = price2num($total_credit, 'MT');
if ($total_debit != $total_credit) {
setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings');
}
print '</table>';
print '</div>';
if ($mode == '_tmp' && $action == '') {
print '<br>';
print '<div class="center">';
if ($total_debit == $total_credit) {
print '<a class="button" href="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'&action=valid">'.$langs->trans("ValidTransaction").'</a>';
} else { } else {
print '<a class="editfielda nohover cursornotallowed disabled" href="#" title="'.dol_escape_htmltag($langs->trans("ForbiddenTransactionAlreadyExported")).'">'; print '<input type="submit" class="button" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $debit, $credit)).'" value="'.dol_escape_htmltag($langs->trans("ValidTransaction")).'">';
print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated"));
print '</a>';
} }
print '</td>'; print ' &nbsp; ';
print '<a class="button button-cancel" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php">'.$langs->trans("Cancel").'</a>';
print "</div>";
} }
print "</tr>\n";
} }
$total_debit = price2num($total_debit, 'MT'); print '</form>';
$total_credit = price2num($total_credit, 'MT');
if ($total_debit != $total_credit) {
setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings');
}
print '</table>';
print '</div>';
if ($mode == '_tmp' && $action == '') {
print '<br>';
print '<div class="center">';
if ($total_debit == $total_credit) {
print '<input type="submit" class="button" name="validate" value="' . $langs->trans("ValidTransaction") . '" />';
} else {
print '<input type="submit" class="button" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $debit, $credit)).'" value="'.dol_escape_htmltag($langs->trans("ValidTransaction")).'" />';
}
print ' &nbsp; ';
print '<a class="button button-cancel" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php">'.$langs->trans("Cancel").'</a>';
print "</div>";
}
} }
} else {
print '</form>'; print load_fiche_titre($langs->trans("NoRecords"));
} }
} else {
print load_fiche_titre($langs->trans("NoRecords"));
} }
print dol_get_fiche_end(); print dol_get_fiche_end();

View File

@ -754,30 +754,33 @@ if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements
} else { } else {
if (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) { if (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) {
if (is_array($object->lines)) { if (is_array($object->lines)) {
dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG);
// Specify as export : update field date_export or date_validated // Specify as export : update field date_export or date_validated
$db->begin(); $db->begin();
// TODO Merge update for each line into one gloacl using rowid IN (list of movement ids)
foreach ($object->lines as $movement) { foreach ($object->lines as $movement) {
$now = dol_now(); $now = dol_now();
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; $setfields = '';
$sql .= " SET"; if (!empty($notifiedexportdate) && empty($movement->date_export)) {
if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) { $setfields .= ($setfields ? "," : "")." date_export = '".$db->idate($now)."'";
$sql .= " date_export = '".$db->idate($now)."'"; }
$sql .= ", date_validated = '".$db->idate($now)."'"; if (!empty($notifiedvalidationdate) && empty($movement->date_validation)) {
} elseif (!empty($notifiedexportdate)) { $setfields .= ($setfields ? "," : "")." date_validated = '".$db->idate($now)."'";
$sql .= " date_export = '".$db->idate($now)."'";
} elseif (!empty($notifiedvalidationdate)) {
$sql .= " date_validated = '".$db->idate($now)."'";
} }
$sql .= " WHERE rowid = ".((int) $movement->id);
dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG); if ($setfields) {
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " SET ".$setfields;
$sql .= " WHERE rowid = ".((int) $movement->id);
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) { if (!$result) {
$error++; $error++;
break; break;
}
} }
} }
@ -1014,17 +1017,17 @@ $newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
if (empty($reshook)) { if (empty($reshook)) {
// Button re-export // Button re-export
if (!empty($conf->global->ACCOUNTING_REEXPORT)) { if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
$newcardbutton .= '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=0'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("ClickToHideAlreadyExportedLines"), 'switch_off', 'class="small size15x valignmiddle"'); $newcardbutton .= '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=0'.($param ? '&'.$param : '').'&sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder).'">'.img_picto($langs->trans("ClickToHideAlreadyExportedLines"), 'switch_off', 'class="small size15x valignmiddle"');
$newcardbutton .= '<span class="valignmiddle marginrightonly paddingleft">'.$langs->trans("ClickToHideAlreadyExportedLines").'</span>'; $newcardbutton .= '<span class="valignmiddle marginrightonly paddingleft">'.$langs->trans("ClickToHideAlreadyExportedLines").'</span>';
$newcardbutton .= '</a>'; $newcardbutton .= '</a>';
} else { } else {
$newcardbutton .= '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=1'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("DocsAlreadyExportedAreExcluded"), 'switch_on', 'class="warning size15x valignmiddle"'); $newcardbutton .= '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=1'.($param ? '&'.$param : '').'&sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder).'">'.img_picto($langs->trans("DocsAlreadyExportedAreExcluded"), 'switch_on', 'class="warning size15x valignmiddle"');
$newcardbutton .= '<span class="valignmiddle marginrightonly paddingleft">'.$langs->trans("DocsAlreadyExportedAreExcluded").'</span>'; $newcardbutton .= '<span class="valignmiddle marginrightonly paddingleft">'.$langs->trans("DocsAlreadyExportedAreExcluded").'</span>';
$newcardbutton .= '</a>'; $newcardbutton .= '</a>';
} }
if ($user->hasRight('accounting', 'mouvements', 'export')) { if ($user->hasRight('accounting', 'mouvements', 'export')) {
$newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file&token='.newToken().($param ? '&'.$param : ''), $user->hasRight('accounting', 'mouvements', 'export')); $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file&token='.newToken().($param ? '&'.$param : '').'&sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder), $user->hasRight('accounting', 'mouvements', 'export'));
} }
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
@ -1355,6 +1358,9 @@ while ($i < min($num, $limit)) {
print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />'; print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
} }
print '</td>'; print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
} }
// Piece number // Piece number
@ -1522,7 +1528,7 @@ while ($i < min($num, $limit)) {
// Creation operation date // Creation operation date
if (!empty($arrayfields['t.date_creation']['checked'])) { if (!empty($arrayfields['t.date_creation']['checked'])) {
print '<td class="center">'.dol_print_date($line->date_creation, 'dayhour').'</td>'; print '<td class="center">'.dol_print_date($line->date_creation, 'dayhour', 'tzuserrel').'</td>';
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
} }
@ -1530,7 +1536,7 @@ while ($i < min($num, $limit)) {
// Modification operation date // Modification operation date
if (!empty($arrayfields['t.tms']['checked'])) { if (!empty($arrayfields['t.tms']['checked'])) {
print '<td class="center">'.dol_print_date($line->date_modification, 'dayhour').'</td>'; print '<td class="center">'.dol_print_date($line->date_modification, 'dayhour', 'tzuserrel').'</td>';
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
} }
@ -1538,7 +1544,7 @@ while ($i < min($num, $limit)) {
// Exported operation date // Exported operation date
if (!empty($arrayfields['t.date_export']['checked'])) { if (!empty($arrayfields['t.date_export']['checked'])) {
print '<td class="center nowraponall">'.dol_print_date($line->date_export, 'dayhour').'</td>'; print '<td class="center nowraponall">'.dol_print_date($line->date_export, 'dayhour', 'tzuserrel').'</td>';
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
} }
@ -1546,7 +1552,7 @@ while ($i < min($num, $limit)) {
// Validated operation date // Validated operation date
if (!empty($arrayfields['t.date_validated']['checked'])) { if (!empty($arrayfields['t.date_validated']['checked'])) {
print '<td class="center nowraponall">'.dol_print_date($line->date_validation, 'dayhour').'</td>'; print '<td class="center nowraponall">'.dol_print_date($line->date_validation, 'dayhour', 'tzuserrel').'</td>';
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
} }
@ -1570,11 +1576,11 @@ while ($i < min($num, $limit)) {
print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />'; print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
} }
print '</td>'; print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
} }
if (!$i) {
$totalarray['nbfield']++;
}
print "</tr>\n"; print "</tr>\n";

View File

@ -951,6 +951,10 @@ while ($i < min($num, $limit)) {
if (!empty($arrayfields['t.date_export']['checked'])) { $colspanend++; } if (!empty($arrayfields['t.date_export']['checked'])) { $colspanend++; }
if (!empty($arrayfields['t.date_validating']['checked'])) { $colspanend++; } if (!empty($arrayfields['t.date_validating']['checked'])) { $colspanend++; }
if (!empty($arrayfields['t.lettering_code']['checked'])) { $colspanend++; } if (!empty($arrayfields['t.lettering_code']['checked'])) { $colspanend++; }
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
$colspan++;
$colspanend--;
}
// Is it a break ? // Is it a break ?
if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
@ -990,7 +994,9 @@ while ($i < min($num, $limit)) {
print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : count($arrayfields)+1).'" class="tdforbreak">'; print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : count($arrayfields)+1).'" class="tdforbreak">';
if ($type == 'sub') { if ($type == 'sub') {
if ($line->subledger_account != "" && $line->subledger_account != '-1') { if ($line->subledger_account != "" && $line->subledger_account != '-1') {
print $line->subledger_label . ' : ' . length_accounta($line->subledger_account); print empty($line->subledger_label) ? '<span class="error">'.$langs->trans("Unknown").'</span>' : $line->subledger_label;
print ' : ';
print length_accounta($line->subledger_account);
} else { } else {
// Should not happen: subledger account must be null or a non empty value // Should not happen: subledger account must be null or a non empty value
print '<span class="error">' . $langs->trans("Unknown"); print '<span class="error">' . $langs->trans("Unknown");
@ -1033,6 +1039,9 @@ while ($i < min($num, $limit)) {
print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />'; print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />';
} }
print '</td>'; print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
} }
// Piece number // Piece number
if (!empty($arrayfields['t.piece_num']['checked'])) { if (!empty($arrayfields['t.piece_num']['checked'])) {
@ -1216,9 +1225,9 @@ while ($i < min($num, $limit)) {
print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />'; print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />';
} }
print '</td>'; print '</td>';
} if (!$i) {
if (!$i) { $totalarray['nbfield']++;
$totalarray['nbfield']++; }
} }
// Comptabilise le sous-total // Comptabilise le sous-total

View File

@ -37,7 +37,6 @@
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

View File

@ -388,12 +388,6 @@ class AccountingJournal extends CommonObject
if (empty($type)) $type = 'view'; if (empty($type)) $type = 'view';
if (empty($in_bookkeeping)) $in_bookkeeping = 'notyet'; if (empty($in_bookkeeping)) $in_bookkeeping = 'notyet';
// Hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$data = array(); $data = array();
$hookmanager->initHooks(array('accountingjournaldao')); $hookmanager->initHooks(array('accountingjournaldao'));
@ -790,12 +784,6 @@ class AccountingJournal extends CommonObject
global $conf, $langs, $hookmanager; global $conf, $langs, $hookmanager;
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
// Hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$error = 0; $error = 0;
$hookmanager->initHooks(array('accountingjournaldao')); $hookmanager->initHooks(array('accountingjournaldao'));
@ -940,11 +928,6 @@ class AccountingJournal extends CommonObject
$out = ''; $out = '';
// Hook // Hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('accountingjournaldao')); $hookmanager->initHooks(array('accountingjournaldao'));
$parameters = array('journal_data' => &$journal_data, 'search_date_end' => &$search_date_end, 'sep' => &$sep, 'out' => &$out); $parameters = array('journal_data' => &$journal_data, 'search_date_end' => &$search_date_end, 'sep' => &$sep, 'out' => &$out);
$reshook = $hookmanager->executeHooks('exportCsv', $parameters, $this); // Note that $action and $object may have been $reshook = $hookmanager->executeHooks('exportCsv', $parameters, $this); // Note that $action and $object may have been

View File

@ -60,7 +60,7 @@ if ($action == 'update') {
$amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2); $amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2);
$minamount = GETPOST('MEMBER_MIN_AMOUNT'); $minamount = GETPOST('MEMBER_MIN_AMOUNT');
$publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC'); $publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC');
$showtable = GETPOST('MEMBER_SHOW_TABLE');; $showtable = GETPOST('MEMBER_SHOW_TABLE');
$showvoteallowed = GETPOST('MEMBER_SHOW_VOTE_ALLOWED'); $showvoteallowed = GETPOST('MEMBER_SHOW_VOTE_ALLOWED');
$payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE'); $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
$forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE', 'int'); $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE', 'int');

View File

@ -61,20 +61,15 @@ abstract class ActionsAdherentCardCommon
*/ */
public function getObject($id) public function getObject($id)
{ {
//$ret = $this->getInstanceDao(); $object = new Adherent($this->db);
/*if (is_object($this->object) && method_exists($this->object,'fetch'))
{
if (!empty($id)) $this->object->fetch($id);
}
else
{*/
$object = new Adherent($this->db);
if (!empty($id)) { if (!empty($id)) {
$object->fetch($id); $object->fetch($id);
} }
$this->object = $object;
//} $this->object = $object;
return $object;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@ -83,7 +78,7 @@ abstract class ActionsAdherentCardCommon
* *
* @param string $action Type of action * @param string $action Type of action
* @param int $id Id * @param int $id Id
* @return string HTML output * @return void
*/ */
public function assign_values(&$action, $id) public function assign_values(&$action, $id)
{ {

View File

@ -84,7 +84,6 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
public function assign_values(&$action, $id) public function assign_values(&$action, $id)
{ {
// phpcs:enable // phpcs:enable
global $limit, $offset, $sortfield, $sortorder;
global $conf, $db, $langs, $user; global $conf, $db, $langs, $user;
global $form; global $form;

View File

@ -356,8 +356,8 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
dol_print_error($db); dol_print_error($db);
} }
print "<table class=\"noborder\" width=\"100%\">\n"; print '<table class="noborder centpercent">'."\n";
print "<tr class=\"liste_titre\">\n"; print '<tr class="liste_titre">'."\n";
print '<td>'.$langs->trans("Name").'</td>'; print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n"; print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
@ -396,7 +396,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
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>';
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);

View File

@ -252,6 +252,7 @@ foreach ($phparray as $key => $value) {
if (!is_array($keyvalue)) { if (!is_array($keyvalue)) {
$keytoshow = $keyparam; $keytoshow = $keyparam;
$valtoshow = $keyvalue; $valtoshow = $keyvalue;
// Hide value of session cookies // Hide value of session cookies
if (in_array($keyparam, array('HTTP_COOKIE', 'Cookie', "\$_SERVER['HTTP_COOKIE']", 'Authorization'))) { if (in_array($keyparam, array('HTTP_COOKIE', 'Cookie', "\$_SERVER['HTTP_COOKIE']", 'Authorization'))) {
$valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>'; $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
@ -260,6 +261,10 @@ foreach ($phparray as $key => $value) {
$keytoshow = $keyparam; $keytoshow = $keyparam;
$valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>'; $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
} }
if (preg_match('/'.preg_quote('$_SERVER[\'PHP_AUTH_PW', '/').'/i', $keyparam)) {
$keytoshow = $keyparam;
$valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
}
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$keytoshow.'</td>'; print '<td>'.$keytoshow.'</td>';

View File

@ -241,14 +241,41 @@ print '<br>';
print '<br>'; print '<br>';
$installlock = DOL_DATA_ROOT.'/install.lock'; $installlock = DOL_DATA_ROOT.'/install.lock';
$upgradeunlock = DOL_DATA_ROOT.'/upgrade.unlock';
$installmoduleslock = DOL_DATA_ROOT.'/installmodules.lock';
// Is install (upgrade) locked
print '<strong>'.$langs->trans("DolibarrSetup").'</strong>: '; print '<strong>'.$langs->trans("DolibarrSetup").'</strong>: ';
if (file_exists($installlock)) { if (file_exists($installlock)) {
print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installlock); if (file_exists($upgradeunlock)) {
print img_picto('', 'tick').' '.$langs->trans("InstallLockedBy", $installlock);
} else {
print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installlock);
}
} else { } else {
print img_warning().' '.$langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT); print img_warning().' '.$langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT);
} }
print '<br>'; print '<br>';
// Is upgrade unlocked
if (file_exists($installlock)) { // If install not locked, no need to show this.
if (file_exists($upgradeunlock)) {
print '<strong>'.$langs->trans("DolibarrUpgrade").'</strong>: ';
print img_warning().' '.$langs->trans("UpgradeHasBeenUnlocked", $upgradeunlock);
print '<br>';
}
}
// Is addon install locked ?
print '<strong>'.$langs->trans("DolibarrAddonInstall").'</strong>: ';
if (file_exists($installmoduleslock)) {
print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installmoduleslock);
} else {
print $langs->trans("InstallOfAddonIsNotBlocked", DOL_DATA_ROOT);
}
print '<br>';
// File conf.php // File conf.php
@ -286,7 +313,7 @@ if (empty($dolibarr_main_restrict_os_commands)) {
} else { } else {
print $dolibarr_main_restrict_os_commands; print $dolibarr_main_restrict_os_commands;
} }
print ' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'mysqldump, mysql, pg_dump, pgrestore').')</span>'; print ' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'mysqldump, mysql, pg_dump, pgrestore, clamdscan').')</span>';
print '<br>'; print '<br>';
if (empty($conf->global->SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF)) { if (empty($conf->global->SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF)) {

View File

@ -116,11 +116,6 @@ class AssetAccountancyCodes extends CommonObject
$asset_id = $asset_id > 0 ? $asset_id : 0; $asset_id = $asset_id > 0 ? $asset_id : 0;
$asset_model_id = $asset_model_id > 0 ? $asset_model_id : 0; $asset_model_id = $asset_model_id > 0 ? $asset_model_id : 0;
if (!is_object($hookmanager)) {
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('assetaccountancycodesdao')); $hookmanager->initHooks(array('assetaccountancycodesdao'));
$parameters = array('asset_id' => $asset_id, 'asset_model_id' => $asset_model_id); $parameters = array('asset_id' => $asset_id, 'asset_model_id' => $asset_model_id);
$reshook = $hookmanager->executeHooks('fetchAccountancyCodes', $parameters, $this); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('fetchAccountancyCodes', $parameters, $this); // Note that $action and $object may have been modified by some hooks
@ -188,11 +183,6 @@ class AssetAccountancyCodes extends CommonObject
$asset_id = $asset_id > 0 ? $asset_id : 0; $asset_id = $asset_id > 0 ? $asset_id : 0;
$asset_model_id = $asset_model_id > 0 ? $asset_model_id : 0; $asset_model_id = $asset_model_id > 0 ? $asset_model_id : 0;
if (!is_object($hookmanager)) {
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('assetaccountancycodesdao')); $hookmanager->initHooks(array('assetaccountancycodesdao'));
$parameters = array('user' => $user, 'asset_id' => $asset_id, 'asset_model_id' => $asset_model_id); $parameters = array('user' => $user, 'asset_id' => $asset_id, 'asset_model_id' => $asset_model_id);
$reshook = $hookmanager->executeHooks('updateAccountancyCodes', $parameters, $this); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('updateAccountancyCodes', $parameters, $this); // Note that $action and $object may have been modified by some hooks

View File

@ -319,11 +319,6 @@ class AssetDepreciationOptions extends CommonObject
$asset_id = $asset_id > 0 ? $asset_id : 0; $asset_id = $asset_id > 0 ? $asset_id : 0;
$asset_model_id = $asset_model_id > 0 ? $asset_model_id : 0; $asset_model_id = $asset_model_id > 0 ? $asset_model_id : 0;
if (!is_object($hookmanager)) {
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('assetdepreciationoptionsdao')); $hookmanager->initHooks(array('assetdepreciationoptionsdao'));
$parameters = array('asset_id' => $asset_id, 'asset_model_id' => $asset_model_id); $parameters = array('asset_id' => $asset_id, 'asset_model_id' => $asset_model_id);
$reshook = $hookmanager->executeHooks('fetchDepreciationOptions', $parameters, $this); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('fetchDepreciationOptions', $parameters, $this); // Note that $action and $object may have been modified by some hooks
@ -392,11 +387,6 @@ class AssetDepreciationOptions extends CommonObject
// Clean parameters // Clean parameters
$mode = strtolower(trim($mode)); $mode = strtolower(trim($mode));
if (!is_object($hookmanager)) {
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('assetdepreciationoptionsdao')); $hookmanager->initHooks(array('assetdepreciationoptionsdao'));
$parameters = array('mode' => $mode); $parameters = array('mode' => $mode);
$reshook = $hookmanager->executeHooks('getGeneralDepreciationInfoForMode', $parameters, $this); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getGeneralDepreciationInfoForMode', $parameters, $this); // Note that $action and $object may have been modified by some hooks
@ -437,11 +427,6 @@ class AssetDepreciationOptions extends CommonObject
$asset_id = $asset_id > 0 ? $asset_id : 0; $asset_id = $asset_id > 0 ? $asset_id : 0;
$asset_model_id = $asset_model_id > 0 ? $asset_model_id : 0; $asset_model_id = $asset_model_id > 0 ? $asset_model_id : 0;
if (!is_object($hookmanager)) {
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('assetdepreciationoptionsdao')); $hookmanager->initHooks(array('assetdepreciationoptionsdao'));
$parameters = array('user' => $user, 'asset_id' => $asset_id, 'asset_model_id' => $asset_model_id); $parameters = array('user' => $user, 'asset_id' => $asset_id, 'asset_model_id' => $asset_model_id);
$reshook = $hookmanager->executeHooks('updateDepreciationOptions', $parameters, $this); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('updateDepreciationOptions', $parameters, $this); // Note that $action and $object may have been modified by some hooks

View File

@ -639,7 +639,7 @@ if ($num == 0) {
$colspan++; $colspan++;
} }
} }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
} }

View File

@ -20,6 +20,11 @@
*/ */
class BlockedLogAuthority class BlockedLogAuthority
{ {
/**
* DoliDB
* @var DoliDB
*/
public $db;
/** /**
* Id of the log * Id of the log
@ -45,6 +50,12 @@ class BlockedLogAuthority
*/ */
public $tms = 0; public $tms = 0;
/**
* Error message
* @var string
*/
public $error;
/** /**
* Constructor * Constructor
* *

View File

@ -845,10 +845,12 @@ class Categorie extends CommonObject
* @param int $offset Offset * @param int $offset Offset
* @param string $sortfield Sort fields * @param string $sortfield Sort fields
* @param string $sortorder Sort order ('ASC' or 'DESC'); * @param string $sortorder Sort order ('ASC' or 'DESC');
* @param array $filter Filter array. Example array('field'=>'valueforlike', 'customsql'=>...)
* @param string $filtermode Filter mode (AND or OR)
* @return array|int -1 if KO, array of instance of object if OK * @return array|int -1 if KO, array of instance of object if OK
* @see containsObject() * @see containsObject()
*/ */
public function getObjectsInCateg($type, $onlyids = 0, $limit = 0, $offset = 0, $sortfield = '', $sortorder = 'ASC') public function getObjectsInCateg($type, $onlyids = 0, $limit = 0, $offset = 0, $sortfield = '', $sortorder = 'ASC', $filter = array(), $filtermode = 'AND')
{ {
global $user; global $user;
@ -867,10 +869,24 @@ class Categorie extends CommonObject
if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) { if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) {
$sql .= " AND o.rowid = ".((int) $user->socid); $sql .= " AND o.rowid = ".((int) $user->socid);
} }
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
if ($key == 'o.rowid') {
$sqlwhere[] = $key." = ".((int) $value);
} elseif ($key == 'customsql') {
$sqlwhere[] = $value;
}
}
}
if (count($sqlwhere) > 0) {
$sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")";
}
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit > 0 || $offset > 0) { if ($limit > 0 || $offset > 0) {
$sql .= $this->db->plimit($limit + 1, $offset); $sql .= $this->db->plimit($limit + 1, $offset);
} }
$sql .= $this->db->order($sortfield, $sortorder);
dol_syslog(get_class($this)."::getObjectsInCateg", LOG_DEBUG); dol_syslog(get_class($this)."::getObjectsInCateg", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -24,6 +24,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';

View File

@ -79,6 +79,7 @@ $cancel = GETPOST('cancel', 'alpha');
$origin = GETPOST('origin', 'alpha'); $origin = GETPOST('origin', 'alpha');
$originid = GETPOST('originid', 'int'); $originid = GETPOST('originid', 'int');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$lineid = GETPOST('lineid', 'int'); $lineid = GETPOST('lineid', 'int');
$contactid = GETPOST('contactid', 'int'); $contactid = GETPOST('contactid', 'int');
$projectid = GETPOST('projectid', 'int'); $projectid = GETPOST('projectid', 'int');
@ -1774,6 +1775,7 @@ if ($action == 'create') {
print '<form name="addprop" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form name="addprop" action="'.$_SERVER["PHP_SELF"].'" 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="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if ($origin != 'project' && $originid) { if ($origin != 'project' && $originid) {
print '<input type="hidden" name="origin" value="'.$origin.'">'; print '<input type="hidden" name="origin" value="'.$origin.'">';
print '<input type="hidden" name="originid" value="'.$originid.'">'; print '<input type="hidden" name="originid" value="'.$originid.'">';
@ -2449,6 +2451,7 @@ if ($action == 'create') {
print '<form name="editdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<form name="editdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" 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="setdate">'; print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print $form->selectDate($object->date, 're', '', '', 0, "editdate"); print $form->selectDate($object->date, 're', '', '', 0, "editdate");
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">'; print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>'; print '</form>';
@ -2476,6 +2479,7 @@ if ($action == 'create') {
print '<form name="editecheance" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<form name="editecheance" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" 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="setecheance">'; print '<input type="hidden" name="action" value="setecheance">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print $form->selectDate($object->fin_validite, 'ech', '', '', '', "editecheance"); print $form->selectDate($object->fin_validite, 'ech', '', '', '', "editecheance");
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">'; print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>'; print '</form>';
@ -2836,6 +2840,7 @@ if ($action == 'create') {
<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="page_y" value=""> <input type="hidden" name="page_y" value="">
<input type="hidden" name="backtopage" value="'.$backtopage.'">
<input type="hidden" name="id" value="' . $object->id.'"> <input type="hidden" name="id" value="' . $object->id.'">
'; ';
@ -2845,7 +2850,7 @@ if ($action == 'create') {
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) {
print '<table id="tablelines" class="noborder noshadow" width="100%">'; print '<table id="tablelines" class="noborder noshadow centpercent">';
} }
if (!empty($object->lines)) { if (!empty($object->lines)) {

View File

@ -24,6 +24,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';

View File

@ -84,6 +84,8 @@ $socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$lineid = GETPOST('lineid', 'int'); $lineid = GETPOST('lineid', 'int');
$contactid = GETPOST('contactid', 'int'); $contactid = GETPOST('contactid', 'int');
$projectid = GETPOST('projectid', 'int'); $projectid = GETPOST('projectid', 'int');
@ -1755,6 +1757,7 @@ if ($action == 'create' && $usercancreate) {
print '<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.'">'; print '<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.'">';
print '<input type="hidden" name="origin" value="'.$origin.'">'; print '<input type="hidden" name="origin" value="'.$origin.'">';
print '<input type="hidden" name="originid" value="'.$originid.'">'; print '<input type="hidden" name="originid" value="'.$originid.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if (!empty($currency_tx)) { if (!empty($currency_tx)) {
print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.'">'; print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.'">';
} }
@ -2449,6 +2452,7 @@ if ($action == 'create' && $usercancreate) {
print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" 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="setdate">'; print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print $form->selectDate($object->date, 'order_', '', '', '', "setdate"); print $form->selectDate($object->date, 'order_', '', '', '', "setdate");
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">'; print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>'; print '</form>';
@ -2470,6 +2474,7 @@ if ($action == 'create' && $usercancreate) {
print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" 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="setdate_livraison">'; print '<input type="hidden" name="action" value="setdate_livraison">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print $form->selectDate($object->delivery_date ? $object->delivery_date : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); print $form->selectDate($object->delivery_date ? $object->delivery_date : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0);
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">'; print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>'; print '</form>';
@ -2763,7 +2768,9 @@ if ($action == 'create' && $usercancreate) {
<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="page_y" value=""> <input type="hidden" name="page_y" value="">
<input type="hidden" name="id" value="' . $object->id.'">'; <input type="hidden" name="id" value="' . $object->id.'">
<input type="hidden" name="backtopage" value="'.$backtopage.'">
';
if (!empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) { if (!empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';

View File

@ -135,14 +135,14 @@ if (empty($entity)) {
$error = 0; $error = 0;
$listofchoices = array( $listofchoices = array(
'selectinvoices'=>array('label'=>'Invoices', 'lang'=>'bills', 'enabled' => isModEnabled('facture'), 'perms' => !empty($user->rights->facture->lire)), 'selectinvoices'=>array('label'=>'Invoices', 'picto'=>'bill', 'lang'=>'bills', 'enabled' => isModEnabled('facture'), 'perms' => !empty($user->rights->facture->lire)),
'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'lang'=>'bills', 'enabled' => isModEnabled('supplier_invoice'), 'perms' => !empty($user->rights->fournisseur->facture->lire)), 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'picto'=>'supplier_invoice', 'lang'=>'bills', 'enabled' => isModEnabled('supplier_invoice'), 'perms' => !empty($user->rights->fournisseur->facture->lire)),
'selectexpensereports'=>array('label'=>'ExpenseReports', 'lang'=>'trips', 'enabled' => isModEnabled('expensereport'), 'perms' => !empty($user->rights->expensereport->lire)), 'selectexpensereports'=>array('label'=>'ExpenseReports', 'picto'=>'expensereport', 'lang'=>'trips', 'enabled' => isModEnabled('expensereport'), 'perms' => !empty($user->rights->expensereport->lire)),
'selectdonations'=>array('label'=>'Donations', 'lang'=>'donation', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->don->lire)), 'selectdonations'=>array('label'=>'Donations', 'picto'=>'donation', 'lang'=>'donation', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->don->lire)),
'selectsocialcontributions'=>array('label'=>'SocialContributions', 'enabled' => isModEnabled('tax'), 'perms' => !empty($user->rights->tax->charges->lire)), 'selectsocialcontributions'=>array('label'=>'SocialContributions', 'picto'=>'bill', 'enabled' => isModEnabled('tax'), 'perms' => !empty($user->rights->tax->charges->lire)),
'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'lang'=>'salaries', 'enabled' => isModEnabled('salaries'), 'perms' => !empty($user->rights->salaries->read)), 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'picto'=>'salary', 'lang'=>'salaries', 'enabled' => isModEnabled('salaries'), 'perms' => !empty($user->rights->salaries->read)),
'selectvariouspayment'=>array('label'=>'VariousPayment', 'enabled' => isModEnabled('banque'), 'perms' => !empty($user->rights->banque->lire)), 'selectvariouspayment'=>array('label'=>'VariousPayment', 'picto'=>'payment', 'enabled' => isModEnabled('banque'), 'perms' => !empty($user->rights->banque->lire)),
'selectloanspayment'=>array('label'=>'PaymentLoan', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->loan->read)), 'selectloanspayment'=>array('label'=>'PaymentLoan','picto'=>'loan', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->loan->read)),
); );
@ -623,7 +623,9 @@ foreach ($listofchoices as $choice => $val) {
$disabled = ' disabled'; $disabled = ' disabled';
} }
$checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : ''); $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : '');
print '<div class="paddingleft inline-block marginrightonly"><input type="checkbox" id="'.$choice.'" name="'.$choice.'" value="1"'.$checked.$disabled.'> <label for="'.$choice.'">'.$langs->trans($val['label']).'</label></div>'; print '<div class="paddingleft inline-block marginrightonly paddingright"><input type="checkbox" id="'.$choice.'" name="'.$choice.'" value="1"'.$checked.$disabled.'><label for="'.$choice.'"> ';
print img_picto($langs->trans($val['label']), $val['picto'], 'class=""').' '.$langs->trans($val['label']);
print '</label></div>';
} }
print '<input type="submit" class="button small" name="search" value="'.$langs->trans("Search").'">'; print '<input type="submit" class="button small" name="search" value="'.$langs->trans("Search").'">';

View File

@ -55,6 +55,7 @@ $langs->loadLangs(array("banks", "bills", "categories", "companies", "compta", "
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$object = new Account($db); $object = new Account($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
@ -380,6 +381,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">';
print '<input type="hidden" name="clos" value="0">'; print '<input type="hidden" name="clos" value="0">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head(''); print dol_get_fiche_head('');
@ -527,6 +529,12 @@ if ($action == 'create') {
print '<td><input type="text" class="flat minwidth150" name="bank" value="'.(GETPOST('bank') ?GETPOST('bank', 'alpha') : $object->bank).'"></td>'; print '<td><input type="text" class="flat minwidth150" name="bank" value="'.(GETPOST('bank') ?GETPOST('bank', 'alpha') : $object->bank).'"></td>';
print '</tr>'; print '</tr>';
$ibankey = FormBank::getIBANLabel($object);
$bickey = "BICNumber";
if ($object->getCountryCode() == 'IN') {
$bickey = "SWIFT";
}
// IBAN // IBAN
print '<tr><td>'.$langs->trans($ibankey).'</td>'; print '<tr><td>'.$langs->trans($ibankey).'</td>';
print '<td><input maxlength="34" type="text" class="flat minwidth300" name="iban" value="'.(GETPOSTISSET('iban') ?GETPOST('iban', 'alpha') : $object->iban).'"></td></tr>'; print '<td><input maxlength="34" type="text" class="flat minwidth300" name="iban" value="'.(GETPOSTISSET('iban') ?GETPOST('iban', 'alpha') : $object->iban).'"></td></tr>';
@ -561,11 +569,6 @@ if ($action == 'create') {
print '<td><input type="text" class="flat '.$sizecss.'" name="'.$name.'" value="'.(GETPOSTISSET($name) ? GETPOST($name, 'alpha') : $content).'"></td>'; print '<td><input type="text" class="flat '.$sizecss.'" name="'.$name.'" value="'.(GETPOSTISSET($name) ? GETPOST($name, 'alpha') : $content).'"></td>';
print '</tr>'; print '</tr>';
} }
$ibankey = FormBank::getIBANLabel($object);
$bickey = "BICNumber";
if ($object->getCountryCode() == 'IN') {
$bickey = "SWIFT";
}
if (isModEnabled('paymentbybanktransfer')) { if (isModEnabled('paymentbybanktransfer')) {
print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td>'; print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td>';
@ -903,6 +906,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="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.GETPOST("id", 'int').'">'."\n\n"; print '<input type="hidden" name="id" value="'.GETPOST("id", 'int').'">'."\n\n";
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head(array(), 0, '', 0); print dol_get_fiche_head(array(), 0, '', 0);

View File

@ -828,4 +828,36 @@ class PaymentVarious extends CommonObject
$return .= '</div>'; $return .= '</div>';
return $return; return $return;
} }
/**
* Return General accounting account with defined length (used for product and miscellaneous)
*
* @param string $account General accounting account
* @return string String with defined length
*/
public function lengthAccountg($account)
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
/*
if (isModEnabled('accounting')) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('', $valuetoshow, 1);
}*/
return length_accountg($account);
}
/**
* Return Auxiliary accounting account of thirdparties with defined length
*
* @param string $account Auxiliary accounting account
* @return string String with defined length
*/
public function lengthAccounta($account)
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
return length_accounta($account);
}
} }

View File

@ -346,7 +346,7 @@ for ($i = 1 ; $i < $MAXLINES; $i++) {
print '<td class="hideobject" class="multicurrency"><input name="'.$i.'_amountto" class="flat" type="text" size="6" value="'.dol_escape_htmltag($amountto).'"></td>'; print '<td class="hideobject" class="multicurrency"><input name="'.$i.'_amountto" class="flat" type="text" size="6" value="'.dol_escape_htmltag($amountto).'"></td>';
print '</tr>'; print '</tr>';
}; }
print '</table>'; print '</table>';
print '</div>'; print '</div>';

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2017-2021 Alexandre Spangaro <aspangaro@open-dsi.fr> /* Copyright (C) 2017-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -71,6 +72,8 @@ $object = new PaymentVarious($db);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('variouscard', 'globalcard')); $hookmanager->initHooks(array('variouscard', 'globalcard'));
$permissiontoadd = $user->hasRight('banque', 'modifier');
/** /**
* Actions * Actions
@ -83,14 +86,8 @@ if ($reshook < 0) {
} }
if (empty($reshook)) { if (empty($reshook)) {
// Link to a project
if ($action == 'classin' && $user->rights->banque->modifier) {
$object->fetch($id);
$object->setProject(GETPOST('projectid'));
}
if ($cancel) { if ($cancel) {
if ($action != 'addlink') { if ($action != 'addlink' && $action != 'setaccountancy_code' && $action != 'setsubledger_account') {
$urltogo = $backtopage ? $backtopage : dol_buildpath('/compta/bank/various_payment/list.php', 1); $urltogo = $backtopage ? $backtopage : dol_buildpath('/compta/bank/various_payment/list.php', 1);
header("Location: ".$urltogo); header("Location: ".$urltogo);
exit; exit;
@ -101,6 +98,12 @@ if (empty($reshook)) {
$action = ''; $action = '';
} }
// Link to a project
if ($action == 'classin' && $permissiontoadd) {
$object->fetch($id);
$object->setProject(GETPOST('projectid', 'int'));
}
if ($action == 'add') { if ($action == 'add') {
$error = 0; $error = 0;
@ -214,6 +217,22 @@ if (empty($reshook)) {
} }
} }
if ($action == 'setaccountancy_code') {
$db->begin();
$result = $object->fetch($id);
$object->accountancy_code = GETPOST('accountancy_code', 'alpha');
$res = $object->update($user);
if ($res > 0) {
$db->commit();
} else {
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
}
if ($action == 'setsubledger_account') { if ($action == 'setsubledger_account') {
$db->begin(); $db->begin();
@ -236,7 +255,7 @@ if ($action == 'confirm_clone' && $confirm != 'yes') {
$action = ''; $action = '';
} }
if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->banque->modifier)) { if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) {
$db->begin(); $db->begin();
$originalId = $id; $originalId = $id;
@ -560,32 +579,25 @@ if ($id) {
// Project // Project
if (isModEnabled('project')) { if (isModEnabled('project')) {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= $langs->trans('Project').' '; //$morehtmlref .= '<br>';
if ($user->rights->banque->modifier) { if ($permissiontoadd) {
$morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') { if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
}
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
} }
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
} else { } else {
if (!empty($object->fk_project)) { if (!empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref .= $proj->getNomUrl(1); $morehtmlref .= $proj->getNomUrl(1);
} else { if ($proj->title) {
$morehtmlref .= ''; $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
}
} }
} }
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
@ -622,25 +634,24 @@ if ($id) {
print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).'</span></td></tr>'; print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).'</span></td></tr>';
// Accountancy code // Account of Chart of account
print '<tr><td class="nowrap">'; $editvalue = '';
print $langs->trans("AccountAccounting");
print '</td><td>';
if (isModEnabled('accounting')) { if (isModEnabled('accounting')) {
$accountingaccount = new AccountingAccount($db); $editvalue = $formaccounting->select_account($object->accountancy_code, 'accountancy_code', 1, null, 1, 1);
$accountingaccount->fetch('', $object->accountancy_code, 1);
print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
} else {
print $object->accountancy_code;
} }
print '</td></tr>';
print '<tr><td class="nowrap">';
print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0);
print '</td><td>';
print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $permissiontoadd), 'asis', $editvalue, 0, null, '', 1, 'lengthAccountg');
print '</td></tr>'; print '</td></tr>';
// Subledger account // Subledger account
print '<tr><td class="nowrap">'; print '<tr><td class="nowrap">';
print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0); print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0);
print '</td><td>'; print '</td><td>';
print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0); print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0, null, '', 1, 'lengthAccounta');
print '</td></tr>'; print '</td></tr>';
$bankaccountnotfound = 0; $bankaccountnotfound = 0;
@ -689,13 +700,13 @@ if ($id) {
// Add button modify // Add button modify
// Clone // Clone
if ($user->rights->banque->modifier) { if ($permissiontoadd) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.dol_buildpath("/compta/bank/various_payment/card.php", 1).'?id='.$object->id.'&amp;action=clone">'.$langs->trans("ToClone")."</a></div>"; print '<div class="inline-block divButAction"><a class="butAction" href="'.dol_buildpath("/compta/bank/various_payment/card.php", 1).'?id='.$object->id.'&amp;action=clone">'.$langs->trans("ToClone")."</a></div>";
} }
// Delete // Delete
if (empty($object->rappro) || $bankaccountnotfound) { if (empty($object->rappro) || $bankaccountnotfound) {
if (!empty($user->rights->banque->modifier)) { if ($permissiontoadd) {
if ($alreadyaccounted) { if ($alreadyaccounted) {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("Accounted").'">'.$langs->trans("Delete").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("Accounted").'">'.$langs->trans("Delete").'</a></div>';
} else { } else {

View File

@ -100,7 +100,6 @@ if ($object->id) {
// Project // Project
if (isModEnabled('project')) { if (isModEnabled('project')) {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= $langs->trans('Project').' : ';
if ($user->rights->banque->modifier && 0) { if ($user->rights->banque->modifier && 0) {
if ($action != 'classify') { if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';

View File

@ -60,7 +60,6 @@ $morehtmlref = '<div class="refidno">';
// Project // Project
if (isModEnabled('project')) { if (isModEnabled('project')) {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= $langs->trans('Project').' : ';
if ($user->rights->banque->modifier && 0) { if ($user->rights->banque->modifier && 0) {
if ($action != 'classify') { if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';

View File

@ -178,8 +178,8 @@ if (empty($reshook)) {
// Mass actions // Mass actions
$objectclass = 'CashControl'; $objectclass = 'CashControl';
$objectlabel = 'CashControl'; $objectlabel = 'CashControl';
//$uploaddir = ''; $uploaddir = $conf->bank->dir_output;
//include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
} }
@ -376,15 +376,9 @@ $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters,
$param .= $hookmanager->resPrint; $param .= $hookmanager->resPrint;
// List of mass actions available // List of mass actions available
$arrayofmassactions = array( $arrayofmassactions = array();
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), if (!empty($permissiontodelete)) {
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
);
//if ($permissiontodelete) {
// $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
//}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
$arrayofmassactions = array();
} }
$massactionbutton = $form->selectMassAction('', $arrayofmassactions); $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
@ -585,7 +579,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
$object->cheque = $obj->cheque; $object->cheque = $obj->cheque;
print $object->getKanbanView(''); print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
if ($i == (min($num, $limit) - 1)) { if ($i == (min($num, $limit) - 1)) {
print '</div>'; print '</div>';
print '</td></tr>'; print '</td></tr>';

View File

@ -26,6 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("facture", "other")); $langs->loadLangs(array("facture", "other"));

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2013-2023 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
@ -437,6 +437,9 @@ if (empty($reshook)) {
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
$remise_percent = price2num(GETPOST('remise_percent'.$predef), '', 2); $remise_percent = price2num(GETPOST('remise_percent'.$predef), '', 2);
if (empty($remise_percent)) {
$remise_percent = 0;
}
// Extrafields // Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
@ -784,6 +787,9 @@ if (empty($reshook)) {
}*/ }*/
$remise_percent = price2num(GETPOST('remise_percent'), '', 2); $remise_percent = price2num(GETPOST('remise_percent'), '', 2);
if (empty($remise_percent)) {
$remise_percent = 0;
}
// Check minimum price // Check minimum price
$productid = GETPOST('productid', 'int'); $productid = GETPOST('productid', 'int');

View File

@ -86,6 +86,8 @@ $socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$lineid = GETPOST('lineid', 'int'); $lineid = GETPOST('lineid', 'int');
$userid = GETPOST('userid', 'int'); $userid = GETPOST('userid', 'int');
$search_ref = GETPOST('sf_ref', 'alpha') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); $search_ref = GETPOST('sf_ref', 'alpha') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
@ -3153,6 +3155,8 @@ if ($action == 'create') {
if ($soc->id > 0) { if ($soc->id > 0) {
print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n"; print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n";
} }
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input name="ref" type="hidden" value="provisoire">'; print '<input name="ref" type="hidden" value="provisoire">';
print '<input name="ref_client" type="hidden" value="'.$ref_client.'">'; print '<input name="ref_client" type="hidden" value="'.$ref_client.'">';
print '<input name="force_cond_reglement_id" type="hidden" value="0">'; print '<input name="force_cond_reglement_id" type="hidden" value="0">';
@ -4688,6 +4692,7 @@ if ($action == 'create') {
print '<form id="retained-warranty-form" method="POST" action="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'">'; print '<form id="retained-warranty-form" method="POST" action="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'">';
print '<input type="hidden" name="action" value="setretainedwarranty">'; print '<input type="hidden" name="action" value="setretainedwarranty">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input name="retained_warranty" type="number" step="0.01" min="0" max="100" value="'.$object->retained_warranty.'" >'; print '<input name="retained_warranty" type="number" step="0.01" min="0" max="100" value="'.$object->retained_warranty.'" >';
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
print '</form>'; print '</form>';
@ -4717,6 +4722,7 @@ if ($action == 'create') {
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'">'; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'">';
print '<input type="hidden" name="action" value="setretainedwarrantyconditions">'; print '<input type="hidden" name="action" value="setretainedwarrantyconditions">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
$retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int');
$retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement; $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement;
$retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID;
@ -4752,6 +4758,7 @@ if ($action == 'create') {
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'">'; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'">';
print '<input type="hidden" name="action" value="setretainedwarrantydatelimit">'; print '<input type="hidden" name="action" value="setretainedwarrantydatelimit">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input name="retained_warranty_date_limit" type="date" step="1" min="'.dol_print_date($object->date, '%Y-%m-%d').'" value="'.dol_print_date($defaultDate, '%Y-%m-%d').'" >'; print '<input name="retained_warranty_date_limit" type="date" step="1" min="'.dol_print_date($object->date, '%Y-%m-%d').'" value="'.dol_print_date($defaultDate, '%Y-%m-%d').'" >';
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
print '</form>'; print '</form>';
@ -4832,6 +4839,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="setrevenuestamp">'; print '<input type="hidden" name="action" value="setrevenuestamp">';
print '<input type="hidden" name="revenuestamp" id="revenuestamp_val" value="'.price2num($object->revenuestamp).'">'; print '<input type="hidden" name="revenuestamp" id="revenuestamp_val" value="'.price2num($object->revenuestamp).'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print $formother->select_revenue_stamp('', 'revenuestamp_type', $mysoc->country_code); print $formother->select_revenue_stamp('', 'revenuestamp_type', $mysoc->country_code);
print ' &rarr; <span id="revenuestamp_span"></span>'; print ' &rarr; <span id="revenuestamp_span"></span>';
print ' <input type="submit" class="button buttongen button-save" value="'.$langs->trans('Modify').'">'; print ' <input type="submit" class="button buttongen button-save" value="'.$langs->trans('Modify').'">';
@ -5371,6 +5379,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="updatealllines" />'; print '<input type="hidden" name="action" value="updatealllines" />';
print '<input type="hidden" name="id" value="'.$object->id.'" />'; print '<input type="hidden" name="id" value="'.$object->id.'" />';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<table id="tablelines_all_progress" class="noborder noshadow" width="100%">'; print '<table id="tablelines_all_progress" class="noborder noshadow" width="100%">';
@ -5409,6 +5418,7 @@ if ($action == 'create') {
<input type="hidden" name="mode" value=""> <input type="hidden" name="mode" value="">
<input type="hidden" name="page_y" value=""> <input type="hidden" name="page_y" value="">
<input type="hidden" name="id" value="' . $object->id.'"> <input type="hidden" name="id" value="' . $object->id.'">
<input type="hidden" name="backtopage" value="'.$backtopage.'">
'; ';
if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { if (!empty($conf->use_javascript_ajax) && $object->statut == 0) {

View File

@ -1733,12 +1733,6 @@ class Facture extends CommonInvoice
} }
} }
if (! is_object($hookmanager)) {
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($origin->db);
}
$hookmanager->initHooks(array('invoicedao')); $hookmanager->initHooks(array('invoicedao'));
$parameters = array('objFrom' => $origin); $parameters = array('objFrom' => $origin);
@ -3584,6 +3578,7 @@ class Facture extends CommonInvoice
/** /**
* Add an invoice line into database (linked to product/service or not). * Add an invoice line into database (linked to product/service or not).
* Note: ->thirdparty must be defined.
* Les parametres sont deja cense etre juste et avec valeurs finales a l'appel * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)

View File

@ -597,7 +597,7 @@ class ChargeSociales extends CommonObject
$this->ref = $this->label; $this->ref = $this->label;
} }
$label = img_picto('', 'tax').'<u class="paddingrightonly">'.$langs->trans("SocialContribution").'</u>'; $label = img_picto('', $this->picto, 'class="pictofixedwidth"').'<u class="paddingrightonly">'.$langs->trans("SocialContribution").'</u>';
if (isset($this->paye)) { if (isset($this->paye)) {
$label .= ' '.$this->getLibStatut(5); $label .= ' '.$this->getLibStatut(5);
} }

View File

@ -45,6 +45,7 @@ $langs->loadLangs(array('compta', 'banks', 'bills', 'hrm', 'projects'));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); $massaction = GETPOST('massaction', 'alpha');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
$optioncss = GETPOST('optioncss', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist'; $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist';
$mode = GETPOST('mode', 'alpha'); $mode = GETPOST('mode', 'alpha');
@ -126,6 +127,7 @@ if ($user->socid) {
$socid = $user->socid; $socid = $user->socid;
} }
$result = restrictedArea($user, 'tax', '', 'chargesociales', 'charges'); $result = restrictedArea($user, 'tax', '', 'chargesociales', 'charges');
$permissiontodelete = $user->rights->tax->charges->supprimer;
/* /*
@ -170,7 +172,14 @@ if (empty($reshook)) {
$search_type = ''; $search_type = '';
$search_account = ''; $search_account = '';
$search_array_options = array(); $search_array_options = array();
$toselect = array();
} }
// Mass actions
$objectclass = 'ChargeSociales';
$objectlabel = 'ChargeSociales';
$uploaddir = $conf->tax->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
} }
/* /*
@ -188,6 +197,8 @@ if (isModEnabled('project')) {
llxHeader('', $langs->trans("SocialContributions")); llxHeader('', $langs->trans("SocialContributions"));
$arrayofselected = is_array($toselect) ? $toselect : array();
$sql = "SELECT cs.rowid, cs.fk_type as type, cs.fk_user,"; $sql = "SELECT cs.rowid, cs.fk_type as type, cs.fk_user,";
$sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode, cs.fk_account,"; $sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode, cs.fk_account,";
if (isModEnabled('project')) { if (isModEnabled('project')) {
@ -378,6 +389,15 @@ if ($user->rights->tax->charges->creer) {
$newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create'); $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create');
} }
// List of mass actions available
$arrayofmassactions = array();
if (!empty($permissiontodelete)) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$moreforfilter = '';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') { if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -394,7 +414,7 @@ print '<input type="hidden" name="mode" value="'.$mode.'">';
$center = ''; $center = '';
print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1);
if (empty($mysoc->country_id) && empty($mysoc->country_code)) { if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
print '<div class="error">'; print '<div class="error">';
@ -408,8 +428,6 @@ if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
$db->close(); $db->close();
} }
$moreforfilter = '';
$massactionbutton = '';
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
@ -417,6 +435,10 @@ if ($massactionbutton) {
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1); $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
} }
$objecttmp = new ChargeSociales($db);
$trackid = 'sc'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
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";
@ -619,7 +641,7 @@ while ($i < $imaxinloop) {
} }
// Output Kanban // Output Kanban
$chargesociale_static->fk_project = $projectstatic->getNomUrl(); $chargesociale_static->fk_project = $projectstatic->getNomUrl();
print $chargesociale_static->getKanbanView(''); print $chargesociale_static->getKanbanView('', array('selected' => in_array($chargesociale_static->id, $arrayofselected)));
if ($i == ($imaxinloop - 1)) { if ($i == ($imaxinloop - 1)) {
print '</div>'; print '</div>';
print '</td></tr>'; print '</td></tr>';
@ -630,7 +652,15 @@ while ($i < $imaxinloop) {
// Action column // Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td></td>'; print '<td class="center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($chargesociale_static->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$chargesociale_static->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$chargesociale_static->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
} }
// Line number // Line number
@ -774,7 +804,15 @@ while ($i < $imaxinloop) {
// Action column // Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td></td>'; print '<td class="center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($chargesociale_static->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$chargesociale_static->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$chargesociale_static->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
} }
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;

View File

@ -86,7 +86,7 @@ abstract class ActionsContactCardCommon
* *
* @param string $action Type of action * @param string $action Type of action
* @param int $id Id * @param int $id Id
* @return string HTML output * @return void
*/ */
public function assign_values(&$action, $id) public function assign_values(&$action, $id)
{ {

View File

@ -83,7 +83,6 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
public function assign_values(&$action, $id) public function assign_values(&$action, $id)
{ {
// phpcs:enable // phpcs:enable
global $limit, $offset, $sortfield, $sortorder;
global $conf, $db, $langs, $user; global $conf, $db, $langs, $user;
global $form; global $form;

View File

@ -23,6 +23,7 @@
*/ */
require "../main.inc.php"; require "../main.inc.php";
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';

View File

@ -56,6 +56,7 @@ $langs->loadLangs(array("contracts", "orders", "companies", "bills", "products",
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
@ -1135,10 +1136,10 @@ if ($action == 'create') {
print '<form name="form_contract" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form name="form_contract" action="'.$_SERVER["PHP_SELF"].'" 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="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n"; print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n";
print '<input type="hidden" name="remise_percent" value="0">'; print '<input type="hidden" name="remise_percent" value="0">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head(); print dol_get_fiche_head();
@ -1350,6 +1351,7 @@ if ($action == 'create') {
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" 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="setremise">'; print '<input type="hidden" name="action" value="setremise">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
} }
// Contract card // Contract card
@ -1490,6 +1492,7 @@ if ($action == 'create') {
print '<form name="update" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">'; print '<form name="update" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" 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="updateline">'; print '<input type="hidden" name="action" value="updateline">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="elrowid" value="'.$object->lines[$cursorline - 1]->id.'">'; print '<input type="hidden" name="elrowid" value="'.$object->lines[$cursorline - 1]->id.'">';
print '<input type="hidden" name="fournprice" value="'.(!empty($object->lines[$cursorline - 1]->fk_fournprice) ? $object->lines[$cursorline - 1]->fk_fournprice : 0).'">'; print '<input type="hidden" name="fournprice" value="'.(!empty($object->lines[$cursorline - 1]->fk_fournprice) ? $object->lines[$cursorline - 1]->fk_fournprice : 0).'">';
@ -1808,7 +1811,7 @@ if ($action == 'create') {
$moreparam = 'style="display: none;"'; $moreparam = 'style="display: none;"';
} }
print '<tr class="oddeven" '.$moreparam.'>'; print '<tr class="oddeven" '.$moreparam.'>';
print '<td class="tdhrthin" colspan="'.($conf->margin->enabled ? 7 : 6).'"><hr class="opacitymedium tdhrthin"></td>'; print '<td class="tdhrthin" colspan="'.(isModEnabled('margin') ? 7 : 6).'"><hr class="opacitymedium tdhrthin"></td>';
print "</tr>\n"; print "</tr>\n";
} }
@ -1914,6 +1917,7 @@ if ($action == 'create') {
print '<form name="active" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form name="active" action="'.$_SERVER["PHP_SELF"].'" 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="confirm_active">'; print '<input type="hidden" name="action" value="confirm_active">';
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.'">';
print '<input type="hidden" name="ligne" value="'.GETPOST('ligne', 'int').'">'; print '<input type="hidden" name="ligne" value="'.GETPOST('ligne', 'int').'">';
print '<input type="hidden" name="confirm" value="yes">'; print '<input type="hidden" name="confirm" value="yes">';
@ -1973,6 +1977,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="confirm" value="yes">'; print '<input type="hidden" name="confirm" value="yes">';
print '<input type="hidden" name="action" value="confirm_closeline">'; print '<input type="hidden" name="action" value="confirm_closeline">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<table class="noborder tableforservicepart2'.($cursorline < $nbofservices ? ' boxtablenobottom' : '').'" width="100%">'; print '<table class="noborder tableforservicepart2'.($cursorline < $nbofservices ? ' boxtablenobottom' : '').'" width="100%">';
@ -2038,6 +2043,7 @@ if ($action == 'create') {
<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.'">
<input type="hidden" name="page_y" value=""> <input type="hidden" name="page_y" value="">
<input type="hidden" name="backtopage" value="'.$backtopage.'">
'; ';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';

View File

@ -18,7 +18,7 @@
/** /**
* \file htdocs/core/ajax/objectonoff.php * \file htdocs/core/ajax/objectonoff.php
* \brief File to set status for an object * \brief File to set status for an object
* This Ajax service is called when option MAIN_DIRECT_STATUS_UPDATE is set. * This Ajax service is oftenly called when option MAIN_DIRECT_STATUS_UPDATE is set.
*/ */
if (!defined('NOTOKENRENEWAL')) { if (!defined('NOTOKENRENEWAL')) {
@ -53,15 +53,34 @@ $format = 'int';
$object = new GenericObject($db); $object = new GenericObject($db);
$tablename = $element; $tmparray = explode('@', $element);
if ($tablename == 'websitepage') { if (empty($tmparray[1])) {
$tablename = 'website_page'; $subelement = '';
}
$object->table_element = $tablename; $object->module = $element;
$object->element = $element;
$object->table_element = $element;
// Special case for compatibility
if ($object->table_element == 'websitepage') {
$object->table_element = 'website_page';
}
} else {
$element = $tmparray[0];
$subelement = $tmparray[1];
$object->module = $element;
$object->element = $subelement;
$object->table_element = $object->module.'_'.$object->element;
}
$object->id = $id; $object->id = $id;
$object->fields[$field] = array('type' => $format, 'enabled' => 1); $object->fields[$field] = array('type' => $format, 'enabled' => 1);
$module = $object->module;
$element = $object->element;
//var_dump($object->module); var_dump($object->element); var_dump($object->table_element);
// Security check // Security check
if (!empty($user->socid)) { if (!empty($user->socid)) {
$socid = $user->socid; $socid = $user->socid;
@ -70,12 +89,20 @@ if (!empty($user->socid)) {
//$user->hasRight('societe', 'lire') = 0;$user->rights->fournisseur->lire = 0; //$user->hasRight('societe', 'lire') = 0;$user->rights->fournisseur->lire = 0;
//restrictedArea($user, 'societe', $id); //restrictedArea($user, 'societe', $id);
if (in_array($field, array('status'))) { // We check permission.
restrictedArea($user, $element, $id); // Check is done on $user->rights->element->create or $user->rights->element->subelement->create (because $action = 'set')
if (preg_match('/status$/', $field)) {
$module = $object->module;
$element = $object->element;
$usesublevelpermission = ($module != $element ? $element : '');
if ($usesublevelpermission && !isset($user->rights->$module->$element)) { // There is no permission on object defined, we will check permission on module directly
$usesublevelpermission = '';
}
restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission);
} elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch'))) { // Special case for products } elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch'))) { // Special case for products
restrictedArea($user, 'produit|service', $id, 'product&product', '', '', 'rowid'); restrictedArea($user, 'produit|service', $object, 'product&product', '', '', 'rowid');
} else { } else {
httponly_accessforbidden("Bad value for combination of parameters element/field."); httponly_accessforbidden("Bad value for combination of parameters element/field."); // This includes the exit.
} }
@ -89,7 +116,7 @@ print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"])
// Registering new values // Registering new values
if (($action == 'set') && !empty($id)) { if (($action == 'set') && !empty($id)) {
$triggerkey = strtoupper($element).'_UPDATE'; $triggerkey = strtoupper(($module != $element ? $module.'_' : '').$element).'_UPDATE';
// Special case // Special case
if ($triggerkey == 'SOCIETE_UPDATE') { if ($triggerkey == 'SOCIETE_UPDATE') {
$triggerkey = 'COMPANY_MODIFY'; $triggerkey = 'COMPANY_MODIFY';
@ -98,5 +125,11 @@ if (($action == 'set') && !empty($id)) {
$triggerkey = 'PRODUCT_MODIFY'; $triggerkey = 'PRODUCT_MODIFY';
} }
$object->setValueFrom($field, $value, $tablename, $id, $format, '', $user, $triggerkey); $result = $object->setValueFrom($field, $value, $object->table_element, $id, $format, '', $user, $triggerkey);
if ($result < 0) {
print $object->error;
http_response_code(500);
exit;
}
} }

View File

@ -25,7 +25,6 @@
*/ */
include_once DOL_DOCUMENT_ROOT . '/core/boxes/modules_boxes.php'; include_once DOL_DOCUMENT_ROOT . '/core/boxes/modules_boxes.php';
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
/** /**

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015-2020 Frederic France <frederic.france@netlogic.fr> * Copyright (C) 2015-2023 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021-2022 Waël Almoman <info@almoman.com> * Copyright (C) 2021-2022 Waël Almoman <info@almoman.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -87,6 +87,7 @@ class box_members_by_tags extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
$staticmember = new Adherent($this->db); $staticmember = new Adherent($this->db);
$now = dol_now();
$year = date('Y'); $year = date('Y');
$numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH"); $numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH");

View File

@ -1268,6 +1268,7 @@ class CMailFile
$srcfile = $dolibarr_main_data_root."/dolibarr_mail.log"; $srcfile = $dolibarr_main_data_root."/dolibarr_mail.log";
$destfile = $dolibarr_main_data_root."/dolibarr_mail.err"; $destfile = $dolibarr_main_data_root."/dolibarr_mail.err";
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_move($srcfile, $destfile, 0, 1, 0, 0); dol_move($srcfile, $destfile, 0, 1, 0, 0);
} }
} }

View File

@ -12,7 +12,7 @@
* Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr> * Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr>
* Copyright (C) 2017-2019 Nicolas ZABOURI <info@inovea-conseil.com> * Copyright (C) 2017-2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com> * Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat> * Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr> * Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2021 Grégory Blémand <gregory.blemand@atm-consulting.fr> * Copyright (C) 2021 Grégory Blémand <gregory.blemand@atm-consulting.fr>
@ -183,6 +183,7 @@ abstract class CommonObject
public $fk_project; public $fk_project;
/** /**
* @var Project The related project object
* @deprecated * @deprecated
* @see project * @see project
*/ */
@ -2121,6 +2122,8 @@ abstract class CommonObject
$error = 0; $error = 0;
dol_syslog(__METHOD__, LOG_DEBUG);
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".$this->db->prefix().$table." SET "; $sql = "UPDATE ".$this->db->prefix().$table." SET ";
@ -2145,7 +2148,6 @@ abstract class CommonObject
$sql .= " WHERE ".$id_field." = ".((int) $id); $sql .= " WHERE ".$id_field." = ".((int) $id);
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
if ($trigkey) { if ($trigkey) {
@ -4967,9 +4969,9 @@ abstract class CommonObject
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
* *
* @param string $action Action code * @param string $action Action code
* @param string $seller Object of seller third party * @param Societe $seller Object of seller third party
* @param string $buyer Object of buyer third party * @param Societe $buyer Object of buyer third party
* @param int $selected Object line selected * @param int $selected ID line selected
* @param int $dateSelector 1=Show also date range input fields * @param int $dateSelector 1=Show also date range input fields
* @param string $defaulttpldir Directory where to find the template * @param string $defaulttpldir Directory where to find the template
* @return void * @return void
@ -5058,9 +5060,9 @@ abstract class CommonObject
* @param int $num Number of line (0) * @param int $num Number of line (0)
* @param int $i I * @param int $i I
* @param int $dateSelector 1=Show also date range input fields * @param int $dateSelector 1=Show also date range input fields
* @param string $seller Object of seller third party * @param Societe $seller Object of seller third party
* @param string $buyer Object of buyer third party * @param Societe $buyer Object of buyer third party
* @param int $selected Object line selected * @param int $selected ID line selected
* @param Extrafields $extrafields Object of extrafields * @param Extrafields $extrafields Object of extrafields
* @param string $defaulttpldir Directory where to find the template (deprecated) * @param string $defaulttpldir Directory where to find the template (deprecated)
* @return void * @return void
@ -5073,8 +5075,6 @@ abstract class CommonObject
$object_rights = $this->getRights(); $object_rights = $this->getRights();
$element = $this->element;
$text = ''; $text = '';
$description = ''; $description = '';

View File

@ -723,14 +723,6 @@ class Conf
} }
} }
// conf->mailing->email_from = email by default to send Dolibarr emailings
if (isModEnabled('mailing')) {
$this->mailing->email_from = $this->email_from;
if (!empty($this->global->MAILING_EMAIL_FROM)) {
$this->mailing->email_from = $this->global->MAILING_EMAIL_FROM;
}
}
if (!isset($this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { if (!isset($this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
$this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP = 1; $this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP = 1;
} }

View File

@ -60,6 +60,7 @@ class FileUpload
$this->element = $element; $this->element = $element;
$pathname = $filename = $element; $pathname = $filename = $element;
$regs = array();
if (preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) { if (preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) {
$pathname = $regs[1]; $pathname = $regs[1];
$filename = $regs[2]; $filename = $regs[2];
@ -266,7 +267,7 @@ class FileUpload
protected function getFileObject($file_name) protected function getFileObject($file_name)
{ {
if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) {
return; return null;
} }
$file_path = $this->options['upload_dir'].$file_name; $file_path = $this->options['upload_dir'].$file_name;
@ -310,7 +311,7 @@ class FileUpload
global $maxwidthmini, $maxheightmini; global $maxwidthmini, $maxheightmini;
if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) {
return; return false;
} }
$file_path = $this->options['upload_dir'].$file_name; $file_path = $this->options['upload_dir'].$file_name;
@ -345,7 +346,7 @@ class FileUpload
protected function validate($uploaded_file, $file, $error, $index) protected function validate($uploaded_file, $file, $error, $index)
{ {
if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) {
return; return false;
} }
if ($error) { if ($error) {
@ -459,12 +460,12 @@ class FileUpload
* @param string $type Type * @param string $type Type
* @param string $error Error * @param string $error Error
* @param string $index Index * @param string $index Index
* @return stdClass * @return stdClass|null
*/ */
protected function handleFileUpload($uploaded_file, $name, $size, $type, $error, $index) protected function handleFileUpload($uploaded_file, $name, $size, $type, $error, $index)
{ {
if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) {
return; return null;
} }
$file = new stdClass(); $file = new stdClass();
@ -590,12 +591,12 @@ class FileUpload
/** /**
* Delete uploaded file * Delete uploaded file
* *
* @return string * @return string|null
*/ */
public function delete() public function delete()
{ {
if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) {
return; return null;
} }
$file_name = isset($_REQUEST['file']) ? $file_name = isset($_REQUEST['file']) ?

View File

@ -191,23 +191,23 @@ class Form
/** /**
* Output value of a field for an editable field * Output value of a field for an editable field
* *
* @param string $text Text of label (not used in this function) * @param string $text Text of label (not used in this function)
* @param string $htmlname Name of select field * @param string $htmlname Name of select field
* @param string $value Value to show/edit * @param string $value Value to show/edit
* @param object $object Object (that we want to show) * @param object $object Object (that we want to show)
* @param boolean $perm Permission to allow button to edit parameter * @param boolean $perm Permission to allow button to edit parameter
* @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...') * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...')
* @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value). Use '' to use same than $value * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value, or a select combo). Use '' to use same than $value
* @param object $extObject External object ??? * @param object $extObject External object ???
* @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
* @param string $moreparam More param to add on the form on action href URL parameter * @param string $moreparam More param to add on the form on action href URL parameter
* @param int $notabletag Do no output table tags * @param int $notabletag Do no output table tags
* @param string $formatfunc Call a specific function to output field in view mode (For example: 'dol_print_email') * @param string $formatfunc Call a specific method of $object->$formatfunc to output field in view mode (For example: 'dol_print_email')
* @param string $paramid Key of parameter for id ('id', 'socid') * @param string $paramid Key of parameter for id ('id', 'socid')
* @param string $gm 'auto' or 'tzuser' or 'tzuserrel' or 'tzserver' (when $typeofdata is a date) * @param string $gm 'auto' or 'tzuser' or 'tzuserrel' or 'tzserver' (when $typeofdata is a date)
* @param array $moreoptions Array with more options. For example array('addnowlink'=>1), array('valuealreadyhtmlescaped'=>1) * @param array $moreoptions Array with more options. For example array('addnowlink'=>1), array('valuealreadyhtmlescaped'=>1)
* @param string $editaction [=''] use GETPOST default action or set action to edit mode * @param string $editaction [=''] use GETPOST default action or set action to edit mode
* @return string HTML edit field * @return string HTML edit field
*/ */
public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 1, $formatfunc = '', $paramid = 'id', $gm = 'auto', $moreoptions = array(), $editaction = '') public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 1, $formatfunc = '', $paramid = 'id', $gm = 'auto', $moreoptions = array(), $editaction = '')
{ {
@ -310,6 +310,8 @@ class Form
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
$doleditor = new DolEditor($htmlname, ($editvalue ? $editvalue : $value), (empty($tmp[2]) ? '' : $tmp[2]), (empty($tmp[3]) ? '100' : $tmp[3]), (empty($tmp[1]) ? 'dolibarr_notes' : $tmp[1]), 'In', (empty($tmp[5]) ? 0 : $tmp[5]), (isset($tmp[8]) ? ($tmp[8] ? true : false) : true), true, (empty($tmp[6]) ? '20' : $tmp[6]), (empty($tmp[7]) ? '100' : $tmp[7])); $doleditor = new DolEditor($htmlname, ($editvalue ? $editvalue : $value), (empty($tmp[2]) ? '' : $tmp[2]), (empty($tmp[3]) ? '100' : $tmp[3]), (empty($tmp[1]) ? 'dolibarr_notes' : $tmp[1]), 'In', (empty($tmp[5]) ? 0 : $tmp[5]), (isset($tmp[8]) ? ($tmp[8] ? true : false) : true), true, (empty($tmp[6]) ? '20' : $tmp[6]), (empty($tmp[7]) ? '100' : $tmp[7]));
$ret .= $doleditor->Create(1); $ret .= $doleditor->Create(1);
} elseif ($typeofdata == 'asis') {
$ret .= ($editvalue ? $editvalue : $value);
} }
if (empty($notabletag)) { if (empty($notabletag)) {
$ret .= '</td>'; $ret .= '</td>';
@ -4877,6 +4879,8 @@ class Form
print '<span class="opacitymedium">' . $langs->trans("NoEstablishmentFound") . '</span>'; print '<span class="opacitymedium">' . $langs->trans("NoEstablishmentFound") . '</span>';
} }
} }
return $num;
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
@ -7947,7 +7951,13 @@ class Form
} }
// Add where from hooks // Add where from hooks
$parameters = array(); $parameters = array(
'object' => $objecttmp,
'htmlname' => $htmlname,
'filter' => $filter,
'searchkey' => $searchkey
);
$reshook = $hookmanager->executeHooks('selectForFormsListWhere', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('selectForFormsListWhere', $parameters); // Note that $action and $object may have been modified by hook
if (!empty($hookmanager->resPrint)) { if (!empty($hookmanager->resPrint)) {
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
@ -8757,9 +8767,9 @@ class Form
); );
$reshook = $hookmanager->executeHooks('showLinkedObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('showLinkedObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) { $nbofdifferenttypes = count($object->linkedObjects);
$nbofdifferenttypes = count($object->linkedObjects);
if (empty($reshook)) {
print '<!-- showLinkedObjectBlock -->'; print '<!-- showLinkedObjectBlock -->';
print load_fiche_titre($langs->trans($title), $morehtmlright, '', 0, 0, 'showlinkedobjectblock'); print load_fiche_titre($langs->trans($title), $morehtmlright, '', 0, 0, 'showlinkedobjectblock');
@ -8885,20 +8895,19 @@ class Form
$res = @include dol_buildpath('core/tpl/objectlinked_lineimport.tpl.php'); $res = @include dol_buildpath('core/tpl/objectlinked_lineimport.tpl.php');
} }
print '</div>'; print '</div>';
return $nbofdifferenttypes;
} }
return $nbofdifferenttypes;
} }
/** /**
* Show block with links to link to other objects. * Show block with links to link to other objects.
* *
* @param CommonObject $object Object we want to show links to * @param CommonObject $object Object we want to show links to
* @param array $restrictlinksto Restrict links to some elements, for exemple array('order') or array('supplier_order'). null or array() if no restriction. * @param array $restrictlinksto Restrict links to some elements, for exemple array('order') or array('supplier_order'). null or array() if no restriction.
* @param array $excludelinksto Do not show links of this type, for exemple array('order') or array('supplier_order'). null or array() if no exclusion. * @param array $excludelinksto Do not show links of this type, for exemple array('order') or array('supplier_order'). null or array() if no exclusion.
* @return string <0 if KO, >0 if OK * @return string HTML block
*/ */
public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array()) public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array())
{ {
@ -10211,9 +10220,9 @@ class Form
$out .= '</select>'; $out .= '</select>';
} }
return $out;
$this->db->free($resql); $this->db->free($resql);
return $out;
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
return ''; return '';

View File

@ -989,15 +989,15 @@ class FormCompany extends Form
// phpcs:enable // phpcs:enable
$tax = get_localtax_by_third($local); $tax = get_localtax_by_third($local);
$num = $this->db->num_rows($tax); if ($tax) {
$i = 0;
if ($num) {
$valors = explode(":", $tax); $valors = explode(":", $tax);
$nbvalues = count($valors);
if (count($valors) > 1) { if ($nbvalues > 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) { $i = 0;
while ($i < $nbvalues) {
if ($selected == $valors[$i]) { if ($selected == $valors[$i]) {
print '<option value="'.$valors[$i].'" selected>'; print '<option value="'.$valors[$i].'" selected>';
} else { } else {
@ -1007,7 +1007,7 @@ class FormCompany extends Form
print '</option>'; print '</option>';
$i++; $i++;
} }
print'</select>'; print '</select>';
} }
} }
} }

View File

@ -58,7 +58,7 @@ class FormProjets
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Output a combo list with projects qualified for a third party / user * Output a combo list with projects qualified for a third party / user
* *
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
* @param string|Project $selected Id of preselected project or Project (or ''). Note: If you know the ref, you can also provide it into $selected_input_value to save one request in some cases. * @param string|Project $selected Id of preselected project or Project (or ''). Note: If you know the ref, you can also provide it into $selected_input_value to save one request in some cases.
@ -145,7 +145,7 @@ class FormProjets
* @param int $htmlid Html id to use instead of htmlname * @param int $htmlid Html id to use instead of htmlname
* @param string $morecss More CSS * @param string $morecss More CSS
* @param string $morefilter More filters (Must be a sql sanitized string) * @param string $morefilter More filters (Must be a sql sanitized string)
* @return int Nb of project if OK, <0 if KO * @return int|string|array HTML string or array of option or <0 if KO
*/ */
public function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500', $morefilter = '') public function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500', $morefilter = '')
{ {

View File

@ -339,7 +339,7 @@ class FormSetup
* Method used to test module builder convertion to this form usage * Method used to test module builder convertion to this form usage
* *
* @param array $params an array of arrays of params from old modulBuilder params * @param array $params an array of arrays of params from old modulBuilder params
* @return void * @return boolean
*/ */
public function addItemsFromParamsArray($params) public function addItemsFromParamsArray($params)
{ {
@ -347,6 +347,7 @@ class FormSetup
foreach ($params as $confKey => $param) { foreach ($params as $confKey => $param) {
$this->addItemFromParams($confKey, $param); // todo manage error $this->addItemFromParams($confKey, $param); // todo manage error
} }
return true;
} }

View File

@ -701,7 +701,7 @@ class FormTicket
{ {
global $langs, $user; global $langs, $user;
$selected = is_array($selected) ? $selected : (!empty($selected) ? array($selected) : array()); $selected = is_array($selected) ? $selected : (!empty($selected) ? explode(',', $selected) : array());
$ticketstat = new Ticket($this->db); $ticketstat = new Ticket($this->db);
dol_syslog(get_class($this) . "::select_types_tickets " . implode(';', $selected) . ", " . $htmlname . ", " . $filtertype . ", " . $format . ", " . $multiselect, LOG_DEBUG); dol_syslog(get_class($this) . "::select_types_tickets " . implode(';', $selected) . ", " . $htmlname . ", " . $filtertype . ", " . $format . ", " . $multiselect, LOG_DEBUG);

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2020-2023 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -98,7 +98,7 @@ $arrayoftype = array(
'proposal' => array('label' => 'Proposals', 'picto'=>'proposal', 'ObjectClassName' => 'Propal', 'enabled' => isModEnabled('propal'), 'ClassPath' => "/comm/propal/class/propal.class.php"), 'proposal' => array('label' => 'Proposals', 'picto'=>'proposal', 'ObjectClassName' => 'Propal', 'enabled' => isModEnabled('propal'), 'ClassPath' => "/comm/propal/class/propal.class.php"),
'order' => array('label' => 'Orders', 'picto'=>'order', 'ObjectClassName' => 'Commande', 'enabled' => isModEnabled('commande'), 'ClassPath' => "/commande/class/commande.class.php"), 'order' => array('label' => 'Orders', 'picto'=>'order', 'ObjectClassName' => 'Commande', 'enabled' => isModEnabled('commande'), 'ClassPath' => "/commande/class/commande.class.php"),
'invoice' => array('langs'=>'facture', 'label' => 'Invoices', 'picto'=>'bill', 'ObjectClassName' => 'Facture', 'enabled' => isModEnabled('facture'), 'ClassPath' => "/compta/facture/class/facture.class.php"), 'invoice' => array('langs'=>'facture', 'label' => 'Invoices', 'picto'=>'bill', 'ObjectClassName' => 'Facture', 'enabled' => isModEnabled('facture'), 'ClassPath' => "/compta/facture/class/facture.class.php"),
'invoice_template'=>array('langs'=>'facture', 'label' => 'PredefinedInvoices', 'picto'=>'bill', 'ObjectClassName' => 'FactureRec', 'enabled' => isModEnabled('facture'), 'ClassPath' => "/compta/class/facturerec.class.php", 'langs'=>'bills'), 'invoice_template'=>array('label' => 'PredefinedInvoices', 'picto'=>'bill', 'ObjectClassName' => 'FactureRec', 'enabled' => isModEnabled('facture'), 'ClassPath' => "/compta/class/facturerec.class.php", 'langs'=>'bills'),
'contract' => array('label' => 'Contracts', 'picto'=>'contract', 'ObjectClassName' => 'Contrat', 'enabled' => isModEnabled('contrat'), 'ClassPath' => "/contrat/class/contrat.class.php", 'langs'=>'contracts'), 'contract' => array('label' => 'Contracts', 'picto'=>'contract', 'ObjectClassName' => 'Contrat', 'enabled' => isModEnabled('contrat'), 'ClassPath' => "/contrat/class/contrat.class.php", 'langs'=>'contracts'),
'contractdet' => array('label' => 'ContractLines', 'picto'=>'contract', 'ObjectClassName' => 'ContratLigne', 'enabled' => isModEnabled('contrat'), 'ClassPath' => "/contrat/class/contrat.class.php", 'langs'=>'contracts'), 'contractdet' => array('label' => 'ContractLines', 'picto'=>'contract', 'ObjectClassName' => 'ContratLigne', 'enabled' => isModEnabled('contrat'), 'ClassPath' => "/contrat/class/contrat.class.php", 'langs'=>'contracts'),
'bom' => array('label' => 'BOM', 'picto'=>'bom', 'ObjectClassName' => 'Bom', 'enabled' => isModEnabled('bom')), 'bom' => array('label' => 'BOM', 'picto'=>'bom', 'ObjectClassName' => 'Bom', 'enabled' => isModEnabled('bom')),

View File

@ -935,17 +935,17 @@ class DoliDBMysqli extends DoliDB
if ($field_desc['null'] == 'not null' || $field_desc['null'] == 'NOT NULL') { if ($field_desc['null'] == 'not null' || $field_desc['null'] == 'NOT NULL') {
// We will try to change format of column to NOT NULL. To be sure the ALTER works, we try to update fields that are NULL // We will try to change format of column to NOT NULL. To be sure the ALTER works, we try to update fields that are NULL
if ($field_desc['type'] == 'varchar' || $field_desc['type'] == 'text') { if ($field_desc['type'] == 'varchar' || $field_desc['type'] == 'text') {
$sqlbis = "UPDATE ".$table." SET ".$field_name." = '".$this->escape($field_desc['default'] ? $field_desc['default'] : '')."' WHERE ".$field_name." IS NULL"; $sqlbis = "UPDATE ".$table." SET ".$field_name." = '".$this->escape(isset($field_desc['default']) ? $field_desc['default'] : '')."' WHERE ".$field_name." IS NULL";
$this->query($sqlbis); $this->query($sqlbis);
} elseif ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') { } elseif ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') {
$sqlbis = "UPDATE ".$table." SET ".$field_name." = ".((int) $this->escape($field_desc['default'] ? $field_desc['default'] : 0))." WHERE ".$field_name." IS NULL"; $sqlbis = "UPDATE ".$table." SET ".$field_name." = ".((int) $this->escape(isset($field_desc['default']) ? $field_desc['default'] : 0))." WHERE ".$field_name." IS NULL";
$this->query($sqlbis); $this->query($sqlbis);
} }
$sql .= " NOT NULL"; $sql .= " NOT NULL";
} }
if ($field_desc['default'] != '') { if (isset($field_desc['default']) && $field_desc['default'] != '') {
if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') { if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') {
$sql .= " DEFAULT ".$this->escape($field_desc['default']); $sql .= " DEFAULT ".$this->escape($field_desc['default']);
} elseif ($field_desc['type'] != 'text') { } elseif ($field_desc['type'] != 'text') {

View File

@ -1183,7 +1183,7 @@ class DoliDBPgsql extends DoliDB
$sql = "ALTER TABLE ".$table." ADD ".$field_name." "; $sql = "ALTER TABLE ".$table." ADD ".$field_name." ";
$sql .= $field_desc['type']; $sql .= $field_desc['type'];
if (preg_match("/^[^\s]/i", $field_desc['value'])) { if (preg_match("/^[^\s]/i", $field_desc['value'])) {
if (!in_array($field_desc['type'], array('int', 'date', 'datetime')) && $field_desc['value']) { if (!in_array($field_desc['type'], array('smallint', 'int', 'date', 'datetime')) && $field_desc['value']) {
$sql .= "(".$field_desc['value'].")"; $sql .= "(".$field_desc['value'].")";
} }
} }
@ -1225,23 +1225,25 @@ class DoliDBPgsql extends DoliDB
{ {
// phpcs:enable // phpcs:enable
$sql = "ALTER TABLE ".$table; $sql = "ALTER TABLE ".$table;
$sql .= " MODIFY COLUMN ".$field_name." ".$field_desc['type']; $sql .= " ALTER COLUMN '".$this->escape($field_name)."' TYPE ".$field_desc['type'];
if (in_array($field_desc['type'], array('double', 'varchar')) && $field_desc['value']) { if (preg_match("/^[^\s]/i", $field_desc['value'])) {
$sql .= "(".$field_desc['value'].")"; if (!in_array($field_desc['type'], array('smallint', 'int', 'date', 'datetime')) && $field_desc['value']) {
$sql .= "(".$field_desc['value'].")";
}
} }
if ($field_desc['null'] == 'not null' || $field_desc['null'] == 'NOT NULL') { if ($field_desc['null'] == 'not null' || $field_desc['null'] == 'NOT NULL') {
// We will try to change format of column to NOT NULL. To be sure the ALTER works, we try to update fields that are NULL // We will try to change format of column to NOT NULL. To be sure the ALTER works, we try to update fields that are NULL
if ($field_desc['type'] == 'varchar' || $field_desc['type'] == 'text') { if ($field_desc['type'] == 'varchar' || $field_desc['type'] == 'text') {
$sqlbis = "UPDATE ".$table." SET ".$field_name." = '".$this->escape($field_desc['default'] ? $field_desc['default'] : '')."' WHERE ".$field_name." IS NULL"; $sqlbis = "UPDATE ".$table." SET ".$this->escape($field_name)." = '".$this->escape(isset($field_desc['default']) ? $field_desc['default'] : '')."' WHERE ".$this->escape($field_name)." IS NULL";
$this->query($sqlbis); $this->query($sqlbis);
} elseif ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') { } elseif ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') {
$sqlbis = "UPDATE ".$table." SET ".$field_name." = ".((int) $this->escape($field_desc['default'] ? $field_desc['default'] : 0))." WHERE ".$field_name." IS NULL"; $sqlbis = "UPDATE ".$table." SET ".$this->escape($field_name)." = ".((int) $this->escape(isset($field_desc['default']) ? $field_desc['default'] : 0))." WHERE ".$this->escape($field_name)." IS NULL";
$this->query($sqlbis); $this->query($sqlbis);
} }
} }
if ($field_desc['default'] != '') { if (isset($field_desc['default']) && $field_desc['default'] != '') {
if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') { if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') {
$sql .= " DEFAULT ".$this->escape($field_desc['default']); $sql .= " DEFAULT ".$this->escape($field_desc['default']);
} elseif ($field_desc['type'] != 'text') { } elseif ($field_desc['type'] != 'text') {

View File

@ -696,8 +696,8 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
* @param Object $object Object to set * @param Object $object Object to set
* @param string $code Name of property in object : 'status' or 'status_buy' for product by example * @param string $code Name of property in object : 'status' or 'status_buy' for product by example
* @param string $field Name of database field : 'tosell' or 'tobuy' for product by example * @param string $field Name of database field : 'tosell' or 'tobuy' for product by example
* @param string $text_on Text if on * @param string $text_on Text if on ('Text' or 'Text:css picto on')
* @param string $text_off Text if off * @param string $text_off Text if off ('Text' or 'Text:css picto on')
* @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
* @param string $morecss More CSS * @param string $morecss More CSS
* @param string $htmlname Name of HTML component. Keep '' or use a different value if you need to use this component several time on same page for same property. * @param string $htmlname Name of HTML component. Keep '' or use a different value if you need to use this component several time on same page for same property.
@ -710,6 +710,7 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input =
if (empty($htmlname)) { if (empty($htmlname)) {
$htmlname = $code; $htmlname = $code;
} }
//var_dump($object->module); var_dump($object->element);
$out = '<script> $out = '<script>
$(function() { $(function() {
@ -722,8 +723,8 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input =
action: \'set\', action: \'set\',
field: \''.dol_escape_js($field).'\', field: \''.dol_escape_js($field).'\',
value: \'1\', value: \'1\',
element: \''.dol_escape_js($object->element).'\', element: \''.dol_escape_js(((empty($object->module) || $object->module == $object->element) ? '' : $object->module.'@').$object->element).'\',
id: \''.$object->id.'\', id: \''.((int) $object->id).'\',
token: \''.currentToken().'\' token: \''.currentToken().'\'
}, },
function() { function() {
@ -754,8 +755,8 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input =
action: \'set\', action: \'set\',
field: \''.dol_escape_js($field).'\', field: \''.dol_escape_js($field).'\',
value: \'0\', value: \'0\',
element: \''.dol_escape_js($object->element).'\', element: \''.dol_escape_js(((empty($object->module) || $object->module == $object->element) ? '' : $object->module.'@').$object->element).'\',
id: \''.$object->id.'\', id: \''.((int) $object->id).'\',
token: \''.currentToken().'\' token: \''.currentToken().'\'
}, },
function() { function() {
@ -780,8 +781,22 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input =
}); });
}); });
</script>'; </script>';
$out .= '<span id="set_'.$htmlname.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? 'hideobject' : '').($morecss ? ' '.$morecss : '').'">'.img_picto($langs->trans($text_off), 'switch_off').'</span>';
$out .= '<span id="del_'.$htmlname.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? '' : 'hideobject').($morecss ? ' '.$morecss : '').'">'.img_picto($langs->trans($text_on), 'switch_on').'</span>'; $switchon = 'switch_on';
$switchoff = 'switch_off';
$tmparray = explode(':', $text_on);
if (!empty($tmparray[1])) {
$text_on = $tmparray[0];
$switchon = $tmparray[1];
}
$tmparray = explode(':', $text_off);
if (!empty($tmparray[1])) {
$text_off = $tmparray[0];
$switchoff = $tmparray[1];
}
$out .= '<span id="set_'.$htmlname.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? 'hideobject' : '').($morecss ? ' '.$morecss : '').'">'.img_picto($langs->trans($text_off), $switchoff).'</span>';
$out .= '<span id="del_'.$htmlname.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? '' : 'hideobject').($morecss ? ' '.$morecss : '').'">'.img_picto($langs->trans($text_on), $switchon).'</span>';
return $out; return $out;
} }

View File

@ -703,10 +703,10 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null)
} }
/** /**
* Retourne le nom traduit de la forme juridique * Return the name translated of juridical status
* *
* @param string $code Code de la forme juridique * @param string $code Code of juridical status
* @return string Nom traduit du pays * @return string Value of the juridical status
*/ */
function getFormeJuridiqueLabel($code) function getFormeJuridiqueLabel($code)
{ {
@ -717,20 +717,24 @@ function getFormeJuridiqueLabel($code)
} }
$sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique"; $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique";
$sql .= " WHERE code='".$db->escape($code)."'"; $sql .= " WHERE code = '".$db->escape($code)."'";
dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG); dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) { if ($num) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$label = ($obj->libelle != '-' ? $obj->libelle : ''); $label = ($obj->libelle != '-' ? $obj->libelle : '');
return $label;
return $langs->trans($label);
} else { } else {
return $langs->trans("NotDefined"); return $langs->trans("NotDefined");
} }
} else {
return 'Error '.$db->lasterror();
} }
} }
@ -1494,7 +1498,7 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprin
*/ */
function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC', $module = '') function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC', $module = '')
{ {
global $user, $conf; global $user, $conf, $hookmanager;
global $form; global $form;
global $param, $massactionbutton; global $param, $massactionbutton;
@ -1541,8 +1545,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$sql = ''; $sql = '';
if (isModEnabled('agenda')) { if (isModEnabled('agenda')) {
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('agendadao')); $hookmanager->initHooks(array('agendadao'));
@ -2238,8 +2240,7 @@ function addEventTypeSQL(&$sql, $actioncode, $sqlANDOR = "AND")
*/ */
function addOtherFilterSQL(&$sql, $donetodo, $now, $filters) function addOtherFilterSQL(&$sql, $donetodo, $now, $filters)
{ {
global $conf, $db; global $db;
// Condition on actioncode
if ($donetodo == 'todo') { if ($donetodo == 'todo') {
$sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
@ -2266,12 +2267,10 @@ function addOtherFilterSQL(&$sql, $donetodo, $now, $filters)
*/ */
function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) function addMailingEventTypeSQL($actioncode, $objcon, $filterobj)
{ {
global $conf, $langs, $db; global $db;
// Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing.
if (isModEnabled('mailing') && !empty($objcon->email)
&& (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) {
$langs->load("mails");
// Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing.
if (isModEnabled('mailing') && !empty($objcon->email) && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) {
$sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type";
$sql2 .= ", null as fk_element, '' as elementtype, null as contact_id"; $sql2 .= ", null as fk_element, '' as elementtype, null as contact_id";
$sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
@ -2292,6 +2291,9 @@ function addMailingEventTypeSQL($actioncode, $objcon, $filterobj)
$sql2 .= " AND mc.statut = 1"; $sql2 .= " AND mc.statut = 1";
$sql2 .= " AND u.rowid = m.fk_user_valid"; $sql2 .= " AND u.rowid = m.fk_user_valid";
$sql2 .= " AND mc.fk_mailing=m.rowid"; $sql2 .= " AND mc.fk_mailing=m.rowid";
return $sql2; return $sql2;
} else {
return '';
} }
} }

View File

@ -4134,7 +4134,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'off', 'on', 'order', 'off', 'on', 'order',
'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'proposal', 'puce', 'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'proposal', 'puce',
'stock', 'resize', 'service', 'stats', 'trip', 'stock', 'resize', 'service', 'stats', 'trip',
'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'switch_on_red', 'tools', 'unlink', 'uparrow', 'user', 'user-tie', 'vcard', 'wrench', 'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'switch_on_warning', 'switch_on_red', 'tools', 'unlink', 'uparrow', 'user', 'user-tie', 'vcard', 'wrench',
'github', 'google', 'jabber', 'microsoft', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'github', 'google', 'jabber', 'microsoft', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp',
'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies',
'generic', 'home', 'hrm', 'members', 'products', 'invoicing', 'generic', 'home', 'hrm', 'members', 'products', 'invoicing',
@ -4180,7 +4180,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'member'=>'user-alt', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right', 'member'=>'user-alt', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right',
'trip'=>'wallet', 'expensereport'=>'wallet', 'group'=>'users', 'movement'=>'people-carry', 'trip'=>'wallet', 'expensereport'=>'wallet', 'group'=>'users', 'movement'=>'people-carry',
'sign-out'=>'sign-out-alt', 'sign-out'=>'sign-out-alt',
'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'switch_on_red'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'switch_on_warning'=>'toggle-on', 'switch_on_red'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star',
'bank'=>'university', 'close_title'=>'times', 'delete'=>'trash', 'filter'=>'filter', 'bank'=>'university', 'close_title'=>'times', 'delete'=>'trash', 'filter'=>'filter',
'list-alt'=>'list-alt', 'calendarlist'=>'bars', 'calendar'=>'calendar-alt', 'calendarmonth'=>'calendar-alt', 'calendarweek'=>'calendar-week', 'calendarday'=>'calendar-day', 'calendarperuser'=>'table', 'list-alt'=>'list-alt', 'calendarlist'=>'bars', 'calendar'=>'calendar-alt', 'calendarmonth'=>'calendar-alt', 'calendarweek'=>'calendar-week', 'calendarday'=>'calendar-day', 'calendarperuser'=>'table',
'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'currency'=>'dollar-sign', 'multicurrency'=>'dollar-sign', 'order'=>'file-invoice', 'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'currency'=>'dollar-sign', 'multicurrency'=>'dollar-sign', 'order'=>'file-invoice',
@ -4264,7 +4264,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'members'=>'infobox-adherent', 'member'=>'infobox-adherent', 'money-bill-alt'=>'infobox-bank_account', 'members'=>'infobox-adherent', 'member'=>'infobox-adherent', 'money-bill-alt'=>'infobox-bank_account',
'order'=>'infobox-commande', 'order'=>'infobox-commande',
'user'=>'infobox-adherent', 'users'=>'infobox-adherent', 'user'=>'infobox-adherent', 'users'=>'infobox-adherent',
'error'=>'pictoerror', 'warning'=>'pictowarning', 'switch_on'=>'font-status4', 'switch_on_red'=>'font-status8', 'error'=>'pictoerror', 'warning'=>'pictowarning', 'switch_on'=>'font-status4', 'switch_on_warning'=>'font-status4 warning', 'switch_on_red'=>'font-status8',
'holiday'=>'infobox-holiday', 'info'=>'opacityhigh', 'invoice'=>'infobox-commande', 'holiday'=>'infobox-holiday', 'info'=>'opacityhigh', 'invoice'=>'infobox-commande',
'knowledgemanagement'=>'infobox-contrat rotate90', 'loan'=>'infobox-bank_account', 'knowledgemanagement'=>'infobox-contrat rotate90', 'loan'=>'infobox-bank_account',
'payment'=>'infobox-bank_account', 'payment_vat'=>'infobox-bank_account', 'poll'=>'infobox-adherent', 'pos'=>'infobox-bank_account', 'project'=>'infobox-project', 'projecttask'=>'infobox-project', 'payment'=>'infobox-bank_account', 'payment_vat'=>'infobox-bank_account', 'poll'=>'infobox-adherent', 'pos'=>'infobox-bank_account', 'project'=>'infobox-project', 'projecttask'=>'infobox-project',
@ -6190,30 +6190,30 @@ function isOnlyOneLocalTax($local)
/** /**
* Get values of localtaxes (1 or 2) for company country for the common vat with the highest value * Get values of localtaxes (1 or 2) for company country for the common vat with the highest value
* *
* @param int $local LocalTax to get * @param int $local LocalTax to get
* @return number Values of localtax * @return string Values of localtax (Can be '20', '-19:-15:-9')
*/ */
function get_localtax_by_third($local) function get_localtax_by_third($local)
{ {
global $db, $mysoc; global $db, $mysoc;
$sql = "SELECT t.localtax1, t.localtax2 ";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=t.fk_pays"; $sql = " SELECT t.localtax".$local." as localtax";
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND t.active = 1 AND t.taux=("; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t INNER JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_pays";
$sql .= " SELECT max(tt.taux) FROM ".MAIN_DB_PREFIX."c_tva as tt inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=tt.fk_pays"; $sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND t.active = 1 AND t.taux = (";
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND tt.active = 1"; $sql .= "SELECT MAX(tt.taux) FROM ".MAIN_DB_PREFIX."c_tva as tt INNER JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = tt.fk_pays";
$sql .= " )"; $sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND tt.active = 1)";
$sql .= " AND t.localtax".$local."_type <> '0'";
$sql .= " ORDER BY t.rowid DESC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($local == 1) { return $obj->localtax;
return $obj->localtax1; } else {
} elseif ($local == 2) { return 'Error';
return $obj->localtax2;
}
} }
return 0; return '0';
} }
@ -6322,10 +6322,12 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
} }
$sql .= ", ".MAIN_DB_PREFIX."c_country as c"; $sql .= ", ".MAIN_DB_PREFIX."c_country as c";
if ($mysoc->country_code == 'ES') { if (!empty($mysoc) && $mysoc->country_code == 'ES') {
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($buyer->country_code)."'"; // local tax in spain use the buyer country ?? $countrycodetouse = ((empty($buyer) || empty($buyer->country_code)) ? $mysoc->country_code : $buyer->country_code);
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse)."'"; // local tax in spain use the buyer country ??
} else { } else {
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(empty($seller->country_code) ? $mysoc->country_code : $seller->country_code)."'"; $countrycodetouse = ((empty($seller) || empty($seller->country_code)) ? $mysoc->country_code : $seller->country_code);
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse)."'";
} }
$sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
if ($vatratecode) { if ($vatratecode) {
@ -10888,8 +10890,8 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
* *
* @param string $label Label or tooltip of button. Also used as tooltip in title attribute. Can be escaped HTML content or full simple text. * @param string $label Label or tooltip of button. Also used as tooltip in title attribute. Can be escaped HTML content or full simple text.
* @param string $text Optional : short label on button. Can be escaped HTML content or full simple text. * @param string $text Optional : short label on button. Can be escaped HTML content or full simple text.
* @param string $actionType 'default', 'delete', 'danger' * @param string $actionType 'default', 'delete', 'danger', 'email', ...
* @param string $url Url for link * @param string|array $url Url for link or array of subbutton description
* @param string $id Attribute id of button * @param string $id Attribute id of button
* @param int|boolean $userRight User action right * @param int|boolean $userRight User action right
* // phpcs:disable * // phpcs:disable
@ -10916,7 +10918,26 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
{ {
global $hookmanager, $action, $object, $langs; global $hookmanager, $action, $object, $langs;
//var_dump($params); // If $url is an array, we must build a dropdown button
if (is_array($url)) {
$out = '<div class="dropdown inline-block dropdown-holder">';
$out .= '<a style="margin-right: auto;" class="dropdown-toggle butAction" data-toggle="dropdown">'.$label.'</a>';
$out .= '<div class="dropdown-content">';
foreach ($url as $subbutton) {
if ($subbutton['enabled'] && $subbutton['perm']) {
if (!empty($subbutton['lang'])) {
$langs->load($subbutton['lang']);
}
$out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&amp;backtopage='.urlencode($params['backtopage'])), '', 1, array('isDropDown' => true));
}
}
$out .= "</div>";
$out .= "</div>";
return $out;
}
// If $url is a simple link
if (!empty($params['isDropdown'])) if (!empty($params['isDropdown']))
$class = "dropdown-item"; $class = "dropdown-item";
else { else {

View File

@ -529,3 +529,94 @@ function reWriteAllPermissions($file, $permissions, $key, $right, $action)
return 1; return 1;
} }
} }
/**
* Write all properties of the object in AsciiDoc format
* @param string $file path of the class
* @param string $objectname name of the objectClass
* @param string $destfile file where write table of properties
* @return int 1 if OK, -1 if KO
*/
function writePropsInAsciiDoc($file, $objectname, $destfile)
{
// stock all properties in array
$attributesUnique = array ('label', 'type', 'arrayofkeyval', 'notnull', 'default', 'index', 'foreignkey', 'position', 'enabled', 'visible', 'noteditable', 'alwayseditable', 'searchall', 'isameasure', 'css','cssview','csslist', 'help', 'showoncombobox', 'validate','comment','picto' );
$start = "public \$fields=array(";
$end = ");";
$i = 1;
$keys = array();
$lines = file($file);
// Search for start and end lines
foreach ($lines as $i => $line) {
if (strpos($line, $start) !== false) {
// Copy lines until the end on array
while (($line = $lines[++$i]) !== false) {
if (strpos($line, $end) !== false) {
break;
}
$keys[] = $line;
}
break;
}
}
// write the begin of table with specifics options
$table = "== DATA SPECIFICATIONS\n";
$table .= "== Table of fields and their properties for object *$objectname* : \n";
$table .= "[options='header',grid=rows,frame=topbot,width=100%,caption=Organisation]\n";
$table .= "|===\n";
$table .= "|code";
// write all properties in the header of the table
foreach ($attributesUnique as $attUnique) {
$table .= "|".$attUnique;
}
$table .="\n";
$countKeys = count($keys);
for ($j=0;$j<$countKeys;$j++) {
$string = $keys[$j];
$string = trim($string, "'");
$string = rtrim($string, ",");
$array = [];
eval("\$array = [$string];");
// check if is array after cleaning string
if (!is_array($array)) {
return -1;
}
// name of field
$field = array_keys($array);
// all values of each property
$values = array_values($array);
// check each field has all properties and add it if missed
if (count($values[0]) <=22) {
foreach ($attributesUnique as $cle) {
if (!in_array($cle, array_keys($values[0]))) {
$values[0][$cle] = '';
}
}
}
//reorganize $values with order attributeUnique
$valuesRestructured = array();
foreach ($attributesUnique as $key) {
if (array_key_exists($key, $values[0])) {
$valuesRestructured[$key] = $values[0][$key];
}
}
// write all values of properties for each field
$table .= "|*".$field[0]."*|";
$table .= implode("|", array_values($valuesRestructured))."\n";
}
// end table
$table .= "|===";
//write in file
$writeInFile = dolReplaceInFile($destfile, array('== DATA SPECIFICATIONS'=> $table));
if ($writeInFile<0) {
return -1;
}
return 1;
}

View File

@ -1071,10 +1071,10 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
} }
//Check if Extrafields is totalizable //Check if Extrafields is totalizable
foreach ($extrafields->attributes['projet_task']['totalizable'] as $key=>$value){ foreach ($extrafields->attributes['projet_task']['totalizable'] as $key=>$value) {
if ($arrayfields['ef.'.$key]['checked'] == 1){ if ($arrayfields['ef.'.$key]['checked'] == 1) {
print '<td align="right">'; print '<td align="right">';
if ($value == 1){ if ($value == 1) {
print $totalarray['totalizable'][$key]['total']; print $totalarray['totalizable'][$key]['total'];
} }
print '</td>'; print '</td>';

View File

@ -485,7 +485,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
$readok = 0; $readok = 0;
$nbko++; $nbko++;
} }
} elseif (!empty($feature2)) { // This is for permissions on 2 levels } elseif (!empty($feature2)) { // This is for permissions on 2 levels (module->object->read)
$tmpreadok = 1; $tmpreadok = 1;
foreach ($feature2 as $subfeature) { foreach ($feature2 as $subfeature) {
if ($subfeature == 'user' && $user->id == $objectid) { if ($subfeature == 'user' && $user->id == $objectid) {
@ -504,7 +504,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
$readok = 0; // All tests are ko (we manage here the and, the or will be managed later using $nbko). $readok = 0; // All tests are ko (we manage here the and, the or will be managed later using $nbko).
$nbko++; $nbko++;
} }
} elseif (!empty($feature) && ($feature != 'user' && $feature != 'usergroup')) { // This is permissions on 1 level } elseif (!empty($feature) && ($feature != 'user' && $feature != 'usergroup')) { // This is permissions on 1 level (module->read)
if (empty($user->rights->$feature->lire) if (empty($user->rights->$feature->lire)
&& empty($user->rights->$feature->read) && empty($user->rights->$feature->read)
&& empty($user->rights->$feature->run)) { && empty($user->rights->$feature->run)) {
@ -531,7 +531,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
// Check write permission from module (we need to know write permission to create but also to delete drafts record or to upload files) // Check write permission from module (we need to know write permission to create but also to delete drafts record or to upload files)
$createok = 1; $createok = 1;
$nbko = 0; $nbko = 0;
$wemustcheckpermissionforcreate = (GETPOST('sendit', 'alpha') || GETPOST('linkit', 'alpha') || in_array(GETPOST('action', 'aZ09'), array('create', 'update', 'add_element_resource', 'confirm_delete_linked_resource')) || GETPOST('roworder', 'alpha', 2)); $wemustcheckpermissionforcreate = (GETPOST('sendit', 'alpha') || GETPOST('linkit', 'alpha') || in_array(GETPOST('action', 'aZ09'), array('create', 'update', 'set', 'add_element_resource', 'confirm_delete_linked_resource')) || GETPOST('roworder', 'alpha', 2));
$wemustcheckpermissionfordeletedraft = ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete'); $wemustcheckpermissionfordeletedraft = ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete');
if ($wemustcheckpermissionforcreate || $wemustcheckpermissionfordeletedraft) { if ($wemustcheckpermissionforcreate || $wemustcheckpermissionfordeletedraft) {
@ -576,7 +576,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
$createok = 0; $createok = 0;
$nbko++; $nbko++;
} }
} elseif (!empty($feature2)) { // This is for permissions on one level } elseif (!empty($feature2)) { // This is for permissions on 2 levels (module->object->write)
foreach ($feature2 as $subfeature) { foreach ($feature2 as $subfeature) {
if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->creer) { if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->creer) {
continue; // User can edit its own card continue; // User can edit its own card
@ -599,7 +599,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
break; break;
} }
} }
} elseif (!empty($feature)) { // This is for permissions on 2 levels ('creer' or 'write') } elseif (!empty($feature)) { // This is for permissions on 1 levels (module->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)

View File

@ -30,7 +30,7 @@
* @param string $desc Description of export * @param string $desc Description of export
* @param array $events_array Array of events ("uid","startdate","duration","enddate","title","summary","category","email","url","desc","author") * @param array $events_array Array of events ("uid","startdate","duration","enddate","title","summary","category","email","url","desc","author")
* @param string $outputfile Output file * @param string $outputfile Output file
* @return int < 0 if ko, Nb of events in file if ok * @return int < 0 if KO, Nb of events in file if OK
*/ */
function build_calfile($format, $title, $desc, $events_array, $outputfile) function build_calfile($format, $title, $desc, $events_array, $outputfile)
{ {
@ -43,6 +43,8 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
return -1; return -1;
} }
$nbevents = 0;
// Note: A cal file is an UTF8 encoded file // Note: A cal file is an UTF8 encoded file
$calfileh = fopen($outputfile, "w"); $calfileh = fopen($outputfile, "w");
@ -144,6 +146,8 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
*/ */
if ($type === "event") { if ($type === "event") {
$nbevents++;
fwrite($calfileh, "BEGIN:VEVENT\n"); fwrite($calfileh, "BEGIN:VEVENT\n");
fwrite($calfileh, "UID:".$uid."\n"); fwrite($calfileh, "UID:".$uid."\n");
@ -247,6 +251,8 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
// Output the vCard/iCal VJOURNAL object // Output the vCard/iCal VJOURNAL object
if ($type === "journal") { if ($type === "journal") {
$nbevents++;
fwrite($calfileh, "BEGIN:VJOURNAL\n"); fwrite($calfileh, "BEGIN:VJOURNAL\n");
fwrite($calfileh, "UID:".$uid."\n"); fwrite($calfileh, "UID:".$uid."\n");
@ -289,6 +295,8 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing"); dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing");
return -2; return -2;
} }
return $nbevents;
} }
/** /**
@ -303,7 +311,7 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
* @param string $filter (optional) Filter * @param string $filter (optional) Filter
* @param string $url Url (If empty, forge URL for agenda RSS export) * @param string $url Url (If empty, forge URL for agenda RSS export)
* @param string $langcode Language code to show in header * @param string $langcode Language code to show in header
* @return int < 0 if ko, Nb of events in file if ok * @return int < 0 if KO, Nb of events in file if OK
*/ */
function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '', $url = '', $langcode = '') function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '', $url = '', $langcode = '')
{ {
@ -317,6 +325,8 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt
return -1; return -1;
} }
$nbevents = 0;
$fichier = fopen($outputfile, "w"); $fichier = fopen($outputfile, "w");
if ($fichier) { if ($fichier) {
@ -362,6 +372,8 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt
} }
if ($eventqualified) { if ($eventqualified) {
$nbevents++;
if (is_object($event) && get_class($event) == 'WebsitePage') { if (is_object($event) && get_class($event) == 'WebsitePage') {
// Convert object into an array // Convert object into an array
$tmpevent = array(); $tmpevent = array();
@ -426,6 +438,8 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt
fclose($fichier); fclose($fichier);
dolChmod($outputfile); dolChmod($outputfile);
} }
return $nbevents;
} }
/** /**
@ -437,8 +451,6 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt
*/ */
function format_cal($format, $string) function format_cal($format, $string)
{ {
global $conf;
$newstring = $string; $newstring = $string;
if ($format === "vcal") { if ($format === "vcal") {

View File

@ -481,11 +481,11 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
-- HRM - Holiday -- HRM - Holiday
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&amp;leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&amp;leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card.php?mainmenu=hrm&amp;action=create', 'New', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card.php?mainmenu=hrm&amp;action=create', 'New', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card_group.php?mainmenu=hrm&amp;action=create', 'NewHolidayForGroup', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5002__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card_group.php?mainmenu=hrm&amp;action=create', 'NewHolidayForGroup', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5002__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&amp;leftmenu=hrm', 'List', 1, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5003__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&amp;leftmenu=hrm', 'List', 1, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5003__+MAX_llx_menu__, 'hrm', '', 5002__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&amp;search_statut=2&leftmenu=hrm', 'ListToApprove', 2, 'trips', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5004__+MAX_llx_menu__, 'hrm', '', 5002__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&amp;search_statut=2&leftmenu=hrm', 'ListToApprove', 2, 'trips', '$user->rights->holiday->read', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5004__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/define_holiday.php?mainmenu=hrm', 'MenuConfCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5005__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/define_holiday.php?mainmenu=hrm', 'MenuConfCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5005__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/view_log.php?mainmenu=hrm', 'MenuLogCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5006__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/view_log.php?mainmenu=hrm', 'MenuLogCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 3, __ENTITY__);
-- HRM - Trips and expenses (old module) -- HRM - Trips and expenses (old module)
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->deplacement->enabled', __HANDLER__, 'left', 2100__+MAX_llx_menu__, 'accountancy', 'tripsandexpenses', 15__+MAX_llx_menu__, '/compta/deplacement/index.php?mainmenu=accountancy&amp;leftmenu=tripsandexpenses', 'TripsAndExpenses', 0, 'trips', '$user->rights->deplacement->lire', '', 0, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->deplacement->enabled', __HANDLER__, 'left', 2100__+MAX_llx_menu__, 'accountancy', 'tripsandexpenses', 15__+MAX_llx_menu__, '/compta/deplacement/index.php?mainmenu=accountancy&amp;leftmenu=tripsandexpenses', 'TripsAndExpenses', 0, 'trips', '$user->rights->deplacement->lire', '', 0, 5, __ENTITY__);

View File

@ -1734,8 +1734,8 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef
$langs->load('accountancy'); $langs->load('accountancy');
$journallabel = ''; $journallabel = '';
if ($objp->label) { if ($objp->label) {
$journallabelwithoutspan = $langs->transnoentities($objp->label); $journallabelwithoutspan = $langs->trans($objp->label);
$journallabel = '<span class="opacitymedium">('.$langs->transnoentities($objp->label).')</span>'; // Label of bank account in llx_accounting_journal $journallabel = '<span class="opacitymedium">('.$langs->trans($objp->label).')</span>'; // Label of bank account in llx_accounting_journal
} }
$key = $langs->trans("AccountingJournalType".$objp->nature); // $objp->nature is 1, 2, 3 ... $key = $langs->trans("AccountingJournalType".$objp->nature); // $objp->nature is 1, 2, 3 ...

View File

@ -207,7 +207,7 @@ class pdf_eagle extends ModelePdfStockTransfer
// Load traductions files required by page // Load traductions files required by page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch", "stocks", "stocktransfer@stocktransfer")); $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch", "stocks", "stocktransfer@stocktransfer"));
$nblines = count($object->lines); $nblines = is_array($object->lines) ? count($object->lines) : 0;
// 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();
@ -287,7 +287,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$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
// Set nblines with the new facture lines content after hook // Set nblines with the new facture lines content after hook
$nblines = count($object->lines); $nblines = is_array($object->lines) ? count($object->lines) : 0;
$pdf = pdf_getInstance($this->format); $pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -777,7 +777,7 @@ class pdf_eagle extends ModelePdfStockTransfer
/** /**
* Show table for lines * Show table for lines
* *
* @param PDF $pdf Object PDF * @param TCPDF $pdf Object PDF
* @param string $tab_top Top position of table * @param string $tab_top Top position of table
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
@ -971,17 +971,11 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->SetFont('', 'B', $default_font_size + 2); $pdf->SetFont('', 'B', $default_font_size + 2);
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$title = $outputlangs->transnoentities("StockTransferSheet"); $title = $outputlangs->transnoentities("StockTransferSheet").' '.$object->ref;
$pdf->MultiCell($w, 4, $title, '', 'R'); $pdf->MultiCell($w, 4, $title, '', 'R');
$pdf->SetFont('', '', $default_font_size + 1); $pdf->SetFont('', '', $default_font_size + 1);
$posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R');
// Date prévue depart // Date prévue depart
if (!empty($object->date_prevue_depart)) { if (!empty($object->date_prevue_depart)) {
$posy += 4; $posy += 4;

View File

@ -209,7 +209,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
} }
$nblines = count($object->lines); $nblines = is_array($object->lines) ? count($object->lines) : 0;
$hidetop = 0; $hidetop = 0;
if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
@ -1551,7 +1551,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Adapt dynamically the width of subprice, if text is too long. // Adapt dynamically the width of subprice, if text is too long.
$tmpwidth = 0; $tmpwidth = 0;
$nblines = count($object->lines); $nblines = is_array($object->lines) ? count($object->lines) : 0;
for ($i = 0; $i < $nblines; $i++) { for ($i = 0; $i < $nblines; $i++) {
$tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails))); $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails)));
$tmpwidth = max($tmpwidth, $tmpwidth2); $tmpwidth = max($tmpwidth, $tmpwidth2);

View File

@ -336,12 +336,7 @@ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$std_soc = new Societe($db); $std_soc = new Societe($db);
$action_search = 'query'; $action_search = 'query';
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $parameters = array('advtarget'=>1);
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
$hookmanager->initHooks(array('thirdpartycard'));
$parameters = array();
if (!empty($advTarget->id)) { if (!empty($advTarget->id)) {
$parameters = array('array_query' => $advTarget->filtervalue); $parameters = array('array_query' => $advTarget->filtervalue);
} }

View File

@ -94,7 +94,6 @@ class InterfaceNotification extends DolibarrTriggers
global $conf, $action; global $conf, $action;
global $hookmanager; global $hookmanager;
if (!is_object($hookmanager)) { if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db); $hookmanager = new HookManager($this->db);

View File

@ -44,7 +44,7 @@ class DataPolicy
/** /**
* getAllContactNotInformed * getAllContactNotInformed
* *
* @return number * @return integer
*/ */
public function getAllContactNotInformed() public function getAllContactNotInformed()
{ {
@ -75,12 +75,14 @@ class DataPolicy
$this->error = $this->db->error(); $this->error = $this->db->error();
return -1; return -1;
} }
return 1;
} }
/** /**
* getAllCompaniesNotInformed * getAllCompaniesNotInformed
* *
* @return number * @return integer
*/ */
public function getAllCompaniesNotInformed() public function getAllCompaniesNotInformed()
{ {
@ -110,12 +112,14 @@ class DataPolicy
$this->error = $this->db->error(); $this->error = $this->db->error();
return -1; return -1;
} }
return 1;
} }
/** /**
* getAllAdherentsNotInformed * getAllAdherentsNotInformed
* *
* @return number * @return integer
*/ */
public function getAllAdherentsNotInformed() public function getAllAdherentsNotInformed()
{ {
@ -145,6 +149,8 @@ class DataPolicy
$this->error = $this->db->error(); $this->error = $this->db->error();
return -1; return -1;
} }
return 1;
} }
/** /**

View File

@ -51,7 +51,13 @@ class DolRequestDataCollector extends RequestDataCollector
} }
//var_dump($arrayofvalues); //var_dump($arrayofvalues);
} }
if ($var == '_SERVER') {
foreach ($arrayofvalues as $key => $val) {
if (preg_match('/^PHP_AUTH_PW/', $key)) {
$arrayofvalues[$key] = '*****hidden*****';
}
}
}
$data["$".$var] = $this->getDataFormatter()->formatVar($arrayofvalues); $data["$".$var] = $this->getDataFormatter()->formatVar($arrayofvalues);
} }
} }

View File

@ -24,7 +24,6 @@
dol_include_once('/debugbar/class/autoloader.php'); dol_include_once('/debugbar/class/autoloader.php');
use \DebugBar\DebugBar; use \DebugBar\DebugBar;
use \DebugBar\DataCollector\PhpInfoCollector;
dol_include_once('/debugbar/class/DataCollector/DolMessagesCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolMessagesCollector.php');
dol_include_once('/debugbar/class/DataCollector/DolRequestDataCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolRequestDataCollector.php');
@ -71,7 +70,7 @@ class DolibarrDebugBar extends DebugBar
/** /**
* Returns a JavascriptRenderer for this instance * Returns a JavascriptRenderer for this instance
* *
* @return DebugBar\JavascriptRenderer String content * @return \DebugBar\JavascriptRenderer String content
*/ */
public function getRenderer() public function getRenderer()
{ {
@ -80,6 +79,7 @@ class DolibarrDebugBar extends DebugBar
$renderer->disableVendor('fontawesome'); // We already have fontawesome loaded globally by the main.inc.php $renderer->disableVendor('fontawesome'); // We already have fontawesome loaded globally by the main.inc.php
$renderer->disableVendor('highlightjs'); // We don't need this $renderer->disableVendor('highlightjs'); // We don't need this
$renderer->setEnableJqueryNoConflict(false); // We don't need no conflict $renderer->setEnableJqueryNoConflict(false); // We don't need no conflict
return $renderer; return $renderer;
} }
} }

View File

@ -281,7 +281,6 @@ class Delivery extends CommonObject
// phpcs:enable // phpcs:enable
$error = 0; $error = 0;
$idprod = $fk_product; $idprod = $fk_product;
$j = 0;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."deliverydet (fk_delivery, fk_origin_line,"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."deliverydet (fk_delivery, fk_origin_line,";
$sql .= " fk_product, description, qty)"; $sql .= " fk_product, description, qty)";
@ -304,9 +303,11 @@ class Delivery extends CommonObject
$result = $line->insertExtraFields(); $result = $line->insertExtraFields();
} }
if ($error == 0) { if (!$error) {
return 1; return 1;
} }
return -1;
} }
/** /**
@ -317,8 +318,6 @@ class Delivery extends CommonObject
*/ */
public function fetch($id) public function fetch($id)
{ {
global $conf;
$sql = "SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,"; $sql = "SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,";
$sql .= " l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public"; $sql .= " l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
$sql .= ", l.date_delivery, l.fk_address, l.model_pdf"; $sql .= ", l.date_delivery, l.fk_address, l.model_pdf";
@ -396,7 +395,8 @@ class Delivery extends CommonObject
*/ */
public function valid($user, $notrigger = 0) public function valid($user, $notrigger = 0)
{ {
global $conf, $langs; global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_syslog(get_class($this)."::valid begin"); dol_syslog(get_class($this)."::valid begin");
@ -521,8 +521,10 @@ class Delivery extends CommonObject
} }
} }
} }
return -1;
} else { } else {
$this->error = "Non autorise"; $this->error = "NotAllowed";
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
return -1; return -1;
} }
@ -532,9 +534,9 @@ class Delivery extends CommonObject
/** /**
* Creating the delivery slip from an existing shipment * Creating the delivery slip from an existing shipment
* *
* @param User $user User who creates * @param User $user User who creates
* @param int $sending_id Id of the expedition that serves as a model * @param int $sending_id Id of the expedition that serves as a model
* @return integer * @return integer <=0 if KO, >0 if OK
*/ */
public function create_from_sending($user, $sending_id) public function create_from_sending($user, $sending_id)
{ {
@ -543,6 +545,9 @@ class Delivery extends CommonObject
$expedition = new Expedition($this->db); $expedition = new Expedition($this->db);
$result = $expedition->fetch($sending_id); $result = $expedition->fetch($sending_id);
if ($result <= 0) {
return $result;
}
$this->lines = array(); $this->lines = array();
@ -638,7 +643,7 @@ class Delivery extends CommonObject
* Delete line * Delete line
* *
* @param int $lineid Line id * @param int $lineid Line id
* @return integer|null * @return integer <0 if KO, 0 if nothing done, >0 if OK
*/ */
public function deleteline($lineid) public function deleteline($lineid)
{ {
@ -651,9 +656,11 @@ class Delivery extends CommonObject
return 1; return 1;
} else { } else {
return 0; return -1;
} }
} }
return 0;
} }
/** /**
@ -737,7 +744,7 @@ class Delivery extends CommonObject
*/ */
public function getTooltipContentArray($params) public function getTooltipContentArray($params)
{ {
global $conf, $langs; global $langs;
$datas = []; $datas = [];
@ -944,8 +951,6 @@ class Delivery extends CommonObject
*/ */
public function initAsSpecimen() public function initAsSpecimen()
{ {
global $user, $langs, $conf;
$now = dol_now(); $now = dol_now();
// Load array of products prodids // Load array of products prodids
@ -994,13 +999,11 @@ class Delivery extends CommonObject
/** /**
* Renvoie la quantite de produit restante a livrer pour une commande * Renvoie la quantite de produit restante a livrer pour une commande
* *
* @return array Product remaining to be delivered * @return array|int Product remaining to be delivered or <0 if KO
* TODO use new function * TODO use new function
*/ */
public function getRemainingDelivered() public function getRemainingDelivered()
{ {
global $langs;
// Get the linked object // Get the linked object
$this->fetchObjectLinked('', '', $this->id, $this->element); $this->fetchObjectLinked('', '', $this->id, $this->element);
//var_dump($this->linkedObjectsIds); //var_dump($this->linkedObjectsIds);
@ -1098,7 +1101,7 @@ class Delivery extends CommonObject
*/ */
public function generateDocument($modele, $outputlangs = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function generateDocument($modele, $outputlangs = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
global $conf, $user, $langs; global $conf, $langs;
$langs->load("deliveries"); $langs->load("deliveries");
$outputlangs->load("products"); $outputlangs->load("products");

View File

@ -278,10 +278,6 @@ if (!file_exists($fullpath_original_file_osencoded)) {
} }
// Hooks // Hooks
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('document')); $hookmanager->initHooks(array('document'));
$parameters = array('ecmfile' => $ecmfile, 'modulepart' => $modulepart, 'original_file' => $original_file, $parameters = array('ecmfile' => $ecmfile, 'modulepart' => $modulepart, 'original_file' => $original_file,
'entity' => $entity, 'refname' => $refname, 'fullpath_original_file' => $fullpath_original_file, 'entity' => $entity, 'refname' => $refname, 'fullpath_original_file' => $fullpath_original_file,

View File

@ -52,6 +52,7 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT'); $amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT');
$donation_date = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $donation_date = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
@ -405,6 +406,7 @@ if ($action == 'create') {
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" 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="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head(''); print dol_get_fiche_head('');
@ -579,7 +581,7 @@ if (!empty($id) && $action == 'edit') {
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="rowid" value="'.$object->id.'">'; print '<input type="hidden" name="rowid" value="'.$object->id.'">';
print '<input type="hidden" name="amount" value="'.$object->amount.'">'; print '<input type="hidden" name="amount" value="'.$object->amount.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'donation'); print dol_get_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'donation');
@ -732,6 +734,7 @@ if (!empty($id) && $action != 'edit') {
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">'; $morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500');
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>'; $morehtmlref .= '</form>';

View File

@ -134,7 +134,7 @@ class PaymentDonation extends CommonObject
$now = dol_now(); $now = dol_now();
// Validate parameters // Validate parameters
if (!$this->datepaid) { if (!$this->datep) {
$this->error = 'ErrorBadValueForParameterCreatePaymentDonation'; $this->error = 'ErrorBadValueForParameterCreatePaymentDonation';
return -1; return -1;
} }
@ -193,7 +193,7 @@ class PaymentDonation extends CommonObject
$sql .= " fk_typepayment, num_payment, note, ext_payment_id, ext_payment_site,"; $sql .= " fk_typepayment, num_payment, note, ext_payment_id, ext_payment_site,";
$sql .= " fk_user_creat, fk_bank)"; $sql .= " fk_user_creat, fk_bank)";
$sql .= " VALUES (".((int) $this->chid).", '".$this->db->idate($now)."',"; $sql .= " VALUES (".((int) $this->chid).", '".$this->db->idate($now)."',";
$sql .= " '".$this->db->idate($this->datepaid)."',"; $sql .= " '".$this->db->idate($this->datep)."',";
$sql .= " ".((float) price2num($totalamount)).","; $sql .= " ".((float) price2num($totalamount)).",";
$sql .= " ".((int) $this->paymenttype).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', "; $sql .= " ".((int) $this->paymenttype).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', ";
$sql .= " ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").","; $sql .= " ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").",";
@ -588,10 +588,9 @@ class PaymentDonation extends CommonObject
if ($mode == 'payment_donation') { if ($mode == 'payment_donation') {
$amount = $total; $amount = $total;
} }
// Insert payment into llx_bank // Insert payment into llx_bank
$bank_line_id = $acc->addline( $bank_line_id = $acc->addline(
$this->datepaid, $this->datep,
$this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example")
$label, $label,
$amount, $amount,

View File

@ -155,6 +155,31 @@ class EcmFiles extends CommonObject
*/ */
public $section_id; public $section_id;
public $fields = array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>-1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1', 'comment'=>"contains hash from filename+filepath"),
'label' => array('type'=>'varchar(128)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1', 'comment'=>"contains hash of file content"),
'share' => array('type'=>'varchar(128)', 'label'=>'Share', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1', 'comment' => "contains hash for file sharing"),
'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'position' => 50, 'index' => 1),
'filepath' => array('type'=>'varchar(255)', 'label'=>'FilePath', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>0, 'searchall'=>0, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1','comment'=> "relative to dolibarr document dir. Example module/def"),
'filename' => array('type'=>'varchar(255)', 'label'=>'FileName', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1','comment'=>"file name only without any directory"),
'src_object_type' => array('type'=>'varchar(64)', 'label'=>'SourceType', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>0, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1','comment'=> "Source object type ('proposal', 'invoice', ...)"),
'src_object_id' => array('type' => 'integer', 'label' => 'SourceID', 'default' => 1, 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 90, 'index' => 1, 'comment' => "Source object id"),
'fullpath_orig' => array('type'=>'varchar(750)', 'label'=>'FullPathOrig', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>0, 'searchall'=>0, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1','comment'=>"full path of original filename, when file is uploaded from a local computer"),
'description' => array('type' => 'text', 'label' => 'Description', 'enabled' => 1, 'visible' => 0, 'position' => 110),
'keywords' => array('type'=>'varchar(750)', 'label'=>'Keywords', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1','comment'=>"list of keywords, separated with comma. Must be limited to most important keywords."),
'cover' => array('type' => 'text', 'label' => 'Cover', 'enabled' => 1, 'visible' => 0, 'position' => 130, 'comment'=>"is this file a file to use for a cover"),
'position' => array('type' => 'integer', 'label' => 'Position', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 140, 'index' => 1, 'comment' => "position of file among others"),
'gen_or_uploaded' => array('type'=>'varchar(12)', 'label'=>'GenOrUpload', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1','comment'=>"'generated' or 'uploaded'"),
'extraparams' => array('type'=>'varchar(255)', 'label'=>'ExtraParams', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1', 'comment' => "for stocking other parameters with json format"),
'date_c' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -1, 'position' => 170),
'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 175),
'fk_user_c' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
'fk_user_m' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
'note_public' => array('type' => 'text', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 155),
'note_private' => array('type' => 'text', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 160),
'acl' => array('type' => 'text', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 160, 'comment' => "for future permission 'per file'"),
);
/** /**

View File

@ -55,6 +55,7 @@ $langs->loadLangs(array("trips", "bills", "mails"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$date_start = dol_mktime(0, 0, 0, GETPOST('date_debutmonth', 'int'), GETPOST('date_debutday', 'int'), GETPOST('date_debutyear', 'int')); $date_start = dol_mktime(0, 0, 0, GETPOST('date_debutmonth', 'int'), GETPOST('date_debutday', 'int'), GETPOST('date_debutyear', 'int'));
@ -1407,6 +1408,7 @@ if ($action == 'create') {
print '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="create">'; print '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="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">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head(''); print dol_get_fiche_head('');
@ -1545,6 +1547,7 @@ if ($action == 'create') {
print "<form name='update' action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n"; print "<form name='update' action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n";
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head($head, 'card', $langs->trans("ExpenseReport"), 0, 'trip'); print dol_get_fiche_head($head, 'card', $langs->trans("ExpenseReport"), 0, 'trip');
@ -2027,6 +2030,7 @@ if ($action == 'create') {
print '<input type="hidden" name="action" value="'.$actiontouse.'">'; print '<input type="hidden" name="action" value="'.$actiontouse.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="fk_expensereport" value="'.$object->id.'" />'; print '<input type="hidden" name="fk_expensereport" value="'.$object->id.'" />';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table id="tablelines" class="noborder centpercent">'; print '<table id="tablelines" class="noborder centpercent">';

View File

@ -111,9 +111,8 @@ class PaymentExpenseReport extends CommonObject
$error = 0; $error = 0;
$now = dol_now(); $now = dol_now();
// Validate parameters // Validate parameters
if (!$this->datepaid) { if (!$this->datep) {
$this->error = 'ErrorBadValueForParameterCreatePaymentExpenseReport'; $this->error = 'ErrorBadValueForParameterCreatePaymentExpenseReport';
return -1; return -1;
} }
@ -170,7 +169,7 @@ class PaymentExpenseReport extends CommonObject
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_expensereport (fk_expensereport, datec, datep, amount,"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_expensereport (fk_expensereport, datec, datep, amount,";
$sql .= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; $sql .= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)";
$sql .= " VALUES ($this->fk_expensereport, '".$this->db->idate($now)."',"; $sql .= " VALUES ($this->fk_expensereport, '".$this->db->idate($now)."',";
$sql .= " '".$this->db->idate($this->datepaid)."',"; $sql .= " '".$this->db->idate($this->datep)."',";
$sql .= " ".price2num($totalamount).","; $sql .= " ".price2num($totalamount).",";
$sql .= " ".((int) $this->fk_typepayment).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', ".((int) $user->id).","; $sql .= " ".((int) $this->fk_typepayment).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', ".((int) $user->id).",";
$sql .= " 0)"; // fk_bank is ID of transaction into ll_bank $sql .= " 0)"; // fk_bank is ID of transaction into ll_bank
@ -531,7 +530,7 @@ class PaymentExpenseReport extends CommonObject
// Insert payment into llx_bank // Insert payment into llx_bank
$bank_line_id = $acc->addline( $bank_line_id = $acc->addline(
$this->datepaid, $this->datep,
$this->fk_typepayment, // Payment mode id or code ("CHQ or VIR for example") $this->fk_typepayment, // Payment mode id or code ("CHQ or VIR for example")
$label, $label,
-$amount, -$amount,

View File

@ -107,8 +107,8 @@ if ($action == 'add_payment') {
// Create a line of payments // Create a line of payments
$payment = new PaymentExpenseReport($db); $payment = new PaymentExpenseReport($db);
$payment->fk_expensereport = $expensereport->id; $payment->fk_expensereport = $expensereport->id;
$payment->datepaid = $datepaid; $payment->datep = $datepaid;
$payment->amounts = $amounts; // Tableau de montant $payment->amounts = $amounts; // Tableau de montant
$payment->total = $total; $payment->total = $total;
$payment->fk_typepayment = GETPOST("fk_typepayment", 'int'); $payment->fk_typepayment = GETPOST("fk_typepayment", 'int');
$payment->num_payment = GETPOST("num_payment", 'alphanothtml'); $payment->num_payment = GETPOST("num_payment", 'alphanothtml');

View File

@ -25,6 +25,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';

View File

@ -62,6 +62,8 @@ $contratid = (int) GETPOST('contratid', 'int');
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$mesg = GETPOST('msg', 'alpha'); $mesg = GETPOST('msg', 'alpha');
$origin = GETPOST('origin', 'alpha'); $origin = GETPOST('origin', 'alpha');
$originid = (GETPOST('originid', 'int') ?GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility $originid = (GETPOST('originid', 'int') ?GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility
@ -890,6 +892,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="socid" value='.$soc->id.'>'; print '<input type="hidden" name="socid" value='.$soc->id.'>';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head(''); print dol_get_fiche_head('');
@ -1043,6 +1046,7 @@ if ($action == 'create') {
print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">'; print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" 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="create">'; // We go back to create action print '<input type="hidden" name="action" value="create">'; // We go back to create action
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head(''); print dol_get_fiche_head('');
@ -1308,6 +1312,7 @@ if ($action == 'create') {
} else { } else {
print '<input type="hidden" name="action" value="addline">'; print '<input type="hidden" name="action" value="addline">';
} }
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
// Intervention lines // Intervention lines
$sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,'; $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,';

View File

@ -1589,16 +1589,17 @@ class FichinterLigne extends CommonObjectLine
*/ */
public function fetch($rowid) public function fetch($rowid)
{ {
dol_syslog("FichinterLigne::fetch", LOG_DEBUG);
$sql = 'SELECT ft.rowid, ft.fk_fichinter, ft.description, ft.duree, ft.rang, ft.date'; $sql = 'SELECT ft.rowid, ft.fk_fichinter, ft.description, ft.duree, ft.rang, ft.date';
$sql .= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft'; $sql .= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft';
$sql .= ' WHERE ft.rowid = '.((int) $rowid); $sql .= ' WHERE ft.rowid = '.((int) $rowid);
dol_syslog("FichinterLigne::fetch", LOG_DEBUG); $resql = $this->db->query($sql);
$result = $this->db->query($sql); if ($resql) {
if ($result) { $objp = $this->db->fetch_object($resql);
$objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid; $this->rowid = $objp->rowid;
$this->id = $objp->rowid; $this->id = $objp->rowid;
$this->fk_fichinter = $objp->fk_fichinter; $this->fk_fichinter = $objp->fk_fichinter;
$this->date = $this->db->jdate($objp->date); $this->date = $this->db->jdate($objp->date);
$this->datei = $this->db->jdate($objp->date); // For backward compatibility $this->datei = $this->db->jdate($objp->date); // For backward compatibility
@ -1606,7 +1607,10 @@ class FichinterLigne extends CommonObjectLine
$this->duration = $objp->duree; $this->duration = $objp->duree;
$this->rang = $objp->rang; $this->rang = $objp->rang;
$this->db->free($result); $this->db->free($resql);
$this->fetch_optionals();
return 1; return 1;
} else { } else {
$this->error = $this->db->error().' sql='.$sql; $this->error = $this->db->error().' sql='.$sql;
@ -1623,8 +1627,6 @@ class FichinterLigne extends CommonObjectLine
*/ */
public function insert($user, $notrigger = 0) public function insert($user, $notrigger = 0)
{ {
global $langs, $conf;
$error = 0; $error = 0;
dol_syslog("FichinterLigne::insert rang=".$this->rang); dol_syslog("FichinterLigne::insert rang=".$this->rang);
@ -1714,8 +1716,6 @@ class FichinterLigne extends CommonObjectLine
*/ */
public function update($user, $notrigger = 0) public function update($user, $notrigger = 0)
{ {
global $langs, $conf;
$error = 0; $error = 0;
if (empty($this->date) && !empty($this->datei)) { // For backward compatibility if (empty($this->date) && !empty($this->datei)) { // For backward compatibility

View File

@ -260,25 +260,25 @@ class CommandeFournisseur extends CommonOrder
'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>35), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>35),
'ref_supplier' =>array('type'=>'varchar(255)', 'label'=>'RefOrderSupplierShort', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'searchall'=>1), 'ref_supplier' =>array('type'=>'varchar(255)', 'label'=>'RefOrderSupplierShort', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'searchall'=>1),
'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:(fk_statut:=:1)', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'visible'=>-1, 'position'=>45), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:(fk_statut:=:1)', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'visible'=>-1, 'position'=>45),
'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>60), 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>710),
'date_approve' =>array('type'=>'datetime', 'label'=>'DateApprove', 'enabled'=>1, 'visible'=>-1, 'position'=>62), 'date_approve' =>array('type'=>'datetime', 'label'=>'DateApprove', 'enabled'=>1, 'visible'=>-1, 'position'=>720),
'date_approve2' =>array('type'=>'datetime', 'label'=>'DateApprove2', 'enabled'=>1, 'visible'=>3, 'position'=>64), 'date_approve2' =>array('type'=>'datetime', 'label'=>'DateApprove2', 'enabled'=>1, 'visible'=>3, 'position'=>725),
'date_commande' =>array('type'=>'date', 'label'=>'OrderDateShort', 'enabled'=>1, 'visible'=>1, 'position'=>70), 'date_commande' =>array('type'=>'date', 'label'=>'OrderDateShort', 'enabled'=>1, 'visible'=>1, 'position'=>70),
'date_livraison' =>array('type'=>'datetime', 'label'=>'DeliveryDate', 'enabled'=>'empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)', 'visible'=>1, 'position'=>74), 'date_livraison' =>array('type'=>'datetime', 'label'=>'DeliveryDate', 'enabled'=>'empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)', 'visible'=>1, 'position'=>74),
'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>3, 'position'=>75), 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>3, 'position'=>41),
'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>3, 'notnull'=>-1, 'position'=>80), 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>3, 'notnull'=>-1, 'position'=>80),
'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>3, 'position'=>85), 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>3, 'position'=>711),
'fk_user_approve' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserApproval', 'enabled'=>1, 'visible'=>3, 'position'=>90), 'fk_user_approve' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserApproval', 'enabled'=>1, 'visible'=>3, 'position'=>721),
'fk_user_approve2' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserApproval2', 'enabled'=>1, 'visible'=>3, 'position'=>95), 'fk_user_approve2' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserApproval2', 'enabled'=>1, 'visible'=>3, 'position'=>726),
'source' =>array('type'=>'smallint(6)', 'label'=>'Source', 'enabled'=>1, 'visible'=>3, 'notnull'=>1, 'position'=>100), 'source' =>array('type'=>'smallint(6)', 'label'=>'Source', 'enabled'=>1, 'visible'=>3, 'notnull'=>1, 'position'=>100),
'billed' =>array('type'=>'smallint(6)', 'label'=>'Billed', 'enabled'=>1, 'visible'=>1, 'position'=>110), 'billed' =>array('type'=>'smallint(6)', 'label'=>'Billed', 'enabled'=>1, 'visible'=>1, 'position'=>710),
'total_tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>1, 'position'=>130, 'isameasure'=>1), 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'AmountHT', 'enabled'=>1, 'visible'=>1, 'position'=>130, 'isameasure'=>1),
'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>3, 'position'=>135, 'isameasure'=>1), 'total_tva' =>array('type'=>'double(24,8)', 'label'=>'AmountVAT', 'enabled'=>1, 'visible'=>1, 'position'=>135, 'isameasure'=>1),
'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>3, 'position'=>140, 'isameasure'=>1), 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'LT1', 'enabled'=>1, 'visible'=>3, 'position'=>140, 'isameasure'=>1),
'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>1, 'position'=>145, 'isameasure'=>1), 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LT2', 'enabled'=>1, 'visible'=>3, 'position'=>145, 'isameasure'=>1),
'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>150, 'isameasure'=>1), 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'AmountTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>150, 'isameasure'=>1),
'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>155, 'searchall'=>1), 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>750, 'searchall'=>1),
'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>160, 'searchall'=>1), 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>760, 'searchall'=>1),
'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>165), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>165),
'fk_input_method' =>array('type'=>'integer', 'label'=>'OrderMode', 'enabled'=>1, 'visible'=>3, 'position'=>170), 'fk_input_method' =>array('type'=>'integer', 'label'=>'OrderMode', 'enabled'=>1, 'visible'=>3, 'position'=>170),
'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>3, 'position'=>175), 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>3, 'position'=>175),
@ -294,7 +294,7 @@ class CommandeFournisseur extends CommonOrder
'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountVAT', 'enabled'=>'isModEnabled("multicurrency")', 'visible'=>-1, 'position'=>235), 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountVAT', 'enabled'=>'isModEnabled("multicurrency")', 'visible'=>-1, 'position'=>235),
'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountTTC', 'enabled'=>'isModEnabled("multicurrency")', 'visible'=>-1, 'position'=>240), 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountTTC', 'enabled'=>'isModEnabled("multicurrency")', 'visible'=>-1, 'position'=>240),
'date_creation' =>array('type'=>'datetime', 'label'=>'Date creation', 'enabled'=>1, 'visible'=>-1, 'position'=>500), 'date_creation' =>array('type'=>'datetime', 'label'=>'Date creation', 'enabled'=>1, 'visible'=>-1, 'position'=>500),
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>1, 'notnull'=>1, 'position'=>46), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>1, 'notnull'=>1, 'position'=>50),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>1000, 'index'=>1), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>1000, 'index'=>1),
'tms'=>array('type'=>'datetime', 'label'=>"DateModificationShort", 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501), 'tms'=>array('type'=>'datetime', 'label'=>"DateModificationShort", 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501),
'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'position'=>700), 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'position'=>700),

View File

@ -190,15 +190,17 @@ $checkedtypetiers = 0;
// Definition of array of fields for columns // Definition of array of fields for columns
$arrayfields = array( $arrayfields = array(
's.name_alias'=>array('label'=>"AliasNameShort", 'position'=>47, 'checked'=>0), 'u.login'=>array('label'=>"AuthorRequest", 'enabled'=>1, 'position'=>41),
's.town'=>array('label'=>"Town", 'enabled'=>1, 'position'=>47, 'checked'=>1), 's.name_alias'=>array('label'=>"AliasNameShort", 'position'=>51, 'checked'=>0),
's.zip'=>array('label'=>"Zip", 'enabled'=>1, 'position'=>47, 'checked'=>1), 's.town'=>array('label'=>"Town", 'enabled'=>1, 'position'=>55, 'checked'=>1),
'state.nom'=>array('label'=>"StateShort", 'enabled'=>1, 'position'=>48), 's.zip'=>array('label'=>"Zip", 'enabled'=>1, 'position'=>56, 'checked'=>1),
'country.code_iso'=>array('label'=>"Country", 'enabled'=>1, 'position'=>49), 'state.nom'=>array('label'=>"StateShort", 'enabled'=>1, 'position'=>57),
'typent.code'=>array('label'=>"ThirdPartyType", 'enabled'=>$checkedtypetiers, 'position'=>50), 'country.code_iso'=>array('label'=>"Country", 'enabled'=>1, 'position'=>58),
'u.login'=>array('label'=>"AuthorRequest", 'enabled'=>1, 'position'=>51), 'typent.code'=>array('label'=>"ThirdPartyType", 'enabled'=>$checkedtypetiers, 'position'=>59),
'cf.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position'=>100), 'cf.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj == "1"), 'position'=>140),
'cf.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'position'=>110), 'cf.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj == "1"), 'position'=>145),
'cf.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position'=>750),
'cf.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'position'=>760),
); );
foreach ($object->fields as $key => $val) { foreach ($object->fields as $key => $val) {
// If $val['visible']==0, then we never show the field // If $val['visible']==0, then we never show the field
@ -766,6 +768,7 @@ $sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.town, s.zip,
$sql .= " typent.code as typent_code,"; $sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= " state.code_departement as state_code, state.nom as state_name,";
$sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_livraison,cf.date_valid, cf.date_approve,"; $sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_livraison,cf.date_valid, cf.date_approve,";
$sql .= ' cf.localtax1 as total_localtax1, cf.localtax2 as total_localtax2,';
$sql .= ' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,'; $sql .= ' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,';
$sql .= ' cf.date_creation as date_creation, cf.tms as date_update,'; $sql .= ' cf.date_creation as date_creation, cf.tms as date_update,';
$sql .= ' cf.note_public, cf.note_private,'; $sql .= ' cf.note_public, cf.note_private,';
@ -1774,7 +1777,7 @@ if ($resql) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
} }
} }
//alias // Alias
if (!empty($arrayfields['s.name_alias']['checked'])) { if (!empty($arrayfields['s.name_alias']['checked'])) {
print '<td class="tdoverflowmax150">'; print '<td class="tdoverflowmax150">';
print $obj->alias; print $obj->alias;

View File

@ -74,6 +74,8 @@ $action = GETPOST('action', 'aZ09');
$confirm = GETPOST("confirm"); $confirm = GETPOST("confirm");
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$lineid = GETPOST('lineid', 'int'); $lineid = GETPOST('lineid', 'int');
$projectid = GETPOST('projectid', 'int'); $projectid = GETPOST('projectid', 'int');
$origin = GETPOST('origin', 'alpha'); $origin = GETPOST('origin', 'alpha');
@ -2156,6 +2158,7 @@ if ($action == 'create') {
if (!empty($currency_tx)) { if (!empty($currency_tx)) {
print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.'">'; print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.'">';
} }
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head(); print dol_get_fiche_head();
@ -3721,6 +3724,7 @@ if ($action == 'create') {
print '<input type="hidden" name="page_y" value="">'; print '<input type="hidden" name="page_y" value="">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="socid" value="'.$societe->id.'">'; print '<input type="hidden" name="socid" value="'.$societe->id.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if (!empty($conf->use_javascript_ajax) && $object->statut == FactureFournisseur::STATUS_DRAFT) { if (!empty($conf->use_javascript_ajax) && $object->statut == FactureFournisseur::STATUS_DRAFT) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';

View File

@ -17,12 +17,13 @@
} }
], ],
"require": { "require": {
"php": ">=5.6", "php": "^7.1|^8",
"psr/log": "^1.0", "psr/log": "^1|^2|^3",
"symfony/var-dumper": "^2.6|^3|^4" "symfony/var-dumper": "^4|^5|^6"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^5" "phpunit/phpunit": ">=7.5.20 <10.0",
"twig/twig": "^1.38|^2.7|^3.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@ -36,7 +37,7 @@
}, },
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.15-dev" "dev-master": "1.18-dev"
} }
} }
} }

View File

@ -57,9 +57,9 @@ class MonologCollector extends AbstractProcessingHandler implements DataCollecto
} }
/** /**
* @param array $record * @param array|\Monolog\LogRecord $record
*/ */
protected function write(array $record) protected function write($record): void
{ {
$this->records[] = array( $this->records[] = array(
'message' => $record['formatted'], 'message' => $record['formatted'],

View File

@ -0,0 +1,204 @@
<?php
declare(strict_types=1);
namespace DebugBar\Bridge;
use DebugBar\DataCollector\AssetProvider;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use Twig\Environment;
use Twig\Loader\LoaderInterface;
use Twig\Profiler\Dumper\HtmlDumper;
use Twig\Profiler\Profile;
/**
* Collects data about rendered templates
*
* http://twig.sensiolabs.org/
*
* A \Twig\Profiler\Profile should be added to your \Twig\Environment
* The root-Twig\Profiler\Profile-object should then be injected into this collector
*
* you can optionally provide the \Twig\Environment or the \Twig\Loader to also create
* debug-links.
*
* @see \Twig\Extension\ProfilerExtension, \Twig\Profiler\Profile
*
* <code>
* $env = new \Twig\Environment($loader); // Or from a PSR11-container
* $profile = new \Twig\Profiler\Profile();
* $env->addExtension(new \Twig\Extension\ProfilerExtension($profile));
* $debugbar->addCollector(new ModernTwigProfileCollector($profile, $env));
* // or: $debugbar->addCollector(new ModernTwigProfileCollector($profile, $loader));
* </code>
*/
class NamespacedTwigProfileCollector extends DataCollector implements Renderable, AssetProvider
{
/**
* @var Profile
*/
private $profile;
/**
* @var LoaderInterface|Environment|null
*/
private $loader;
/**
* @var int
*/
private $templateCount;
/**
* @var int
*/
private $blockCount;
/**
* @var int
*/
private $macroCount;
/**
* @var array[] {
* @var string $name
* @var int $render_time
* @var string $render_time_str
* @var string $memory_str
* @var string $xdebug_link
* }
*/
private $templates;
/**
* TwigProfileCollector constructor.
*
* @param Profile $profile
* @param LoaderInterface|Environment $loaderOrEnv
*/
public function __construct(Profile $profile, $loaderOrEnv = null)
{
$this->profile = $profile;
if ($loaderOrEnv instanceof Environment) {
$loaderOrEnv = $loaderOrEnv->getLoader();
}
$this->loader = $loaderOrEnv;
}
/**
* Returns a hash where keys are control names and their values
* an array of options as defined in {@see \DebugBar\JavascriptRenderer::addControl()}
*
* @return array
*/
public function getWidgets()
{
return [
'twig' => [
'icon' => 'leaf',
'widget' => 'PhpDebugBar.Widgets.TemplatesWidget',
'map' => 'twig',
'default' => json_encode(['templates' => []]),
],
'twig:badge' => [
'map' => 'twig.badge',
'default' => 0,
],
];
}
/**
* @return array
*/
public function getAssets()
{
return [
'css' => 'widgets/templates/widget.css',
'js' => 'widgets/templates/widget.js',
];
}
/**
* Called by the DebugBar when data needs to be collected
*
* @return array Collected data
*/
public function collect()
{
$this->templateCount = $this->blockCount = $this->macroCount = 0;
$this->templates = [];
$this->computeData($this->profile);
return [
'nb_templates' => $this->templateCount,
'nb_blocks' => $this->blockCount,
'nb_macros' => $this->macroCount,
'templates' => $this->templates,
'accumulated_render_time' => $this->profile->getDuration(),
'accumulated_render_time_str' => $this->getDataFormatter()->formatDuration($this->profile->getDuration()),
'memory_usage_str' => $this->getDataFormatter()->formatBytes($this->profile->getMemoryUsage()),
'callgraph' => $this->getHtmlCallGraph(),
'badge' => implode(
'/',
[
$this->templateCount,
$this->blockCount,
$this->macroCount,
]
),
];
}
/**
* Returns the unique name of the collector
*
* @return string
*/
public function getName()
{
return 'twig';
}
public function getHtmlCallGraph()
{
$dumper = new HtmlDumper();
return $dumper->dump($this->profile);
}
/**
* Get an Xdebug Link to a file
*
* @return array {
* @var string url
* @var bool ajax
* }
*/
public function getXdebugLink($template, $line = 1)
{
if (is_null($this->loader)) {
return null;
}
$file = $this->loader->getSourceContext($template)->getPath();
return parent::getXdebugLink($file, $line);
}
private function computeData(Profile $profile)
{
$this->templateCount += ($profile->isTemplate() ? 1 : 0);
$this->blockCount += ($profile->isBlock() ? 1 : 0);
$this->macroCount += ($profile->isMacro() ? 1 : 0);
if ($profile->isTemplate()) {
$this->templates[] = [
'name' => $profile->getName(),
'render_time' => $profile->getDuration(),
'render_time_str' => $this->getDataFormatter()->formatDuration($profile->getDuration()),
'memory_str' => $this->getDataFormatter()->formatBytes($profile->getMemoryUsage()),
'xdebug_link' => $this->getXdebugLink($profile->getTemplate()),
];
}
foreach ($profile as $p) {
$this->computeData($p);
}
}
}

View File

@ -34,7 +34,16 @@ class SwiftLogCollector extends MessagesCollector implements Swift_Plugins_Logge
public function dump() public function dump()
{ {
return implode(PHP_EOL, $this->_log); $dump = '';
foreach ($this->messages as $message) {
if (!$message['is_string']) {
continue;
}
$dump .= $message['message'] . PHP_EOL;
}
return $dump;
} }
public function getName() public function getName()

View File

@ -57,4 +57,4 @@ class TimeableTwigExtensionProfiler extends \Twig_Extension_Profiler
$this->timeDataCollector->stopMeasure($profile->getName()); $this->timeDataCollector->stopMeasure($profile->getName());
} }
} }
} }

View File

@ -24,6 +24,8 @@ use Twig_TokenStream;
/** /**
* Wrapped a Twig Environment to provide profiling features * Wrapped a Twig Environment to provide profiling features
*
* @deprecated
*/ */
class TraceableTwigEnvironment extends Twig_Environment class TraceableTwigEnvironment extends Twig_Environment
{ {

View File

@ -15,6 +15,8 @@ use Twig_TemplateInterface;
/** /**
* Wraps a Twig_Template to add profiling features * Wraps a Twig_Template to add profiling features
*
* @deprecated
*/ */
class TraceableTwigTemplate extends Twig_Template implements Twig_TemplateInterface class TraceableTwigTemplate extends Twig_Template implements Twig_TemplateInterface
{ {

View File

@ -26,6 +26,8 @@ use DebugBar\DataCollector\Renderable;
* $env = new TraceableTwigEnvironment(new Twig_Environment($loader)); * $env = new TraceableTwigEnvironment(new Twig_Environment($loader));
* $debugbar->addCollector(new TwigCollector($env)); * $debugbar->addCollector(new TwigCollector($env));
* </code> * </code>
*
* @deprecated use DebugBar\Bridge\TwigProfileCollector instead
*/ */
class TwigCollector extends DataCollector implements Renderable, AssetProvider class TwigCollector extends DataCollector implements Renderable, AssetProvider
{ {

View File

@ -34,6 +34,8 @@ use DebugBar\DataCollector\Renderable;
* $debugbar->addCollector(new TwigProfileCollector($profile, $env)); * $debugbar->addCollector(new TwigProfileCollector($profile, $env));
* // or: $debugbar->addCollector(new TwigProfileCollector($profile, $loader)); * // or: $debugbar->addCollector(new TwigProfileCollector($profile, $loader));
* </code> * </code>
*
* @deprecated Use `\Debugbar\Bridge\NamespacedTwigProfileCollector` instead for Twig 2.x and 3.x
*/ */
class TwigProfileCollector extends DataCollector implements Renderable, AssetProvider class TwigProfileCollector extends DataCollector implements Renderable, AssetProvider
{ {

View File

@ -48,7 +48,7 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
/** /**
* @param DataCollectorInterface $collector * @param DataCollectorInterface $collector
*/ */
public function addCollector(DataCollectorInterface $collector) public function addCollector(DataCollectorInterface $collector) : void
{ {
$this->collectors[$collector->getName()] = $collector; $this->collectors[$collector->getName()] = $collector;
} }
@ -56,7 +56,7 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
/** /**
* @return array * @return array
*/ */
public function getCollectors() public function getCollectors() : array
{ {
return $this->collectors; return $this->collectors;
} }
@ -66,7 +66,7 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
* *
* @param string $property * @param string $property
*/ */
public function setMergeProperty($property) public function setMergeProperty($property) : void
{ {
$this->mergeProperty = $property; $this->mergeProperty = $property;
} }
@ -74,7 +74,7 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
/** /**
* @return string * @return string
*/ */
public function getMergeProperty() public function getMergeProperty() : string
{ {
return $this->mergeProperty; return $this->mergeProperty;
} }
@ -87,7 +87,7 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
* *
* @param bool|string $sort * @param bool|string $sort
*/ */
public function setSort($sort) public function setSort($sort) : void
{ {
$this->sort = $sort; $this->sort = $sort;
} }
@ -103,7 +103,7 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
/** /**
* @return array * @return array
*/ */
public function collect() public function collect() : array
{ {
$aggregate = array(); $aggregate = array();
foreach ($this->collectors as $collector) { foreach ($this->collectors as $collector) {
@ -123,7 +123,7 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
* @param array $data * @param array $data
* @return array * @return array
*/ */
protected function sort($data) protected function sort($data) : array
{ {
if (is_string($this->sort)) { if (is_string($this->sort)) {
$p = $this->sort; $p = $this->sort;
@ -142,7 +142,7 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
/** /**
* @return string * @return string
*/ */
public function getName() public function getName() : string
{ {
return $this->name; return $this->name;
} }
@ -155,7 +155,7 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
* @param mixed $value * @param mixed $value
* @throws DebugBarException * @throws DebugBarException
*/ */
public function offsetSet($key, $value) public function offsetSet($key, $value): void
{ {
throw new DebugBarException("AggregatedCollector[] is read-only"); throw new DebugBarException("AggregatedCollector[] is read-only");
} }
@ -164,6 +164,7 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
* @param mixed $key * @param mixed $key
* @return mixed * @return mixed
*/ */
#[\ReturnTypeWillChange]
public function offsetGet($key) public function offsetGet($key)
{ {
return $this->collectors[$key]; return $this->collectors[$key];
@ -173,7 +174,7 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
* @param mixed $key * @param mixed $key
* @return bool * @return bool
*/ */
public function offsetExists($key) public function offsetExists($key): bool
{ {
return isset($this->collectors[$key]); return isset($this->collectors[$key]);
} }
@ -182,7 +183,7 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
* @param mixed $key * @param mixed $key
* @throws DebugBarException * @throws DebugBarException
*/ */
public function offsetUnset($key) public function offsetUnset($key): void
{ {
throw new DebugBarException("AggregatedCollector[] is read-only"); throw new DebugBarException("AggregatedCollector[] is read-only");
} }

View File

@ -21,6 +21,10 @@ class ExceptionsCollector extends DataCollector implements Renderable
protected $exceptions = array(); protected $exceptions = array();
protected $chainExceptions = false; protected $chainExceptions = false;
// The HTML var dumper requires debug bar users to support the new inline assets, which not all
// may support yet - so return false by default for now.
protected $useHtmlVarDumper = false;
/** /**
* Adds an exception to be profiled in the debug bar * Adds an exception to be profiled in the debug bar
* *
@ -65,6 +69,30 @@ class ExceptionsCollector extends DataCollector implements Renderable
return $this->exceptions; return $this->exceptions;
} }
/**
* Sets a flag indicating whether the Symfony HtmlDumper will be used to dump variables for
* rich variable rendering.
*
* @param bool $value
* @return $this
*/
public function useHtmlVarDumper($value = true)
{
$this->useHtmlVarDumper = $value;
return $this;
}
/**
* Indicates whether the Symfony HtmlDumper will be used to dump variables for rich variable
* rendering.
*
* @return mixed
*/
public function isHtmlVarDumperUsed()
{
return $this->useHtmlVarDumper;
}
public function collect() public function collect()
{ {
return array( return array(
@ -102,6 +130,11 @@ class ExceptionsCollector extends DataCollector implements Renderable
$lines = array("Cannot open the file ($filePath) in which the exception occurred "); $lines = array("Cannot open the file ($filePath) in which the exception occurred ");
} }
$traceHtml = null;
if ($this->isHtmlVarDumperUsed()) {
$traceHtml = $this->getVarDumper()->renderVar($e->getTrace());
}
return array( return array(
'type' => get_class($e), 'type' => get_class($e),
'message' => $e->getMessage(), 'message' => $e->getMessage(),
@ -109,6 +142,7 @@ class ExceptionsCollector extends DataCollector implements Renderable
'file' => $filePath, 'file' => $filePath,
'line' => $e->getLine(), 'line' => $e->getLine(),
'stack_trace' => $e->getTraceAsString(), 'stack_trace' => $e->getTraceAsString(),
'stack_trace_html' => $traceHtml,
'surrounding_lines' => $lines, 'surrounding_lines' => $lines,
'xdebug_link' => $this->getXdebugLink($filePath, $e->getLine()) 'xdebug_link' => $this->getXdebugLink($filePath, $e->getLine())
); );

View File

@ -67,7 +67,7 @@ class MemoryCollector extends DataCollector implements Renderable
$this->updatePeakUsage(); $this->updatePeakUsage();
return array( return array(
'peak_usage' => $this->peakUsage, 'peak_usage' => $this->peakUsage,
'peak_usage_str' => $this->getDataFormatter()->formatBytes($this->peakUsage) 'peak_usage_str' => $this->getDataFormatter()->formatBytes($this->peakUsage, 0)
); );
} }

View File

@ -183,11 +183,37 @@ class MessagesCollector extends AbstractLogger implements DataCollectorInterface
* @param $message * @param $message
* @param array $context * @param array $context
*/ */
public function log($level, $message, array $context = array()) public function log($level, $message, array $context = array()): void
{ {
// For string messages, interpolate the context following PSR-3
if (is_string($message)) {
$message = $this->interpolate($message, $context);
}
$this->addMessage($message, $level); $this->addMessage($message, $level);
} }
/**
* Interpolates context values into the message placeholders.
*
* @param $message
* @param array $context
* @return string
*/
function interpolate($message, array $context = array())
{
// build a replacement array with braces around the context keys
$replace = array();
foreach ($context as $key => $val) {
// check that the value can be cast to string
if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) {
$replace['{' . $key . '}'] = $val;
}
}
// interpolate replacement values into the message and return
return strtr($message, $replace);
}
/** /**
* Deletes all messages * Deletes all messages
*/ */

View File

@ -21,10 +21,10 @@ class PDOCollector extends DataCollector implements Renderable, AssetProvider
protected $sqlQuotationChar = '<>'; protected $sqlQuotationChar = '<>';
/** /**
* @param TraceablePDO $pdo * @param \PDO $pdo
* @param TimeDataCollector $timeCollector * @param TimeDataCollector $timeCollector
*/ */
public function __construct(TraceablePDO $pdo = null, TimeDataCollector $timeCollector = null) public function __construct(\PDO $pdo = null, TimeDataCollector $timeCollector = null)
{ {
$this->timeCollector = $timeCollector; $this->timeCollector = $timeCollector;
if ($pdo !== null) { if ($pdo !== null) {
@ -65,11 +65,14 @@ class PDOCollector extends DataCollector implements Renderable, AssetProvider
* @param TraceablePDO $pdo * @param TraceablePDO $pdo
* @param string $name Optional connection name * @param string $name Optional connection name
*/ */
public function addConnection(TraceablePDO $pdo, $name = null) public function addConnection(\PDO $pdo, $name = null)
{ {
if ($name === null) { if ($name === null) {
$name = spl_object_hash($pdo); $name = spl_object_hash($pdo);
} }
if (!($pdo instanceof TraceablePDO)) {
$pdo = new TraceablePDO($pdo);
}
$this->connections[$name] = $pdo; $this->connections[$name] = $pdo;
} }

View File

@ -23,13 +23,13 @@ class TraceablePDO extends PDO
$this->pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, [TraceablePDOStatement::class, [$this]]); $this->pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, [TraceablePDOStatement::class, [$this]]);
} }
/** /**
* Initiates a transaction * Initiates a transaction
* *
* @link http://php.net/manual/en/pdo.begintransaction.php * @link http://php.net/manual/en/pdo.begintransaction.php
* @return bool TRUE on success or FALSE on failure. * @return bool TRUE on success or FALSE on failure.
*/ */
public function beginTransaction() public function beginTransaction() : bool
{ {
return $this->pdo->beginTransaction(); return $this->pdo->beginTransaction();
} }
@ -40,7 +40,7 @@ class TraceablePDO extends PDO
* @link http://php.net/manual/en/pdo.commit.php * @link http://php.net/manual/en/pdo.commit.php
* @return bool TRUE on success or FALSE on failure. * @return bool TRUE on success or FALSE on failure.
*/ */
public function commit() public function commit() : bool
{ {
return $this->pdo->commit(); return $this->pdo->commit();
} }
@ -51,6 +51,7 @@ class TraceablePDO extends PDO
* @link http://php.net/manual/en/pdo.errorinfo.php * @link http://php.net/manual/en/pdo.errorinfo.php
* @return array PDO::errorInfo returns an array of error information * @return array PDO::errorInfo returns an array of error information
*/ */
#[\ReturnTypeWillChange]
public function errorCode() public function errorCode()
{ {
return $this->pdo->errorCode(); return $this->pdo->errorCode();
@ -62,7 +63,7 @@ class TraceablePDO extends PDO
* @link http://php.net/manual/en/pdo.errorinfo.php * @link http://php.net/manual/en/pdo.errorinfo.php
* @return array PDO::errorInfo returns an array of error information * @return array PDO::errorInfo returns an array of error information
*/ */
public function errorInfo() public function errorInfo() : array
{ {
return $this->pdo->errorInfo(); return $this->pdo->errorInfo();
} }
@ -77,6 +78,7 @@ class TraceablePDO extends PDO
* return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. * return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE.
* Please read the section on Booleans for more information * Please read the section on Booleans for more information
*/ */
#[\ReturnTypeWillChange]
public function exec($statement) public function exec($statement)
{ {
return $this->profileCall('exec', $statement, func_get_args()); return $this->profileCall('exec', $statement, func_get_args());
@ -90,6 +92,7 @@ class TraceablePDO extends PDO
* @return mixed A successful call returns the value of the requested PDO attribute. * @return mixed A successful call returns the value of the requested PDO attribute.
* An unsuccessful call returns null. * An unsuccessful call returns null.
*/ */
#[\ReturnTypeWillChange]
public function getAttribute($attribute) public function getAttribute($attribute)
{ {
return $this->pdo->getAttribute($attribute); return $this->pdo->getAttribute($attribute);
@ -101,7 +104,7 @@ class TraceablePDO extends PDO
* @link http://php.net/manual/en/pdo.intransaction.php * @link http://php.net/manual/en/pdo.intransaction.php
* @return bool TRUE if a transaction is currently active, and FALSE if not. * @return bool TRUE if a transaction is currently active, and FALSE if not.
*/ */
public function inTransaction() public function inTransaction() : bool
{ {
return $this->pdo->inTransaction(); return $this->pdo->inTransaction();
} }
@ -114,36 +117,41 @@ class TraceablePDO extends PDO
* @return string If a sequence name was not specified for the name parameter, PDO::lastInsertId * @return string If a sequence name was not specified for the name parameter, PDO::lastInsertId
* returns a string representing the row ID of the last row that was inserted into the database. * returns a string representing the row ID of the last row that was inserted into the database.
*/ */
#[\ReturnTypeWillChange]
public function lastInsertId($name = null) public function lastInsertId($name = null)
{ {
return $this->pdo->lastInsertId($name); return $this->pdo->lastInsertId($name);
} }
/** /**
* Prepares a statement for execution and returns a statement object * Prepares a statement for execution and returns a statement object
* *
* @link http://php.net/manual/en/pdo.prepare.php * @link http://php.net/manual/en/pdo.prepare.php
* @param string $statement This must be a valid SQL statement template for the target DB server. * @param string $statement This must be a valid SQL statement template for the target DB server.
* @param array $driver_options [optional] This array holds one or more key=&gt;value pairs to * @param array $driver_options [optional] This array holds one or more key=&gt;value pairs to
* set attribute values for the PDOStatement object that this method returns. * set attribute values for the PDOStatement object that this method returns.
* @return TraceablePDOStatement|bool If the database server successfully prepares the statement, * @return TraceablePDOStatement|bool If the database server successfully prepares the statement,
* PDO::prepare returns a PDOStatement object. If the database server cannot successfully prepare * PDO::prepare returns a PDOStatement object. If the database server cannot successfully prepare
* the statement, PDO::prepare returns FALSE or emits PDOException (depending on error handling). * the statement, PDO::prepare returns FALSE or emits PDOException (depending on error handling).
*/ */
#[\ReturnTypeWillChange]
public function prepare($statement, $driver_options = []) public function prepare($statement, $driver_options = [])
{ {
return $this->pdo->prepare($statement, $driver_options); return $this->pdo->prepare($statement, $driver_options);
} }
/** /**
* Executes an SQL statement, returning a result set as a PDOStatement object * Executes an SQL statement, returning a result set as a PDOStatement object
* *
* @link http://php.net/manual/en/pdo.query.php * @link http://php.net/manual/en/pdo.query.php
* @param string $statement * @param string $statement
* @return TraceablePDOStatement|bool PDO::query returns a PDOStatement object, or FALSE on * @param int $fetchMode
* failure. * @param mixed ...$fetchModeArgs
*/ * @return TraceablePDOStatement|bool PDO::query returns a PDOStatement object, or FALSE on
public function query($statement) * failure.
*/
#[\ReturnTypeWillChange]
public function query($statement, $fetchMode = null, ...$fetchModeArgs)
{ {
return $this->profileCall('query', $statement, func_get_args()); return $this->profileCall('query', $statement, func_get_args());
} }
@ -158,6 +166,7 @@ class TraceablePDO extends PDO
* @return string|bool A quoted string that is theoretically safe to pass into an SQL statement. * @return string|bool A quoted string that is theoretically safe to pass into an SQL statement.
* Returns FALSE if the driver does not support quoting in this way. * Returns FALSE if the driver does not support quoting in this way.
*/ */
#[\ReturnTypeWillChange]
public function quote($string, $parameter_type = PDO::PARAM_STR) public function quote($string, $parameter_type = PDO::PARAM_STR)
{ {
return $this->pdo->quote($string, $parameter_type); return $this->pdo->quote($string, $parameter_type);
@ -169,7 +178,7 @@ class TraceablePDO extends PDO
* @link http://php.net/manual/en/pdo.rollback.php * @link http://php.net/manual/en/pdo.rollback.php
* @return bool TRUE on success or FALSE on failure. * @return bool TRUE on success or FALSE on failure.
*/ */
public function rollBack() public function rollBack() : bool
{ {
return $this->pdo->rollBack(); return $this->pdo->rollBack();
} }
@ -182,7 +191,7 @@ class TraceablePDO extends PDO
* @param mixed $value * @param mixed $value
* @return bool TRUE on success or FALSE on failure. * @return bool TRUE on success or FALSE on failure.
*/ */
public function setAttribute($attribute, $value) public function setAttribute($attribute, $value) : bool
{ {
return $this->pdo->setAttribute($attribute, $value); return $this->pdo->setAttribute($attribute, $value);
} }
@ -195,6 +204,7 @@ class TraceablePDO extends PDO
* @param array $args * @param array $args
* @return mixed The result of the call * @return mixed The result of the call
*/ */
#[\ReturnTypeWillChange]
protected function profileCall($method, $sql, array $args) protected function profileCall($method, $sql, array $args)
{ {
$trace = new TracedStatement($sql); $trace = new TracedStatement($sql);
@ -226,7 +236,7 @@ class TraceablePDO extends PDO
* *
* @param TracedStatement $stmt * @param TracedStatement $stmt
*/ */
public function addExecutedStatement(TracedStatement $stmt) public function addExecutedStatement(TracedStatement $stmt) : void
{ {
$this->executedStatements[] = $stmt; $this->executedStatements[] = $stmt;
} }
@ -234,9 +244,9 @@ class TraceablePDO extends PDO
/** /**
* Returns the accumulated execution time of statements * Returns the accumulated execution time of statements
* *
* @return int * @return float
*/ */
public function getAccumulatedStatementsDuration() public function getAccumulatedStatementsDuration() : float
{ {
return array_reduce($this->executedStatements, function ($v, $s) { return $v + $s->getDuration(); }); return array_reduce($this->executedStatements, function ($v, $s) { return $v + $s->getDuration(); });
} }
@ -246,7 +256,7 @@ class TraceablePDO extends PDO
* *
* @return int * @return int
*/ */
public function getMemoryUsage() public function getMemoryUsage() : int
{ {
return array_reduce($this->executedStatements, function ($v, $s) { return $v + $s->getMemoryUsage(); }); return array_reduce($this->executedStatements, function ($v, $s) { return $v + $s->getMemoryUsage(); });
} }
@ -256,7 +266,7 @@ class TraceablePDO extends PDO
* *
* @return int * @return int
*/ */
public function getPeakMemoryUsage() public function getPeakMemoryUsage() : int
{ {
return array_reduce($this->executedStatements, function ($v, $s) { $m = $s->getEndMemory(); return $m > $v ? $m : $v; }); return array_reduce($this->executedStatements, function ($v, $s) { $m = $s->getEndMemory(); return $m > $v ? $m : $v; });
} }
@ -266,7 +276,7 @@ class TraceablePDO extends PDO
* *
* @return TracedStatement[] * @return TracedStatement[]
*/ */
public function getExecutedStatements() public function getExecutedStatements() : array
{ {
return $this->executedStatements; return $this->executedStatements;
} }
@ -276,7 +286,7 @@ class TraceablePDO extends PDO
* *
* @return TracedStatement[] * @return TracedStatement[]
*/ */
public function getFailedExecutedStatements() public function getFailedExecutedStatements() : array
{ {
return array_filter($this->executedStatements, function ($s) { return !$s->isSuccess(); }); return array_filter($this->executedStatements, function ($s) { return !$s->isSuccess(); });
} }

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