Merge branch 'develop' into 6.0-salary

This commit is contained in:
Laurent Destailleur 2017-06-06 11:01:28 +02:00 committed by GitHub
commit 63920930bf
207 changed files with 4115 additions and 2174 deletions

View File

@ -22,6 +22,26 @@ Following changes may create regression for some external modules, but were nece
* Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still
exists, but if an external module need action on it, it must provides itself its trigger file.
***** ChangeLog for 5.0.3 compared to 5.0.2 *****
FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty
FIX: #6813
FIX: 6863
FIX: #6877
FIX: #6881
FIX: Better sanitizing of search all parameter.
FIX: Correction with author and validator user on orders
FIX: dialog window with md theme must not be hidden by left menu part.
FIX: doactions hook missing in invoice model page
FIX: Fullname when member is a moral entity with no name.
FIX: Link to files on bank account tab broken with multicompany FIX: Link to preview on thirdparty broken with multicompany
FIX: New vat code not correctly implemented if "1 price per customer".
FIX: Pagination of invoices
FIX: pagination on resources
FIX: REST API not possible to add agendaevents
FIX: situation invoice broken due to the all percent application form inside addline form
FIX: SQL injection on user/index.php parameter search_statut.
FIX: XSS
***** ChangeLog for 5.0.2 compared to 5.0.1 *****
FIX: #6468 + Fix missing translation
FIX: #6517 #6525 Autocompletion of thirdparty after n chars not implemented

View File

@ -444,3 +444,4 @@ Note that package 3.5.7 contains not only fixed for bugs reported to debian. It
so it is a better solution to validate this maintenance release than applying a patch of the only CVE-2015-3935.
After discussion with ..., it appears that security holes are enough to request this unblock request."
Note: If there is a response to ask more information, don't forget to remove the tag during answer.

View File

@ -4,7 +4,12 @@ dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jsgantt/*
dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jstz/*
# Those are false positives, the files are their own sources since
# they are not minified
source-is-missing htdocs/includes/jsgantt/jsgantt.js *
source-is-missing htdocs/includes/jquery/plugins/colorpicker/jquery.colorpicker.js *
source-is-missing htdocs/includes/jquery/plugins/select2/select2.js *
source-is-missing htdocs/includes/jquery/plugins/select2/select2_locale_ar.js *
source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/a11yhelp/dialogs/lang/*.js
source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/specialchar/dialogs/lang/*.js
source-is-missing htdocs/includes/ckeditor/ckeditor/lang/*.js
source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/*/dialogs/*.js
source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/*/filter/*.js
source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/templates/templates/default.js
source-is-missing htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.json
source-is-missing htdocs/includes/restler/framework/Luracast/Restler/explorer/lib/*.js

View File

@ -32,7 +32,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -43,7 +43,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTIN
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -74,7 +74,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTIN
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -65,10 +65,8 @@ $langs->load("accountancy");
$langs->load("trips");
$langs->load("salaries");
// Old system menu
$id_bank_account = GETPOST('id_account', 'int');
// Multi journal
$code_journal = GETPOST('code_journal', 'alpha');
$id_journal = GETPOST('id_journal', 'int');
$date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday');
@ -81,7 +79,7 @@ $action = GETPOST('action','aZ09');
$now = dol_now();
// Security check
if ($user->societe_id > 0 && empty($id_bank_account))
if ($user->societe_id > 0 && empty($id_journal))
accessforbidden();
@ -112,7 +110,7 @@ $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
$idpays = $p[0];
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
$sql .= " ba.courant, ba.ref as baref, ba.account_number,";
$sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop,";
$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop";
$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b";
@ -121,7 +119,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.row
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid";
$sql .= " WHERE ba.rowid=" . $id_bank_account;
$sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal;
$sql .= ' AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy
if ($date_start && $date_end)
$sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'";
@ -139,20 +137,8 @@ $paymentsalstatic = new PaymentSalary($db);
$paymentexpensereportstatic = new PaymentExpenseReport($db);
// Get code of finance journal
$journal = '';
$bankstatic = new Account($db);
$bankstatic->fetch($id_bank_account);
$bankstatic->rowid;
$bankstatic->number;
$bankstatic->label;
$bankstatic->fk_accountancy_journal;
$accountingjournalstatic = new AccountingJournal($db);
if(! empty($id_bank_account)) {
$accountingjournalstatic->fetch($bankstatic->fk_accountancy_journal);
} else {
$accountingjournalstatic->fetch('',$code_journal);
}
$accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code;
dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
@ -194,7 +180,7 @@ if ($result) {
$tabcompany[$obj->rowid] = array (
'id' => $obj->socid,
'name' => $obj->name,
'code_compta' => $compta_soc,
'code_compta' => $compta_soc,
);
$compta_user = (! empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee);
@ -202,6 +188,8 @@ if ($result) {
$tabuser[$obj->rowid] = array (
'id' => $obj->userid,
'name' => $obj->firstname.' '.$obj->lastname,
'lastname' => $obj->lastname,
'firstname' => $obj->firstname,
'accountancy_code' => $compta_user,
);
@ -219,7 +207,7 @@ if ($result) {
// get_url may return -1 which is not traversable
if (is_array($links)) {
// Now loop on each link of record in bank.
// Now loop on each link of record in bank.
foreach ( $links as $key => $val ) {
if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary'))) // So we excluded 'company' here
@ -754,13 +742,13 @@ if (empty($action) || $action == 'view') {
llxHeader('', $langs->trans("FinanceJournal"));
$nom = $langs->trans("FinanceJournal") . ' - ' . $bankstatic->getNomUrl(1);
$nom = $langs->trans("FinanceJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1);
$builddate = time();
//$description = $langs->trans("DescFinanceJournal") . '<br>';
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
$varlink = 'id_account=' . $id_bank_account;
$varlink = 'id_journal=' . $id_journal;
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);

View File

@ -3,7 +3,7 @@
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
*
@ -32,10 +32,11 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
// Langs
$langs->load("compta");
@ -45,6 +46,9 @@ $langs->load("main");
$langs->load("accountancy");
$langs->load("trips");
// Multi journal
$id_journal = GETPOST('id_journal', 'int');
$date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday');
$date_startyear = GETPOST('date_startyear');
@ -64,6 +68,10 @@ $action = GETPOST('action','aZ09');
/*
* Actions
*/
// Get code of finance journal
$accountingjournalstatic = new AccountingJournal($db);
$accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code;
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
@ -157,161 +165,159 @@ if ($action == 'writebookkeeping') {
{
$errorforline = 0;
$db->begin();
if (! $errorforline)
{
foreach ( $tabttc[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->code_tiers = $tabuser[$key]['user_accountancy_code'];
$bookkeeping->label_compte = $tabuser[$key]['name'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt <= 0) ? $mt : 0;
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user);
if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
{
$error++;
$errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
}
else
{
$error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
}
}
}
if (! $errorforline)
{
// Fees
foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
if ($mt) {
// get compte id and label
$accountingaccount = new AccountingAccount($db);
if ($accountingaccount->fetch(null, $k, true)) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->code_tiers = '';
$bookkeeping->label_compte = $accountingaccount->label;
$bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user);
if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
{
$error++;
$errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
}
else
{
$error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
}
}
}
}
if (! $errorforline)
{
// VAT
// var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->code_tiers = '';
$bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key];
$bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user);
if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
{
$error++;
$errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
}
else
{
$error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
}
}
}
$db->begin();
if (! $errorforline)
{
$db->commit();
foreach ( $tabttc[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->code_tiers = $tabuser[$key]['user_accountancy_code'];
$bookkeeping->label_compte = $tabuser[$key]['name'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt <= 0) ? $mt : 0;
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user);
if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
{
$error++;
$errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
}
else
{
$error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
}
}
}
if (! $errorforline)
{
// Fees
foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
if ($mt) {
// get compte id and label
$accountingaccount = new AccountingAccount($db);
if ($accountingaccount->fetch(null, $k, true)) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->code_tiers = '';
$bookkeeping->label_compte = $accountingaccount->label;
$bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user);
if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
{
$error++;
$errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
}
else
{
$error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
}
}
}
}
if (! $errorforline)
{
// VAT
// var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->code_tiers = '';
$bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key];
$bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user);
if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
{
$error++;
$errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
}
else
{
$error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
}
}
}
if (! $errorforline)
{
$db->commit();
}
else
{
$db->rollback();
$db->rollback();
}
}
if (empty($error) && count($tabpay)) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
}
elseif (count($tabpay) == $error)
{
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
}
else
{
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
}
$action='';
@ -328,7 +334,6 @@ $userstatic = new User($db);
// Export
/*if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL;
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
@ -448,7 +453,9 @@ if (empty($action) || $action == 'view') {
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''));
$varlink = 'id_journal=' . $id_journal;
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
/*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
@ -456,10 +463,10 @@ if (empty($action) || $action == 'view') {
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
}*/
print '<div class="tabsAction">';
print '<div class="tabsAction">';
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
print '</div>';
print '</div>';
print '
<script type="text/javascript">
function launch_export() {
@ -556,9 +563,9 @@ if (empty($action) || $action == 'view') {
// Third party
foreach ( $tabttc[$key] as $k => $mt ) {
print '<tr class="oddeven">';
print "<td><!-- Thirdparty --></td>";
print "<td>" . $date . "</td>";
print '<tr class="oddeven">';
print "<td><!-- Thirdparty --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
$userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name'];
@ -566,14 +573,14 @@ if (empty($action) || $action == 'view') {
$accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("Code_tiers") . "</td>";
print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>";
print "</tr>";
}
}

View File

@ -66,7 +66,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -48,7 +48,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -49,6 +49,8 @@ $type = 'action';
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if (preg_match('/set_(.*)/',$action,$reg))
{
$code=$reg[1];
@ -77,21 +79,6 @@ if (preg_match('/del_(.*)/',$action,$reg))
dol_print_error($db);
}
}
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
if ($action == 'set')
{
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
@ -233,7 +220,7 @@ else
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
print load_fiche_titre($langs->trans("AgendaModelModule"),'','');
print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre">'."\n";
print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
@ -243,13 +230,13 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print '<td align="center" width="40">'.$langs->trans("ShortInfo").'</td>';
print '<td align="center" width="40">'.$langs->trans("Preview").'</td>';
print '</tr>'."\n";
clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/action/doc/");
if (is_dir($dir))
{
$handle=opendir($dir);
@ -261,10 +248,10 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
require_once $dir.'/'.$file;
$module = new $classname($db, new ActionComm($db));
$module = new $classname($db, new ActionComm($db));
print '<tr class="oddeven">'."\n";
print "<td>";
print (empty($module->name)?$name:$module->name);
@ -272,16 +259,16 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print "<td>\n";
require_once $dir.$file;
$module = new $classname($db,$specimenthirdparty);
if (method_exists($module,'info'))
if (method_exists($module,'info'))
print $module->info($langs);
else
else
print $module->description;
print "</td>\n";
// Active
if (in_array($name, $def))
{
print '<td align="center">'."\n";
if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name")
{
@ -301,7 +288,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
print "</td>";
}
// Default
print '<td align="center">';
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name")
@ -313,7 +300,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
}
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
@ -326,7 +313,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print '<td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>';
print '</td>';
print "</tr>\n";
}
}
@ -366,7 +353,7 @@ print '</td></tr>'."\n";
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n";
@ -404,30 +391,30 @@ print '</td></tr>'."\n";
// AGENDA NOTIFICATION
if ($conf->global->MAIN_FEATURES_LEVEL > 0)
{
print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans('AGENDA_NOTIFICATION').'</td>'."\n";
print '<td align="center">&nbsp;</td>'."\n";
print '<td align="right">'."\n";
if (empty($conf->global->AGENDA_NOTIFICATION)) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_NOTIFICATION">'.img_picto($langs->trans('Disabled'),'switch_off').'</a>';
print '</td></tr>'."\n";
} else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_NOTIFICATION">'.img_picto($langs->trans('Enabled'),'switch_on').'</a>';
print '</td></tr>'."\n";
print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans('AGENDA_NOTIFICATION_SOUND').'</td>'."\n";
print '<td align="center">&nbsp;</td>'."\n";
print '<td align="right">'."\n";
if (empty($conf->global->AGENDA_NOTIFICATION_SOUND)) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_NOTIFICATION_SOUND">'.img_picto($langs->trans('Disabled'),'switch_off').'</a>';
} else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_NOTIFICATION_SOUND">'.img_picto($langs->trans('Enabled'),'switch_on').'</a>';
}
print '</td></tr>'."\n";
}
}

View File

@ -39,6 +39,8 @@ $action = GETPOST('action','alpha');
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'setbarcodeproducton')
{
$res=dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", GETPOST('value'), 'chaine', 0, '', $conf->entity);
@ -72,33 +74,7 @@ else if ($action == 'update')
else if ($action == 'updateengine')
{
// TODO Update engines.
}
// define constants for models generator that need parameters
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
}
}
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
if ($action && $action != 'setcoder' && $action != 'setModuleOptions')
@ -276,7 +252,7 @@ if ($resql)
print '<td align="center">';
print $formbarcode->setBarcodeEncoder($obj->coder,$barcodelist,$obj->rowid,'form'.$i);
print "</td></tr>\n";
$i++;
}
}
@ -312,7 +288,7 @@ print '</tr>';
// Chemin du binaire genbarcode sous linux
if (! isset($_SERVER['WINDIR']))
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("GenbarcodeLocation").'</td>';
print '<td width="60" align="center">';
@ -328,7 +304,7 @@ if (! isset($_SERVER['WINDIR']))
// Module products
if (! empty($conf->product->enabled))
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>';
print '<td width="60" align="right">';
@ -339,7 +315,7 @@ if (! empty($conf->product->enabled))
// Module thirdparty
if (! empty($conf->societe->enabled))
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("SetDefaultBarcodeTypeThirdParties").'</td>';
print '<td width="60" align="right">';

View File

@ -77,7 +77,7 @@ if ($action == 'setmod')
if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT')
{
$freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT'); // No alpha here, we want exact string
$freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT','none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);

View File

@ -54,6 +54,8 @@ $type = 'order';
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconstorder=GETPOST('maskconstorder','alpha');
@ -118,35 +120,6 @@ else if ($action == 'specimen')
}
}
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
// Activate a model
else if ($action == 'set')
{
@ -182,7 +155,7 @@ else if ($action == 'setdoc')
else if ($action == 'setmod')
{
// TODO Check if numbering module chosen can be activated
// TODO Check if numbering module chosen can be activated
// by calling method canBeActivated
dolibarr_set_const($db, "COMMANDE_ADDON",$value,'chaine',0,'',$conf->entity);
@ -207,7 +180,7 @@ else if ($action == 'set_COMMANDE_DRAFT_WATERMARK')
else if ($action == 'set_ORDER_FREE_TEXT')
{
$freetext = GETPOST("ORDER_FREE_TEXT"); // No alpha here, we want exact string
$freetext = GETPOST("ORDER_FREE_TEXT",'none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "ORDER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
@ -331,7 +304,7 @@ foreach ($dirmodels as $reldir)
if ($module->isEnabled())
{
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
@ -609,7 +582,7 @@ print "</td></tr>\n";
print '</form>';
// Shippable Icon in List
/* Kept as hidden feature for the moment, result seems bugged.
/* Kept as hidden feature for the moment, result seems bugged.
Whet is definition of "shippable" according to all different STOCK_CALCULATE_... options ?
print '<tr class="oddeven">';
@ -631,7 +604,7 @@ print '</tr>';
// Ask for payment bank during order
if ($conf->banque->enabled)
{
print '<tr class="oddeven"><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td>&nbsp</td><td align="center">';
if (! empty($conf->use_javascript_ajax))
@ -653,7 +626,7 @@ if ($conf->banque->enabled)
}
else
{
print '<tr class="oddeven"><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td>&nbsp;</td><td align="center">'.$langs->trans('NotAvailable').'</td></tr>';
}
@ -661,7 +634,7 @@ else
// Ask for warehouse during order
if ($conf->stock->enabled)
{
print '<tr class="oddeven"><td>';
print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td>&nbsp</td><td align="center">';
if (! empty($conf->use_javascript_ajax))
@ -683,7 +656,7 @@ if ($conf->stock->enabled)
}
else
{
print '<tr class="oddeven"><td>';
print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td>&nbsp;</td><td align="center">'.$langs->trans('NotAvailable').'</td></tr>';
}

View File

@ -50,6 +50,8 @@ if (empty($conf->global->CONTRACT_ADDON))
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconst = GETPOST('maskconstcontract','alpha');
@ -113,35 +115,6 @@ else if ($action == 'specimen') // For contract
}
}
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
// Activate a model
else if ($action == 'set')
{
@ -185,7 +158,7 @@ else if ($action == 'setmod')
else if ($action == 'set_other')
{
$freetext= GETPOST('CONTRACT_FREE_TEXT'); // No alpha here, we want exact string
$freetext= GETPOST('CONTRACT_FREE_TEXT','none'); // No alpha here, we want exact string
$res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
$draft= GETPOST('CONTRACT_DRAFT_WATERMARK','alpha');
@ -265,7 +238,7 @@ foreach ($dirmodels as $reldir)
if ($module->isEnabled())
{
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
@ -501,7 +474,7 @@ print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
print "</tr>\n";
$var=true;
$substitutionarray=pdf_getSubstitutionArray($langs);
$substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'));
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';

View File

@ -43,7 +43,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -120,11 +120,11 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
$error++;
}
}
if (! $error)
{
$db->begin();
if ($action == 'add' || (GETPOST('add') && $action != 'update'))
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")";
@ -134,7 +134,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
$sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'";
$sql.= " WHERE rowid = ".$id;
}
$result = $db->query($sql);
if ($result > 0)
{
@ -223,7 +223,7 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
$head=defaultvalues_prepare_head();
dol_fiche_head($head, $mode, '', -1, '');
if ($mode == 'sortorder')
@ -249,11 +249,11 @@ $texturl=$form->textwithpicto($langs->trans("Url"), $texthelp);
print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'page,param','',$param,'',$sortfield,$sortorder);
// Field
$texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField");
if ($mode != 'sortorder')
if ($mode != 'sortorder')
{
$textkey=$form->textwithpicto($langs->trans("Field"), $texthelp);
}
else
else
{
$texthelp='field or alias.field';
$textkey=$form->textwithpicto($langs->trans("Field"), $texthelp);
@ -264,22 +264,14 @@ if ($mode != 'focus')
{
if ($mode != 'sortorder')
{
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); // Must match list into GETPOST
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
// See list into GETPOST
$texthelp.='__USERID__<br>';
$texthelp.='__SUPERVISORID__<br>';
$texthelp.='__MYCOUNTRYID__<br>';
$texthelp.='__DAY__<br>';
$texthelp.='__MONTH__<br>';
$texthelp.='__YEAR__<br>';
$texthelp.='__PREVIOUS_DAY__<br>';
$texthelp.='__PREVIOUS_MONTH__<br>';
$texthelp.='__PREVIOUS_YEAR__<br>';
$texthelp.='__NEXT_DAY__<br>';
$texthelp.='__NEXT_MONTH__<br>';
$texthelp.='__NEXT_YEAR__<br>';
if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__<br>';
$textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, '');
foreach($substitutionarray as $key => $val)
{
$texthelp.=$key.'<br>';
}
$textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); // No tooltip on click, this also triggers the sort click
}
else
{
@ -351,18 +343,18 @@ if ($result)
while ($i < $num)
{
$obj = $db->fetch_object($result);
print "\n";
print '<tr class="oddeven">';
// Page
print '<td>';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->page;
else print '<input type="text" name="urlpage" value="'.dol_escape_htmltag($obj->page).'">';
print '</td>'."\n";
// Field
print '<td>';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param;
@ -382,7 +374,7 @@ if ($result)
else print '<input type="text" name="value" value="'.dol_escape_htmltag($obj->value).'">';
print '</td>';
}
// Actions
print '<td align="center">';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid)
@ -400,7 +392,7 @@ if ($result)
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
}
print '</td>';
print "</tr>\n";
print "\n";
$i++;

View File

@ -57,6 +57,9 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconst=GETPOST('maskconstexpedition','alpha');
@ -75,14 +78,14 @@ if ($action == 'updateMask')
else if ($action == 'set_param')
{
$freetext=GETPOST('SHIPPING_FREE_TEXT'); // No alpha here, we want exact string
$freetext=GETPOST('SHIPPING_FREE_TEXT','none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
if ($res <= 0)
{
$error++;
setEventMessages($langs->trans("Error"), null, 'errors');
}
$draft=GETPOST('SHIPPING_DRAFT_WATERMARK','alpha');
$res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
if ($res <= 0)
@ -142,35 +145,6 @@ else if ($action == 'specimen')
}
}
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
else if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
// Activate a model
else if ($action == 'set')
{

View File

@ -51,6 +51,9 @@ $type='expensereport';
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconst=GETPOST('maskconst','alpha');
@ -77,7 +80,7 @@ else if ($action == 'specimen') // For fiche inter
$inter->initAsSpecimen();
$inter->status = 0; // Force statut draft to show watermark
$inter->fk_statut = 0; // Force statut draft to show watermark
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
@ -116,35 +119,6 @@ else if ($action == 'specimen') // For fiche inter
}
}
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
// Activate a model
else if ($action == 'set')
{
@ -193,13 +167,13 @@ else if ($action == 'setmod')
else if ($action == 'setoptions')
{
$db->begin();
$freetext= GETPOST('EXPENSEREPORT_FREE_TEXT'); // No alpha here, we want exact string
$freetext= GETPOST('EXPENSEREPORT_FREE_TEXT','none'); // No alpha here, we want exact string
$res1 = dolibarr_set_const($db, "EXPENSEREPORT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
$draft= GETPOST('EXPENSEREPORT_DRAFT_WATERMARK','alpha');
$res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
if (! $res1 > 0 || ! $res2 > 0) $error++;
if (! $error)
@ -276,7 +250,7 @@ foreach ($dirmodels as $reldir)
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
@ -399,7 +373,7 @@ foreach ($dirmodels as $reldir)
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);

View File

@ -51,6 +51,8 @@ $type='invoice';
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconstinvoice=GETPOST('maskconstinvoice','alpha');
@ -123,31 +125,6 @@ if ($action == 'specimen')
}
}
// define constants for models generator that need parameters
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
}
}
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
// Activate a model
else if ($action == 'set')
{
@ -229,7 +206,7 @@ if ($action == 'set_FACTURE_DRAFT_WATERMARK')
if ($action == 'set_INVOICE_FREE_TEXT')
{
$freetext = GETPOST('INVOICE_FREE_TEXT'); // No alpha here, we want exact string
$freetext = GETPOST('INVOICE_FREE_TEXT','none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "INVOICE_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
@ -693,7 +670,7 @@ if ($resql)
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"';

View File

@ -51,6 +51,9 @@ $type='ficheinter';
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconst=GETPOST('maskconst','alpha');
@ -114,35 +117,6 @@ else if ($action == 'specimen') // For fiche inter
}
}
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
// Activate a model
else if ($action == 'set')
{
@ -186,7 +160,7 @@ else if ($action == 'setmod')
else if ($action == 'set_FICHINTER_FREE_TEXT')
{
$freetext= GETPOST('FICHINTER_FREE_TEXT'); // No alpha here, we want exact string
$freetext= GETPOST('FICHINTER_FREE_TEXT','none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
@ -310,7 +284,7 @@ foreach ($dirmodels as $reldir)
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
@ -432,7 +406,7 @@ foreach ($dirmodels as $reldir)
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);

View File

@ -90,11 +90,11 @@ if ($action == 'update')
$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE');
if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity);
else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'),'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val,'chaine',0,'',$conf->entity);
@ -109,25 +109,25 @@ if ($action == 'update')
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val,'chaine',0,'',$conf->entity);
if (GETPOST('THEME_ELDY_USE_HOVER') == '') dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", '0', 'chaine', 0, '', $conf->entity); // If empty, we set to '0' ('000000' is for black)
else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $_POST["THEME_ELDY_USE_HOVER"], 'chaine', 0, '', $conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val,'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
@ -137,7 +137,7 @@ if ($action == 'update')
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", $_POST["MAIN_DEFAULT_WORKING_HOURS"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", $_POST["MAIN_HELPCENTER_DISABLELINK"],'chaine',0,'',0); // Param for all entities
dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr($_POST["main_home"]),'chaine',0,'',$conf->entity);
@ -150,7 +150,7 @@ if ($action == 'update')
if (preg_match('/([^\\/:]+)$/i',$_FILES[$varforimage]["name"],$reg))
{
$original_file=$reg[1];
$isimage=image_format_supported($original_file);
if ($isimage >= 0)
{
@ -185,9 +185,9 @@ if ($action == 'update')
}
}
}
$_SESSION["mainmenu"]=""; // Le gestionnaire de menu a pu changer
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
@ -222,7 +222,7 @@ if ($action == 'edit') // Edit
print '<input type="hidden" name="action" value="update">';
clearstatcache();
print '<br>';
print '<table summary="edit" class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Language").'</td><td></td>';
@ -264,7 +264,7 @@ if ($action == 'edit') // Edit
print '<tr><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '"></td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// show input border
/*
print '<tr><td>'.$langs->trans("showInputBorder").'</td><td>';
@ -273,7 +273,7 @@ if ($action == 'edit') // Edit
print '<td width="20">&nbsp;</td>';
print '</tr>';
*/
// Disable javascript and ajax
print '<tr><td>'.$langs->trans("DisableJavascript").'</td><td>';
print $form->selectyesno('main_disable_javascript',isset($conf->global->MAIN_DISABLE_JAVASCRIPT)?$conf->global->MAIN_DISABLE_JAVASCRIPT:0,1);
@ -323,17 +323,17 @@ if ($action == 'edit') // Edit
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Hide version link
/*
print '<tr><td class="titlefield">'.$langs->trans("HideVersionLink").'</td><td>';
print $form->selectyesno('MAIN_HIDE_VERSION',$conf->global->MAIN_HIDE_VERSION,1);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
*/
// Show bugtrack link
print '<tr><td class="titlefield">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
print $form->selectyesno('MAIN_BUGTRACK_ENABLELINK',$conf->global->MAIN_BUGTRACK_ENABLELINK,1);
@ -349,7 +349,19 @@ if ($action == 'edit') // Edit
print '</tr>';
// Message of the day on home page
print '<tr><td class="titlefield">'.$langs->trans("MessageOfDay").'</td><td colspan="2">';
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object'));
complete_substitutions_array($substitutionarray, $langs);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey');
print '<tr><td class="titlefield">';
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach($substitutionarray as $key => $val)
{
$texthelp.=$key.'<br>';
}
print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, '');
print '</td><td colspan="2">';
$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
$doleditor->Create();
@ -359,26 +371,36 @@ if ($action == 'edit') // Edit
print '</table>'."\n";
print '<br>';
// Other
print '<table summary="edit" class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("LoginPage").'</td><td></td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Message on login page
print '<tr><td>'.$langs->trans("MessageLogin").'</td><td colspan="2">';
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','user'));
complete_substitutions_array($substitutionarray, $langs);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey');
print '<tr><td>';
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach($substitutionarray as $key => $val)
{
$texthelp.=$key.'<br>';
}
print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, '');
print '</td><td colspan="2">';
$doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME)?$conf->global->MAIN_HOME:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
$doleditor->Create();
print '</td></tr>'."\n";
// Hide helpcenter link on login page
print '<tr><td class="titlefield">'.$langs->trans("DisableLinkToHelpCenter").'</td><td>';
print $form->selectyesno('MAIN_HELPCENTER_DISABLELINK',isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0,1);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Background
print '<tr><td><label for="imagebackground">'.$langs->trans("BackgroundImageLogin").' (png,jpg)</label></td><td colspan="2">';
print '<div class="centpercent inline-block">';
@ -394,9 +416,9 @@ if ($action == 'edit') // Edit
}
print '</div>';
print '</td></tr>';
print '</table>'."\n";
print '<br><div class="center">';
print '<input class="button" type="submit" name="submit" value="'.$langs->trans("Save").'">';
@ -421,7 +443,7 @@ else // Show
if ($user->admin && $conf->global->MAIN_LANG_DEFAULT!='auto') print info_admin($langs->trans("SubmitTranslation".($conf->global->MAIN_LANG_DEFAULT=='en_US'?'ENUS':''),$conf->global->MAIN_LANG_DEFAULT),1);
print '</td>';
print "</tr>";
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>' . yn($conf->global->MAIN_MULTILANGS) . '</td>';
print '<td width="20">&nbsp;</td>';
print "</tr>";
@ -441,7 +463,7 @@ else // Show
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMaxSizeList").'</td><td>' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '</td>';
print '<td width="20">&nbsp;</td>';
print "</tr>";
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td>' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '</td>';
print '<td width="20">&nbsp;</td>';
print "</tr>";
@ -452,7 +474,7 @@ else // Show
print '<td width="20">&nbsp;</td>';
print "</tr>";
*/
// Disable javascript/ajax
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableJavascript").'</td><td>';
print yn($conf->global->MAIN_DISABLE_JAVASCRIPT)."</td>";
@ -506,7 +528,7 @@ else // Show
print '<td width="20">&nbsp;</td>';
print '</tr>';
*/
// Show bugtrack link
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
print yn($conf->global->MAIN_BUGTRACK_ENABLELINK)."</td>";
@ -527,7 +549,7 @@ else // Show
print '</table>'."\n";
print '<br>';
// Login page
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("LoginPage").'</td><td></td><td>&nbsp;</td></tr>';
@ -537,7 +559,7 @@ else // Show
if (isset($conf->global->MAIN_HOME)) print dol_htmlcleanlastbr($conf->global->MAIN_HOME);
else print '&nbsp;';
print '</td></tr>'."\n";
// Link to help center
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableLinkToHelpCenter").'</td><td colspan="2">';
print yn((isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0),1);
@ -557,9 +579,9 @@ else // Show
}
print '</div>';
print '</td></tr>';
print '</table>'."\n";
print '<div class="tabsAction tabsActionNoBottom">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
print '</div>';

View File

@ -47,10 +47,13 @@ $label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha');
$type='delivery';
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconstdelivery=GETPOST('maskconstdelivery','alpha');
@ -71,7 +74,7 @@ if ($action == 'updateMask')
if ($action == 'set_DELIVERY_FREE_TEXT')
{
$free=GETPOST('DELIVERY_FREE_TEXT'); // No alpha here, we want exact string
$free=GETPOST('DELIVERY_FREE_TEXT','none'); // No alpha here, we want exact string
$res=dolibarr_set_const($db, "DELIVERY_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
@ -131,35 +134,6 @@ if ($action == 'specimen')
}
}
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
if ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir);
@ -259,7 +233,7 @@ foreach ($dirmodels as $reldir)
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
@ -386,7 +360,7 @@ foreach ($dirmodels as $reldir)
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);

View File

@ -59,8 +59,8 @@ $acts[1] = "disable";
$actl[0] = img_picto($langs->trans("Disabled"),'switch_off');
$actl[1] = img_picto($langs->trans("Activated"),'switch_on');
$listoffset=GETPOST('listoffset');
$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000;
$listoffset=GETPOST('listoffset','alpha');
$listlimit=GETPOST('listlimit','alpha')>0?GETPOST('listlimit','alpha'):1000;
$active = 1;
$sortfield = GETPOST("sortfield",'alpha');
@ -119,14 +119,14 @@ $formmail=new FormMail($db);
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{
$tmp=FormMail::getAvailableSubstitKey('formemail');
$tmp['__(AnyTransKey)__']='__(AnyTransKey)__';
$tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__';
$helpsubstit = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
}
else
{
$tmp=FormMail::getAvailableSubstitKey('formemailwithlines');
$tmp['__(AnyTransKey)__']='__(AnyTransKey)__';
$tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__';
$helpsubstit = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
$tmp=FormMail::getAvailableSubstitKey('formemailforlines');
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
@ -175,7 +175,7 @@ $id = 25;
if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x'))
{
//$search_country_id = '';
//$search_country_id = '';
}
// Actions add or modify an entry into a dictionary
@ -479,12 +479,12 @@ if ($action != 'edit')
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
if ($fieldlist[$field]=='content') { $valuetoshow=''; }
if ($fieldlist[$field]=='content_lines') { $valuetoshow=''; }
if ($valuetoshow != '')
{
print '<td align="'.$align.'">';
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1,$valuetoshow).'</a>';
else if (! empty($tabhelp[$id][$value]))
else if (! empty($tabhelp[$id][$value]))
{
if (in_array($value, array('topic'))) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, $value); // Tooltip on click
else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
@ -494,15 +494,15 @@ if ($action != 'edit')
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
}
print '<td colspan="3">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '</td>';
print '</tr>';
// Line to enter new values
print "<tr ".$bcnd[$var].">";
$obj = new stdClass();
// If data was already input, we define them in obj to populate input fields.
if (GETPOST('actionadd'))
@ -513,12 +513,12 @@ if ($action != 'edit')
$obj->$val=GETPOST($val);
}
}
$tmpaction = 'create';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
if (empty($reshook))
{
if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit')
@ -530,11 +530,11 @@ if ($action != 'edit')
fieldList($fieldlist,$obj,$tabname[$id],'add');
}
}
print '<td align="right" colspan="3">';
print '</td>';
print "</tr>";
$fieldsforcontent = array('content');
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{
@ -545,7 +545,7 @@ if ($action != 'edit')
print '<tr class="impair nodrag nodrop nohover"><td colspan="5">';
if ($tmpfieldlist == 'content') print '<strong>'.$form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong><br>';
if ($tmpfieldlist == 'content_lines') print '<strong>'.$form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong><br>';
if ($context != 'hide')
{
//print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea>';
@ -556,7 +556,7 @@ if ($action != 'edit')
}
else print '&nbsp;';
print '</td>';
if ($tmpfieldlist == 'content')
if ($tmpfieldlist == 'content')
{
print '<td align="center" colspan="3" rowspan="'.(count($fieldsforcontent)).'">';
if ($action != 'edit')
@ -568,12 +568,12 @@ if ($action != 'edit')
//else print '<td></td>';
print '</tr>';
}
$colspan=count($fieldlist)+1;
print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
}
}
// List of available record in database
@ -590,7 +590,7 @@ if ($resql)
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha');
// There is several pages
if ($num > $listlimit)
{
@ -628,7 +628,7 @@ if ($resql)
// Affiche nom du champ
if ($showfield)
{
if (! empty($tabhelp[$id][$value]))
if (! empty($tabhelp[$id][$value]))
{
if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
@ -653,7 +653,7 @@ if ($resql)
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '</tr>';
if ($num)
{
// Lines with values
@ -680,7 +680,7 @@ if ($resql)
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '</td>';
$fieldsforcontent = array('content');
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{
@ -691,11 +691,11 @@ if ($resql)
$showfield = 1;
$align = "left";
$valuetoshow = $obj->{$tmpfieldlist};
$class = 'tddict';
// Show value for field
if ($showfield) {
print '</tr><tr class="oddeven" nohover tr-'.$tmpfieldlist.'-'.$rowid.' "><td colspan="5">'; // To create an artificial CR for the current tr we are on
$okforextended = true;
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
@ -704,9 +704,9 @@ if ($resql)
print $doleditor->Create(1);
print '</td>';
print '<td></td><td></td><td></td>';
}
}
}
}
else
{
@ -778,16 +778,16 @@ if ($resql)
{
$fieldsforcontent = array('content', 'content_lines');
}
foreach ($fieldsforcontent as $tmpfieldlist)
foreach ($fieldsforcontent as $tmpfieldlist)
{
$showfield = 1;
$align = "left";
$valuetoshow = $obj->{$tmpfieldlist};
$class = 'tddict';
// Show value for field
if ($showfield) {
print '</tr><tr class="oddeven" nohover tr-'.$tmpfieldlist.'-'.$i.' "><td colspan="5">'; // To create an artificial CR for the current tr we are on
$okforextended = true;
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
@ -796,13 +796,13 @@ if ($resql)
print $doleditor->Create(1);
print '</td>';
print '<td></td><td></td><td></td>';
}
}*/
}
print "</tr>\n";
$i++;
}
}

View File

@ -71,7 +71,7 @@ if ($action == 'setmod')
if ($action == 'setparams')
{
$freetext = GETPOST('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS'); // No alpha here, we want exact string
$freetext = GETPOST('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS','none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS",$freetext,'chaine',0,'',$conf->entity);
@ -81,24 +81,11 @@ if ($action == 'setparams')
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
/*
$freetext = GETPOST('INVOICE_AUTO_FILLJS'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "INVOICE_AUTO_FILLJS",$freetext,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if ($error)
{
setEventMessages($langs->trans("Error"), null, 'errors');
}*/
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
}

View File

@ -49,6 +49,9 @@ $type='propal';
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
$error=0;
if ($action == 'updateMask')
{
@ -132,7 +135,7 @@ if ($action == 'set_PROPALE_DRAFT_WATERMARK')
if ($action == 'set_PROPOSAL_FREE_TEXT')
{
$freetext = GETPOST('PROPOSAL_FREE_TEXT'); // No alpha here, we want exact string
$freetext = GETPOST('PROPOSAL_FREE_TEXT','none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "PROPOSAL_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
@ -180,35 +183,6 @@ if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL')
}
}
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
// Activate a model
if ($action == 'set')
{
@ -310,7 +284,7 @@ foreach ($dirmodels as $reldir)
if ($module->isEnabled())
{
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
@ -614,7 +588,7 @@ print '</form>';
/* Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation.
if ($conf->banque->enabled)
{
print '<tr class="oddeven"><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL").'</td><td>&nbsp</td><td align="right">';
if (! empty($conf->use_javascript_ajax))
@ -636,7 +610,7 @@ if ($conf->banque->enabled)
}
else
{
print '<tr class="oddeven"><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL").'</td><td>&nbsp;</td><td align="center">'.$langs->trans('NotAvailable').'</td></tr>';
}

View File

@ -172,7 +172,7 @@ if ($action == 'addcat')
if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT')
{
$freetext = GETPOST('SUPPLIER_INVOICE_FREE_TEXT'); // No alpha here, we want exact string
$freetext = GETPOST('SUPPLIER_INVOICE_FREE_TEXT','none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
@ -251,7 +251,7 @@ foreach ($dirmodels as $reldir)
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
@ -370,7 +370,7 @@ foreach ($dirmodels as $reldir)
{
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
@ -378,7 +378,7 @@ foreach ($dirmodels as $reldir)
require_once $dir.'/'.$file;
$module = new $classname($db, new FactureFournisseur($db));
print "<tr class=\"oddeven\">\n";
print "<td>";
print (empty($module->name)?$name:$module->name);

View File

@ -169,7 +169,7 @@ else if ($action == 'addcat')
else if ($action == 'set_SUPPLIER_ORDER_OTHER')
{
$freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT'); // No alpha here, we want exact string
$freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT','none'); // No alpha here, we want exact string
$doubleapproval = GETPOST('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED','alpha');
$doubleapproval = price2num($doubleapproval );
@ -280,7 +280,7 @@ foreach ($dirmodels as $reldir)
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
@ -402,7 +402,7 @@ foreach ($dirmodels as $reldir)
require_once $dir.'/'.$file;
$module = new $classname($db, new CommandeFournisseur($db));
print "<tr class=\"oddeven\">\n";
print "<td>";
print (empty($module->name)?$name:$module->name);
@ -502,14 +502,14 @@ $var=false;
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";
//}
// Ask for payment bank during supplier order
/* Kept as hidden for the moment
if ($conf->banque->enabled)
{
print '<tr class="oddeven"><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").'</td><td>&nbsp</td><td align="center">';
if (! empty($conf->use_javascript_ajax))
@ -531,7 +531,7 @@ if ($conf->banque->enabled)
}
else
{
print '<tr class="oddeven"><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").'</td><td>&nbsp;</td><td align="center">'.$langs->trans('NotAvailable').'</td></tr>';
}

View File

@ -47,6 +47,8 @@ $type='supplier_payment';
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconstsupplierpayment=GETPOST('maskconstsupplierpayment','alpha');
@ -68,31 +70,6 @@ if ($action == 'updateMask')
dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity);
}
// define constants for models generator that need parameters
else if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
}
}
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
// Activate a model
else if ($action == 'set')
{
@ -195,7 +172,7 @@ dol_fiche_head($head, 'supplierpayment', $langs->trans("Suppliers"), -1, 'compan
*/
if (empty($conf->global->SUPPLIER_PAYMENT_ADDON)) $conf->global->SUPPLIER_PAYMENT_ADDON = 'mod_supplier_payment_bronan';
print load_fiche_titre($langs->trans("PaymentsNumberingModule"), '', '');
// Load array def with activated templates
@ -265,7 +242,7 @@ foreach ($dirmodels as $reldir)
require_once $dir.$filebis;
$module = new $classname($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
@ -375,7 +352,7 @@ foreach ($dirmodels as $reldir)
{
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
@ -383,7 +360,7 @@ foreach ($dirmodels as $reldir)
require_once $dir.'/'.$file;
$module = new $classname($db, new PaiementFourn($db));
print "<tr class=\"oddeven\">\n";
print "<td>";
print (empty($module->name)?$name:$module->name);

View File

@ -41,10 +41,15 @@ $label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha');
$type='supplier_proposal';
$error=0;
/*
* Actions
*/
$error=0;
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconstsupplier_proposal=GETPOST('maskconstsupplier_proposal','alpha');
@ -127,7 +132,7 @@ if ($action == 'set_SUPPLIER_PROPOSAL_DRAFT_WATERMARK')
if ($action == 'set_SUPPLIER_PROPOSAL_FREE_TEXT')
{
$freetext = GETPOST('SUPPLIER_PROPOSAL_FREE_TEXT'); // No alpha here, we want exact string
$freetext = GETPOST('SUPPLIER_PROPOSAL_FREE_TEXT','none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "SUPPLIER_PROPOSAL_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
@ -159,35 +164,6 @@ if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL')
}
}
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
// Activate a model
if ($action == 'set')
{
@ -289,7 +265,7 @@ foreach ($dirmodels as $reldir)
if ($module->isEnabled())
{
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
@ -567,7 +543,7 @@ print '</form>';
if ($conf->banque->enabled)
{
print '<tr class="oddeven"><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").'</td><td>&nbsp</td><td align="right">';
if (! empty($conf->use_javascript_ajax))
@ -589,7 +565,7 @@ if ($conf->banque->enabled)
}
else
{
print '<tr class="oddeven"><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").'</td><td>&nbsp;</td><td align="center">'.$langs->trans('NotAvailable').'</td></tr>';
}

View File

@ -49,7 +49,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -47,37 +47,9 @@ $type='user';
* Action
*/
// Activate a model
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
elseif ($action == 'set_default')
if ($action == 'set_default')
{
$ret = addDocumentModel($value, $type, $label, $scandir);
$res = true;

View File

@ -47,37 +47,9 @@ $type='group';
* Action
*/
// Activate a model
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
elseif ($action == 'set_default')
if ($action == 'set_default')
{
$ret = addDocumentModel($value, $type, $label, $scandir);
$res = true;

View File

@ -43,7 +43,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -1208,7 +1208,7 @@ if ($id > 0)
$out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewCal").'</a>';
$out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>';
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>';
$out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>';
$linkback.=$out;

View File

@ -67,7 +67,7 @@ if ($id > 0)
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -58,7 +58,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page","int");
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$offset = $limit * $page;
if (! $sortorder) $sortorder="ASC";

View File

@ -54,7 +54,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page","int");
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$offset = $limit * $page;
if (! $sortorder) $sortorder="ASC";

View File

@ -54,7 +54,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page","int");
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$offset = $limit * $page;
if (! $sortorder) $sortorder="ASC";

View File

@ -66,7 +66,7 @@ $mode = GETPOST("mode");
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -43,7 +43,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -34,7 +34,7 @@ $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -54,7 +54,7 @@ $result = restrictedArea($user, 'propal', $id);
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -88,7 +88,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -49,7 +49,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -53,7 +53,7 @@ $result=restrictedArea($user,'commande',$id,'');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -86,7 +86,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -103,7 +103,7 @@ $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
$pageplusone = GETPOST("pageplusone",'int');
if ($pageplusone) $page = $pageplusone - 1;
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -59,7 +59,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -77,7 +77,7 @@ $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
$pageplusone = GETPOST("pageplusone",'int');
if ($pageplusone) $page = $pageplusone - 1;
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -46,7 +46,7 @@ $result = restrictedArea($user, 'salaries', $id, '');
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -44,7 +44,7 @@ $search_account = GETPOST('search_account','int');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -52,7 +52,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -47,7 +47,7 @@ $mode=GETPOST("mode");
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -53,7 +53,7 @@ $result = restrictedArea($user, 'deplacement', $id, '');
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -39,7 +39,7 @@ $result = restrictedArea($user, 'deplacement','','');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -47,7 +47,7 @@ $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -54,7 +54,7 @@ class Facture extends CommonInvoice
public $fk_element = 'fk_facture';
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $picto='bill';
/**
* {@inheritdoc}
*/
@ -243,7 +243,7 @@ class Facture extends CommonInvoice
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
$this->brouillon = 1;
if (empty($this->entity)) $this->entity = $conf->entity;
// Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate)
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
@ -280,7 +280,7 @@ class Facture extends CommonInvoice
if ($this->fac_rec > 0)
{
$this->fk_fac_rec_source = $this->fac_rec;
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
$_facrec = new FactureRec($this->db);
$result=$_facrec->fetch($this->fac_rec);
@ -288,7 +288,7 @@ class Facture extends CommonInvoice
$this->socid = $_facrec->socid; // Invoice created on same thirdparty than template
$this->entity = $_facrec->entity; // Invoice created in same entity than template
// Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI
$this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project;
$this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public;
@ -301,7 +301,7 @@ class Facture extends CommonInvoice
// Set here to have this defined for substitution into notes, should be recalculated after adding lines to get same result
$this->total_ht = $_facrec->total_ht;
$this->total_ttc = $_facrec->total_ttc;
// Fields always coming from template
$this->remise_absolue = $_facrec->remise_absolue;
$this->remise_percent = $_facrec->remise_percent;
@ -360,9 +360,10 @@ class Facture extends CommonInvoice
'__INVOICE_YEAR__' => dol_print_date($this->date, '%Y'),
'__INVOICE_NEXT_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'),
);
$substitutionisok=true;
complete_substitutions_array($substitutionarray, $outputlangs);
$this->note_public=make_substitutions($this->note_public,$substitutionarray);
$this->note_private=make_substitutions($this->note_private,$substitutionarray);
}
@ -472,7 +473,7 @@ class Facture extends CommonInvoice
}
}
}
if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object
{
$originforcontact = $this->origin;
@ -483,7 +484,7 @@ class Facture extends CommonInvoice
$exp = new Expedition($this->db);
$exp->fetch($this->origin_id);
$exp->fetchObjectLinked();
if (count($exp->linkedObjectsIds['commande']) > 0)
if (count($exp->linkedObjectsIds['commande']) > 0)
{
foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
{
@ -493,10 +494,10 @@ class Facture extends CommonInvoice
}
}
}
$sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
$sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
$resqlcontact = $this->db->query($sqlcontact);
if ($resqlcontact)
{
@ -555,11 +556,11 @@ class Facture extends CommonInvoice
foreach ($this->lines as $i => $val)
{
$line = $this->lines[$i];
// Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array
//if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object.
if (! is_object($line)) $line = (object) $line;
if (($line->info_bits & 0x01) == 0) // We keep only lines with first bit = 0
{
// Reset fk_parent_line for no child products and special product
@ -1060,7 +1061,7 @@ class Facture extends CommonInvoice
if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note
if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice
$label='';
if ($user->rights->facture->lire) {
$label = '<u>' . $langs->trans("ShowInvoice") . '</u>';
if (! empty($this->ref))
@ -1079,7 +1080,7 @@ class Facture extends CommonInvoice
if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref;
if ($moretitle) $label.=' - '.$moretitle;
}
$linkclose='';
if (empty($notooltip) && $user->rights->facture->lire)
{
@ -1113,7 +1114,7 @@ class Facture extends CommonInvoice
$result.='</span>';
}
}
return $result;
}
@ -1321,7 +1322,7 @@ class Facture extends CommonInvoice
$line->qty = $objp->qty;
$line->subprice = $objp->subprice;
$line->vat_src_code = $objp->vat_src_code;
$line->vat_src_code = $objp->vat_src_code;
$line->tva_tx = $objp->tva_tx;
$line->localtax1_tx = $objp->localtax1_tx;
$line->localtax2_tx = $objp->localtax2_tx;
@ -1574,7 +1575,7 @@ class Facture extends CommonInvoice
$arraytmp=$formmargin->getMarginInfosArray($srcinvoice, false);
$facligne->pa_ht = $arraytmp['pa_total'];
}
$facligne->total_ht = -$remise->amount_ht;
$facligne->total_tva = -$remise->amount_tva;
$facligne->total_ttc = -$remise->amount_ttc;
@ -1628,7 +1629,7 @@ class Facture extends CommonInvoice
function set_ref_client($ref_client, $notrigger=0)
{
global $user;
$error=0;
$this->db->begin();
@ -2457,7 +2458,7 @@ class Facture extends CommonInvoice
if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100;
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
// Clean vat code
$vat_src_code='';
if (preg_match('/\((.*)\)/', $txtva, $reg))
@ -2465,7 +2466,7 @@ class Facture extends CommonInvoice
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu_ht=price2num($pu_ht);
@ -2650,7 +2651,7 @@ class Facture extends CommonInvoice
* @param double $pu_ht_devise Unit price in currency
* @return int < 0 if KO, > 0 if OK
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null, $pu_ht_devise = 0)
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=100, $fk_unit = null, $pu_ht_devise = 0)
{
global $conf,$user;
// Deprecation warning
@ -2770,14 +2771,14 @@ class Facture extends CommonInvoice
$this->line->label = $label;
$this->line->desc = $desc;
$this->line->qty = ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
$this->line->vat_src_code = $vat_src_code;
$this->line->tva_tx = $txtva;
$this->line->localtax1_tx = $txlocaltax1;
$this->line->localtax2_tx = $txlocaltax2;
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->remise_percent = $remise_percent;
$this->line->subprice = ($this->type==2?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise
$this->line->date_start = $date_start;
@ -2896,7 +2897,7 @@ class Facture extends CommonInvoice
function deleteline($rowid)
{
global $user;
dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG);
if (! $this->brouillon)
@ -2922,13 +2923,13 @@ class Facture extends CommonInvoice
}
$line=new FactureLigne($this->db);
$line->context = $this->context;
// For triggers
$result = $line->fetch($rowid);
if (! ($result > 0)) dol_print_error($db, $line->error, $line->errors);
if ($line->delete($user) > 0)
{
$result=$this->update_price(1);
@ -4292,7 +4293,7 @@ class FactureLigne extends CommonInvoiceLine
$this->fk_unit = $objp->fk_unit;
$this->fk_user_modif = $objp->fk_user_modif;
$this->fk_user_author = $objp->fk_user_author;
$this->situation_percent = $objp->situation_percent;
$this->fk_prev_id = $objp->fk_prev_id;

View File

@ -58,7 +58,7 @@ $result=restrictedArea($user,'facture',$id,'');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -76,7 +76,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
if (! $sortorder) $sortorder='DESC';
if (! $sortfield) $sortfield='f.titre';

View File

@ -102,7 +102,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
if (! $sortorder && ! empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == 1) $sortorder=$conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER;
if (! $sortorder) $sortorder='DESC';

View File

@ -42,7 +42,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -47,7 +47,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -61,7 +61,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -41,7 +41,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -52,7 +52,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -252,7 +252,7 @@ class BonPrelevement extends CommonObject
function getErrorString($error)
{
global $langs;
$errors = array();
$errors[1027] = $langs->trans("DateInvalid");
@ -813,7 +813,7 @@ class BonPrelevement extends CommonObject
dol_syslog(__METHOD__."::Read invoices error ".$this->db->error(), LOG_ERR);
}
}
if (! $error)
{
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
@ -834,7 +834,7 @@ class BonPrelevement extends CommonObject
{
$bac = new CompanyBankAccount($this->db);
$bac->fetch(0,$soc->id);
if ($bac->verif() >= 1)
//if (true)
{
@ -867,7 +867,7 @@ class BonPrelevement extends CommonObject
}
$ok=0;
// Withdraw invoices in factures_prev array
$out=count($factures_prev)." invoices will be withdrawn.";
//print $out."\n";
@ -920,7 +920,7 @@ class BonPrelevement extends CommonObject
$dir=$conf->prelevement->dir_output.'/receipts';
if (! is_dir($dir)) dol_mkdir($dir);
$this->filename = $dir.'/'.$ref.'.xml';
// Create withdraw receipt in database
@ -1028,7 +1028,7 @@ class BonPrelevement extends CommonObject
$this->emetteur_bic = $account->bic;
$this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
$this->raison_sociale = $account->proprio;
}
@ -1272,16 +1272,6 @@ class BonPrelevement extends CommonObject
* section Debiteur (sepa Debiteurs bloc lines)
*/
/*$tmp_invoices = array();
$sql = "SELECT f.facnumber as fac FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."prelevement_facture as pf, ".MAIN_DB_PREFIX."societe as soc, ".MAIN_DB_PREFIX."c_country as p, ".MAIN_DB_PREFIX."societe_rib as rib WHERE pl.fk_prelevement_bons = ".$this->id." AND pl.rowid = pf.fk_prelevement_lignes AND pf.fk_facture = f.rowid AND soc.fk_pays = p.rowid AND soc.rowid = f.fk_soc AND rib.fk_soc = f.fk_soc AND rib.default_rib = 1";
$resql=$this->db->query($sql);
if ($resql) {
while ($objfac = $this->db->fetch_object($resql)) {
$tmp_invoices[] = $objfac->fac;
}
}*/
$sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
$sql.= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
$sql.= " f.facnumber as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum";
@ -1365,35 +1355,6 @@ class BonPrelevement extends CommonObject
fputs($this->file, ' </PmtInf>'.$CrLf);
fputs($this->file, ' </CstmrDrctDbtInitn>'.$CrLf);
fputs($this->file, '</Document>'.$CrLf);
/*$sql = "SELECT pl.amount";
$sql.= " FROM";
$sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql.= " ".MAIN_DB_PREFIX."facture as f,";
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture as pf";
$sql.= " WHERE pl.fk_prelevement_bons = ".$this->id;
$sql.= " AND pl.rowid = pf.fk_prelevement_lignes";
$sql.= " AND pf.fk_facture = f.rowid";
//Lines
$i = 0;
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$this->total = $this->total + $obj->amount;
$i++;
}
}
else
{
$result = -2;
}*/
}
// Build file for Other Countries with unknow format
@ -1580,11 +1541,11 @@ class BonPrelevement extends CommonObject
$XML_DEBITOR .=' </FinInstnId>'.$CrLf;
$XML_DEBITOR .=' </DbtrAgt>'.$CrLf;
$XML_DEBITOR .=' <Dbtr>'.$CrLf;
$XML_DEBITOR .=' <Nm>'.strtoupper(dol_string_unaccent($row_nom)).'</Nm>'.$CrLf;
$XML_DEBITOR .=' <Nm>'.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).'</Nm>'.$CrLf;
$XML_DEBITOR .=' <PstlAdr>'.$CrLf;
$XML_DEBITOR .=' <Ctry>'.$row_country_code.'</Ctry>'.$CrLf;
$XML_DEBITOR .=' <AdrLine>'.dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))).'</AdrLine>'.$CrLf;
$XML_DEBITOR .=' <AdrLine>'.dol_string_unaccent($row_zip.' '.$row_town).'</AdrLine>'.$CrLf;
$XML_DEBITOR .=' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))),70,'right','UTF-8',true)).'</AdrLine>'.$CrLf;
$XML_DEBITOR .=' <AdrLine>'.dolEscapeXML(dol_string_unaccent($row_zip.' '.$row_town)).'</AdrLine>'.$CrLf;
$XML_DEBITOR .=' </PstlAdr>'.$CrLf;
$XML_DEBITOR .=' </Dbtr>'.$CrLf;
$XML_DEBITOR .=' <DbtrAcct>'.$CrLf;
@ -1679,7 +1640,7 @@ class BonPrelevement extends CommonObject
* @return string String with SEPA Sender
*/
function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n')
{
{
// SEPA INITIALISATION
global $conf;
@ -1698,12 +1659,12 @@ class BonPrelevement extends CommonObject
$this->emetteur_number_key = $account->cle_rib;
$this->emetteur_iban = $account->iban;
$this->emetteur_bic = $account->bic;
$this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
$this->raison_sociale = $account->proprio;
}
// Récupération info demandeur
$sql = "SELECT rowid, ref";
$sql.= " FROM";

View File

@ -49,7 +49,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -48,7 +48,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -44,7 +44,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -44,7 +44,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -56,7 +56,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -55,7 +55,7 @@ $result = restrictedArea($user, 'salaries', $id, '');
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -48,7 +48,7 @@ $search_account = GETPOST('search_account','int');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -46,7 +46,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -49,7 +49,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -50,7 +50,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -93,7 +93,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -46,7 +46,7 @@ class Contrat extends CommonObject
public $fk_element='fk_contrat';
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $picto='contract';
/**
* {@inheritdoc}
*/
@ -530,7 +530,7 @@ class Contrat extends CommonObject
$this->fin_validite = $this->db->jdate($result["fin_validite"]);
$this->date_cloture = $this->db->jdate($result["date_cloture"]);
$this->user_author_id = $result["fk_user_author"];
$this->commercial_signature_id = $result["fk_commercial_signature"];
@ -613,7 +613,7 @@ class Contrat extends CommonObject
$this->lines=array();
$pos = 0;
// Selectionne les lignes contrats liees a un produit
$sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref,";
$sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,";
@ -1858,7 +1858,7 @@ class Contrat extends CommonObject
$url = DOL_URL_ROOT.'/contrat/card.php?id='.$this->id;
$picto = 'contract';
$label = '';
if ($user->rights->contrat->lire) {
$label = '<u>'.$langs->trans("ShowContract").'</u>';
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
@ -1874,7 +1874,7 @@ class Contrat extends CommonObject
$label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
}
}
$linkclose='';
if (empty($notooltip) && $user->rights->contrat->lire)
{
@ -1890,7 +1890,7 @@ class Contrat extends CommonObject
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
if ($withpicto && $withpicto != 2) $result.=' ';
$result.=$linkstart.$this->ref.$linkend;
@ -2225,7 +2225,11 @@ class Contrat extends CommonObject
$line->total_ht=90;
$line->total_ttc=107.64; // 90 * 1.196
$line->total_tva=17.64;
if ($num_prods > 0)
$line->date_ouverture = dol_now() - 200000;
$line->date_ouverture_prevue = dol_now() - 500000;
$line->date_fin_validite = dol_now() + 500000;
$line->date_cloture = dol_now() - 100000;
if ($num_prods > 0)
{
$prodid = mt_rand(1, $num_prods);
$line->fk_product=$prodids[$prodid];
@ -2233,11 +2237,6 @@ class Contrat extends CommonObject
$this->lines[$xnbp]=$line;
$xnbp++;
}
$this->amount_ht = $xnbp*100;
$this->total_ht = $xnbp*100;
$this->total_tva = $xnbp*19.6;
$this->total_ttc = $xnbp*119.6;
}
/**
@ -2750,6 +2749,8 @@ class ContratLigne extends CommonObjectLine
if (empty($this->total_ht)) $this->total_ht = 0;
if (empty($this->total_tva)) $this->total_tva = 0;
if (empty($this->total_ttc)) $this->total_ttc = 0;
if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
// Check parameters
// Put here code to add control on parameters values

View File

@ -55,7 +55,7 @@ $result = restrictedArea($user, 'contrat', $id);
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -69,7 +69,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -37,7 +37,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -24,20 +24,22 @@
// $massaction must be defined
// $objectclass and $$objectlabel must be defined
// $uploaddir (example $conf->projet->dir_output . "/";)
// $parameters, $object, $action must be defined for the hook.
// $uploaddir may be defined (example to $conf->projet->dir_output."/";)
// $toselect may be defined
// Protection
if (empty($objectclass) || empty($uploaddir))
if (empty($objectclass) || empty($uploaddir))
{
dol_print_error(null, 'include of actions_massactions.inc.php is done but var $massaction or $objectclass or $uploaddir was not defined');
exit;
}
// Mass actions. Controls on number of lines checked
$maxformassaction=1000;
// Mass actions. Controls on number of lines checked.
$maxformassaction=(empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS)?1000:$conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
if (! empty($massaction) && count($toselect) < 1)
{
$error++;
@ -87,7 +89,7 @@ if (! $error && $massaction == 'confirm_presend')
}
}
//var_dump($listofobjectthirdparties);exit;
foreach ($listofobjectthirdparties as $thirdpartyid)
{
$result = $thirdparty->fetch($thirdpartyid);
@ -144,7 +146,7 @@ if (! $error && $massaction == 'confirm_presend')
{
//var_dump($object);
//var_dump($thirdpartyid.' - '.$objectid.' - '.$object->statut);
if ($objectclass == 'Facture' && $object->statut != Facture::STATUS_VALIDATED)
{
$nbignored++;
@ -157,7 +159,7 @@ if (! $error && $massaction == 'confirm_presend')
$resaction.='<div class="error">'.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction',$object->ref).'</div><br>';
continue;
}
// Read document
// TODO Use future field $object->fullpathdoc to know where is stored default file
// TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc.
@ -202,7 +204,7 @@ if (! $error && $massaction == 'confirm_presend')
dol_syslog('Failed to read file: '.$file, LOG_WARNING);
continue;
}
//var_dump($listofqualifiedref);
}
@ -252,9 +254,9 @@ if (! $error && $massaction == 'confirm_presend')
$filepath = $attachedfiles['paths'];
$filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes'];
//var_dump($filepath);
// Send mail
require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php');
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1);
@ -280,7 +282,7 @@ if (! $error && $massaction == 'confirm_presend')
if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO';
if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD';
if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto;
if ($message)
{
@ -290,7 +292,7 @@ if (! $error && $massaction == 'confirm_presend')
$actionmsg = dol_concatdesc($actionmsg, $message);
}
$actionmsg2='';
// Initialisation donnees
$object->sendtoid = 0;
$object->actionmsg = $actionmsg; // Long text
@ -335,7 +337,7 @@ if (! $error && $massaction == 'confirm_presend')
$resaction.=$langs->trans("NbSelected").': '.count($toselect)."\n<br>";
$resaction.=$langs->trans("NbIgnored").': '.($nbignored?$nbignored:0)."\n<br>";
$resaction.=$langs->trans("NbSent").': '.($nbsent?$nbsent:0)."\n<br>";
if ($nbsent)
{
$action=''; // Do not show form post if there was at least one successfull sent
@ -359,7 +361,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$objecttmp=new $objectclass($db);
$listofobjectid=array();
$listofobjectthirdparties=array();
@ -425,21 +427,21 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
if (count($files)>0)
{
$now=dol_now();
$file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf';
$input_files = '';
foreach($files as $f) {
$input_files.=' '.escapeshellarg($f);
}
$cmd = 'pdftk '.$input_files.' cat output '.escapeshellarg($file);
exec($cmd);
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$langs->load("exports");
setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs');
}
@ -447,7 +449,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
{
setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
}
}
else {
// Create empty PDF
@ -481,7 +483,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
// Defined name of merged file
$filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel)));
$filename=preg_replace('/\s/','_',$filename);
// Save merged file
if ($filter=='paye:0')
{
@ -565,6 +567,11 @@ if (! $error && $massaction == 'delete' && $permtodelete)
//var_dump($listofobjectthirdparties);exit;
}
$parameters['toselect']=$toselect;
$parameters['uploaddir']=$uploaddir;
$reshook=$hookmanager->executeHooks('doMassActions',$parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

View File

@ -0,0 +1,86 @@
<?php
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/actions_setnotes.inc.php
* \brief Code for actions on setting notes of object page
*/
// $action must be defined
// $_FILES may be defined
// $nomessageinsetmoduleoptions can be set to 1
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$db->begin();
// Process common param fields
foreach($_POST as $key => $val)
{
if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ...
{
$param=GETPOST("param".$reg[1],'alpha');
$value=GETPOST("value".$reg[1],'alpha');
if ($param)
{
$res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
}
// Process upload fields
if (GETPOST('upload','alpha') && GETPOST('keyforuploaddir','aZ09'))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$keyforuploaddir=GETPOST('keyforuploaddir','aZ09');
$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->$keyforuploaddir)));
foreach($listofdir as $key=>$tmpdir)
{
$tmpdir=trim($tmpdir);
$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
if (! $tmpdir) {
unset($listofdir[$key]); continue;
}
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
else
{
$upload_dir=$tmpdir;
}
}
if ($upload_dir)
{
$result = dol_add_file_process($upload_dir, 0, 1, 'uploadfile', '');
if ($result <= 0) $error++;
}
}
if (! $error)
{
$db->commit();
if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
}
}

View File

@ -49,7 +49,7 @@ if (! isset($mode) || $mode != 'noajax') // For ajax call
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Jean Heimburger <jean@tiaris.info>
*
* This program is free software; you can redistribute it and/or modify
@ -320,7 +320,7 @@ class Conf
// For backward compatibility
$this->user->dir_output=$rootforuser."/users";
$this->user->dir_temp=$rootforuser."/users/temp";
// UserGroup
$this->usergroup->dir_output=$rootforuser."/usergroups";
$this->usergroup->dir_temp=$rootforuser."/usergroups/temp";
@ -386,13 +386,13 @@ class Conf
$this->global->MAIN_ACTIVATE_HTML5=1;
$this->global->MAIN_MAIL_USE_MULTI_PART=1;
// societe
if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON="mod_codeclient_leopard";
if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON="mod_codecompta_panicum";
if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON='mod_chequereceipt_mint';
// Security
if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED='standard'; // Default password generator
if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK='0664'; // Default mask
@ -425,7 +425,7 @@ class Conf
$this->currency=$this->global->MAIN_MONNAIE;
if (empty($conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
// conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...)
if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE='RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
@ -434,7 +434,7 @@ class Conf
// MAIN_HTML_TITLE
if (! isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE='noapp,thirdpartynameonly,contactnameonly,projectnameonly';
// conf->liste_limit = constante de taille maximale des listes
if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT=25;
$this->liste_limit=$this->global->MAIN_SIZE_LISTE_LIMIT;
@ -461,7 +461,7 @@ class Conf
$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_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID=1;
// Format for date (used by default when not found or not searched in lang)
$this->format_date_short="%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
$this->format_date_short_java="dd/MM/yyyy"; // Format of day with Java tags
@ -485,7 +485,7 @@ class Conf
// Default pdf option
if (! isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES=1; // use dash between lines
if (! isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT=1; // allow html content into free footer text
// Set default value to MAIN_SHOW_LOGO
if (! isset($this->global->MAIN_SHOW_LOGO)) $this->global->MAIN_SHOW_LOGO=1;
@ -500,7 +500,7 @@ class Conf
// By default, we open card if one found
if (! isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE=1;
// Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later.
@ -568,12 +568,12 @@ class Conf
$this->expensereport->payment = new stdClass();
$this->expensereport->payment->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY)?$this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY:0)*24*60*60;
}
if (! empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT))
{
$this->global->PRODUIT_MULTIPRICES_LIMIT = 5;
}
// For modules that want to disable top or left menu
if (! empty($this->global->MAIN_HIDE_TOP_MENU)) $this->dol_hide_topmenu=$this->global->MAIN_HIDE_TOP_MENU;
if (! empty($this->global->MAIN_HIDE_LEFT_MENU)) $this->dol_hide_leftmenu=$this->global->MAIN_HIDE_LEFT_MENU;
@ -581,11 +581,11 @@ class Conf
if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) $this->global->MAIN_SIZE_SHORTLIST_LIMIT=3;
// Save inconsistent option
if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && $conf->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')
if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && (! isset($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $conf->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO'))
{
$conf->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
}
// For backward compatibility
if (isset($this->product)) $this->produit=$this->product;
if (isset($this->facture)) $this->invoice=$this->facture;
@ -633,7 +633,7 @@ class Conf
$this->loghandlers[$handler] = $loghandlerinstance;
}
}
}
}

View File

@ -1681,7 +1681,7 @@ class ExtraFields
// Clean parameters
$value_key=dol_mktime($_POST[$keysuffix."options_".$key.$keyprefix."hour"], $_POST[$keysuffix."options_".$key.$keyprefix."min"], 0, $_POST[$keysuffix."options_".$key.$keyprefix."month"], $_POST[$keysuffix."options_".$key.$keyprefix."day"], $_POST[$keysuffix."options_".$key.$keyprefix."year"]);
}
else if (in_array($key_type,array('checkbox')))
else if (in_array($key_type,array('checkbox', 'chkbxlst')))
{
$value_arr=GETPOST($keysuffix."options_".$key.$keyprefix);
// Make sure we get an array even if there's only one checkbox

View File

@ -43,6 +43,8 @@ class HookManager
var $resArray=array();
// Printable result
var $resPrint='';
// Nb of qualified hook ran
var $resNbOfHooks=0;
/**
* Constructor
@ -133,11 +135,14 @@ class HookManager
if (in_array(
$method,
array(
'addMoreActionsButtons',
'addCalendarChoice',
'addMoreActionsButtons',
'addMoreMassActions',
'addSearchEntry',
'addStatisticLine',
'deleteFile',
'deleteFile',
'doActions',
'doMassActions',
'formCreateThirdpartyOptions',
'formObjectOptions',
'formattachOptions',
@ -169,7 +174,6 @@ class HookManager
'printSearchForm',
'printTabsHead',
'formatEvent',
'addCalendarChoice',
'printObjectLine',
'printObjectSubLine',
'createDictionaryFieldList',
@ -181,14 +185,16 @@ class HookManager
if ($method == 'insertExtraFields')
{
$hooktype='returnvalue'; // deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available.
$hooktype='returnvalue'; // @deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available.
dol_syslog("Warning: The hook 'insertExtraFields' is deprecated and must not be used. Use instead trigger on CRUD event (ask it to dev team if not implemented)", LOG_WARNING);
}
// Init return properties
$this->resPrint=''; $this->resArray=array(); $this->resNbOfHooks=0;
// Loop on each hook to qualify modules that have declared context
$modulealreadyexecuted=array();
$resaction=0; $error=0; $result='';
$this->resPrint=''; $this->resArray=array();
foreach($this->hooks as $context => $modules) // $this->hooks is an array with context as key and value is an array of modules that handle this context
{
if (! empty($modules))
@ -197,14 +203,16 @@ class HookManager
{
//print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction." result=".$result."<br>\n";
// test to avoid running twice a hook, when a module implements several active contexts
if (in_array($module,$modulealreadyexecuted)) continue;
// jump to next module/class if method does not exist
if (! method_exists($actionclassinstance,$method)) continue;
// test to avoid running twice a hook, when a module implements several active contexts
if (in_array($module,$modulealreadyexecuted)) continue;
$this->resNbOfHooks++;
dol_syslog(get_class($this).'::executeHooks a qualified hook was found for method='.$method.' module='.$module." action=".$action." context=".$context);
$modulealreadyexecuted[$module]=$module; // Use the $currentcontext in method to avoid running twice
// Clean class (an error may have been set from a previous call of another method for same module/hook)

View File

@ -545,11 +545,20 @@ class Form
$disabled=0;
$ret='<div class="centpercent center">';
$ret.='<select data-role="none" class="flat'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionselect" name="massaction"'.($disabled?' disabled="disabled"':'').'>';
$ret.='<option value="0"'.($disabled?' disabled="disabled"':'').'>-- '.$langs->trans("SelectAction").' --</option>';
foreach($arrayofaction as $code => $label)
{
$ret.='<option value="'.$code.'"'.($disabled?' disabled="disabled"':'').'>'.$label.'</option>';
}
// Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks.
$parameters=array();
$reshook=$hookmanager->executeHooks('addMoreMassActions',$parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
$ret.='<option value="0"'.($disabled?' disabled="disabled"':'').'>-- '.$langs->trans("SelectAction").' --</option>';
foreach($arrayofaction as $code => $label)
{
$ret.='<option value="'.$code.'"'.($disabled?' disabled="disabled"':'').'>'.$label.'</option>';
}
}
$ret.=$hookmanager->resPrint;
$ret.='</select>';
// Warning: if you set submit button to disabled, post using 'Enter' will no more work.
$ret.='<input type="submit" data-role="none" name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionconfirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">';
@ -1391,7 +1400,7 @@ class Form
* @deprecated
* @see select_dolusers()
*/
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0)
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude=null,$disabled=0,$include='',$enableonly='',$force_entity=0)
{
print $this->select_dolusers($selected,$htmlname,$show_empty,$exclude,$disabled,$include,$enableonly,$force_entity);
}
@ -1411,13 +1420,13 @@ class Form
* @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
* @param string $morefilter Add more filters into sql request
* @param integer $show_every 0=default list, 1=add also a value "Everybody" at beginning of list
* @param string $enableonlytext If option $enableonly is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty.
* @param string $enableonlytext If option $enableonlytext is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty.
* @param string $morecss More css
* @param int $noactive Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on).
* @return string HTML select string
* @see select_dolgroups
*/
function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0)
function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0)
{
global $conf,$user,$langs;
@ -1613,7 +1622,7 @@ class Form
* @return string HTML select string
* @see select_dolgroups
*/
function select_dolusers_forevent($action='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='')
function select_dolusers_forevent($action='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='')
{
global $conf,$user,$langs;

View File

@ -358,7 +358,7 @@ class FormCompany
*
* @param string $selected Title preselected
* @param string $htmlname Name of HTML select combo field
* @param string $morecss Add more css on SELECT element
* @param string $morecss Add more css on SELECT element
* @return string String with HTML select
*/
function select_civility($selected='',$htmlname='civility_id',$morecss='maxwidth100')
@ -563,11 +563,11 @@ class FormCompany
$events=array();
// Add an entry 'method' to say 'yes, we must execute url with param action = method';
// Add an entry 'url' to say which url to execute
// Add an entry htmlname to say which element we must change once url is called
// Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines
// Add an entry htmlname to say which element we must change once url is called
// Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines
// To refresh contacts list on thirdparty list change
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events
{
print '<script type="text/javascript">
@ -583,7 +583,7 @@ class FormCompany
/* Clean contact */
$("div#s2id_contactid>a>span").html(\'\');
});
// Function used to execute events when search_htmlname change
function runJsCodeForEvent'.$htmlname.'(obj) {
var id = $("#'.$htmlname.'").val();
@ -693,16 +693,17 @@ class FormCompany
* @param string $source Source ('internal' or 'external')
* @param string $sortorder Sort criteria ('position', 'code', ...)
* @param int $showempty 1=Add en empty line
* @param string $morecss Add more css to select component
* @return void
*/
function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $sortorder='position', $showempty=0)
function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $sortorder='position', $showempty=0, $morecss='')
{
global $user, $langs;
if (is_object($object) && method_exists($object, 'liste_type_contact'))
{
$lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1);
print '<select class="flat valignmiddle" name="'.$htmlname.'" id="'.$htmlname.'">';
print '<select class="flat valignmiddle'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">';
if ($showempty) print '<option value="0"></option>';
foreach($lesTypes as $key=>$value)
{
@ -791,7 +792,7 @@ class FormCompany
$maxlength=$formlength;
if (empty($formlength)) { $formlength=24; $maxlength=128; }
$out = '<input type="text" '.($morecss?'class="'.$morecss.'" ':'').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">';
return $out;

View File

@ -155,7 +155,7 @@ class FormMail extends Form
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
@ -182,7 +182,7 @@ class FormMail extends Form
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
@ -209,7 +209,7 @@ class FormMail extends Form
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
@ -266,13 +266,13 @@ class FormMail extends Form
$out='';
$disablebademails=1;
// Define list of attached files
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
@ -415,7 +415,7 @@ class FormMail extends Form
{
$posalias++;
$listaliasval=trim($listaliasval);
if ($listaliasval)
if ($listaliasval)
{
$listaliasval=preg_replace('/</', '&lt;', $listaliasval);
$listaliasval=preg_replace('/>/', '&gt;', $listaliasval);
@ -720,7 +720,7 @@ class FormMail extends Form
$this->substit['__PERSONALIZED__']=str_replace('\n',"\n",$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url));
}
}
//Add lines substitution key from each line
$lines = '';
$defaultlines = $arraydefaultmessage['content_lines'];
@ -979,14 +979,14 @@ class FormMail extends Form
return -1;
}
}
/**
* Set substit array from object
*
*
* @param CommonObject $object Object to use
* @param Translate $outputlangs Object lang
* @param Translate $outputlangs Object lang
* @return void
*/
function setSubstitFromObject($object, $outputlangs=null)
@ -1001,14 +1001,14 @@ class FormMail extends Form
$this->substit['__AMOUNT__'] = price($object->total_ttc);
$this->substit['__AMOUNT_WO_TAX__'] = price($object->total_ht);
$this->substit['__AMOUNT_VAT__'] = price($object->total_tva);
$this->substit['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:'');
$this->substit['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:'');
$this->substit['__PROJECT_ID__'] = (is_object($object->projet)?$object->projet->id:'');
$this->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:'');
$this->substit['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:'');
$this->substit['__SIGNATURE__'] = $user->signature;
$this->substit['__PERSONALIZED__'] = '';
$this->substit['__CONTACTCIVNAME__'] = ''; // Will be replace just before sending
@ -1020,7 +1020,7 @@ class FormMail extends Form
foreach ($extrafields->attribute_label as $key => $label) {
$this->substit['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key];
}
//Fill substit_lines with each object lines content
if (is_array($object->lines))
{
@ -1057,36 +1057,37 @@ class FormMail extends Form
}
}
}
/**
* Get list of substition keys available.
*
* Get list of substition keys available for emails.
* This include the complete_substitutions_array. TODO Include the getCommonSubstitutionArray().
*
* @param string $mode 'formemail', 'formemailwithlines', 'formemailforlines', 'emailing', ...
* @return void
* @return array Array of substitution values for emails.
*/
static function getAvailableSubstitKey($mode='formemail')
{
global $conf, $langs;
$vars=array();
if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines')
{
$vars=array(
'__REF__',
'__REFCLIENT__',
'__REFSUPPLIER__',
'__THIRDPARTY_ID__',
'__THIRDPARTY_NAME__',
'__PROJECT_ID__',
'__PROJECT_REF__',
'__REF__',
'__REFCLIENT__',
'__REFSUPPLIER__',
'__THIRDPARTY_ID__',
'__THIRDPARTY_NAME__',
'__PROJECT_ID__',
'__PROJECT_REF__',
'__PROJECT_NAME__',
'__CONTACTCIVNAME__',
'__AMOUNT__',
'__AMOUNT_WO_TAX__',
'__AMOUNT_VAT__',
'__AMOUNT__',
'__AMOUNT_WO_TAX__',
'__AMOUNT_VAT__',
'__PERSONALIZED__', // Paypal link will be added here in form mode
'__SIGNATURE__',
'__SIGNATURE__',
);
if ($mode == 'formwithlines')
{
@ -1127,21 +1128,21 @@ class FormMail extends Form
if ($conf->contrat->enabled) $vars['__SECUREKEYPAYPAL_CONTRACTLINE__']='SecureKeyPaypalUniquePerContractLine';
}
}
else
else
{
$vars['__SECUREKEYPAYPAL__']='';
$vars['__SECUREKEYPAYPAL_MEMBER__']='';
}
}
$tmparray=array();
$parameters=array('mode'=>$mode);
$tmparray=getCommonSubstitutionArray($langs);
complete_substitutions_array($tmparray, $langs, null, $parameters);
foreach($tmparray as $key => $val)
{
$vars[$key]=$key;
}
return $vars;
}

View File

@ -68,7 +68,7 @@ class FormProjets
global $langs,$conf,$form;
$out='';
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT))
{
$placeholder='';
@ -92,7 +92,7 @@ class FormProjets
else
{
$out.=$this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, $discard_closed, $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid);
if ($discard_closed)
if ($discard_closed)
{
if (class_exists('Form'))
{
@ -101,8 +101,8 @@ class FormProjets
}
}
}
if (empty($nooutput))
if (empty($nooutput))
{
print $out;
return '';
@ -136,10 +136,10 @@ class FormProjets
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
if (empty($htmlid)) $htmlid = $htmlname;
$out='';
$outarray=array();
$hideunselectables = false;
if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
@ -170,21 +170,19 @@ class FormProjets
$resql=$this->db->query($sql);
if ($resql)
{
$minmax='maxwidth500';
$morecss='maxwidth500';
// Use select2 selector
$nodatarole='';
if (! empty($conf->use_javascript_ajax))
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
$out.=$comboenhancement;
$nodatarole=($comboenhancement?' data-role="none"':'');
$minmax='minwidth100 maxwidth300';
$morecss='minwidth100 maxwidth300';
}
if (empty($option_only)) {
$out.= '<select class="flat'.($minmax?' '.$minmax:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlid.'" name="'.$htmlname.'"'.$nodatarole.'>';
$out.= '<select class="flat'.($morecss?' '.$morecss:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlid.'" name="'.$htmlname.'">';
}
if (!empty($show_empty)) {
$out.= '<option value="0">&nbsp;</option>';
@ -213,12 +211,12 @@ class FormProjets
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
$labeltoshow.=', '.dol_trunc($obj->title, $maxlength);
if ($obj->name)
if ($obj->name)
{
$labeltoshow.=' - '.$obj->name;
if ($obj->name_alias) $labeltoshow.=' ('.$obj->name_alias.')';
}
$disabled=0;
if ($obj->fk_statut == 0)
{
@ -277,7 +275,7 @@ class FormProjets
if (!$mode) {
if (empty($option_only)) $out.= '</select>';
if (empty($nooutput))
if (empty($nooutput))
{
print $out;
return '';
@ -302,13 +300,14 @@ class FormProjets
* @param string $htmlname Name of HTML select
* @param int $maxlength Maximum length of label
* @param int $option_only Return only html options lines without the select tag
* @param int $show_empty Add an empty line
* @param string $show_empty Add an empty line ('1' or string to show for empty line)
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
* @param int $forcefocus Force focus on field (works with javascript only)
* @param int $disabled Disabled
* @param string $morecss More css added to the select component
* @return int Nbr of project if OK, <0 if KO
*/
function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0)
function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500')
{
global $user,$conf,$langs;
@ -339,28 +338,26 @@ class FormProjets
if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
$sql.= " ORDER BY p.ref, t.ref ASC";
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$minmax='maxwidth500';
// Use select2 selector
$nodatarole='';
if (! empty($conf->use_javascript_ajax))
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
$out.=$comboenhancement;
$nodatarole=($comboenhancement?' data-role="none"':'');
$minmax='minwidth200 maxwidth500';
$morecss='minwidth200 maxwidth500';
}
if (empty($option_only)) {
$out.= '<select class="valignmiddle flat'.($minmax?' '.$minmax:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.$htmlname.'"'.$nodatarole.'>';
$out.= '<select class="valignmiddle flat'.($morecss?' '.$morecss:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.$htmlname.'">';
}
if (!empty($show_empty)) {
$out.= '<option value="0">&nbsp;</option>';
if (! empty($show_empty)) {
$out.= '<option value="0" class="optiongrey">';
if (! is_numeric($show_empty)) $out.=$show_empty;
else $out.='&nbsp;';
$out.= '</option>';
}
$num = $this->db->num_rows($resql);
$i = 0;
@ -370,7 +367,7 @@ class FormProjets
{
$obj = $this->db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire)
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire))
{
// Do nothing
}
@ -382,7 +379,7 @@ class FormProjets
continue;
}
$labeltoshow=dol_trunc($obj->ref,18);
$labeltoshow=dol_trunc($obj->ref,18); // Project ref
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
$labeltoshow.=' '.dol_trunc($obj->title,$maxlength);
@ -532,7 +529,6 @@ class FormProjets
$sql.= " ORDER BY ref DESC";
dol_syslog(get_class($this).'::select_element', LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{

View File

@ -76,14 +76,14 @@ class Interfaces
global $db;
$user = new User($db);
}
$nbfile = $nbtotal = $nbok = $nbko = 0;
$files = array();
$modules = array();
$orders = array();
$i=0;
$dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']);
foreach($dirtriggers as $reldir)
{
@ -106,7 +106,7 @@ class Interfaces
$part3=$reg[3];
$nbfile++;
// Check if trigger file is disabled by name
if (preg_match('/NORUN$/i',$file)) continue;
// Check if trigger file is for a particular module
@ -132,7 +132,7 @@ class Interfaces
dol_syslog(get_class($this)."::run_triggers action=".$action." ".$langs->trans("ErrorDuplicateTrigger", $newdir."/".$file, $fullpathfiles[$modName]), LOG_WARNING);
continue;
}
try {
//print 'Todo for '.$modName." : ".$newdir.'/'.$file."\n";
include_once $newdir.'/'.$file;
@ -142,7 +142,7 @@ class Interfaces
{
dol_syslog('ko for '.$modName." ".$e->getMessage()."\n", LOG_ERR);
}
$modules[$i] = $modName;
$files[$i] = $file;
$fullpathfiles[$modName] = $newdir.'/'.$file;
@ -155,7 +155,7 @@ class Interfaces
}
asort($orders);
// Loop on each trigger
foreach ($orders as $key => $value)
{
@ -246,7 +246,7 @@ class Interfaces
{
$dirtriggers=$forcedirtriggers;
}
foreach($dirtriggers as $reldir)
{
$dir=dol_buildpath($reldir,0);

View File

@ -1,5 +1,5 @@
/* Copyright (C) 2014 delcroip <delcroip@gmail.com>
* Laurent Destailleur 2015 <eldy@users.sourceforge.net>
/* Copyright (C) 2014 delcroip <delcroip@gmail.com>
* Copyright (C) 2015-2017 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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

View File

@ -44,7 +44,7 @@ function dol_basename($pathfile)
* @param string $path Starting path from which to search. This is a full path.
* @param string $types Can be "directories", "files", or "all"
* @param int $recursive Determines whether subdirectories are searched
* @param string $filter Regex filter to restrict list. This regex value must be escaped for '/' by doing preg_quote($var,'/'), since this char is used for preg_match function,
* @param string $filter Regex filter to restrict list. This regex value must be escaped for '/' by doing preg_quote($var,'/'), since this char is used for preg_match function,
* but must not contains the start and end '/'. Filter is checked into basename only.
* @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). Exclude is checked into fullpath.
* @param string $sortcriteria Sort criteria ("","fullname","name","date","size")
@ -71,9 +71,9 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
$reshook = 0;
$file_list = array();
$hookmanager->resArray=array();
if (! $nohook)
{
$hookmanager->initHooks(array('fileslib'));
@ -196,9 +196,9 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
}
}
}
$file_list = array_merge($file_list, $hookmanager->resArray);
return $file_list;
}
@ -219,7 +219,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
{
global $conf, $db;
$sql=" SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m, acl, position";
if ($mode) $sql.=", description";
$sql.=" FROM ".MAIN_DB_PREFIX."ecm_files";
@ -234,7 +234,7 @@ function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortc
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$obj = $db->fetch_object($resql);
if ($obj)
{
preg_match('/([^\/]+)\/[^\/]+$/',DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename,$reg);
@ -258,7 +258,7 @@ function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortc
}
$i++;
}
// Obtain a list of columns
if (! empty($sortcriteria))
{
@ -270,7 +270,7 @@ function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortc
// Sort the data
if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
}
return $file_list;
}
else
@ -279,7 +279,7 @@ function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortc
return array();
}
}
/**
* Fast compare of 2 files identified by their properties ->name, ->date and ->size
@ -460,10 +460,10 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile='', $newmask=0,
if (empty($srcfile)) return -1;
if (empty($destfile)) $destfile=$srcfile;
$destexists=dol_is_file($destfile);
if (($destfile != $srcfile) && $destexists) return 0;
$tmpdestfile=$destfile.'.tmp';
$newpathofsrcfile=dol_osencode($srcfile);
@ -481,17 +481,17 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile='', $newmask=0,
dol_syslog("files.lib.php::dolReplaceInFile failed Permission denied to write into target directory ".$newdirdestfile, LOG_WARNING);
return -2;
}
dol_delete_file($tmpdestfile);
// Create $newpathoftmpdestfile from $newpathofsrcfile
$content=file_get_contents($newpathofsrcfile, 'r');
$content = make_substitutions($content, $arrayreplacement, null);
file_put_contents($newpathoftmpdestfile, $content);
@chmod($newpathoftmpdestfile, octdec($newmask));
// Rename
$result=dol_move($newpathoftmpdestfile, $newpathofdestfile, $newmask, (($destfile == $srcfile)?1:0), 0, $indexdatabase);
if (! $result)
@ -589,7 +589,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep
$destexists=dol_is_dir($destfile);
//if (! $overwriteifexists && $destexists) return 0; // The overwriteifexists is for files only, so propagated to dol_copy only.
if (! $destexists)
{
// We must set mask just before creating dir, becaause it can be set differently by dol_copy
@ -599,7 +599,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep
$dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files
dol_mkdir($destfile, '', decoct($dirmaskdec));
}
$ossrcfile=dol_osencode($srcfile);
$osdestfile=dol_osencode($destfile);
@ -639,7 +639,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep
$result=$tmpresult;
}
if ($result < 0) break;
}
}
closedir($dir_handle);
@ -656,10 +656,10 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep
/**
* Move a file into another name.
* Note:
* Note:
* - This function differs from dol_move_uploaded_file, because it can be called in any context.
* - Database of files is updated.
* - Test on antivirus is done only if param testvirus is provided and an antivirus was set.
* - Test on antivirus is done only if param testvirus is provided and an antivirus was set.
*
* @param string $srcfile Source file (can't be a directory. use native php @rename() to move a directory)
* @param string $destfile Destination file (can't be a directory. use native php @rename() to move a directory)
@ -679,12 +679,12 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvi
$srcexists=dol_is_file($srcfile);
$destexists=dol_is_file($destfile);
if (! $srcexists)
if (! $srcexists)
{
dol_syslog("files.lib.php::dol_move srcfile does not exists. we ignore the move request.");
return false;
}
if ($overwriteifexists || ! $destexists)
{
$newpathofsrcfile=dol_osencode($srcfile);
@ -695,7 +695,7 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvi
if ($testvirus)
{
$testvirusarray=dolCheckVirus($newpathofsrcfile);
if (count($testvirusarray))
if (count($testvirusarray))
{
dol_syslog("files.lib.php::dol_move canceled because a virus was found into source file. we ignore the move request.", LOG_WARNING);
return false;
@ -729,14 +729,14 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvi
dol_syslog("Try to rename also entries in database for full relative path before = ".$rel_filetorenamebefore." after = ".$rel_filetorenameafter, LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfiletarget=new EcmFiles($db);
$resultecmtarget = $ecmfiletarget->fetch(0, '', $rel_filetorenameafter);
if ($resultecmtarget > 0) // An entry for target name already exists for target, we delete it, a new one will be created.
{
$ecmfiletarget->delete($user);
}
$ecmfile=new EcmFiles($db);
$resultecm = $ecmfile->fetch(0, '', $rel_filetorenamebefore);
if ($resultecm > 0) // If an entry was found for src file, we use it to move entry
@ -745,7 +745,7 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvi
$rel_dir = dirname($rel_filetorenameafter);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$resultecm = $ecmfile->update($user);
@ -756,7 +756,7 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvi
$rel_dir = dirname($rel_filetorenameafter);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($destfile)); // $destfile is a full path to file
@ -774,12 +774,12 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvi
{
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
if ($resultecm > 0) $result=true;
else $result = false;
}
}
}
if (empty($newmask)) $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK;
$newmaskdec=octdec($newmask);
// Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too)
@ -809,14 +809,14 @@ function dol_unescapefile($filename)
/**
* Check virus into a file
*
*
* @param string $src_file Source file to check
* @return array Array of errors or empty array if not virus found
*/
function dolCheckVirus($src_file)
{
global $conf;
if (! empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
{
if (! class_exists('AntiVir')) {
@ -837,10 +837,10 @@ function dolCheckVirus($src_file)
/**
* Make control on an uploaded file from an GUI page and move it to final destination.
* If there is errors (virus found, antivir in error, bad filename), file is not moved.
* Note:
* Note:
* - This function can be used only into a HTML page context. Use dol_move if you are outside.
* - Database of files is not updated.
* - Test on antivirus is always done (if antivirus set).
* - Database of files is NOT updated.
*
* @param string $src_file Source full path filename ($_FILES['field']['tmp_name'])
* @param string $dest_file Target full path filename ($_FILES['field']['name'])
@ -867,7 +867,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
$parameters=array('dest_file' => $dest_file, 'src_file' => $src_file, 'file_name' => $file_name, 'varfiles' => $varfiles, 'allowoverwrite' => $allowoverwrite);
$reshook=$hookmanager->executeHooks('moveUploadedFile', $parameters, $object);
}
if (empty($reshook))
{
// If an upload error has been reported
@ -897,7 +897,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
break;
}
}
// If we need to make a virus scan
if (empty($disablevirusscan) && file_exists($src_file))
{
@ -908,7 +908,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
return 'ErrorFileIsInfectedWithAVirus: '.join(',',$checkvirusarray);
}
}
// Security:
// Disallow file with some extensions. We renamed them.
// Car si on a mis le rep documents dans un rep de la racine web (pas bien), cela permet d'executer du code a la demande.
@ -916,7 +916,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
{
$file_name.= '.noexe';
}
// Security:
// We refuse cache files/dirs, upload using .. and pipes into filenames.
if (preg_match('/^\./',$src_file) || preg_match('/\.\./',$src_file) || preg_match('/[<>|]/',$src_file))
@ -924,7 +924,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
dol_syslog("Refused to deliver file ".$src_file, LOG_WARNING);
return -1;
}
// Security:
// On interdit fichiers caches, remontees de repertoire ainsi que les pipe dans les noms de fichiers.
if (preg_match('/^\./',$dest_file) || preg_match('/\.\./',$dest_file) || preg_match('/[<>|]/',$dest_file))
@ -933,7 +933,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
return -2;
}
}
if ($reshook < 0) // At least one blocking error returned by one hook
{
$errmsg = join(',', $hookmanager->errors);
@ -1005,7 +1005,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
dol_syslog("Refused to delete file ".$file, LOG_WARNING);
return False;
}
if (empty($nohook))
{
$hookmanager->initHooks(array('fileslib'));
@ -1042,16 +1042,16 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
{
if ($nophperrors) $ok=@unlink($filename);
else $ok=unlink($filename);
if ($ok)
if ($ok)
{
dol_syslog("Removed file ".$filename, LOG_DEBUG);
// Delete entry into ecm database
$rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filename);
if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete)) // If not a tmp file
{
$rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete);
dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
@ -1079,7 +1079,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
if ($nophperrors) $ok=@unlink($file_osencoded);
else $ok=unlink($file_osencoded);
if ($ok) dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG);
else dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING);
else dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING);
}
return $ok;
@ -1104,7 +1104,7 @@ function dol_delete_dir($dir,$nophperrors=0)
dol_syslog("Refused to delete dir ".$dir, LOG_WARNING);
return False;
}
$dir_osencoded=dol_osencode($dir);
return ($nophperrors?@rmdir($dir_osencoded):rmdir($dir_osencoded));
}
@ -1340,7 +1340,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
global $db,$user,$conf,$langs;
$res = 0;
if (! empty($_FILES[$varfiles])) // For view $_FILES[$varfiles]['error']
{
dol_syslog('dol_add_file_process upload_dir='.$upload_dir.' allowoverwrite='.$allowoverwrite.' donotupdatesession='.$donotupdatesession.' savingdocmask='.$savingdocmask, LOG_DEBUG);
@ -1354,17 +1354,17 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
$val = array($val);
}
}
$nbfile = count($TFile['name']);
for ($i = 0; $i < $nbfile; $i++)
{
// Define $destfull (path to file including filename) and $destfile (only filename)
$destfull=$upload_dir . "/" . $TFile['name'][$i];
$destfile=$TFile['name'][$i];
$savingdocmask = dol_sanitizeFileName($savingdocmask);
if ($savingdocmask)
{
$destfull=$upload_dir . "/" . preg_replace('/__file__/',$TFile['name'][$i],$savingdocmask);
@ -1378,26 +1378,26 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
$destfile = $info['filename'].'.'.strtolower($info['extension']);
$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles);
if (is_numeric($resupload) && $resupload > 0) // $resupload can be 'ErrorFileAlreadyExists'
{
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini;
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
// Generate thumbs.
if (image_format_supported($destfull) == 1)
{
// Create thumbs
// We can't use $object->addThumbs here because there is no $object known
// Used on logon for example
$imgThumbSmall = vignette($destfull, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs");
// Create mini thumbs for image (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
}
// Update session
if (empty($donotupdatesession))
{
@ -1406,18 +1406,18 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
$formmail->trackid = $trackid;
$formmail->add_attached_files($destfull, $destfile, $TFile['type'][$i]);
}
// Update table of files
if ($donotupdatesession)
if ($donotupdatesession)
{
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
if (! preg_match('/[\\/]temp[\\/]/', $rel_dir)) // If not a tmp dir
{
$filename = basename($destfile);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
$ecmfile->filepath = $rel_dir;
@ -1455,7 +1455,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
}
}
}
}
} elseif ($link) {
require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
@ -1478,7 +1478,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("File")), null, 'errors');
}
return $res;
}
@ -1718,11 +1718,11 @@ function dol_compress_dir($inputdir, $outputfile, $mode="zip")
if (class_exists('ZipArchive'))
{
$foundhandler=1;
// Initialize archive object
$zip = new ZipArchive();
$zip->open($outputfile, ZipArchive::CREATE | ZipArchive::OVERWRITE);
// Create recursive directory iterator
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
@ -1738,15 +1738,15 @@ function dol_compress_dir($inputdir, $outputfile, $mode="zip")
// Get real and relative path for current file
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($inputdir) + 1);
// Add current file to archive
$zip->addFile($filePath, $relativePath);
}
}
// Zip archive will be created only after closing object
$zip->close();
$zip->close();
return 1;
}
}
@ -1793,7 +1793,7 @@ function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta
* @param string $entity Restrict onto entity (0=no restriction)
* @param User $fuser User object (forced)
* @param string $refname Ref of object to check permission for external users (autodetect if not provided)
* @param string $mode Check permission for 'read' or 'write'
* @param string $mode Check permission for 'read' or 'write'
* @return mixed Array with access information : 'accessallowed' & 'sqlprotectagainstexternals' & 'original_file' (as a full path name)
* @see restrictedArea
*/
@ -1801,7 +1801,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
{
global $user, $conf, $db;
global $dolibarr_main_data_root;
if (! is_object($fuser)) $fuser=$user;
if (empty($modulepart)) return 'ErrorBadParameter';
@ -1823,7 +1823,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
{
$lire='creer'; $read='write'; $download='upload';
}
// Wrapping for some images
if (($modulepart == 'mycompany' || $modulepart == 'companylogo') && !empty($conf->mycompany->dir_output))
{
@ -2022,7 +2022,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
}
$original_file=$conf->user->dir_output.'/'.$original_file;
}
// Wrapping for third parties
else if (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output))
{
@ -2119,7 +2119,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
}
$original_file=$conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
}
// Wrapping for interventions
else if (($modulepart == 'fichinter' || $modulepart == 'ficheinter') && !empty($conf->ficheinter->dir_output))
{
@ -2185,7 +2185,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
}
// Wrapping pour les commandes fournisseurs
else if (($modulepart == 'commande_fournisseur' || $modulepart == 'order_supplier') && !empty($conf->fournisseur->commande->dir_output))
else if (($modulepart == 'commande_fournisseur' || $modulepart == 'order_supplier') && !empty($conf->fournisseur->commande->dir_output))
{
if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i',$original_file))
{
@ -2317,7 +2317,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
}
$original_file=$conf->resource->dir_output.'/'.$original_file;
}
// Wrapping pour les remises de cheques
else if ($modulepart == 'remisecheque' && !empty($conf->banque->dir_output))
{
@ -2361,14 +2361,14 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$accessallowed=1;
$original_file=$conf->fckeditor->dir_output.'/'.$original_file;
}
// Wrapping for miscellaneous medias files
elseif ($modulepart == 'medias' && !empty($dolibarr_main_data_root))
{
$accessallowed=1;
$original_file=$dolibarr_main_data_root.'/medias/'.$original_file;
}
// Wrapping for backups
else if ($modulepart == 'systemtools' && !empty($conf->admin->dir_output))
{
@ -2416,7 +2416,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
// If modulepart=module Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart
else
{
if (preg_match('/^specimen/i',$original_file)) $accessallowed=1; // If link to a file called specimen. Test must be done before changing $original_file int full path.
if (preg_match('/^specimen/i',$original_file)) $accessallowed=1; // If link to a file called specimen. Test must be done before changing $original_file int full path.
if ($fuser->admin) $accessallowed=1; // If user is admin
// Define $accessallowed

View File

@ -239,7 +239,7 @@ function dol_shutdown()
/**
* Return value of a param into GET or POST supervariable.
* Use the property $user->default_values[path]['creatform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder']
* Note: The property $user->default_values is loaded by the main when loading the user.
* Note: The property $user->default_values is loaded by main.php when loading the user.
*
* @param string $paramname Name of parameter to found
* @param string $check Type of check
@ -359,32 +359,34 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
if (! empty($check))
{
// Replace vars like __DAY__, __MONTH__, __YEAR__, __MYCOUNTRYID__, __USERID__, __ENTITYID__, ...
if (! is_array($out))
// Substitution variables for GETPOST (used to get final url with variable parameters or final default value with variable paramaters)
// Example of variables: __DAY__, __MONTH__, __YEAR__, __MYCOUNTRYID__, __USERID__, __ENTITYID__, ...
// We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text.
if (! is_array($out) && empty($_POST[$paramname]))
{
$maxloop=20; $loopnb=0; // Protection against infinite loop
while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side.
{
$loopnb++; $newout = '';
if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; }
elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; }
elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; }
if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; }
elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; }
elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; }
elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; }
elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; }
elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); }
elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; }
elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; }
elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); }
elseif ($reg[1] == 'MYCOUNTRYID')
elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; }
elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; }
elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); }
elseif ($reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID')
{
$newout = $mysoc->country_id;
}
elseif ($reg[1] == 'USERID')
elseif ($reg[1] == 'USER_ID' || $reg[1] == 'USERID')
{
$newout = $user->id;
}
elseif ($reg[1] == 'SUPERVISORID')
elseif ($reg[1] == 'SUPERVISOR_ID' || $reg[1] == 'SUPERVISORID')
{
$newout = $user->fk_user;
}
@ -1586,7 +1588,8 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
if (preg_match('/__b__/i',$format))
{
// Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs.
$month=adodb_strftime('%m',$time+$offsettz+$offsetdst); // TODO Remove this
$month=adodb_strftime('%m',$time+$offsettz+$offsetdst); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
$month=sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'.
if ($encodetooutput)
{
$monthtext=$outputlangs->transnoentities('Month'.$month);
@ -2554,6 +2557,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
$picto = $regs[1];
$path = $regs[2]; // $path is $mymodule
}
// Clean parameters
if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto .= '.png';
// If alt path are defined, define url where img file is, according to physical path
@ -2792,7 +2796,7 @@ function img_printer($titlealt = "default", $other='')
}
/**
* Show delete logo
* Show split logo
*
* @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
* @param string $other Add more attributes on img
@ -3233,15 +3237,19 @@ function dol_print_error($db='',$error='',$errors=null)
* Show a public email and error code to contact if technical error
*
* @param string $prefixcode Prefix of public error code
* @param string $errormessage Complete error message
* @return void
*/
function dol_print_error_email($prefixcode)
function dol_print_error_email($prefixcode, $errormessage='')
{
global $langs,$conf;
$langs->load("errors");
$now=dol_now();
print '<br><div class="error">'.$langs->trans("ErrorContactEMail", $conf->global->MAIN_INFO_SOCIETE_MAIL, $prefixcode.dol_print_date($now,'%Y%m%d')).'</div>';
print '<br><div class="center login_main_message"><div class="error">';
print $langs->trans("ErrorContactEMail", $conf->global->MAIN_INFO_SOCIETE_MAIL, $prefixcode.dol_print_date($now,'%Y%m%d'));
if ($errormessage) print '<br><br>'.$errormessage;
print '</div></div>';
}
/**
@ -5014,8 +5022,100 @@ function dol_concatdesc($text1,$text2,$forxml=false)
return $ret;
}
/**
* Make substition into a string replacing key with vals from $substitutionarray (oldval=>newval)
* Return array of possible common substitutions.
*
* @param Translate $outputlangs Output language
* @param int $onlykey Do not calculate heavy values of keys (performance enhancement when we need only the keys)
* @param array $exclude Array of family keys we want to exclude. For example array('mycompany', 'objectamount', 'date', 'user', ...)
* @param Object $object Object for keys on object
* @return array Array of substitutions
*/
function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
{
global $conf, $mysoc, $user;
$substitutionarray=array();
if (empty($exclude) || ! in_array('mycompany', $exclude))
{
$substitutionarray=array_merge($substitutionarray, array(
'__MYCOMPANY_NAME__' => $mysoc->name,
'__MYCOMPANY_EMAIL__' => $mysoc->email,
'__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
'__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
'__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
'__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
'__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
'__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
'__MYCOMPANY_CAPITAL__' => $mysoc->capital,
'__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id
));
}
if (empty($exclude) || ! in_array('objectamount', $exclude))
{
if (is_object($object)) // For backward compatibility
{
$substitutionarray['__TOTAL_TTC__'] =is_object($object)?$object->total_ttc:'';
$substitutionarray['__TOTAL_HT__'] =is_object($object)?$object->total_ht:'';
$substitutionarray['__TOTAL_VAT__'] =is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):'';
}
$substitutionarray['__AMOUNT__'] =is_object($object)?$object->total_ttc:'';
$substitutionarray['__AMOUNT_WO_TAX__']=is_object($object)?$object->total_ht:'';
$substitutionarray['__AMOUNT_VAT__'] =is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):'';
}
if (empty($exclude) || ! in_array('date', $exclude))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (! empty($onlykey))
{
$tmp=$tmp2=$tmp3=$tmp4=$tmp5=array();
}
else
{
$tmp=dol_getdate(dol_now(), true);
$tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp3=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp4=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp5=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']);
}
$substitutionarray=array_merge($substitutionarray, array(
'__DAY__' => $tmp['mday'],
'__MONTH__' => $tmp['mon'],
'__YEAR__' => $tmp['year'],
'__PREVIOUS_DAY__' => $tmp2['day'],
'__PREVIOUS_MONTH__' => $tmp3['month'],
'__PREVIOUS_YEAR__' => ($tmp['year'] - 1),
'__NEXT_DAY__' => $tmp4['day'],
'__NEXT_MONTH__' => $tmp5['month'],
'__NEXT_YEAR__' => ($tmp['year'] + 1),
));
}
if (empty($exclude) || ! in_array('user', $exclude))
{
$substitutionarray=array_merge($substitutionarray, array(
'__USER_ID__' => $user->id,
'__USER_LOGIN__' => $user->login,
'__USER_LASTNAME__' => $user->lastname,
'__USER_FIRSTNAME__' => $user->firstname,
'__USER_FULLNAME__' => $user->getFullName($outputlangs),
'__USER_SUPERVISOR_ID__' => $user->fk_user
));
}
if (! empty($conf->multicompany->enabled))
{
$substitutionarray=array_merge($substitutionarray, array('__ENTITY_ID__' => $conf->entity));
}
return $substitutionarray;
}
/**
* Make substition into a text string, replacing keys with vals from $substitutionarray (oldval=>newval).
*
* @param string $text Source string in which we must do substitution
* @param array $substitutionarray Array with key->val to substitute
@ -5034,11 +5134,16 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
// Make substitution for language keys
if (is_object($outputlangs))
{
while (preg_match('/__\((.*)\)__/', $text, $reg))
while (preg_match('/__\(([^\)]*)\)__/', $text, $reg))
{
// If key is __(TranslationKey|langfile)__, then force load of langfile.lang
$tmp=explode('|',$reg[1]);
if (! empty($tmp[1])) $outputlangs->load($tmp[1]);
$msgishtml = 0;
if (dol_textishtml($text,1)) $msgishtml = 1;
$text = preg_replace('/__\('.preg_quote($reg[1]).'\)__/', $msgishtml?dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])):$outputlangs->transnoentitiesnoconv($reg[1]), $text);
$text = preg_replace('/__\('.preg_quote($reg[1], '/').'\)__/', $msgishtml?dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])):$outputlangs->transnoentitiesnoconv($reg[1]), $text);
}
}

View File

@ -588,38 +588,26 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height)
/**
* Return array of possible substitutions
* Return array of possible substitutions for PDF content (without external module substitutions).
*
* @param Translate $outputlangs Output language
* @param array $exclude Array of family keys we want to exclude. For example array('mycompany', 'object', 'date', 'user', ...)
* @param Object $object Object
* @return array Array of substitutions
*/
function pdf_getSubstitutionArray($outputlangs)
function pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null)
{
global $conf, $mysoc, $user;
$substitutionarray=array(
'__MYCOMPANY_NAME__' => $mysoc->name,
'__MYCOMPANY_EMAIL__' => $mysoc->email,
'__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
'__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
'__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
'__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
'__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
'__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
'__MYCOMPANY_CAPITAL__' => $mysoc->capital,
'__USER_ID__' => $user->id,
'__USER_LOGIN__' => $user->login,
'__USER_LASTNAME__' => $user->lastname,
'__USER_FIRSTNAME__' => $user->firstname,
'__USER_FULLNAME__' => $user->getFullName($outputlangs)
);
return $substitutionarray;
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $exclude, $object);
$substitutionarray['__FROM_NAME__']='__FROM_NAME__';
$substitutionarray['__FROM_EMAIL__']='__FROM_EMAIL__';
return $substitutionarray;
}
/**
* Add a draft watermark on PDF files
*
* @param TCPDF $pdf Object PDF
* @param TCPDF $pdf Object PDF
* @param Translate $outputlangs Object lang
* @param int $h Height of PDF
* @param int $w Width of PDF
@ -630,7 +618,7 @@ function pdf_getSubstitutionArray($outputlangs)
function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
{
global $langs, $mysoc, $user;
// Print Draft Watermark
if ($unit=='pt') $k=1;
elseif ($unit=='mm') $k=72/25.4;
@ -638,11 +626,11 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
elseif ($unit=='in') $k=72;
// Make substitution
$substitutionarray=pdf_getSubstitutionArray($outputlangs);
complete_substitutions_array($substitutionarray,$outputlangs,$object);
$text=make_substitutions($text,$substitutionarray,$outputlangs);
$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, null);
complete_substitutions_array($substitutionarray, $outputlangs, null);
$text=make_substitutions($text, $substitutionarray, $outputlangs);
$text=$outputlangs->convToOutputCharset($text);
$savx=$pdf->getX(); $savy=$pdf->getY();
$watermark_angle=atan($h/$w)/2;
@ -867,15 +855,12 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
// Line of free text
if (empty($hidefreetext) && ! empty($conf->global->$paramfreetext))
{
$substitutionarray=pdf_getSubstitutionArray($outputlangs);
$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
// More substitution keys
$substitutionarray['__FROM_NAME__']=$fromcompany->name;
$substitutionarray['__FROM_EMAIL__']=$fromcompany->email;
$substitutionarray['__TOTAL_TTC__']=$object->total_ttc;
$substitutionarray['__TOTAL_HT__']=$object->total_ht;
$substitutionarray['__TOTAL_VAT__']=$object->total_vat;
complete_substitutions_array($substitutionarray,$outputlangs,$object);
$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray,$outputlangs);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs);
$line.=$outputlangs->convToOutputCharset($newfreetext);
}
@ -1289,16 +1274,16 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
if (empty($hideref))
{
if ($issupplierline)
if ($issupplierline)
{
if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1)
$ref_prodserv = $ref_supplier;
elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2)
$ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')';
else
$ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')';
else
$ref_prodserv = $prodser->ref.' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')';
}
else
else
$ref_prodserv = $prodser->ref; // Show local ref only
if (! empty($libelleproduitservice)) $ref_prodserv .= " - ";

View File

@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
function project_prepare_head($object)
{
global $db, $langs, $conf, $user;
$h = 0;
$head = array();
@ -119,7 +119,7 @@ function project_prepare_head($object)
}
$head[$h][2] = 'agenda';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove');
return $head;
@ -163,7 +163,7 @@ function task_prepare_head($object)
if ($obj) $nbTimeSpent=1;
}
else dol_print_error($db);
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
$head[$h][1] = $langs->trans("TimeSpent");
if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>';
@ -208,9 +208,10 @@ function task_prepare_head($object)
* Prepare array with list of tabs
*
* @param string $mode Mode
* @param string $fuser Filter on user
* @return array Array of tabs to show
*/
function project_timesheet_prepare_head($mode)
function project_timesheet_prepare_head($mode, $fuser=null)
{
global $langs, $conf, $user;
$h = 0;
@ -218,9 +219,13 @@ function project_timesheet_prepare_head($mode)
$h = 0;
$param='';
$param.=($mode?'&mode='.$mode:'');
if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id;
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK))
{
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($mode?'?mode='.$mode:'');
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:'');
$head[$h][1] = $langs->trans("InputPerWeek");
$head[$h][2] = 'inputperweek';
$h++;
@ -228,7 +233,7 @@ function project_timesheet_prepare_head($mode)
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME))
{
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($mode?'?mode='.$mode:'');
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:'');
$head[$h][1] = $langs->trans("InputPerDay");
$head[$h][2] = 'inputperday';
$h++;
@ -507,7 +512,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
$level--;
}
$total_projectlinesa_spent += $lines[$i]->duration;
$total_projectlinesa_planned += $lines[$i]->planned_workload;
if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
@ -571,9 +576,9 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$lastprojectid=0;
$workloadforid=array();
$lineswithoutlevel0=array();
$numlines=count($lines);
// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
if ($parent == 0) // Always and only if at first level
{
@ -581,7 +586,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
{
if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
}
}
}
//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
for ($i = 0 ; $i < $numlines ; $i++)
@ -594,7 +599,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
{
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
// Break on a new project
if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
{
@ -604,7 +609,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$projectstatic->id = $lines[$i]->fk_project;
}
}
if (empty($workloadforid[$projectstatic->id]))
{
if ($preselectedday)
@ -613,7 +618,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$workloadforid[$projectstatic->id]=1;
}
}
$projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref;
$projectstatic->title=$lines[$i]->projectlabel;
@ -621,7 +626,12 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$taskstatic->id=$lines[$i]->id;
print "<tr ".$bc[$var].">\n";
print '<tr class="oddeven">'."\n";
// User
print '<td class="nowrap">';
print $fuser->getNomUrl(1, 'withproject', 'time');
print '</td>';
// Ref
print '<td>';
@ -656,7 +666,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
print $thirdpartystatic->getNomUrl(1, 'project', 10);
print '</td>';
}
// Planned Workload
print '<td align="right">';
if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
@ -707,7 +717,10 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
print '<td class="nowrap" align="center">';
$tableCell=$form->select_date($preselectedday,$lines[$i]->id,1,1,2,"addtime",0,0,1,$disabledtask);
print $tableCell;
print '</td><td align="right">';
print '</td>';
// Duration
print '<td align="right">';
$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
$alreadyspent='';
@ -723,24 +736,25 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
print '</td>';
print '<td align="right">';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou"));
print '</td>';
print '<td align="right">';
print '<textarea name="'.$lines[$i]->id.'note" rows="2" id="note">';
print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>';
print '</textarea>';
print '</td>';
// Warning
print '<td align="right">';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $langs->transnoentitiesnoconv("AssignTaskToUser", '...')));
print '</td>';
print "</tr>\n";
}
$inc++;
$level++;
if ($lines[$i]->id > 0)
if ($lines[$i]->id > 0)
{
if ($parent == 0) projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $var);
else projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $var);
else projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $var);
}
$level--;
}
@ -781,7 +795,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$lastprojectid=0;
$workloadforid=array();
$lineswithoutlevel0=array();
// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
if ($parent == 0) // Always and only if at first level
{
@ -792,18 +806,18 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
}
//dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
for ($i = 0 ; $i < $numlines ; $i++)
{
if ($parent == 0) $level = 0;
if ($lines[$i]->fk_task_parent == $parent)
{
// If we want all or we have a role on task, we show it
if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
{
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
// Break on a new project
if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
{
@ -811,14 +825,19 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$lastprojectid=$lines[$i]->fk_project;
$projectstatic->id = $lines[$i]->fk_project;
}
if (empty($workloadforid[$projectstatic->id]))
{
$projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
$workloadforid[$projectstatic->id]=1;
}
print "<tr ".$bc[$var].">\n";
print '<tr class="oddeven">'."\n";
// User
print '<td class="nowrap">';
print $fuser->getNomUrl(1, 'withproject', 'time');
print '</td>';
// Ref
print '<td class="nowrap">';
@ -842,7 +861,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
print "</td>\n";
// Project
print '<td class="nowrap">'.$var;
print '<td class="nowrap">';
$projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref;
$projectstatic->title=$lines[$i]->projectlabel;
@ -860,7 +879,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
print $thirdpartystatic->getNomUrl(1, 'project');
print '</td>';
}
// Planned Workload
print '<td align="right">';
if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
@ -908,7 +927,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
}
//var_dump($projectstatic->weekWorkLoadPerTask);
// Fields to show current time
$tableCell=''; $modeinput='hours';
for ($idw = 0; $idw < 7; $idw++)
@ -919,7 +938,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$alreadyspent='';
if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
$alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
$tableCell ='<td align="center" class="hide'.$idw.'">';
if ($alreadyspent)
{
@ -934,10 +953,11 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$tableCell.='</td>';
print $tableCell;
}
// Warning
print '<td align="right">';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou"));
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $langs->transnoentitiesnoconv("AssignTaskToUser", '...')));
print '</td>';
print "</tr>\n";
@ -946,7 +966,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
// Call to show task with a lower level (task under the current task)
$inc++;
$level++;
if ($lines[$i]->id > 0)
if ($lines[$i]->id > 0)
{
if ($parent == 0) projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $var);
else projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $var);
@ -1020,7 +1040,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
$projectstatic=new Project($db);
$thirdpartystatic=new Societe($db);
$sortfield='';
$sortorder='';
$project_year_filter=0;
@ -1029,7 +1049,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]);
$arrayidtypeofcontact=array();
print '<table class="noborder" width="100%">';
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
@ -1072,11 +1092,11 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
$sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter,1,false)).")";
}
}
// Get id of project we must show tasks
$arrayidofprojects=array();
$sql1 = "SELECT p.rowid as projectid";
$sql1.= $sql;
$sql1.= $sql;
$resql = $db->query($sql1);
if ($resql)
{
@ -1091,7 +1111,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
}
else dol_print_error($db);
if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1;
// Get list of project with calculation on tasks
$sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,";
$sql2.= " p.dateo, p.datee,";
@ -1122,7 +1142,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
print_liste_field_titre($langs->trans("OpportunityAmount"),"","","","",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("OpportunityStatus"),"","","","",'align="right"',$sortfield,$sortorder);
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print_liste_field_titre($langs->trans("Tasks"),"","","","",'align="right"',$sortfield,$sortorder);
if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre($langs->trans("PlannedWorkload"),"","","","",'align="right"',$sortfield,$sortorder);
@ -1130,7 +1150,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
}
print_liste_field_titre($langs->trans("Status"),"","","","",'align="right"',$sortfield,$sortorder);
print "</tr>\n";
while ($i < $num)
{
$objp = $db->fetch_object($resql);
@ -1148,8 +1168,8 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
$projectstatic->title = $objp->title;
$projectstatic->datee = $db->jdate($objp->datee);
$projectstatic->dateo = $db->jdate($objp->dateo);
print '<tr class="oddeven">';
print '<td>';
print $projectstatic->getNomUrl(1);
@ -1174,17 +1194,17 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
if ($code) print $langs->trans("OppStatus".$code);
print '</td>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print '<td align="right">'.$objp->nb.'</td>';
$plannedworkload=$objp->planned_workload;
$total_plannedworkload+=$plannedworkload;
if (! in_array('plannedworkload', $hiddenfields))
{
print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>';
}
if (! in_array('declaredprogress', $hiddenfields))
if (! in_array('declaredprogress', $hiddenfields))
{
$declaredprogressworkload=$objp->declared_progess_workload;
$total_declaredprogressworkload+=$declaredprogressworkload;
@ -1194,7 +1214,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
print '</td>';
}
}
print '<td align="right">'.$projectstatic->getLibStatut(3).'</td>';
print "</tr>\n";
@ -1213,7 +1233,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
print '<td class="liste_total" align="right">'.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).'</td>';
print '<td class="liste_total" align="right">'.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).'</td>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print '<td class="liste_total" align="right">'.$total_task.'</td>';
if (! in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
@ -1221,7 +1241,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
}
print '<td class="liste_total"></td>';
print '</tr>';
$db->free($resql);
}
else

View File

@ -345,7 +345,7 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu
* This function is also called by restrictedArea
*
* @param User $user User to check
* @param array $featuresarray Features/modules to check. Example: ('user','service')
* @param array $featuresarray Features/modules to check. Example: ('user','service','member','project','task',...)
* @param int $objectid Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).
* @param string $tableandshare 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany modume. Param not used if objectid is null (optional).
* @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.
@ -369,11 +369,14 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
// For backward compatibility
if ($feature == 'member') $feature='adherent';
if ($feature == 'project') $feature='projet';
if ($feature == 'task') $feature='projet_task';
$check = array('adherent','banque','user','usergroup','produit','service','produit|service','categorie'); // Test on entity only (Objects with no link to company)
$checksoc = array('societe'); // Test for societe object
$checkother = array('contact'); // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
$checkproject = array('projet'); // Test for project object
$checkproject = array('projet','project'); // Test for project object
$checktask = array('projet_task');
$nocheck = array('barcode','stock','fournisseur'); // No test
$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...).
@ -453,7 +456,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
}
else if (in_array($feature,$checkproject))
{
if (! empty($conf->projet->enabled) && ! $user->rights->projet->all->lire)
if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
{
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$projectstatic=new Project($db);
@ -469,6 +472,27 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
}
}
else if (in_array($feature,$checktask))
{
if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
{
$task = new Task($db);
$task->fetch($objectid);
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$projectstatic=new Project($db);
$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0);
$tmparray=explode(',',$tmps);
if (! in_array($task->fk_project,$tmparray)) return false;
}
else
{
$sql = "SELECT dbt.".$dbt_select;
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
}
}
else if (! in_array($feature,$nocheck)) // By default we check with link to third party
{
// If external user: Check permission for external users

View File

@ -265,15 +265,11 @@ function dol_loginfunction($langs,$conf,$mysoc)
$main_home='';
if (! empty($conf->global->MAIN_HOME))
{
$i=0;
while (preg_match('/__\(([a-zA-Z|@]+)\)__/i',$conf->global->MAIN_HOME,$reg) && $i < 100)
{
$tmp=explode('|',$reg[1]);
if (! empty($tmp[1])) $langs->load($tmp[1]);
$conf->global->MAIN_HOME=preg_replace('/__\('.preg_quote($reg[1]).'\)__/i',$langs->trans($tmp[0]),$conf->global->MAIN_HOME);
$i++;
}
$main_home=dol_htmlcleanlastbr($conf->global->MAIN_HOME);
$substitutionarray=getCommonSubstitutionArray($langs);
complete_substitutions_array($substitutionarray, $langs);
$texttoshow = make_substitutions($conf->global->MAIN_HOME, $substitutionarray, $langs);
$main_home=dol_htmlcleanlastbr($texttoshow);
}
// Google AD
@ -415,7 +411,7 @@ function encodedecode_dbpassconf($level=0)
fflush($fp);
fclose($fp);
clearstatcache();
// It's config file, so we set read permission for creator only.
// Should set permission to web user and groups for users used by batch
//@chmod($file, octdec('0600'));

View File

@ -288,6 +288,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
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->projet->enabled', __HANDLER__, 'left', 3701__+MAX_llx_menu__, 'project', '', 3700__+MAX_llx_menu__, '/projet/tasks.php?leftmenu=projects&amp;action=create', 'NewTask', 1, 'projects', '$user->rights->projet->creer', '', 2, 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->projet->enabled', __HANDLER__, 'left', 3702__+MAX_llx_menu__, 'project', '', 3700__+MAX_llx_menu__, '/projet/tasks/list.php?leftmenu=projects', 'List', 1, 'projects', '$user->rights->projet->lire', '', 2, 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->projet->enabled', __HANDLER__, 'left', 3703__+MAX_llx_menu__, 'project', '', 3700__+MAX_llx_menu__, '/projet/activity/perweek.php?leftmenu=projects', 'NewTimeSpent', 1, 'projects', '$user->rights->projet->lire', '', 2, 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->projet->enabled', __HANDLER__, 'left', 3704__+MAX_llx_menu__, 'project', '', 3600__+MAX_llx_menu__, '/projet/tasks/stats/index.php?leftmenu=projects', 'Statistics', 1, 'projects', '$user->rights->projet->lire', '', 2, 4, __ENTITY__);
-- Project - Categories
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->categorie->enabled', __HANDLER__, 'left', 3804__+MAX_llx_menu__, 'project', 'cat', 3__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&amp;type=6', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__);

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