Merge branch 'develop' into develop#6

This commit is contained in:
Laurent Destailleur 2022-05-10 11:43:27 +02:00 committed by GitHub
commit 86b4c97287
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
258 changed files with 5552 additions and 3504 deletions

View File

@ -27,6 +27,8 @@ NEW: A lot of addition of hooks.
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* There is a new specific permission to be allowed to enter timesheets. If you use timesheet, don't forget to give the new permission (disable and
enable the module project if it is not visible).
* The default value for MAIN_SECURITY_CSRF_WITH_TOKEN has been set to 2. It means any POST and any GET request that contains the "action" or "massaction"
with a value of a sensitive action must also a valid token parameter (With previous value 1, only POST was concerned). Note: With value 3, any URL
with parameter "action" or "massaction" need the token, whatever is the value of the action.
@ -37,7 +39,7 @@ Following changes may create regressions for some external modules, but were nec
* Move massaction 'confirm_createbills' from actions_massactions.inc.php to commande/list.php
* Method fetch_all_resources(), fetch_all_used(), fetch_all_available() of DolResource has been removed (they were not used by core code).
* Method fetch_all of DolResource has been renamed into fetchAll() to match naming conventions.
* The hook 'upgrade' and 'doUpgrade2" has been renamed 'doUpgradeBefore' and 'doUpgradeAfterDB'. A new trigger 'doUpgradeAfterFiles' has been introduced.
***** ChangeLog for 15.0.1 compared to 15.0.0 *****
FIX: #19777 #20281

View File

@ -111,7 +111,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- Customers/Prospects + Contacts management
- Opportunities or Leads management
- Commercial proposals management
- Commercial proposals management (online signing)
- Customer Orders management
- Contracts/Subscription management
- Interventions management
@ -129,11 +129,11 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- Supplier Invoices/credit notes and payment management
- INCOTERMS
Finance / Accounting
Finance/Accounting
- Invoices / Payments
- Invoices/Payments
- Bank accounts management
- Direct debit orders management (European SEPA)
- Direct debit and Credit transfer management (European SEPA)
- Accounting management
- Donations management
- Loan management
@ -142,14 +142,14 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
Collaboration
- Shared calendar/agenda (with ical and vcal export for third party tools integration)
- Shared calendar/agenda (with ical and vcal import/export for third party tools integration)
- Projects & Tasks management
- Ticket System
- Surveys
HR
- Employee's leave requests management
- Employee's leaves management
- Expense reports
- Recruitment management
- Timesheets
@ -157,16 +157,14 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
### Other application/modules
- Electronic Document Management (EDM)
- Bookmarks management
- Bookmarks
- Reporting
- Data export/import
- Barcodes
- Margin calculations
- LDAP connectivity
- ClickToDial integration
- Mass emailing
- RSS integration
- Skype integration
- Social platforms linking
- Payment platforms integration (PayPal, Stripe, Paybox...)
- Email-Collector
@ -175,13 +173,12 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
### Other general features
- Localization in most major languages
- Multi-Language Support
- Multi-Language Support (Localization in most major languages)
- Multi-Users and groups with finely grained rights
- Multi-Currency
- Multi-Company (by adding of an external module)
- Very user friendly and easy to use
- customizable Dashboard
- Customizable dashboards
- Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one)
- APIs (REST, SOAP)
- Code that is easy to understand, maintain and develop (PHP with no heavy framework; trigger and hook architecture)
@ -191,8 +188,9 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- Canadian double taxes (federal/province) and other countries using cumulative VAT
- Tunisian tax stamp
- Argentina invoice numbering using A,B,C...
- ZATCA e-invoicing QR-Code
- Compatible with [European directives](https://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE)
- Compatible with European GDPR rules
- Compatible with data privacy rules (europe GDPR, ...)
- ...
- Flexible PDF & ODT generation for invoices, proposals, orders...
- ...
@ -244,6 +242,7 @@ Follow Dolibarr project on:
- [Facebook](https://www.facebook.com/dolibarr)
- [Twitter](https://www.twitter.com/dolibarr)
- [LinkedIn](https://www.linkedin.com/company/association-dolibarr)
- [Reddit](https://www.reddit.com/r/Dolibarr_ERP_CRM/)
- [YouTube](https://www.youtube.com/user/DolibarrERPCRM)
- [GitHub](https://github.com/Dolibarr/dolibarr)

View File

@ -300,7 +300,7 @@ if ($action == 'create') {
// Edit mode
if ($action == 'update') {
print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'accounting_account');
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -368,7 +368,7 @@ if ($action == 'create') {
// View mode
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr');
print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'accounting_account');
dol_banner_tab($object, 'ref', $linkback, 1, 'account_number', 'ref');

View File

@ -95,10 +95,11 @@ if ($conf->loan->enabled) {
$list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INTEREST';
$list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE';
}
$list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE';
if ($conf->societe->enabled) {
$list_account[] = '---Deposits---';
$list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT';
}
$list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE';
/*
* Actions
@ -134,6 +135,20 @@ if ($action == 'update') {
}
}
if ($action == 'setdisableauxiliaryaccountoncustomerdeposit') {
$setDisableAuxiliaryAccountOnCustomerDeposit = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT", $setDisableAuxiliaryAccountOnCustomerDeposit, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
}
}
/*
* View
@ -231,6 +246,20 @@ foreach ($list_account as $key) {
}
}
if ($conf->societe->enabled) {
print '<tr class="oddeven">';
print '<td>' . img_picto('', 'bill', 'class="pictofixedwidth"') . $langs->trans("UseAuxiliaryAccountOnCustomerDeposit") . '</td>';
if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setdisableauxiliaryaccountoncustomerdeposit&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setdisableauxiliaryaccountoncustomerdeposit&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
}
print "</table>\n";
print "</div>\n";

View File

@ -384,6 +384,7 @@ if ($search_onpurchase != '' && $search_onpurchase != '-1') {
$sql .= " GROUP BY p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,";
$sql .= " p.fk_product_type,";
$sql .= ' p.tms,';
$sql .= ' aa.rowid,';
if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export";
} else {

View File

@ -431,12 +431,12 @@ if ($action == 'create') {
// Account movement
print '<tr>';
print '<td class="titlefield">'.$langs->trans("NumMvts").'</td>';
print '<td>'.$object->piece_num.'</td>';
print '<td>'.($mode == '_tmp' ? '<span class="opacitymedium" title="Id tmp '.$object->piece_num.'">'.$langs->trans("Draft").'</span>' : $object->piece_num).'</td>';
print '</tr>';
// Date
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('Docdate');
print '</td>';
if ($action != 'editdate') {

View File

@ -304,7 +304,7 @@ if (empty($reshook)) {
$search_lettering_code = '';
$search_not_reconciled = '';
$search_import_key = '';
$toselect = '';
$toselect = array();
}
// Must be after the remove filter action, before the export.

View File

@ -259,7 +259,7 @@ if (empty($reshook)) {
$search_lettering_code = '';
$search_not_reconciled = '';
$search_import_key = '';
$toselect = '';
$toselect = array();
}
// Must be after the remove filter action, before the export.
@ -653,6 +653,11 @@ if (preg_match('/^asc/i', $sortorder)) {
$sortorder = "desc";
}
// Warning to explain why list of record is not consistent with the other list view (missing a lot of lines)
if ($type == 'sub') {
print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded"));
}
$moreforfilter = '';
// Accountancy account

View File

@ -1843,8 +1843,8 @@ class BookKeeping extends CommonObject
/**
* Transform transaction
*
* @param number $direction If 0 tmp => real, if 1 real => tmp
* @param string $piece_num Piece num
* @param number $direction If 0: tmp => real, if 1: real => tmp
* @param string $piece_num Piece num = Transaction ref
* @return int int <0 if KO, >0 if OK
*/
public function transformTransaction($direction = 0, $piece_num = '')
@ -1862,57 +1862,82 @@ class BookKeeping extends CommonObject
if ($next_piecenum < 0) {
$error++;
}
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' (doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation)';
$sql .= ' SELECT doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.((int) $next_piecenum).", '".$this->db->idate($now)."'";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
if (!$error) {
// Delete if there is an empty line
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity)." AND numero_compte IS NULL AND debit = 0 AND credit = 0";
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
}
}
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
if (!$error) {
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' (doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation)';
$sql .= ' SELECT doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.((int) $next_piecenum).", '".$this->db->idate($now)."'";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
}
}
if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
}
}
} elseif ($direction == 1) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
}
}
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'_tmp (doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)';
$sql .= ' SELECT doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
if (!$error) {
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'_tmp (doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)';
$sql .= ' SELECT doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
}
}
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
}
}
}
if (!$error) {

View File

@ -418,9 +418,14 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->thirdparty_code = $companystatic->code_client;
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) {
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) {
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) {
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
} else {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
}
} else {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
@ -897,12 +902,12 @@ if (empty($action) || $action == 'view') {
print "</td>";
// Subledger account
print "<td>";
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) {
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
} else {
if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) {
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) {
print length_accounta($tabcompany[$key]['code_compta']);
}
} elseif (($accountoshow == "") || $accountoshow == 'NotDefined') {
print '<span class="error">' . $langs->trans("ThirdpartyAccountNotDefined") . '</span>';
}
print '</td>';
$companystatic->id = $tabcompany[$key]['id'];

View File

@ -215,7 +215,7 @@ if (empty($reshook)) {
$search_status = "";
$catid = "";
$sall = "";
$toselect = '';
$toselect = array();
$search_array_options = array();
}

View File

@ -135,7 +135,7 @@ if (empty($reshook)) {
$search_note = "";
$search_amount = "";
$search_account = "";
$toselect = '';
$toselect = array();
$search_array_options = array();
}
}

View File

@ -93,15 +93,17 @@ print '<td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td
print '<td class="right"><input type="submit" class="button button-edit" '.$option.' value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n";
print '<tr class="oddeven"><td>'.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").'</td>';
print '<td colspan="2"><input type="text" class="flat" name="DEBUGBAR_LOGS_LINES_NUMBER" value="'.(empty($conf->global->DEBUGBAR_LOGS_LINES_NUMBER) ? 250 : $conf->global->DEBUGBAR_LOGS_LINES_NUMBER).'">'; // This slow seriously output
print ' '.$langs->trans("WarningValueHigherSlowsDramaticalyOutput");
print '<tr class="oddeven"><td class="nowrap">'.$langs->trans("DEBUGBAR_USE_LOG_FILE").'</td>';
print '<td>';
print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1);
print '</td><td>';
print '<span class="opacitymedium"> '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower").'</span>';
print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("DEBUGBAR_USE_LOG_FILE").'</td>';
print '<td colspan="2">';
print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1);
print ' '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower");
print '<tr class="oddeven"><td class="nowrap">'.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").'</td>';
print '<td><input type="text" class="flat width75" name="DEBUGBAR_LOGS_LINES_NUMBER" value="'.(empty($conf->global->DEBUGBAR_LOGS_LINES_NUMBER) ? 250 : $conf->global->DEBUGBAR_LOGS_LINES_NUMBER).'">'; // This slow seriously output
print '</td><td>';
print '<span class="opacitymedium">'.$langs->trans("WarningValueHigherSlowsDramaticalyOutput").'</span>';
print '</td></tr>';
print '</table>';

View File

@ -101,7 +101,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$defaulturl = '';
$defaultkey = '';
$defaultvalue = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
}

View File

@ -104,50 +104,50 @@ $taborder = array(9, 15, 30, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5,
// Name of SQL tables of dictionaries
$tabname = array();
$tabname[1] = MAIN_DB_PREFIX."c_forme_juridique";
$tabname[2] = MAIN_DB_PREFIX."c_departements";
$tabname[3] = MAIN_DB_PREFIX."c_regions";
$tabname[4] = MAIN_DB_PREFIX."c_country";
$tabname[5] = MAIN_DB_PREFIX."c_civility";
$tabname[6] = MAIN_DB_PREFIX."c_actioncomm";
$tabname[7] = MAIN_DB_PREFIX."c_chargesociales";
$tabname[8] = MAIN_DB_PREFIX."c_typent";
$tabname[9] = MAIN_DB_PREFIX."c_currencies";
$tabname[10] = MAIN_DB_PREFIX."c_tva";
$tabname[11] = MAIN_DB_PREFIX."c_type_contact";
$tabname[12] = MAIN_DB_PREFIX."c_payment_term";
$tabname[13] = MAIN_DB_PREFIX."c_paiement";
$tabname[14] = MAIN_DB_PREFIX."c_ecotaxe";
$tabname[15] = MAIN_DB_PREFIX."c_paper_format";
$tabname[16] = MAIN_DB_PREFIX."c_prospectlevel";
$tabname[17] = MAIN_DB_PREFIX."c_type_fees";
$tabname[18] = MAIN_DB_PREFIX."c_shipment_mode";
$tabname[19] = MAIN_DB_PREFIX."c_effectif";
$tabname[20] = MAIN_DB_PREFIX."c_input_method";
$tabname[21] = MAIN_DB_PREFIX."c_availability";
$tabname[22] = MAIN_DB_PREFIX."c_input_reason";
$tabname[23] = MAIN_DB_PREFIX."c_revenuestamp";
$tabname[24] = MAIN_DB_PREFIX."c_type_resource";
$tabname[25] = MAIN_DB_PREFIX."c_type_container";
//$tabname[26]= MAIN_DB_PREFIX."c_units";
$tabname[27] = MAIN_DB_PREFIX."c_stcomm";
$tabname[28] = MAIN_DB_PREFIX."c_holiday_types";
$tabname[29] = MAIN_DB_PREFIX."c_lead_status";
$tabname[30] = MAIN_DB_PREFIX."c_format_cards";
//$tabname[31]= MAIN_DB_PREFIX."accounting_system";
$tabname[32] = MAIN_DB_PREFIX."c_hrm_public_holiday";
$tabname[33] = MAIN_DB_PREFIX."c_hrm_department";
$tabname[34] = MAIN_DB_PREFIX."c_hrm_function";
$tabname[35] = MAIN_DB_PREFIX."c_exp_tax_cat";
$tabname[36] = MAIN_DB_PREFIX."c_exp_tax_range";
$tabname[37] = MAIN_DB_PREFIX."c_units";
$tabname[38] = MAIN_DB_PREFIX."c_socialnetworks";
$tabname[39] = MAIN_DB_PREFIX."c_prospectcontactlevel";
$tabname[40] = MAIN_DB_PREFIX."c_stcommcontact";
$tabname[41] = MAIN_DB_PREFIX."c_transport_mode";
$tabname[42] = MAIN_DB_PREFIX."c_product_nature";
$tabname[43] = MAIN_DB_PREFIX."c_productbatch_qcstatus";
$tabname[44] = MAIN_DB_PREFIX."c_asset_disposal_type";
$tabname[1] = "c_forme_juridique";
$tabname[2] = "c_departements";
$tabname[3] = "c_regions";
$tabname[4] = "c_country";
$tabname[5] = "c_civility";
$tabname[6] = "c_actioncomm";
$tabname[7] = "c_chargesociales";
$tabname[8] = "c_typent";
$tabname[9] = "c_currencies";
$tabname[10] = "c_tva";
$tabname[11] = "c_type_contact";
$tabname[12] = "c_payment_term";
$tabname[13] = "c_paiement";
$tabname[14] = "c_ecotaxe";
$tabname[15] = "c_paper_format";
$tabname[16] = "c_prospectlevel";
$tabname[17] = "c_type_fees";
$tabname[18] = "c_shipment_mode";
$tabname[19] = "c_effectif";
$tabname[20] = "c_input_method";
$tabname[21] = "c_availability";
$tabname[22] = "c_input_reason";
$tabname[23] = "c_revenuestamp";
$tabname[24] = "c_type_resource";
$tabname[25] = "c_type_container";
//$tabname[26]= "c_units";
$tabname[27] = "c_stcomm";
$tabname[28] = "c_holiday_types";
$tabname[29] = "c_lead_status";
$tabname[30] = "c_format_cards";
//$tabname[31]= "accounting_system";
$tabname[32] = "c_hrm_public_holiday";
$tabname[33] = "c_hrm_department";
$tabname[34] = "c_hrm_function";
$tabname[35] = "c_exp_tax_cat";
$tabname[36] = "c_exp_tax_range";
$tabname[37] = "c_units";
$tabname[38] = "c_socialnetworks";
$tabname[39] = "c_prospectcontactlevel";
$tabname[40] = "c_stcommcontact";
$tabname[41] = "c_transport_mode";
$tabname[42] = "c_product_nature";
$tabname[43] = "c_productbatch_qcstatus";
$tabname[44] = "c_asset_disposal_type";
// Dictionary labels
$tablib = array();
@ -209,7 +209,7 @@ $tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as
$tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c";
$tabsql[10] = "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
$tabsql[11] = "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
$tabsql[12] = "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = ".getEntity($tabname[12]);
$tabsql[12] = "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.deposit_percent, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = ".getEntity($tabname[12]);
$tabsql[13] = "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = ".getEntity($tabname[13]);
$tabsql[14] = "SELECT e.rowid as rowid, e.code as code, e.label, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1";
$tabsql[15] = "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format";
@ -265,7 +265,7 @@ $tabsqlsort[17] = "code ASC";
$tabsqlsort[18] = "code ASC, libelle ASC";
$tabsqlsort[19] = "id ASC";
$tabsqlsort[20] = "code ASC, libelle ASC";
$tabsqlsort[21] = "code ASC, label ASC, position ASC, type_duration ASC, qty ASC";
$tabsqlsort[21] = "position ASC, type_duration ASC, qty ASC";
$tabsqlsort[22] = "code ASC, label ASC";
$tabsqlsort[23] = "country ASC, taux ASC";
$tabsqlsort[24] = "code ASC, label ASC";
@ -303,7 +303,7 @@ $tabfield[8] = "code,libelle,country_id,country".(!empty($conf->global->SOCIETE_
$tabfield[9] = "code,label,unicode";
$tabfield[10] = "country_id,country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
$tabfield[11] = "element,source,code,libelle,position";
$tabfield[12] = "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity";
$tabfield[12] = "code,libelle,libelle_facture,deposit_percent,nbjour,type_cdr,decalage,sortorder,entity";
$tabfield[13] = "code,libelle,type,entity";
$tabfield[14] = "code,label,price,organization,country";
$tabfield[15] = "code,libelle,width,height,unit";
@ -350,7 +350,7 @@ $tabfieldvalue[8] = "code,libelle,country".(!empty($conf->global->SOCIETE_SORT_O
$tabfieldvalue[9] = "code,label,unicode";
$tabfieldvalue[10] = "country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldvalue[11] = "element,source,code,libelle,position";
$tabfieldvalue[12] = "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder";
$tabfieldvalue[12] = "code,libelle,libelle_facture,deposit_percent,nbjour,type_cdr,decalage,sortorder";
$tabfieldvalue[13] = "code,libelle,type";
$tabfieldvalue[14] = "code,label,price,organization,country";
$tabfieldvalue[15] = "code,libelle,width,height,unit";
@ -397,7 +397,7 @@ $tabfieldinsert[8] = "code,libelle,fk_country".(!empty($conf->global->SOCIETE_SO
$tabfieldinsert[9] = "code_iso,label,unicode";
$tabfieldinsert[10] = "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldinsert[11] = "element,source,code,libelle,position";
$tabfieldinsert[12] = "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity";
$tabfieldinsert[12] = "code,libelle,libelle_facture,deposit_percent,nbjour,type_cdr,decalage,sortorder,entity";
$tabfieldinsert[13] = "code,libelle,type,entity";
$tabfieldinsert[14] = "code,label,price,organization,fk_pays";
$tabfieldinsert[15] = "code,label,width,height,unit";
@ -528,112 +528,90 @@ $tabcond[42] = !empty($conf->product->enabled);
$tabcond[43] = !empty($conf->product->enabled) && !empty($conf->productbatch->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2;
$tabcond[44] = !empty($conf->asset->enabled);
// List of help for fields
// List of help for fields (no more used, help is defined into tabcomplete)
$tabhelp = array();
$tabhelp[1] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[2] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[3] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[4] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[5] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[6] = array('code'=>$langs->trans("EnterAnyCode"), 'color'=>$langs->trans("ColorFormat"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[7] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[8] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[9] = array('code'=>$langs->trans("EnterAnyCode"), 'unicode'=>$langs->trans("UnicodeCurrency"));
$tabhelp[10] = array('code'=>$langs->trans("EnterAnyCode"), 'taux'=>$langs->trans("SellTaxRate"), 'recuperableonly'=>$langs->trans("RecuperableOnly"), 'localtax1_type'=>$langs->trans("LocalTaxDesc"), 'localtax2_type'=>$langs->trans("LocalTaxDesc"));
$tabhelp[11] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[12] = array('code'=>$langs->trans("EnterAnyCode"), 'type_cdr'=>$langs->trans("TypeCdr", $langs->transnoentitiesnoconv("NbOfDays"), $langs->transnoentitiesnoconv("Offset"), $langs->transnoentitiesnoconv("NbOfDays"), $langs->transnoentitiesnoconv("Offset")));
$tabhelp[13] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[14] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[15] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[16] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[17] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[18] = array('code'=>$langs->trans("EnterAnyCode"), 'tracking'=>$langs->trans("UrlTrackingDesc"));
$tabhelp[19] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[20] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[23] = array('revenuestamp_type'=>'FixedOrPercent');
$tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[25] = array('code'=>$langs->trans('EnterAnyCode'));
//$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp"));
$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"), 'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically"));
$tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize"));
//$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode"));
$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"), 'dayrule'=>"Keep empty for a date defined with month and day (most common case).<br>Use a keyword like 'easter', 'eastermonday', ... for a date predefined by complex rules.", 'country'=>$langs->trans("CountryIfSpecificToOneCountry"), 'year'=>$langs->trans("ZeroMeansEveryYear"));
$tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[35] = array();
$tabhelp[36] = array('range_ik'=>$langs->trans('PrevRangeToThisRange'));
$tabhelp[37] = array('code'=>$langs->trans("EnterAnyCode"), 'unit_type' => $langs->trans('Measuringtype_durationDesc'), 'scale' => $langs->trans('MeasuringScaleDesc'));
$tabhelp[38] = array('code'=>$langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc'));
$tabhelp[39] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[40] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp"));
$tabhelp[41] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[42] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[43] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[44] = array('code'=>$langs->trans("EnterAnyCode"));
// Table to store complete informations (will replace all other table). Key is table name.
$tabcomplete = array(
'c_forme_juridique'=>array('picto'=>'company'),
'c_departements'=>array('picto'=>'state'),
'c_regions'=>array('picto'=>'region'),
'c_country'=>array('picto'=>'country'),
'c_civility'=>array('picto'=>'contact'),
'c_actioncomm'=>array('picto'=>'action'),
'c_chargesociales'=>array('picto'=>'bill'),
'c_typent'=>array('picto'=>'company'),
'c_currencies'=>array('picto'=>'multicurrency'),
'c_tva'=>array('picto'=>'bill'),
'c_type_contact'=>array('picto'=>'contact'),
'c_payment_term'=>array('picto'=>'bill'),
'c_paiement'=>array('picto'=>'bill'),
'c_ecotaxe'=>array('picto'=>'bill'),
'c_paper_format'=>array('picto'=>'generic'),
'c_prospectlevel'=>array('picto'=>'company'),
'c_type_fees'=>array('picto'=>'trip'),
'c_effectif'=>array('picto'=>'company'),
'c_input_method'=>array('picto'=>'order'),
'c_input_reason'=>array('picto'=>'order'),
'c_availability'=>array('picto'=>'shipment'),
'c_shipment_mode'=>array('picto'=>'shipment'),
'c_revenuestamp'=>array('picto'=>'bill'),
'c_type_resource'=>array('picto'=>'resource'),
'c_type_container'=>array('picto'=>'website'),
'c_stcomm'=>array('picto'=>'company'),
'c_holiday_types'=>array('picto'=>'holiday'),
'c_lead_status'=>array('picto'=>'project'),
'c_format_cards'=>array('picto'=>'generic'),
'c_hrm_public_holiday'=>array('picto'=>'holiday'),
'c_hrm_department'=>array('picto'=>'hrm'),
'c_hrm_function'=>array('picto'=>'hrm'),
'c_exp_tax_cat'=>array('picto'=>'expensereport'),
'c_exp_tax_range'=>array('picto'=>'expensereport'),
'c_units'=>array('picto'=>'product'),
'c_socialnetworks'=>array('picto'=>'share-alt'),
'c_product_nature'=>array('picto'=>'product'),
'c_transport_mode'=>array('picto'=>'incoterm'),
'c_prospectcontactlevel'=>array('picto'=>'company'),
'c_stcommcontact'=>array('picto'=>'company'),
'c_product_nature'=>array('picto'=>'product'),
'c_productbatch_qcstatus'=>array('picto'=>'lot'),
'c_asset_disposal_type'=>array('picto'=>'asset'),
'c_forme_juridique'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_departements'=>array('picto'=>'state', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_regions'=>array('picto'=>'region', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_country'=>array('picto'=>'country', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_civility'=>array('picto'=>'contact', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_actioncomm'=>array('picto'=>'action', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'color'=>$langs->trans("ColorFormat"), 'position'=>$langs->trans("PositionIntoComboList"))),
'c_chargesociales'=>array('picto'=>'bill', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_typent'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"))),
'c_currencies'=>array('picto'=>'multicurrency', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'unicode'=>$langs->trans("UnicodeCurrency"))),
'c_tva'=>array('picto'=>'bill', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'taux'=>$langs->trans("SellTaxRate"), 'recuperableonly'=>$langs->trans("RecuperableOnly"), 'localtax1_type'=>$langs->trans("LocalTaxDesc"), 'localtax2_type'=>$langs->trans("LocalTaxDesc"))),
'c_type_contact'=>array('picto'=>'contact', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"))),
'c_payment_term'=>array('picto'=>'bill', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'type_cdr'=>$langs->trans("TypeCdr", $langs->transnoentitiesnoconv("NbOfDays"), $langs->transnoentitiesnoconv("Offset"), $langs->transnoentitiesnoconv("NbOfDays"), $langs->transnoentitiesnoconv("Offset")))),
'c_paiement'=>array('picto'=>'bill', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_ecotaxe'=>array('picto'=>'bill', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_paper_format'=>array('picto'=>'generic', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_prospectlevel'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_type_fees'=>array('picto'=>'trip', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_shipment_mode'=>array('picto'=>'shipment', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'tracking'=>$langs->trans("UrlTrackingDesc"))),
'c_effectif'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_input_method'=>array('picto'=>'order', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_input_reason'=>array('picto'=>'order', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"))),
'c_availability'=>array('picto'=>'shipment', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_revenuestamp'=>array('picto'=>'bill', 'help'=>array('revenuestamp_type'=>$langs->trans('FixedOrPercent'))),
'c_type_resource'=>array('picto'=>'resource', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_type_container'=>array('picto'=>'website', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_stcomm'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp"))),
'c_holiday_types'=>array('picto'=>'holiday', 'help'=>array('affect'=>$langs->trans("FollowedByACounter"), 'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically"))),
'c_lead_status'=>array('picto'=>'project', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList"))),
'c_format_cards'=>array('picto'=>'generic', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize"))),
'c_hrm_public_holiday'=>array('picto'=>'holiday', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'dayrule'=>"Keep empty for a date defined with month and day (most common case).<br>Use a keyword like 'easter', 'eastermonday', ... for a date predefined by complex rules.", 'country'=>$langs->trans("CountryIfSpecificToOneCountry"), 'year'=>$langs->trans("ZeroMeansEveryYear"))),
'c_hrm_department'=>array('picto'=>'hrm', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_hrm_function'=>array('picto'=>'hrm', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_exp_tax_cat'=>array('picto'=>'expensereport', 'help'=>array()),
'c_exp_tax_range'=>array('picto'=>'expensereport', 'help'=>array('range_ik'=>$langs->trans('PrevRangeToThisRange'))),
'c_units'=>array('picto'=>'product', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'unit_type' => $langs->trans('Measuringtype_durationDesc'), 'scale' => $langs->trans('MeasuringScaleDesc'))),
'c_socialnetworks'=>array('picto'=>'share-alt', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc'))),
'c_prospectcontactlevel'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_stcommcontact'=>array('picto'=>'company', 'help'=>array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp"))),
'c_transport_mode'=>array('picto'=>'incoterm', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_product_nature'=>array('picto'=>'product', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_productbatch_qcstatus'=>array('picto'=>'lot', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
'c_asset_disposal_type'=>array('picto'=>'asset', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))),
);
// Complete all arrays with entries found into modules
complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabcomplete);
// Complete the table $tabcomplete
$i = 0;
foreach ($tabcomplete as $key => $value) {
$i++;
$tabcomplete[$key]['id'] = $i;
$tabcomplete[$key]['cond'] = $tabcond[$i];
$tabcomplete[$key]['rowid'] = $tabrowid[$i];
$tabcomplete[$key]['fieldinsert'] = $tabfieldinsert[$i];
$tabcomplete[$key]['fieldvalue'] = $tabfieldvalue[$i];
$tabcomplete[$key]['lib'] = $tablib[$i];
$tabcomplete[$key]['sql'] = $tabsql[$i];
$tabcomplete[$key]['sqlsort'] = $tabsqlsort[$i];
$tabcomplete[$key]['field'] = $tabfield[$i];
}
$keytable = '';
if ($id > 0) {
$arrayofkeys = array_keys($tabcomplete);
$keytable = $arrayofkeys[$id - 1];
}
// Defaut sortorder
if (empty($sortfield)) {
$tmp1 = explode(',', empty($tabsqlsort[$id]) ? '' : $tabsqlsort[$id]);
$tmp1 = explode(',', empty($tabcomplete[$keytable]['sqlsort']) ? '' : $tabcomplete[$keytable]['sqlsort']);
$tmp2 = explode(' ', $tmp1[0]);
$sortfield = preg_replace('/^.*\./', '', $tmp2[0]);
$sortorder = $tmp2[1];
//var_dump($sortfield);var_dump($sortorder);
}
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
$elementList = array();
$sourceList = array();
@ -675,25 +653,22 @@ if ($id == 11) {
}
// Define localtax_typeList (used for dictionary "llx_c_tva")
$localtax_typeList = array();
if ($id == 10) {
$localtax_typeList = array(
"0" => $langs->trans("No"),
"1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"),
"2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"),
"3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"),
"4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"),
"5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"),
"6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)" //$langs->trans("%ageOnServiceBeforeVAT"),
);
}
$localtax_typeList = array(
"0" => $langs->trans("No"),
"1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"),
"2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"),
"3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"),
"4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"),
"5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"),
"6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)" //$langs->trans("%ageOnServiceBeforeVAT"),
);
/*
* Actions
*/
$object = new stdClass();
$parameters = array(
'id' =>$id,
'rowid' =>$rowid,
@ -761,7 +736,7 @@ if (empty($reshook)) {
continue; // For a column name 'sortorder', we use the field name 'position'
}
if ((!GETPOSTISSET($value) || GETPOST($value) == '')
&& (!in_array($value, array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking', 'picto')) // Fields that are not mandatory
&& (!in_array($value, array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking', 'picto', 'deposit_percent')) // Fields that are not mandatory
&& ($id != 10 || ($value != 'code' && $value != 'note')) // Field code and note is not mandatory for dictionary table 10
)
) {
@ -774,6 +749,9 @@ if (empty($reshook)) {
if ($fieldnamekey == 'libelle_facture') {
$fieldnamekey = 'LabelOnDocuments';
}
if ($fieldnamekey == 'deposit_percent') {
$fieldnamekey = 'DepositPercent';
}
if ($fieldnamekey == 'nbjour') {
$fieldnamekey = 'NbOfDays';
}
@ -817,11 +795,11 @@ if (empty($reshook)) {
$fieldnamekey = 'UseByDefault';
}
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
}
}
// Other checks
if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array(GETPOST("type"), array('system', 'systemauto'))) {
if (GETPOST('actionadd') && $tabname[$id] == "c_actioncomm" && GETPOSTISSET("type") && in_array(GETPOST("type"), array('system', 'systemauto'))) {
$ok = 0;
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
}
@ -869,7 +847,7 @@ if (empty($reshook)) {
if ($tabrowid[$id]) {
// Get free id for insert
$newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$sql = "SELECT MAX(".$tabrowid[$id].") as newid FROM ".MAIN_DB_PREFIX.$tabname[$id];
$result = $db->query($sql);
if ($result) {
$obj = $db->fetch_object($result);
@ -880,7 +858,7 @@ if (empty($reshook)) {
}
// Add new entry
$sql = "INSERT INTO ".$tabname[$id]." (";
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$tabname[$id]." (";
// List of fields
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
$sql .= $tabrowid[$id].",";
@ -956,7 +934,7 @@ if (empty($reshook)) {
}
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET ";
// Modifie valeur des champs
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
$sql .= $tabrowid[$id]."=";
@ -1011,11 +989,6 @@ if (empty($reshook)) {
setEventMessages($db->error(), null, 'errors');
}
}
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
}
if (GETPOST('actioncancel')) {
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
}
if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
@ -1025,7 +998,7 @@ if (empty($reshook)) {
$rowidcol = "rowid";
}
$sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabname[$id]." WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
@ -1047,9 +1020,9 @@ if (empty($reshook)) {
}
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
} elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET active = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
}
$result = $db->query($sql);
@ -1067,9 +1040,9 @@ if (empty($reshook)) {
}
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
} elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET active = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
}
$result = $db->query($sql);
@ -1087,9 +1060,9 @@ if (empty($reshook)) {
}
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
} elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
}
$result = $db->query($sql);
@ -1107,9 +1080,9 @@ if (empty($reshook)) {
}
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
} elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
}
$result = $db->query($sql);
@ -1127,9 +1100,9 @@ if (empty($reshook)) {
}
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET eec = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET eec = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
} elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET eec = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET eec = 1 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
}
$result = $db->query($sql);
@ -1147,9 +1120,9 @@ if (empty($reshook)) {
}
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET eec = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET eec = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
} elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET eec = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
$sql = "UPDATE ".MAIN_DB_PREFIX.$tabname[$id]." SET eec = 0 WHERE code = '".$db->escape(dol_escape_htmltag($code))."'".($entity != '' ? " AND entity = ".(int) $entity : '');
}
$result = $db->query($sql);
@ -1225,7 +1198,7 @@ if ($action == 'delete') {
/*
* Show a dictionary
*/
if ($id) {
if ($id > 0) {
// Complete search values request with sort criteria
$sql = $tabsql[$id];
@ -1293,6 +1266,7 @@ if ($id) {
print '<table class="noborder centpercent">';
// Line for title
print '<!-- line title to add new entry -->';
$tdsoffields = '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) {
if ($value == 'entity') {
@ -1315,7 +1289,7 @@ if ($id) {
$valuetoshow = $langs->trans("PriceUHT");
}
if ($value == 'taux') {
if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") {
if ($tabname[$id] != "c_revenuestamp") {
$valuetoshow = $langs->trans("Rate");
} else {
$valuetoshow = $langs->trans("Amount");
@ -1341,7 +1315,7 @@ if ($id) {
$valuetoshow = $langs->trans("Language");
}
if ($value == 'type') {
if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") {
if ($tabname[$id] == "c_paiement") {
$valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
} else {
$valuetoshow = $langs->trans("Type");
@ -1356,6 +1330,10 @@ if ($id) {
if ($value == 'libelle_facture') {
$valuetoshow = $form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, ''));
}
if ($value == 'deposit_percent') {
$valuetoshow = $langs->trans('DepositPercent');
$class = 'right';
}
if ($value == 'country') {
if (in_array('region_id', $fieldlist)) {
print '<td>&nbsp;</td>'; continue;
@ -1367,12 +1345,14 @@ if ($id) {
}
if ($value == 'nbjour') {
$valuetoshow = $langs->trans("NbOfDays");
$class = 'right';
}
if ($value == 'type_cdr') {
$valuetoshow = $langs->trans("AtEndOfMonth"); $class = "center";
}
if ($value == 'decalage') {
$valuetoshow = $langs->trans("Offset");
$class = 'right';
}
if ($value == 'width' || $value == 'nx') {
$valuetoshow = $langs->trans("Width");
@ -1409,6 +1389,7 @@ if ($id) {
}
if ($value == 'sortorder') {
$valuetoshow = $langs->trans("SortOrder");
$class = 'center';
}
if ($value == 'short_label') {
$valuetoshow = $langs->trans("ShortLabel");
@ -1505,7 +1486,7 @@ if ($id) {
}
if ($valuetoshow != '') {
$tdsoffields .= '<td'.($class ? ' class="'.$class.'"' : '').'>';
$tdsoffields .= '<th'.($class ? ' class="'.$class.'"' : '').'>';
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
$tdsoffields .= '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
} elseif (!empty($tabhelp[$id][$value])) {
@ -1513,29 +1494,29 @@ if ($id) {
} else {
$tdsoffields .= $valuetoshow;
}
$tdsoffields .= '</td>';
$tdsoffields .= '</th>';
}
}
if ($id == 4) {
$tdsoffields .= '<td></td>';
$tdsoffields .= '<td></td>';
$tdsoffields .= '<th></th>';
$tdsoffields .= '<th></th>';
}
$tdsoffields .= '<td>';
$tdsoffields .= '<th>';
$tdsoffields .= '<input type="hidden" name="id" value="'.$id.'">';
if (!is_null($withentity)) {
$tdsoffields .= '<input type="hidden" name="entity" value="'.$withentity.'">';
}
$tdsoffields .= '</td>';
$tdsoffields .= '<td style="min-width: 26px;"></td>';
$tdsoffields .= '<td style="min-width: 26px;"></td>';
$tdsoffields .= '</th>';
$tdsoffields .= '<th style="min-width: 26px;"></th>';
$tdsoffields .= '<th style="min-width: 26px;"></th>';
$tdsoffields .= '</tr>';
print $tdsoffields;
// Line to enter new values
print '<!-- line to add new entry -->';
print '<!-- line input to add new entry -->';
print '<tr class="oddeven nodrag nodrop nohover">';
$obj = new stdClass();
@ -1606,6 +1587,7 @@ if ($id) {
print '<table class="noborder centpercent">';
// Title line with search input fields
print '<!-- line title to search record -->'."\n";
print '<tr class="liste_titre_filter">';
$filterfound = 0;
foreach ($fieldlist as $field => $value) {
@ -1650,6 +1632,7 @@ if ($id) {
print '</tr>';
// Title of lines
print '<!-- line title of record -->'."\n";
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) {
if ($value == 'entity') {
@ -1676,7 +1659,7 @@ if ($id) {
$valuetoshow = $langs->trans("PriceUHT");
}
if ($value == 'taux') {
if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") {
if ($tabname[$id] != "c_revenuestamp") {
$valuetoshow = $langs->trans("Rate");
} else {
$valuetoshow = $langs->trans("Amount");
@ -1717,6 +1700,10 @@ if ($id) {
if ($value == 'libelle_facture') {
$valuetoshow = $langs->trans("LabelOnDocuments");
}
if ($value == 'deposit_percent') {
$valuetoshow = $langs->trans('DepositPercent');
$cssprefix = 'right ';
}
if ($value == 'country') {
$valuetoshow = $langs->trans("Country");
}
@ -1725,12 +1712,14 @@ if ($id) {
}
if ($value == 'nbjour') {
$valuetoshow = $langs->trans("NbOfDays");
$cssprefix = 'right ';
}
if ($value == 'type_cdr') {
$valuetoshow = $langs->trans("AtEndOfMonth"); $cssprefix = "center ";
}
if ($value == 'decalage') {
$valuetoshow = $langs->trans("Offset");
$cssprefix = 'right ';
}
if ($value == 'width' || $value == 'nx') {
$valuetoshow = $langs->trans("Width");
@ -1764,6 +1753,7 @@ if ($id) {
}
if ($value == 'sortorder') {
$valuetoshow = $langs->trans("SortOrder");
$cssprefix = 'center ';
}
if ($value == 'short_label') {
$valuetoshow = $langs->trans("ShortLabel");
@ -1962,58 +1952,58 @@ if ($id) {
$key = $langs->trans("PaymentCondition".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->{$value});
$valuetoshow = nl2br($valuetoshow);
} elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') {
} elseif ($value == 'label' && $tabname[$id] == 'c_country') {
$key = $langs->trans("Country".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$value});
} elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') {
} elseif ($value == 'label' && $tabname[$id] == 'c_availability') {
$langs->load("propal");
$key = $langs->trans("AvailabilityType".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$value});
} elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') {
} elseif ($value == 'libelle' && $tabname[$id] == 'c_actioncomm') {
$key = $langs->trans("Action".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$value});
} elseif (!empty($obj->code_iso) && $value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_currencies') {
} elseif (!empty($obj->code_iso) && $value == 'label' && $tabname[$id] == 'c_currencies') {
$key = $langs->trans("Currency".strtoupper($obj->code_iso));
$valuetoshow = ($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->{$value});
} elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_typent') {
} elseif ($value == 'libelle' && $tabname[$id] == 'c_typent') {
$key = $langs->trans(strtoupper($obj->code));
$valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$value});
} elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_prospectlevel') {
} elseif ($value == 'libelle' && $tabname[$id] == 'c_prospectlevel') {
$key = $langs->trans(strtoupper($obj->code));
$valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$value});
} elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_civility') {
} elseif ($value == 'label' && $tabname[$id] == 'c_civility') {
$key = $langs->trans("Civility".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->{$value});
} elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_contact') {
} elseif ($value == 'libelle' && $tabname[$id] == 'c_type_contact') {
$langs->load('agenda');
$key = $langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->{$value});
} elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_payment_term') {
} elseif ($value == 'libelle' && $tabname[$id] == 'c_payment_term') {
$langs->load("bills");
$key = $langs->trans("PaymentConditionShort".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->{$value});
} elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_paiement') {
} elseif ($value == 'libelle' && $tabname[$id] == 'c_paiement') {
$langs->load("bills");
$key = $langs->trans("PaymentType".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "PaymentType".strtoupper($obj->code) ? $key : $obj->{$value});
} elseif ($value == 'type' && $tabname[$id] == MAIN_DB_PREFIX.'c_paiement') {
} elseif ($value == 'type' && $tabname[$id] == 'c_paiement') {
$payment_type_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth'));
$valuetoshow = $payment_type_list[$valuetoshow];
} elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_input_reason') {
} elseif ($value == 'label' && $tabname[$id] == 'c_input_reason') {
$key = $langs->trans("DemandReasonType".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->{$value});
} elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_input_method') {
} elseif ($value == 'libelle' && $tabname[$id] == 'c_input_method') {
$langs->load("orders");
$key = $langs->trans($obj->code);
$valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->{$value};
} elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_shipment_mode') {
} elseif ($value == 'libelle' && $tabname[$id] == 'c_shipment_mode') {
$langs->load("sendings");
$key = $langs->trans("SendingMethod".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->{$value});
} elseif ($value == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_paper_format') {
} elseif ($value == 'libelle' && $tabname[$id] == 'c_paper_format') {
$key = $langs->trans('PaperFormat'.strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->{$value});
} elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees') {
} elseif ($value == 'label' && $tabname[$id] == 'c_type_fees') {
$langs->load('trips');
$key = $langs->trans(strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$value});
@ -2021,13 +2011,13 @@ if ($id) {
$showfield = 0;
} elseif ($value == 'unicode') {
$valuetoshow = $langs->getCurrencySymbol($obj->code, 1);
} elseif ($value == 'label' && $tabname[GETPOST("id", 'int')] == MAIN_DB_PREFIX.'c_units') {
} elseif ($value == 'label' && $tabname[GETPOST("id", 'int')] == 'c_units') {
$langs->load("products");
$valuetoshow = $langs->trans($obj->{$value});
} elseif ($value == 'short_label' && $tabname[GETPOST("id", 'int')] == MAIN_DB_PREFIX.'c_units') {
} elseif ($value == 'short_label' && $tabname[GETPOST("id", 'int')] == 'c_units') {
$langs->load("products");
$valuetoshow = $langs->trans($obj->{$value});
} elseif (($value == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')) {
} elseif (($value == 'unit') && ($tabname[$id] == 'c_paper_format')) {
$key = $langs->trans('SizeUnit'.strtolower($obj->unit));
$valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$value});
} elseif ($value == 'localtax1' || $value == 'localtax2') {
@ -2068,20 +2058,20 @@ if ($id) {
}
} elseif ($value == 'fk_c_exp_tax_cat') {
$tmpid = $valuetoshow;
$valuetoshow = getDictionaryValue(MAIN_DB_PREFIX.'c_exp_tax_cat', 'label', $tmpid);
$valuetoshow = getDictionaryValue('c_exp_tax_cat', 'label', $tmpid);
$valuetoshow = $langs->trans($valuetoshow ? $valuetoshow : $tmpid);
} elseif ($tabname[$id] == MAIN_DB_PREFIX.'c_exp_tax_cat') {
} elseif ($tabname[$id] == 'c_exp_tax_cat') {
$valuetoshow = $langs->trans($valuetoshow);
} elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_units') {
} elseif ($value == 'label' && $tabname[$id] == 'c_units') {
$langs->load('other');
$key = $langs->trans($obj->label);
$valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$value});
} elseif ($value == 'code' && $id == 3) {
$valuetoshow = $obj->state_code;
} elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_product_nature') {
} elseif ($value == 'label' && $tabname[$id] == 'c_product_nature') {
$langs->load("products");
$valuetoshow = $langs->trans($obj->{$value});
} elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_productbatch_qcstatus') {
} elseif ($fieldlist[$field] == 'label' && $tabname[$id] == 'c_productbatch_qcstatus') {
$langs->load("productbatch");
$valuetoshow = $langs->trans($obj->{$value});
} elseif ($value == 'block_if_negative') {
@ -2097,13 +2087,13 @@ if ($id) {
if ($value == 'tracking') {
$class .= ' tdoverflowauto';
}
if (in_array($value, array('pos', 'position'))) {
if (in_array($value, array('nbjour', 'decalage', 'pos', 'position', 'deposit_percent'))) {
$class .= ' right';
}
if (in_array($value, array('localtax1_type', 'localtax2_type'))) {
$class .= ' nowrap';
}
if (in_array($value, array('use_default', 'fk_parent'))) {
if (in_array($value, array('use_default', 'fk_parent', 'sortorder'))) {
$class .= ' center';
}
if ($value == 'public') {
@ -2147,7 +2137,7 @@ if ($id) {
if (!empty($obj->code) && $obj->code == 'RECEP') {
$canbemodified = 1;
}
if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm") {
if ($tabname[$id] == "c_actioncomm") {
$canbemodified = 1;
}
@ -2174,7 +2164,7 @@ if ($id) {
if ($iserasable) {
print '<a class="reposition" href="'.$url.'action='.$acts[$obj->eec].'_eec&token='.newToken().'">'.$actl[$obj->eec].'</a>';
} else {
print $langs->trans("AlwaysActive");
print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
}
print '</td>';
print '<td class="nowrap center">';
@ -2182,7 +2172,7 @@ if ($id) {
if ($iserasable) {
print '<a class="reposition" href="'.$url.'action='.$acts[$obj->favorite].'_favorite&token='.newToken().'">'.$actl[$obj->favorite].'</a>';
} else {
print $langs->trans("AlwaysActive");
print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
}
print '</td>';
}
@ -2199,7 +2189,7 @@ if ($id) {
} elseif (isset($obj->type) && in_array($obj->type, array('system')) && !empty($obj->active) && $obj->code != 'AC_OTH') {
print $langs->trans("UsedOnlyWithTypeOption");
} else {
print $langs->trans("AlwaysActive");
print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
}
}
print "</td>";
@ -2283,7 +2273,7 @@ if ($id) {
print '</a>';
print '</td>';
print '<td class="right">';
print $form->textwithpicto('', $langs->trans("Table").': '.$tabname[$i]);
print $form->textwithpicto('', $langs->trans("Table").': '.MAIN_DB_PREFIX.$tabname[$i]);
print '</td>';
print '</tr>';
$lastlineisempty = false;
@ -2333,7 +2323,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
continue;
}
if (in_array($value, array('code', 'libelle', 'type')) && $tabname == MAIN_DB_PREFIX."c_actioncomm" && in_array($obj->type, array('system', 'systemauto'))) {
if (in_array($value, array('code', 'libelle', 'type')) && $tabname == "c_actioncomm" && in_array($obj->type, array('system', 'systemauto'))) {
$hidden = (!empty($obj->{$value}) ? $obj->{$value}:'');
print '<td>';
print '<input type="hidden" name="'. $value .'" value="'.$hidden.'">';
@ -2369,15 +2359,9 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
print '<td>';
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'lang');
print '</td>';
} elseif ($value == 'element') {
// The type of the element (for contact types)
} elseif (in_array($value, array('element', 'source'))) { //Example: the type and source of the element (for contact types)
print '<td>';
print $form->selectarray('element', $elementList, (!empty($obj->{$value}) ? $obj->{$value}:''));
print '</td>';
} elseif ($value == 'source') {
// The source of the element (for contact types)
print '<td>';
print $form->selectarray('source', $sourceList, (!empty($obj->{$value}) ? $obj->{$value}:''));
print $form->selectarray($value, $elementList, (!empty($obj->{$value}) ? $obj->{$value}:''));
print '</td>';
} elseif (in_array($value, array('public', 'use_default'))) {
// Fields 0/1 with a combo select Yes/No
@ -2389,12 +2373,12 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
print '<td>';
print $form->selectyesno("private", (!empty($obj->{$value}) ? $obj->{$value}:''));
print '</td>';
} elseif ($value == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm") {
} elseif ($value == 'type' && $tabname == "c_actioncomm") {
$type = (!empty($obj->type) ? $obj->type : 'user'); // Check if type is different of 'user' (external module)
print '<td>';
print $type.'<input type="hidden" name="type" value="'.$type.'">';
print '</td>';
} elseif ($value == 'type' && $tabname == MAIN_DB_PREFIX.'c_paiement') {
} elseif ($value == 'type' && $tabname == 'c_paiement') {
print '<td>';
$select_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth'));
print $form->selectarray($value, $select_list, (!empty($obj->{$value}) ? $obj->{$value}:'2'));
@ -2412,7 +2396,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
}
print '</td>';
} elseif (in_array($value, array('nbjour', 'decalage', 'taux', 'localtax1', 'localtax2'))) {
$class = "left";
$class = "right";
if (in_array($value, array('taux', 'localtax1', 'localtax2'))) {
$class = "center"; // Fields aligned on right
}
@ -2424,7 +2408,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
$transfound = 0;
$transkey = '';
// Special case for labels
if ($tabname == MAIN_DB_PREFIX.'c_payment_term') {
if ($tabname == 'c_payment_term') {
$langs->load("bills");
$transkey = "PaymentCondition".strtoupper($obj->code);
if ($langs->trans($transkey) != $transkey) {
@ -2490,18 +2474,21 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
print '</td>';
} else {
$fieldValue = isset($obj->{$value}) ? $obj->{$value}: '';
$classtd = ''; $class = '';
if ($value == 'sortorder') {
$fieldlist[$field] = 'position';
}
$classtd = ''; $class = '';
if ($fieldlist[$field] == 'code') {
$class = 'maxwidth100';
}
if (in_array($fieldlist[$field], array('pos', 'position'))) {
if (in_array($fieldlist[$field], array('deposit_percent'))) {
$classtd = 'right'; $class = 'maxwidth50 right';
}
if (in_array($fieldlist[$field], array('pos', 'position'))) {
$classtd = 'center'; $class = 'maxwidth50 center';
}
if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'use_default', 'affect', 'delay', 'public', 'sortorder', 'sens', 'category_type', 'fk_parent'))) {
$class = 'maxwidth50 center';
}
@ -2522,19 +2509,19 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
$maxlength = '';
if (in_array($fieldlist[$field], array('libelle', 'label'))) {
switch ($tabname) {
case MAIN_DB_PREFIX . 'c_accounting_category':
case MAIN_DB_PREFIX . 'c_ecotaxe':
case MAIN_DB_PREFIX . 'c_email_senderprofile':
case MAIN_DB_PREFIX . 'c_forme_juridique':
case MAIN_DB_PREFIX . 'c_holiday_types':
case MAIN_DB_PREFIX . 'c_payment_term':
case MAIN_DB_PREFIX . 'c_transport_mode':
case 'c_accounting_category':
case 'c_ecotaxe':
case 'c_email_senderprofile':
case 'c_forme_juridique':
case 'c_holiday_types':
case 'c_payment_term':
case 'c_transport_mode':
$maxlength = ' maxlength="255"';
break;
case MAIN_DB_PREFIX . 'c_email_templates':
case 'c_email_templates':
$maxlength = ' maxlength="180"';
break;
case MAIN_DB_PREFIX . 'c_socialnetworks':
case 'c_socialnetworks':
$maxlength = ' maxlength="150"';
break;
default:
@ -2547,10 +2534,10 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
$transkey = '';
if (in_array($fieldlist[$field], array('label', 'libelle'))) { // For label
// Special case for labels
if ($tabname == MAIN_DB_PREFIX.'c_civility' && !empty($obj->code)) {
if ($tabname == 'c_civility' && !empty($obj->code)) {
$transkey = "Civility".strtoupper($obj->code);
}
if ($tabname == MAIN_DB_PREFIX.'c_payment_term' && !empty($obj->code)) {
if ($tabname == 'c_payment_term' && !empty($obj->code)) {
$langs->load("bills");
$transkey = "PaymentConditionShort".strtoupper($obj->code);
}

View File

@ -232,6 +232,9 @@ class PrestaShopWebservice
if ($response != '') {
libxml_clear_errors();
libxml_use_internal_errors(true);
if (!function_exists('simplexml_load_string')) {
throw new PrestaShopWebserviceException('Method simplexml_load_string not available. Your PHP does not support xml.');
}
$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
if (libxml_get_errors()) {
$msg = var_export(libxml_get_errors(), true);

View File

@ -428,15 +428,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$connectstringtarget = $connectstringserver.$object->getEncodedUtf7($targetdir);
}
$timeoutconnect = empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT;
$timeoutread = empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT;
$timeoutconnect = empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT;
$timeoutread = empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 20 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT;
dol_syslog("imap_open connectstring=".$connectstringsource." login=".$object->login." password=".$object->password." timeoutconnect=".$timeoutconnect." timeoutread=".$timeoutread);
imap_timeout(IMAP_OPENTIMEOUT, $timeoutconnect);
imap_timeout(IMAP_READTIMEOUT, $timeoutread);
$result1 = imap_timeout(IMAP_OPENTIMEOUT, $timeoutconnect); // timeout seems ignored with ssl connect
$result2 = imap_timeout(IMAP_READTIMEOUT, $timeoutread);
$result3 = imap_timeout(IMAP_WRITETIMEOUT, 5);
$result4 = imap_timeout(IMAP_CLOSETIMEOUT, 5);
dol_syslog("result1=".$result1." result2=".$result2." result3=".$result3." result4=".$result4);
$connection = imap_open($connectstringsource, $object->login, $object->password);
//dol_syslog("end imap_open connection=".var_export($connection, true));
} catch (Exception $e) {
print $e->getMessage();
}
@ -490,7 +496,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="div-table-responsive-no-min">';
print '<table id="tablelineoffilters" class="noborder margintable noshadow">';
print '<tr class="liste_titre nodrag nodrop">';
print '<td>'.img_picto('', 'filter', 'class="pictofixedwidth"').$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'</td><td></td><td></td>';
print '<td>'.img_picto('', 'filter', 'class="pictofixedwidth opacitymedium"').$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'</td><td></td><td></td>';
print '</tr>';
// Add filter
print '<tr class="oddeven nodrag nodrop">';
@ -647,7 +653,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp'));
}
print '</td>';
print '<td class="wordbreak minwidth300">';
print '<td class="wordbreak minwidth300 small">';
if ($action == 'editoperation' && $ruleaction['id'] == $operationid) {
print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>';
print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'">';

View File

@ -44,6 +44,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'emailcollectorlist'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$mode = GETPOST('mode', 'aZ');
$id = GETPOST('id', 'int');
@ -53,8 +54,9 @@ $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
// If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
}
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -74,7 +76,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) {
$sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
$sortfield = "t.ref"; // Set here default search field. By default 1st field in definition.
}
if (!$sortorder) {
$sortorder = "ASC";
@ -89,12 +91,16 @@ if ($user->socid > 0) { // Protection if external user
//$result = restrictedArea($user, 'emailcollector', $id, '');
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alphanohtml');
$search_all = GETPOST('search_all', 'alphanohtml');
$search = array();
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha') !== '') {
$search[$key] = GETPOST('search_'.$key, 'alpha');
}
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
}
}
// List of fields to search into when doing a "search in all"
@ -110,29 +116,19 @@ $arrayfields = array();
foreach ($object->fields as $key => $val) {
// If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) {
$visible = dol_eval($val['visible'], 1, 1, '1');
$visible = (int) dol_eval($val['visible'], 1);
$arrayfields['t.'.$key] = array(
'label'=>$val['label'],
'checked'=>(($visible < 0) ? 0 : 1),
'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
'position'=>$val['position']
'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
'position'=>$val['position'],
'help'=> isset($val['help']) ? $val['help'] : ''
);
}
}
// Extra fields
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array(
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]),
'langfile'=>$extrafields->attributes[$object->table_element]['langfile'][$key]
);
}
}
}
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
@ -157,7 +153,8 @@ if (empty($conf->emailcollector->enabled)) {
*/
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
$action = 'list';
$massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
@ -177,8 +174,12 @@ if (empty($reshook)) {
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
foreach ($object->fields as $key => $val) {
$search[$key] = '';
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
$search[$key.'_dtstart'] = '';
$search[$key.'_dtend'] = '';
}
}
$toselect = '';
$toselect = array();
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
@ -201,20 +202,22 @@ if (empty($reshook)) {
$form = new Form($db);
$now = dol_now();
$help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector"));
$morejs = array();
$morecss = array();
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ';
foreach ($object->fields as $key => $val) {
$sql .= "t.".$key.", ";
}
$sql .= $object->getFieldList('t');
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : '');
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
}
}
// Add fields from hooks
@ -232,18 +235,32 @@ if ($object->ismultientitymanaged == 1) {
$sql .= " WHERE 1 = 1";
}
foreach ($search as $key => $val) {
if ($key == 'status' && $search[$key] == -1) {
continue;
}
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
if ($search[$key] == '-1') {
$search[$key] = '';
if (array_key_exists($key, $object->fields)) {
if ($key == 'status' && $search[$key] == -1) {
continue;
}
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
$search[$key] = '';
}
$mode_search = 2;
}
if ($search[$key] != '') {
$sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
}
} else {
if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
$columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
if (preg_match('/_dtstart$/', $key)) {
$sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
}
if (preg_match('/_dtend$/', $key)) {
$sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
}
}
}
$mode_search = 2;
}
if ($search[$key] != '') {
$sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
}
}
if ($search_all) {
@ -258,49 +275,48 @@ $sql .= $hookmanager->resPrint;
/* If a group by is required
$sql.= " GROUP BY ";
foreach ($object->fields as $key => $val)
{
$sql .= "t.".$key.", ";
foreach ($object->fields as $key => $val) {
$sql .= "t.".$db->escape($key).", ";
}
// Add fields from extrafields
if (! empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
}
}
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql=preg_replace('/, $/','', $sql);
$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
*/
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
$page = 0;
$offset = 0;
}
}
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
$num = $nbtotalofrecords;
} else {
if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql);
if (!$resql) {
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
$db->free($resql);
}
// Complete request and execute it with limit
$sql .= $db->order($sortfield, $sortorder);
if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql);
if (!$resql) {
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
// Direct jump if only one record found
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
@ -314,7 +330,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
// Output page
// --------------------------------------------------------------------
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
$arrayofselected = is_array($toselect) ? $toselect : array();
@ -328,9 +344,11 @@ if ($limit > 0 && $limit != $conf->liste_limit) {
foreach ($search as $key => $val) {
if (is_array($search[$key]) && count($search[$key])) {
foreach ($search[$key] as $skey) {
$param .= '&search_'.$key.'[]='.urlencode($skey);
if ($skey != '') {
$param .= '&search_'.$key.'[]='.urlencode($skey);
}
}
} else {
} elseif ($search[$key] != '') {
$param .= '&search_'.$key.'='.urlencode($search[$key]);
}
}
@ -339,6 +357,10 @@ if ($optioncss != '') {
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// Add $param from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
$param .= $hookmanager->resPrint;
// List of mass actions available
$arrayofmassactions = array(
@ -353,7 +375,7 @@ if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'pr
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
@ -408,25 +430,43 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons('left');
print $searchpicto;
print '</td>';
}
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
} elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
} elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
} elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
print '<div class="nowrap">';
print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '</div>';
} elseif ($key == 'lang') {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
$formadmin = new FormAdmin($db);
print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
} else {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
}
print '</td>';
}
@ -439,39 +479,51 @@ $parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
}
print '</tr>'."\n";
$totalarray = array();
$totalarray['nbfield'] = 0;
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
}
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
$cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
if (!empty($arrayfields['t.'.$key]['checked'])) {
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
$totalarray['nbfield']++;
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
}
$totalarray['nbfield']++;
print '</tr>'."\n";
@ -489,8 +541,10 @@ if (isset($extrafields->attributes[$object->table_element]['computed']) && is_ar
// Loop on record
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
while ($i < ($limit ? min($num, $limit) : $num)) {
$savnbfield = $totalarray['nbfield'];
$totalarray['nbfield'] = 0;
$imaxinloop = ($limit ? min($num, $limit) : $num);
while ($i < $imaxinloop) {
$obj = $db->fetch_object($resql);
if (empty($obj)) {
break; // Should not happen
@ -499,73 +553,107 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
// Store properties in $object
$object->setVarsFromFetchObj($obj);
// Show here line of result
print '<tr class="oddeven">';
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
if ($mode == 'kanban') {
if ($i == 0) {
print '<tr><td colspan="'.$savnbfield.'">';
print '<div class="box-flex-container">';
}
if (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif ($key == 'ref') {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
// Output Kanban
print $object->getKanbanView('');
if ($i == ($imaxinloop - 1)) {
print '</div>';
print '</td></tr>';
}
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
if ($key == 'status') {
print $object->getLibStatut(5);
} else {
print $object->showOutputField($val, $key, $object->$key, '');
} else {
// Show here line of result
$j = 0;
print '<tr data-rowid="'.$object->id.'" class="oddeven">';
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
if (!isset($totalarray['val'])) {
$totalarray['val'] = array();
}
if (!isset($totalarray['val']['t.'.$key])) {
$totalarray['val']['t.'.$key] = 0;
}
$totalarray['val']['t.'.$key] += $object->$key;
}
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
}
print '</tr>'."\n";
if (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif ($key == 'ref') {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
}
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '');
if (preg_match('/tdoverflow/', $cssforfield)) {
print ' title="'.dol_escape_htmltag($object->$key).'"';
}
print '>';
if ($key == 'status') {
print $object->getLibStatut(5);
} elseif ($key == 'rowid') {
print $object->showOutputField($val, $key, $object->id, '');
} else {
print $object->showOutputField($val, $key, $object->$key, '');
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
if (!isset($totalarray['val'])) {
$totalarray['val'] = array();
}
if (!isset($totalarray['val']['t.'.$key])) {
$totalarray['val']['t.'.$key] = 0;
}
$totalarray['val']['t.'.$key] += $object->$key;
}
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
}
if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n";
}
$i++;
}
@ -582,7 +670,7 @@ if ($num == 0) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
@ -596,16 +684,18 @@ print '</table>'."\n";
print '</div>'."\n";
print load_fiche_titre($langs->trans("Other"), '', '');
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td></td>';
print '<td></td>';
print "</tr>\n";
// Hide e-mail headers from collected messages
print '<tr class="oddeven"><td>'.$langs->trans("EmailCollectorHideMailHeaders").'</td>';
print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("EmailCollectorHideMailHeaders"), $langs->transnoentitiesnoconv("EmailCollectorHideMailHeadersHelp")).'</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER');
@ -614,12 +704,13 @@ if ($conf->use_javascript_ajax) {
print $form->selectarray("MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND);
}
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("EmailCollectorHideMailHeadersHelp"), 1, 'help');
print '</td>';
print '</tr>';
print '</table><br>';
print '</table>';
print '</div>';
print '<br>';
print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {

View File

@ -220,7 +220,7 @@ if ($action == 'edit') {
foreach ($arrayofparameters as $constname => $val) {
if ($val['enabled']==1) {
$setupnotempty++;
print '<tr class="oddeven"><td>aa';
print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
$tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
@ -457,7 +457,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print '<td class="center">';
$constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $file) {
if (getDolGlobalString($constforvar) == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
@ -597,7 +597,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Default
print '<td class="center">';
$constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $name) {
if (getDolGlobalString($constforvar) == $name) {
//print img_picto($langs->trans("Default"), 'on');
// Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&amp;token='.newToken().'&amp;object='.urlencode(strtolower($myTmpObjectKey)).'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';

View File

@ -266,11 +266,11 @@ foreach ($rules as $rule) {
if ($rule->fk_c_type_fees == -1) {
echo $langs->trans('AllExpenseReport');
} else {
$key = getDictionaryValue(MAIN_DB_PREFIX . 'c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id');
$key = getDictionaryValue('c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id');
if ($key && $key != $langs->trans($key)) {
echo $langs->trans($key);
} else {
$value = getDictionaryValue(MAIN_DB_PREFIX . 'c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id');
$value = getDictionaryValue('c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id');
echo $langs->trans($value ? $value : 'Undefined'); // TODO check to return trans of 'code'
}
}

View File

@ -279,7 +279,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print '<td class="center">';
$constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $file) {
if (getDolGlobalString($constforvar) == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
@ -421,7 +421,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Default
print '<td class="center">';
$constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $name) {
if (getDolGlobalString($constforvar) == $name) {
//print img_picto($langs->trans("Default"), 'on');
// Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&amp;token='.newToken().'&amp;object='.urlencode(strtolower($myTmpObjectKey)).'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';

View File

@ -323,130 +323,6 @@ print '<br>';
clearstatcache();
if ($mode == 'template') {
// Themes and themes options
showSkins(null, 1);
}
if ($mode == 'dashboard') {
print '<div class="div-table-responsive-no-min">';
print '<table summary="blockdashboard" class="noborder centpercent editmode tableforfield">';
// Message of the day on home page
$substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'));
complete_substitutions_array($substitutionarray, $langs);
print '<tr class="oddeven width25p"><td>';
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted") . '<br>';
foreach ($substitutionarray as $key => $val) {
$texthelp .= $key . '<br>';
}
print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday');
print '</td><td>';
$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();
print '</td></tr>' . "\n";
/* no more need for this option. It is now a widget already controlled by end user
print '<tr class="oddeven"><td>' . $langs->trans('BoxstatsDisableGlobal') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_GLOBAL_BOXSTATS", array(), $conf->entity, 0, 0, 1, 0);
print '</td>';
print '</tr>';
*/
print '</table>';
print '</div>';
print '<br>';
print '<div class="div-table-responsive-no-min">';
print '<table summary="blockdashboard" class="noborder centpercent editmode tableforfield">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">';
print $langs->trans("DashboardDisableBlocks");
print '</td><td class="titlefieldmiddle">';
print '</td></tr>';
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableGlobal') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_GLOBAL_WORKBOARD", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
// Block meteo
print '<tr class="oddeven"><td>' . $langs->trans('MAIN_DISABLE_METEO') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_METEO", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block agenda
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockAgenda') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_AGENDA", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block agenda
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockProject') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_PROJECT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block customer
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockCustomer') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_CUSTOMER", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block supplier
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockSupplier') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_SUPPLIER", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block contract
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockContract') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_CONTRACT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block ticket
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockTicket') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_TICKET", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block bank
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockBank') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_BANK", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block adherent
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockAdherent') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_ADHERENT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block expense report
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockExpenseReport') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_EXPENSEREPORT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block holiday
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockHoliday') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_HOLIDAY", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
}
print '</table>' . "\n";
print '</div>';
}
if ($mode == 'other') {
print '<div class="div-table-responsive-no-min">';
print '<table summary="edit" class="noborder centpercent editmode tableforfield">';
@ -587,6 +463,133 @@ if ($mode == 'other') {
print '</div>';
}
if ($mode == 'template') {
// Themes and themes options
showSkins(null, 1);
}
if ($mode == 'dashboard') {
print '<div class="div-table-responsive-no-min">';
print '<table summary="blockdashboard" class="noborder centpercent editmode tableforfield">';
// Message of the day on home page
$substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'));
complete_substitutions_array($substitutionarray, $langs);
print '<tr class="oddeven width25p"><td>';
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted") . '<br>';
foreach ($substitutionarray as $key => $val) {
$texthelp .= $key . '<br>';
}
print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday');
print '</td><td>';
$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();
print '</td></tr>' . "\n";
/* no more need for this option. It is now a widget already controlled by end user
print '<tr class="oddeven"><td>' . $langs->trans('BoxstatsDisableGlobal') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_GLOBAL_BOXSTATS", array(), $conf->entity, 0, 0, 1, 0);
print '</td>';
print '</tr>';
*/
print '</table>';
print '</div>';
print '<br>';
print '<div class="div-table-responsive-no-min">';
print '<table summary="blockdashboard" class="noborder centpercent editmode tableforfield">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">';
print $langs->trans("DashboardDisableBlocks");
print '</td><td class="titlefieldmiddle">';
print '</td></tr>';
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableGlobal') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_GLOBAL_WORKBOARD", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
// Block meteo
print '<tr class="oddeven"><td>' . $langs->trans('MAIN_DISABLE_METEO') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_METEO", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block agenda
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockAgenda') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_AGENDA", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block agenda
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockProject') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_PROJECT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block customer
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockCustomer') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_CUSTOMER", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block supplier
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockSupplier') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_SUPPLIER", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block contract
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockContract') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_CONTRACT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block ticket
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockTicket') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_TICKET", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block bank
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockBank') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_BANK", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block adherent
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockAdherent') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_ADHERENT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block expense report
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockExpenseReport') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_EXPENSEREPORT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
// Block holiday
print '<tr class="oddeven"><td>' . $langs->trans('DashboardDisableBlockHoliday') . '</td><td>';
print ajax_constantonoff("MAIN_DISABLE_BLOCK_HOLIDAY", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard');
print '</td>';
print '</tr>';
}
print '</table>' . "\n";
print '</div>';
}
if ($mode == 'login') {
// Other
print '<div class="div-table-responsive-no-min">';

View File

@ -403,7 +403,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print '<td class="center">';
$constforvar = 'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $file) {
if (getDolGlobalString($constforvar) == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
@ -545,7 +545,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Default
print '<td class="center">';
$constforvar = 'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $name) {
if (getDolGlobalString($constforvar) == $name) {
//print img_picto($langs->trans("Default"), 'on');
// Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&amp;token='.newToken().'&amp;object='.urlencode(strtolower($myTmpObjectKey)).'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';

View File

@ -169,7 +169,7 @@ if (empty($reshook)) {
foreach ($object->fields as $key => $val) {
$search[$key] = '';
}
$toselect = '';
$toselect = array();
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')

View File

@ -66,10 +66,6 @@ $search_lang = GETPOST('search_lang', 'alpha');
$search_fk_user = GETPOST('search_fk_user', 'intcomma');
$search_topic = GETPOST('search_topic', 'alpha');
if (!empty($user->socid)) {
accessforbidden();
}
$acts = array();
$actl = array();
$acts[0] = "activate";
@ -100,6 +96,7 @@ if (empty($sortorder)) {
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('emailtemplates'));
// Name of SQL tables of dictionaries
$tabname = array();
$tabname[25] = MAIN_DB_PREFIX."c_email_templates";
@ -246,6 +243,12 @@ if ($reshook == 0) {
}
}
if (!empty($user->socid)) {
accessforbidden();
}
$permissiontoadd = 1;
//asort($elementList);
@ -273,6 +276,9 @@ if ($reshook < 0) {
}
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
// All tests are required to be compatible with all browsers
@ -281,7 +287,7 @@ if (empty($reshook)) {
$search_lang = '';
$search_fk_user = '';
$search_topic = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
}
@ -395,7 +401,7 @@ if (empty($reshook)) {
}
} elseif ($keycode == 'content') {
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
} elseif (in_array($keycode, array('joinfiles', 'private', 'position'))) {
} elseif (in_array($keycode, array('joinfiles', 'private', 'position', 'entity'))) {
$sql .= (int) GETPOST($keycode, 'int');
} else {
$sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
@ -502,9 +508,9 @@ if (empty($reshook)) {
if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
$rowidcol = "rowid";
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."=".((int) $rowid);
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
if (!$user->admin) { // A non admin user can only edit its own template
$sql .= " AND fk_user = ".((int) $user->id);
$sql .= " AND fk_user = ".((int) $user->id);
}
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
@ -548,47 +554,20 @@ if (empty($reshook)) {
*/
$form = new Form($db);
$now = dol_now();
$formadmin = new FormAdmin($db);
//$help_url = "EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
$help_url = '';
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
$title = $langs->trans("EMailsSetup");
} else {
$title = $langs->trans("EMailsTemplates");
$title = $langs->trans("EMailTemplates");
}
llxHeader('', $title, $help_url);
$linkback = '';
$titlepicto = 'title_setup';
$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=add';
$newcardbutton = dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
print load_fiche_titre($title, '', $titlepicto);
} else {
print load_fiche_titre($title, $newcardbutton, $titlepicto);
}
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
$head = email_admin_prepare_head();
print dol_get_fiche_head($head, 'templates', '', -1);
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
print load_fiche_titre('', $newcardbutton, '');
}
}
// Confirmation de la suppression de la ligne
if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
}
$morejs = array();
$morecss = array();
$sql = "SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, joinfiles, content_lines, content, enabled, active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_email_templates";
@ -623,6 +602,78 @@ $sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($listlimit + 1, $offset);
//print $sql;
// Output page
// --------------------------------------------------------------------
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
if (!empty($mode)) {
$param .= '&mode='.urlencode($mode);
}
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
foreach ($search as $key => $val) {
if (is_array($search[$key]) && count($search[$key])) {
foreach ($search[$key] as $skey) {
if ($skey != '') {
$param .= '&search_'.$key.'[]='.urlencode($skey);
}
}
} elseif ($search[$key] != '') {
$param .= '&search_'.$key.'='.urlencode($search[$key]);
}
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// Add $param from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
$param .= $hookmanager->resPrint;
$linkback = '';
$titlepicto = 'title_setup';
$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=add&token='.newToken();
$newcardbutton = dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
print load_fiche_titre($title, '', $titlepicto);
} else {
print load_fiche_titre($title, $newcardbutton, $titlepicto);
}
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
$head = email_admin_prepare_head();
print dol_get_fiche_head($head, 'templates', '', -1);
if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
print load_fiche_titre('', $newcardbutton, '');
}
}
// Confirmation de la suppression de la ligne
if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
}
$fieldlist = explode(',', $tabfield[$id]);
if ($action == 'add') {
@ -681,7 +732,7 @@ if ($action == 'add') {
}
if ($valuetoshow != '') {
print '<td class="'.$align.'">';
print '<th class="'.$align.'">';
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
print '<a href="'.$tabhelp[$id][$value].'" target="_blank" rel="noopener noreferrer">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
} elseif (!empty($tabhelp[$id][$value])) {
@ -693,12 +744,12 @@ if ($action == 'add') {
} else {
print $valuetoshow;
}
print '</td>';
print '</th>';
}
}
print '<td>';
print '<th>';
print '<input type="hidden" name="id" value="'.$id.'">';
print '</td>';
print '</th>';
print '</tr>';
$obj = new stdClass();
@ -742,7 +793,7 @@ if ($action == 'add') {
$fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines');
}
foreach ($fieldsforcontent as $tmpfieldlist) {
print '<tr class="impair nodrag nodrop nohover"><td colspan="6" class="nobottom">';
print '<tr class="impair nodrag nodrop nohover"><td colspan="7" class="nobottom">';
// Label
if ($tmpfieldlist == 'topic') {
@ -773,24 +824,33 @@ if ($action == 'add') {
print $doleditor->Create(1);
}
print '</td>';
if ($tmpfieldlist == 'topic') {
print '<td class="center" rowspan="'.(count($fieldsforcontent)).'">';
if ($action != 'edit') {
print '<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans("Add").'"><br>';
print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
}
print '</td>';
}
// else print '<td></td>';
print '</tr>';
}
print '</table>';
if ($action != 'edit') {
print '<center>';
print '<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans("Add").'"> ';
print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '</center>';
}
print '</div>';
print '</form>';
print '<br>';
print '<br><br>';
} // END IF not edit
// List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql = $db->query($sql);
if (!$resql) {
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
@ -798,157 +858,155 @@ print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('fro
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
// List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
$i = 0;
$param = '&id='.$id;
if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
if ($search_lang > 0) {
$param .= '&search_lang='.urlencode($search_lang);
}
if ($search_type_template != '-1') {
$param .= '&search_type_template='.urlencode($search_type_template);
}
if ($search_fk_user > 0) {
$param .= '&search_fk_user='.urlencode($search_fk_user);
}
if ($search_topic) {
$param .= '&search_topic='.urlencode($search_topic);
}
$param = '&id='.$id;
if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
if ($search_lang > 0) {
$param .= '&search_lang='.urlencode($search_lang);
}
if ($search_type_template != '-1') {
$param .= '&search_type_template='.urlencode($search_type_template);
}
if ($search_fk_user > 0) {
$param .= '&search_fk_user='.urlencode($search_fk_user);
}
if ($search_topic) {
$param .= '&search_topic='.urlencode($search_topic);
}
$paramwithsearch = $param;
if ($sortorder) {
$paramwithsearch .= '&sortorder='.urlencode($sortorder);
}
if ($sortfield) {
$paramwithsearch .= '&sortfield='.urlencode($sortfield);
}
if (GETPOST('from', 'alpha')) {
$paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha'));
}
$paramwithsearch = $param;
if ($sortorder) {
$paramwithsearch .= '&sortorder='.urlencode($sortorder);
}
if ($sortfield) {
$paramwithsearch .= '&sortfield='.urlencode($sortfield);
}
if (GETPOST('from', 'alpha')) {
$paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha'));
}
// There is several pages
if ($num > $listlimit) {
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>';
}
// There is several pages
if ($num > $listlimit) {
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>';
}
// Title line with search boxes
print '<tr class="liste_titre">';
// Title line with search boxes
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) {
if ($value == 'label') {
print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth200" value="'.dol_escape_htmltag($search_label).'"></td>';
} elseif ($value == 'lang') {
print '<td class="liste_titre">';
print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth150');
print '</td>';
} elseif ($value == 'fk_user') {
print '<td class="liste_titre">';
print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth150');
print '</td>';
} elseif ($value == 'topic') {
print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
} elseif ($value == 'type_template') {
print '<td class="liste_titre center">';
print $form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1);
print '</td>';
} elseif (!in_array($value, array('content', 'content_lines'))) {
print '<td class="liste_titre"></td>';
}
}
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) {
foreach ($fieldlist as $field => $value) {
if ($value == 'label') {
print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth200" value="'.dol_escape_htmltag($search_label).'"></td>';
} elseif ($value == 'lang') {
print '<td class="liste_titre">';
print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth150');
print '</td>';
} elseif ($value == 'fk_user') {
print '<td class="liste_titre">';
print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth150');
print '</td>';
} elseif ($value == 'topic') {
print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
} elseif ($value == 'type_template') {
print '<td class="liste_titre center">';
print $form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1);
print '</td>';
} elseif (!in_array($value, array('content', 'content_lines'))) {
print '<td class="liste_titre"></td>';
}
}
// Action column
print '<td class="liste_titre right" width="64">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) {
print '<td class="liste_titre"></td>';
}
// Title of lines
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) {
$showfield = 1; // By defaut
$align = "left";
$sortable = 1;
$valuetoshow = '';
$forcenowrap = 1;
/*
$tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield'];
$valuetoshow=$tmp['valuetoshow'];
$align=$tmp['align'];
$sortable=$tmp['sortable'];
*/
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field] == 'fk_user') {
$valuetoshow = $langs->trans("Owner");
}
if ($fieldlist[$field] == 'lang') {
$valuetoshow = $langs->trans("Language");
}
if ($fieldlist[$field] == 'type') {
$valuetoshow = $langs->trans("Type");
}
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Code");
}
if ($fieldlist[$field] == 'type_template') {
$align = 'center';
$valuetoshow = $langs->trans("TypeOfTemplate");
}
if ($fieldlist[$field] == 'private') {
$align = 'center';
}
if ($fieldlist[$field] == 'position') {
$align = 'center';
}
// Action column
print '<td class="liste_titre right" width="64">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
if ($fieldlist[$field] == 'joinfiles') {
$valuetoshow = $langs->trans("FilesAttachedToEmail"); $align = 'center'; $forcenowrap = 0;
}
if ($fieldlist[$field] == 'content') {
$valuetoshow = $langs->trans("Content"); $showfield = 0;
}
if ($fieldlist[$field] == 'content_lines') {
$valuetoshow = $langs->trans("ContentForLines"); $showfield = 0;
}
// Show fields
if ($showfield) {
if (!empty($tabhelp[$id][$value])) {
if (in_array($value, array('topic'))) {
$valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click
} else {
$valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover
}
}
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder);
}
// Title of lines
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) {
$showfield = 1; // By defaut
$align = "left";
$sortable = 1;
$valuetoshow = '';
$forcenowrap = 1;
/*
$tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield'];
$valuetoshow=$tmp['valuetoshow'];
$align=$tmp['align'];
$sortable=$tmp['sortable'];
*/
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field] == 'fk_user') {
$valuetoshow = $langs->trans("Owner");
}
if ($fieldlist[$field] == 'lang') {
$valuetoshow = $langs->trans("Language");
}
if ($fieldlist[$field] == 'type') {
$valuetoshow = $langs->trans("Type");
}
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Code");
}
if ($fieldlist[$field] == 'type_template') {
$align = 'center';
$valuetoshow = $langs->trans("TypeOfTemplate");
}
if ($fieldlist[$field] == 'private') {
$align = 'center';
}
if ($fieldlist[$field] == 'position') {
$align = 'center';
}
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList('');
print '</tr>';
if ($fieldlist[$field] == 'joinfiles') {
$valuetoshow = $langs->trans("FilesAttachedToEmail"); $align = 'center'; $forcenowrap = 0;
}
if ($fieldlist[$field] == 'content') {
$valuetoshow = $langs->trans("Content"); $showfield = 0;
}
if ($fieldlist[$field] == 'content_lines') {
$valuetoshow = $langs->trans("ContentForLines"); $showfield = 0;
}
if ($num) {
// Lines with values
while ($i < $num) {
$obj = $db->fetch_object($resql);
// Show fields
if ($showfield) {
if (!empty($tabhelp[$id][$value])) {
if (in_array($value, array('topic'))) {
$valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click
} else {
$valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover
}
}
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder);
}
}
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList('');
print '</tr>';
if ($num) {
$nbqualified = 0;
// Lines with values
while ($i < $num) {
$obj = $db->fetch_object($resql);
if ($obj) {
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
@ -1018,6 +1076,8 @@ if ($resql) {
}
print "</tr>\n";
$nbqualified++;
} else {
// If template is for a module, check module is enabled.
if ($obj->module) {
@ -1039,6 +1099,8 @@ if ($resql) {
continue; // Email template not qualified
}
$nbqualified++;
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
$tmpaction = 'view';
@ -1155,13 +1217,16 @@ if ($resql) {
print "</tr>\n";
}
$i++;
}
$i++;
}
} else {
dol_print_error($db);
}
// If no record found
if ($nbqualified == 0) {
$colspan = 10;
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
print '</table>';

View File

@ -172,6 +172,10 @@ foreach ($modulesdir as $dir) {
$moduleposition = '80'; // External modules at end by default
}
if (empty($familyinfo[$familykey]['position'])) {
$familyinfo[$familykey]['position'] = '0';
}
$orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number
$dirmod[$i] = $dir;
//print $i.'-'.$dirmod[$i].'<br>';
@ -250,19 +254,19 @@ if (!empty($conf->global->$const_name)) {
$text .= $langs->trans("Disabled");
}
$tmp = $objMod->getLastActivationInfo();
$authorid = $tmp['authorid'];
$authorid = (empty($tmp['authorid']) ? '' : $tmp['authorid']);
if ($authorid > 0) {
$tmpuser = new User($db);
$tmpuser->fetch($authorid);
$text .= '<br><span class="opacitymedium">'.$langs->trans("LastActivationAuthor").':</span> ';
$text .= $tmpuser->getNomUrl(1);
}
$ip = $tmp['ip'];
$ip = (empty($tmp['ip']) ? '' : $tmp['ip']);
if ($ip) {
$text .= '<br><span class="opacitymedium">'.$langs->trans("LastActivationIP").':</span> ';
$text .= $ip;
}
$lastactivationversion = $tmp['lastactivationversion'];
$lastactivationversion = (empty($tmp['lastactivationversion']) ? '' : $tmp['lastactivationversion']);
if ($lastactivationversion) {
$text .= '<br><span class="opacitymedium">'.$langs->trans("LastActivationVersion").':</span> ';
$text .= $lastactivationversion;

View File

@ -183,6 +183,22 @@ print "<td>".$name."</td>";
print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
print "</tr>";
$functions = ["easter_date"];
$name = "Calendar";
print "<tr>";
print "<td>".$name."</td>";
print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
print "</tr>";
$functions = ["simplexml_load_string"];
$name = "Xml";
print "<tr>";
print "<td>".$name."</td>";
print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
print "</tr>";
if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') {
$functions = ["locale_get_primary_language", "locale_get_region"];
$name = "Intl";

View File

@ -99,6 +99,50 @@ if ($action == 'updateMask') {
// par appel methode canBeActivated
dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'setvarworkflow') {
$param_auto_read = GETPOST('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', $param_auto_read, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
if (GETPOSTISSET('product_category_id')) {
$param_ticket_product_category = GETPOST('product_category_id', 'int');
$res = dolibarr_set_const($db, 'TICKET_PRODUCT_CATEGORY', $param_ticket_product_category, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
}
$param_delay_first_response = GETPOST('delay_first_response', 'int');
$res = dolibarr_set_const($db, 'TICKET_DELAY_BEFORE_FIRST_RESPONSE', $param_delay_first_response, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$param_delay_between_responses = GETPOST('delay_between_responses', 'int');
$res = dolibarr_set_const($db, 'TICKET_DELAY_SINCE_LAST_RESPONSE', $param_delay_between_responses, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$param_auto_notify_close = GETPOST('TICKET_NOTIFY_AT_CLOSING', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_NOTIFY_AT_CLOSING', $param_auto_notify_close, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
} elseif ($action == 'setvar') {
include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
@ -146,50 +190,6 @@ if ($action == 'updateMask') {
if (!($res > 0)) {
$error++;
}
}
if ($action == 'setvarworkflow') {
$param_auto_read = GETPOST('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', $param_auto_read, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
}
if ($action == 'setvarworkflowother' || $action == 'setvarworkflow') {
$param_ticket_product_category = GETPOST('product_category_id', 'int');
$res = dolibarr_set_const($db, 'TICKET_PRODUCT_CATEGORY', $param_ticket_product_category, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
}
if ($action == 'setvarother') {
$param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$param_disable_email = GETPOST('TICKET_DISABLE_NOTIFICATION_MAILS', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_DISABLE_NOTIFICATION_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
$param_show_module_logo = GETPOST('TICKET_SHOW_MODULE_LOGO', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
$param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
@ -198,34 +198,9 @@ if ($action == 'setvarother') {
$error++;
}
}
$param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$param_delay_first_response = GETPOST('delay_first_response', 'int');
$res = dolibarr_set_const($db, 'TICKET_DELAY_BEFORE_FIRST_RESPONSE', $param_delay_first_response, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$param_delay_between_responses = GETPOST('delay_between_responses', 'int');
$res = dolibarr_set_const($db, 'TICKET_DELAY_SINCE_LAST_RESPONSE', $param_delay_between_responses, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$param_auto_notify_close = GETPOST('TICKET_NOTIFY_AT_CLOSING', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_NOTIFY_AT_CLOSING', $param_auto_notify_close, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
}
/*
* View
*/
@ -384,8 +359,8 @@ if ($resql) {
print '<div class="div-table-responsive-no-min">';
print "<table class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n";
print '<table class="noborder cenpercent">'."\n";
print '<tr class="liste_titre">'."\n";
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
@ -502,13 +477,14 @@ foreach ($dirmodels as $reldir) {
print '</table>';
print '</div><br>';
if (empty($conf->use_javascript_ajax)) {
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvarworkflow">';
}
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvarworkflow">';
print '<input type="hidden" name="page_y" value="">';
print load_fiche_titre($langs->trans("Other"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
@ -563,34 +539,24 @@ print $formcategory->textwithpicto('', $langs->trans("TicketsAutoNotifyCloseHelp
print '</td>';
print '</tr>';
// Choose which product category is used for tickets
if ($conf->use_javascript_ajax) {
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvarworkflowother">';
if (! empty($conf->product->enabled)) {
print '<tr class="oddeven"><td>'.$langs->trans("TicketChooseProductCategory").'</td>';
print '<td class="left">';
$formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id');
if ($conf->use_javascript_ajax) {
print ajax_combobox('select_'.$htmlname);
}
print '</td>';
print '<td class="center">';
print $formcategory->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help');
print '</td>';
print '</tr>';
}
print '<tr class="oddeven"><td>'.$langs->trans("TicketChooseProductCategory").'</td>';
print '<td class="left">';
$formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id');
if ($conf->use_javascript_ajax) {
print ajax_combobox('select_'.$htmlname);
}
print '</td>';
print '<td class="center">';
print $formcategory->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help');
print '</td>';
print '</tr>';
// Define wanted maximum time elapsed before answers to tickets
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="action" value="setvarother">';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("TicketsDelayBeforeFirstAnswer")."</td>";
print '<td class="left">
<input type="number" value="'.$conf->global->TICKET_DELAY_BEFORE_FIRST_RESPONSE.'" name="delay_first_response">
<input type="submit" class="button small" value="'.$langs->trans("Save").'">
<input type="number" value="'.$conf->global->TICKET_DELAY_BEFORE_FIRST_RESPONSE.'" name="delay_first_response" class="width50">
</td>';
print '<td class="center">';
print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help');
@ -600,8 +566,7 @@ print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("TicketsDelayBetweenAnswers")."</td>";
print '<td class="left">
<input type="number" value="'.$conf->global->TICKET_DELAY_SINCE_LAST_RESPONSE.'" name="delay_between_responses">
<input type="submit" class="button small" value="'.$langs->trans("Save").'">
<input type="number" value="'.$conf->global->TICKET_DELAY_SINCE_LAST_RESPONSE.'" name="delay_between_responses" class="width50">
</td>';
print '<td class="center">';
print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help');
@ -610,9 +575,7 @@ print '</tr>';
print '</table><br>';
print '<div class="center">';
print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">';
print '</div>';
print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition');
print '</form>';
@ -622,9 +585,10 @@ print load_fiche_titre($langs->trans("Notification"), '', '');
print '<table class="noborder centpercent">';
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvar">';
print '<input type="hidden" name="page_y" value="">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("Email").'</td>';
@ -699,7 +663,7 @@ print '</td></tr>';
print '</table>';
print $formcategory->buttonsSaveCancel("Save", '');
print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition');
print '</form>';

View File

@ -61,7 +61,11 @@ $version = '0.0';
if ($action == 'getlastversion') {
$result = getURLContent('https://sourceforge.net/projects/dolibarr/rss');
//var_dump($result['content']);
$sfurl = simplexml_load_string($result['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
if (function_exists('simplexml_load_string')) {
$sfurl = simplexml_load_string($result['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
} else {
$sfurl = 'xml_not_available';
}
}
@ -82,7 +86,10 @@ if (function_exists('curl_init')) {
$conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10;
if ($action == 'getlastversion') {
if ($sfurl) {
if ($sfurl == 'xml_not_available') {
$langs->load("errors");
print $langs->trans("LastStableVersion").' : <b class="error">'.$langs->trans("ErrorFunctionNotAvailableInPHP", 'simplexml_load_string').'</b><br>';
} elseif ($sfurl) {
$i = 0;
while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) {
$title = $sfurl->channel[0]->item[$i]->title;

View File

@ -90,7 +90,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$transkey = '';
$transvalue = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
}

View File

@ -295,7 +295,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print '<td class="center">';
$constforvar = 'WORKSTATION_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $file) {
if (getDolGlobalString($constforvar) == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
@ -437,7 +437,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Default
print '<td class="center">';
$constforvar = 'WORKSTATION_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $name) {
if (getDolGlobalString($constforvar) == $name) {
print img_picto($langs->trans("Default"), 'on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';

View File

@ -266,7 +266,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print '<td class="center">';
$constforvar = 'ASSET_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $file) {
if (getDolGlobalString($constforvar) == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
@ -408,7 +408,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Default
print '<td class="center">';
$constforvar = 'ASSET_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $name) {
if (getDolGlobalString($constforvar) == $name) {
//print img_picto($langs->trans("Default"), 'on');
// Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&token='.newToken().'&object='.urlencode(strtolower($myTmpObjectKey)).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';

View File

@ -286,7 +286,7 @@ if ($conf->product->enabled || $conf->product->service) {
print '<input type="submit" class="button" name="submitformbarcodeproductgen" id="submitformbarcodeproductgen" value="'.$langs->trans("InitEmptyBarCode", min($maxperinit, $nbno)).'"'.$moretags1.'>';
$moretags2 = (($nbno == $nbtotal) ? ' disabled' : '');
print ' &nbsp; ';
print '<input type="submit" class="button" name="eraseallbarcode" id="eraseallbarcode" value="'.$langs->trans("EraseAllCurrentBarCode").'"'.$moretags2.' onClick="return confirm_erase();">';
print '<input type="submit" class="button butActionDelete" name="eraseallbarcode" id="eraseallbarcode" value="'.$langs->trans("EraseAllCurrentBarCode").'"'.$moretags2.' onClick="return confirm_erase();">';
print '<br><br><br><br>';
}

View File

@ -118,7 +118,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_ref = '';
$search_amount = '';
$search_showonlyerrors = 0;
$toselect = '';
$toselect = array();
$search_array_options = array();
}

View File

@ -734,9 +734,9 @@ if ($type == Categorie::TYPE_MEMBER) {
print '<input type="hidden" name="action" value="addintocategory">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>';
print $langs->trans("AddMemberIntoCategory").' &nbsp;';
print $langs->trans("AssignCategoryTo").' &nbsp;';
print $form->selectMembers('', 'elemid');
print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
print '<input type="submit" class="button buttongen" value="'.$langs->trans("Save").'"></td>';
print '</tr>';
print '</table>';
print '</form>';

View File

@ -217,7 +217,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$dateend_dtstart = '';
$dateend_dtend = '';
$search_status = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
}

View File

@ -173,7 +173,7 @@ if (empty($reshook)) {
// terms of the settlement
if ($action == 'setconditions' && $user->rights->societe->creer) {
$object->fetch($id);
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'), GETPOST('cond_reglement_id_deposit_percent', 'alpha'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
@ -415,9 +415,9 @@ if ($object->id > 0) {
print '</tr></table>';
print '</td><td>';
if ($action == 'editconditions') {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1);
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1, '', 1, $object->deposit_percent);
} else {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'none');
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'none', 0, '', 1, $object->deposit_percent);
}
print "</td>";
print '</tr>';

View File

@ -103,7 +103,7 @@ if (empty($reshook)) {
}*/
$search_ref = '';
$search_all = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')

View File

@ -402,6 +402,7 @@ if (empty($reshook)) {
$object->warehouse_id = GETPOST('warehouse_id', 'int');
$object->duree_validite = $duration;
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'alpha');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU', 2); // deprecated
@ -434,6 +435,7 @@ if (empty($reshook)) {
$object->warehouse_id = GETPOST('warehouse_id', 'int');
$object->duree_validite = price2num(GETPOST('duree_validite', 'alpha'));
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
$object->deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'alpha');
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
$object->fk_account = GETPOST('fk_account', 'int');
$object->contact_id = GETPOST('contactid', 'int');
@ -687,10 +689,62 @@ if (empty($reshook)) {
$error++;
}
$deposit = null;
$locationTarget = '';
$deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id);
if (
!$error && GETPOST('statut', 'int') == $object::STATUS_SIGNED && GETPOST('generate_deposit', 'alpha') == 'on'
&& ! empty($deposit_percent_from_payment_terms) && ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer)
) {
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
$date = dol_mktime(0, 0, 0, GETPOST('datefmonth', 'int'), GETPOST('datefday', 'int'), GETPOST('datefyear', 'int'));
$forceFields = array();
if (GETPOSTISSET('date_pointoftax')) {
$forceFields['date_pointoftax'] = dol_mktime(0, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'));
}
$deposit = Facture::createDepositFromOrigin($object, $date, GETPOST('cond_reglement_id', 'int'), $user, 0, GETPOST('validate_generated_deposit', 'alpha') == 'on', $forceFields);
if ($deposit) {
setEventMessage('DepositGenerated');
$locationTarget = DOL_URL_ROOT . '/compta/facture/card.php?id=' . $deposit->id;
} else {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
if (!$error) {
$db->commit();
if ($deposit && empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$ret = $deposit->fetch($deposit->id); // Reload to get new records
$outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS) {
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($deposit->thirdparty->default_lang);
$outputlangs->load('products');
}
$result = $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) {
setEventMessages($deposit->error, $deposit->errors, 'errors');
}
}
if ($locationTarget) {
header('Location: ' . $locationTarget);
exit;
}
} else {
$db->rollback();
$action = '';
}
}
}
@ -831,6 +885,13 @@ if (empty($reshook)) {
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) {
// Define vat_rate
$remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0);
$remise_percent = str_replace('*', '', $remise_percent);
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && $usercancreate) { // Add line
// Set if we used free entry or predefined product
$predef = '';
@ -1363,7 +1424,7 @@ if (empty($reshook)) {
$result = $object->set_demand_reason($user, GETPOST('demand_reason_id', 'int'));
} elseif ($action == 'setconditions' && $usercancreate) {
// Terms of payment
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'), GETPOST('cond_reglement_id_deposit_percent', 'alpha'));
} elseif ($action == 'setremisepercent' && $usercancreate) {
$result = $object->set_remise_percent($user, price2num(GETPOST('remise_percent'), '', 2));
} elseif ($action == 'setremiseabsolue' && $usercancreate) {
@ -1579,19 +1640,19 @@ if ($action == 'create') {
print '<table class="border centpercent">';
// Reference
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td>'.$langs->trans("Draft").'</td></tr>';
print '<tr class="field_ref"><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td class="valuefieldcreate">'.$langs->trans("Draft").'</td></tr>';
// Ref customer
print '<tr><td>'.$langs->trans('RefCustomer').'</td><td>';
print '<tr class="field_ref_client"><td class="titlefieldcreate">'.$langs->trans('RefCustomer').'</td><td class="valuefieldcreate">';
print '<input type="text" name="ref_client" value="'.GETPOST('ref_client').'"></td>';
print '</tr>';
// Third party
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('Customer').'</td>';
print '<tr class="field_socid">';
print '<td class="titlefieldcreate fieldrequired">'.$langs->trans('Customer').'</td>';
$shipping_method_id = 0;
if ($socid > 0) {
print '<td>';
print '<td class="valuefieldcreate">';
print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
print '</td>';
@ -1600,7 +1661,7 @@ if ($action == 'create') {
}
//$warehouse_id = $soc->warehouse_id;
} else {
print '<td>';
print '<td class="valuefieldcreate">';
print img_picto('', 'company').$form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx');
// reload page to retrieve customer informations
if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) {
@ -1623,13 +1684,13 @@ if ($action == 'create') {
if ($socid > 0) {
// Contacts (ask contact only if thirdparty already defined).
print "<tr><td>".$langs->trans("DefaultContact").'</td><td>';
print '<tr class="field_contactid"><td class="titlefieldcreate">'.$langs->trans("DefaultContact").'</td><td class="valuefieldcreate">';
print img_picto('', 'contact');
print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, '', '', 0, 'minwidth300');
print '</td></tr>';
// Third party discounts info line
print '<tr><td>'.$langs->trans('Discounts').'</td><td>';
print '<tr class="field_discount_info"><td class="titlefieldcreate">'.$langs->trans('Discounts').'</td><td class="valuefieldcreate">';
$absolute_discount = $soc->getAvailableDiscounts();
@ -1641,44 +1702,44 @@ if ($action == 'create') {
}
// Date
print '<tr><td class="fieldrequired">'.$langs->trans('DatePropal').'</td><td>';
print '<tr class="field_addprop"><td class="titlefieldcreate fieldrequired">'.$langs->trans('DatePropal').'</td><td class="valuefieldcreate">';
print $form->selectDate('', '', '', '', '', "addprop", 1, 1);
print '</td></tr>';
// Validaty duration
print '<tr><td class="fieldrequired">'.$langs->trans("ValidityDuration").'</td><td>'.img_picto('', 'clock', 'class="paddingright"').'<input name="duree_validite" class="width50" value="'.(GETPOSTISSET('duree_validite') ? GETPOST('duree_validite', 'alphanohtml') : $conf->global->PROPALE_VALIDITY_DURATION).'"> '.$langs->trans("days").'</td></tr>';
print '<tr class="field_duree_validitee"><td class="titlefieldcreate fieldrequired">'.$langs->trans("ValidityDuration").'</td><td class="valuefieldcreate">'.img_picto('', 'clock', 'class="paddingright"').'<input name="duree_validite" class="width50" value="'.(GETPOSTISSET('duree_validite') ? GETPOST('duree_validite', 'alphanohtml') : $conf->global->PROPALE_VALIDITY_DURATION).'"> '.$langs->trans("days").'</td></tr>';
// Terms of payment
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
print img_picto('', 'payment', 'class="pictofixedwidth"');
$form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id') != 0) ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1);
print '<tr class="field_cond_reglement_id"><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
print img_picto('', 'paiment');
$form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id') != 0) ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', (GETPOSTISSET('cond_reglement_id_deposit_percent') ? GETPOST('cond_reglement_id_deposit_percent', 'alpha') : $soc->deposit_percent));
print '</td></tr>';
// Mode of payment
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
print '<tr class="field_mode_reglement_id"><td class="titlefieldcreate">'.$langs->trans('PaymentMode').'</td><td class="valuefieldcreate">';
print img_picto('', 'bank', 'class="pictofixedwidth"');
$form->select_types_paiements((GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $soc->mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
// Bank Account
if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) {
print '<tr><td>'.$langs->trans('BankAccount').'</td><td>';
print '<tr class="field_fk_account"><td class="titlefieldcreate">'.$langs->trans('BankAccount').'</td><td class="valuefieldcreate">';
print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes($soc->fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1);
print '</td></tr>';
}
// Source / Channel - What trigger creation
print '<tr><td>'.$langs->trans('Source').'</td><td>';
print '<tr class="field_demand_reason_id"><td class="titlefieldcreate">'.$langs->trans('Source').'</td><td class="valuefieldcreate">';
print img_picto('', 'question', 'class="pictofixedwidth"');
$form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
// Delivery delay
print '<tr class="fielddeliverydelay"><td>'.$langs->trans('AvailabilityPeriod');
print '<tr class="field_availability_id"><td class="titlefieldcreate">'.$langs->trans('AvailabilityPeriod');
if (!empty($conf->commande->enabled)) {
print ' ('.$langs->trans('AfterOrder').')';
}
print '</td><td>';
print '</td><td class="valuefieldcreate">';
print img_picto('', 'clock', 'class="pictofixedwidth"');
$form->selectAvailabilityDelay('', 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
@ -1688,7 +1749,7 @@ if ($action == 'create') {
if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) {
$shipping_method_id = $soc->shipping_method_id;
}
print '<tr><td>'.$langs->trans('SendingMethod').'</td><td>';
print '<tr class="field_shipping_method_id"><td class="titlefieldcreate">'.$langs->trans('SendingMethod').'</td><td class="valuefieldcreate">';
print img_picto('', 'object_dollyrevert', 'class="pictofixedwidth"');
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
@ -1698,14 +1759,14 @@ if ($action == 'create') {
if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
print '<tr><td>'.$langs->trans('Warehouse').'</td><td>';
print '<tr class="field_warehouse_id"><td class="titlefieldcreate">'.$langs->trans('Warehouse').'</td><td class="valuefieldcreate">';
print img_picto('', 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx');
print '</td></tr>';
}
// Delivery date (or manufacturing)
print '<tr><td>'.$langs->trans("DeliveryDate").'</td>';
print '<td>';
print '<tr class="field_date_livraison"><td class="titlefieldcreate">'.$langs->trans("DeliveryDate").'</td>';
print '<td class="valuefieldcreate">';
if (isset($conf->global->DATE_LIVRAISON_WEEK_DELAY) && is_numeric($conf->global->DATE_LIVRAISON_WEEK_DELAY)) {
$tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
$syear = date("Y", $tmpdte);
@ -1720,8 +1781,8 @@ if ($action == 'create') {
// Project
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
print '<tr>';
print '<td>'.$langs->trans("Project").'</td><td>';
print '<tr class="field_projectid">';
print '<td class="titlefieldcreate">'.$langs->trans("Project").'</td><td class="valuefieldcreate">';
print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx');
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddProject").'"></span></a>';
print '</td>';
@ -1730,17 +1791,17 @@ if ($action == 'create') {
// Incoterms
if (!empty($conf->incoterm->enabled)) {
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->label_incoterms, 1).'</label></td>';
print '<td class="maxwidthonsmartphone">';
print '<tr class="field_incoterm_id">';
print '<td class="titlefieldcreate"><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->label_incoterms, 1).'</label></td>';
print '<td class="valuefieldcreate maxwidthonsmartphone">';
print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms) ? $soc->location_incoterms : ''));
print '</td></tr>';
}
// Template to use by default
print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td>';
print '<tr class="field_model">';
print '<td class="titlefieldcreate">'.$langs->trans("DefaultModel").'</td>';
print '<td class="valuefieldcreate">';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
$liste = ModelePDFPropales::liste_modeles($db);
$preselected = (!empty($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT) ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : getDolGlobalString("PROPALE_ADDON_PDF"));
@ -1749,26 +1810,26 @@ if ($action == 'create') {
// Multicurrency
if (!empty($conf->multicurrency->enabled)) {
print '<tr>';
print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>';
print '<td class="maxwidthonsmartphone">';
print '<tr class="field_currency">';
print '<td class="titlefieldcreate">'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>';
print '<td class="valuefieldcreate maxwidthonsmartphone">';
print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
print '</td></tr>';
}
// Public note
print '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td valign="top">';
print '<tr class="field_note_public">';
print '<td class="titlefieldcreate tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td class="valuefieldcreate">';
$note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc) ? $objectsrc->note_public : null));
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
// Private note
if (empty($user->socid)) {
print '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top">';
print '<tr class="field_note_private">';
print '<td class="titlefieldcreate tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td class="valuefieldcreate">';
$note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private : null));
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
@ -1938,6 +1999,129 @@ if ($action == 'create') {
array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace)
);
$deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id);
if (! empty($deposit_percent_from_payment_terms) && ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer)) {
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
$object->fetchObjectLinked();
$eligibleForDepositGeneration = true;
if (array_key_exists('facture', $object->linkedObjects)) {
foreach ($object->linkedObjects['facture'] as $invoice) {
if ($invoice->type == Facture::TYPE_DEPOSIT) {
$eligibleForDepositGeneration = false;
break;
}
}
}
if ($eligibleForDepositGeneration && array_key_exists('commande', $object->linkedObjects)) {
foreach ($object->linkedObjects['commande'] as $order) {
$order->fetchObjectLinked();
if (array_key_exists('facture', $order->linkedObjects)) {
foreach ($order->linkedObjects['facture'] as $invoice) {
if ($invoice->type == Facture::TYPE_DEPOSIT) {
$eligibleForDepositGeneration = false;
break 2;
}
}
}
}
}
if ($eligibleForDepositGeneration) {
$formquestion[] = array(
'type' => 'checkbox',
'tdclass' => 'showonlyifsigned',
'name' => 'generate_deposit',
'label' => $form->textwithpicto($langs->trans('GenerateDeposit', $object->deposit_percent), $langs->trans('DepositGenerationPermittedByThePaymentTermsSelected'))
);
$formquestion[] = array(
'type' => 'date',
'tdclass' => 'fieldrequired showonlyifgeneratedeposit',
'name' => 'datef',
'label' => $langs->trans('DateInvoice'),
'value' => dol_now(),
'datenow' => true
);
if (! empty($conf->global->INVOICE_POINTOFTAX_DATE)) {
$formquestion[] = array(
'type' => 'date',
'tdclass' => 'fieldrequired showonlyifgeneratedeposit',
'name' => 'date_pointoftax',
'label' => $langs->trans('DatePointOfTax'),
'value' => dol_now(),
'datenow' => true
);
}
ob_start();
$form->select_conditions_paiements(0, 'cond_reglement_id', -1, 0, 0, 'minwidth200');
$paymentTermsSelect = ob_get_clean();
$formquestion[] = array(
'type' => 'other',
'tdclass' => 'fieldrequired showonlyifgeneratedeposit',
'name' => 'cond_reglement_id',
'label' => $langs->trans('PaymentTerm'),
'value' => $paymentTermsSelect
);
$formquestion[] = array(
'type' => 'checkbox',
'tdclass' => 'showonlyifgeneratedeposit',
'name' => 'validate_generated_deposit',
'label' => $langs->trans('ValidateGeneratedDeposit')
);
$formquestion[] = array(
'type' => 'onecolumn',
'value' => '
<script>
let signedValue = ' . $object::STATUS_SIGNED . ';
$(document).ready(function() {
$("[name=generate_deposit]").change(function () {
let $self = $(this);
let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
$target.show();
} else {
$target.hide();
}
return true;
});
$("#statut").change(function() {
let $target = $(".showonlyifsigned").parent(".tagtr");
if ($(this).val() == signedValue) {
$target.show();
} else {
$target.hide();
}
$("[name=generate_deposit]").trigger("change");
return true;
});
$("#statut").trigger("change");
});
</script>
'
);
}
}
if (!empty($conf->notification->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
$notify = new Notify($db);
@ -2164,17 +2348,17 @@ if ($action == 'create') {
print '</tr></table>';
print '</td><td class="valuefield">';
if ($action == 'editconditions' && $usercancreate && $caneditfield) {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id');
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 0, '', 1, $object->deposit_percent);
} else {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none');
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 0, '', 1, $object->deposit_percent);
}
print '</td>';
print '</tr>';
// Payment mode
print '<tr>';
print '<td class="valuefield">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<tr class="field_mode_reglement_id">';
print '<td class="titlefieldcreate">';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($action != 'editmode' && $usercancreate && $caneditfield) {
@ -2193,7 +2377,7 @@ if ($action == 'create') {
$langs->load('deliveries');
print '<tr><td>';
print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker');
print '</td><td class="valuefield">';
print '</td><td class="valuefieldedit">';
print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker');
print '</td>';
print '</tr>';
@ -2224,7 +2408,7 @@ if ($action == 'create') {
// Shipping Method
if (!empty($conf->expedition->enabled)) {
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('SendingMethod');
print '</td>';
if ($action != 'editshippingmethod' && $usercancreate && $caneditfield) {
@ -2246,7 +2430,7 @@ if ($action == 'create') {
$langs->load('stocks');
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
print '<tr><td>';
print '<tr class="field_warehouse_id"><td class="titlefieldcreate">';
$editenable = $usercancreate;
print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable);
print '</td><td class="valuefieldcreate">';
@ -2261,7 +2445,7 @@ if ($action == 'create') {
// Origin of demand
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('Source');
print '</td>';
if ($action != 'editdemandreason' && $usercancreate) {

View File

@ -206,6 +206,7 @@ class Propal extends CommonObject
public $total;
public $cond_reglement_code;
public $deposit_percent;
public $mode_reglement_code;
public $remise_percent;
@ -319,6 +320,7 @@ class Propal extends CommonObject
'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>1, 'visible'=>-1, 'position'=>150),
'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'Currency', 'enabled'=>1, 'visible'=>-1, 'position'=>155),
'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>160),
'deposit_percent' =>array('type'=>'varchar(63)', 'label'=>'DepositPercent', 'enabled'=>1, 'visible'=>-1, 'position'=>161),
'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'PaymentMode', 'enabled'=>1, 'visible'=>-1, 'position'=>165),
'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>170),
'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>175),
@ -1100,6 +1102,7 @@ class Propal extends CommonObject
$sql .= ", model_pdf";
$sql .= ", fin_validite";
$sql .= ", fk_cond_reglement";
$sql .= ", deposit_percent";
$sql .= ", fk_mode_reglement";
$sql .= ", fk_account";
$sql .= ", ref_client";
@ -1133,6 +1136,7 @@ class Propal extends CommonObject
$sql .= ", '".$this->db->escape($this->model_pdf)."'";
$sql .= ", ".($this->fin_validite != '' ? "'".$this->db->idate($this->fin_validite)."'" : "NULL");
$sql .= ", ".($this->cond_reglement_id > 0 ? ((int) $this->cond_reglement_id) : 'NULL');
$sql .= ", ".(! empty($this->deposit_percent) ? "'".$this->db->escape($this->deposit_percent)."'" : 'NULL');
$sql .= ", ".($this->mode_reglement_id > 0 ? ((int) $this->mode_reglement_id) : 'NULL');
$sql .= ", ".($this->fk_account > 0 ? ((int) $this->fk_account) : 'NULL');
$sql .= ", '".$this->db->escape($this->ref_client)."'";
@ -1360,6 +1364,7 @@ class Propal extends CommonObject
if ($objsoc->fetch($socid) > 0) {
$object->socid = $objsoc->id;
$object->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
$object->deposit_percent = (!empty($objsoc->deposit_percent) ? $objsoc->deposit_percent : null);
$object->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
$object->fk_delivery_address = '';
@ -1536,7 +1541,7 @@ class Propal extends CommonObject
$sql .= ", c.label as statut_label";
$sql .= ", ca.code as availability_code, ca.label as availability";
$sql .= ", dr.code as demand_reason_code, dr.label as demand_reason";
$sql .= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc";
$sql .= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc, p.deposit_percent";
$sql .= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_propalst as c ON p.fk_statut = c.id';
@ -1619,6 +1624,7 @@ class Propal extends CommonObject
$this->cond_reglement_code = $obj->cond_reglement_code;
$this->cond_reglement = $obj->cond_reglement;
$this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
$this->deposit_percent = $obj->deposit_percent;
$this->extraparams = (array) json_decode($obj->extraparams, true);
@ -1728,6 +1734,7 @@ class Propal extends CommonObject
$sql .= " fk_user_valid=".(isset($this->user_valid) ? $this->user_valid : "null").",";
$sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").",";
$sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").",";
$sql .= " deposit_percent=".(! empty($this->deposit_percent) ? "'".$this->db->escape($this->deposit_percent)."'" : "null").",";
$sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->mode_reglement_id : "null").",";
$sql .= " fk_input_reason=".(isset($this->demand_reason_id) ? $this->demand_reason_id : "null").",";
$sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";

View File

@ -340,7 +340,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_availability = '';
$search_status = '';
$object_statut = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
$search_categ_cus = 0;
$search_fk_cond_reglement = '';
@ -537,7 +537,7 @@ $sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multic
$sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,';
$sql .= ' p.date_signature as dsignature,';
$sql .= ' p.note_public, p.note_private,';
$sql .= ' p.fk_cond_reglement,p.fk_mode_reglement,p.fk_shipping_method,p.fk_input_reason,';
$sql .= ' p.fk_cond_reglement,p.deposit_percent,p.fk_mode_reglement,p.fk_shipping_method,p.fk_input_reason,';
$sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,";
$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity as user_entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
if (empty($user->rights->societe->client->voir) && !$socid) {
@ -1043,7 +1043,7 @@ if ($resql) {
$moreforfilter = '';
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) {
if ($user->rights->user->user->lire) {
$langs->load("commercial");
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
@ -1051,9 +1051,9 @@ if ($resql) {
$moreforfilter .= '</div>';
}
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) {
if ($user->rights->user->user->lire) {
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('LinkedToSpecificUsers');
$tmptitle = $langs->trans('LinkedToSpecificUsers');
$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
$moreforfilter .= '</div>';
}
@ -1224,7 +1224,7 @@ if ($resql) {
// Payment term
if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) {
print '<td class="liste_titre">';
$form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', -1, 1, 1);
$form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1);
print '</td>';
}
// Payment mode
@ -1821,7 +1821,7 @@ if ($resql) {
// Payment terms
if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) {
print '<td>';
$form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none');
$form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@ -2097,7 +2097,7 @@ if ($resql) {
// Note public
if (!empty($arrayfields['p.note_public']['checked'])) {
print '<td class="center">';
print dol_escape_htmltag($obj->note_public);
print dol_string_nohtmltag($obj->note_public);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@ -2106,7 +2106,7 @@ if ($resql) {
// Note private
if (!empty($arrayfields['p.note_private']['checked'])) {
print '<td class="center">';
print dol_escape_htmltag($obj->note_private);
print dol_string_nohtmltag($obj->note_private);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@ -2133,7 +2133,7 @@ if ($resql) {
$totalarray['nbfield']++;
}
print "</tr>\n";
print '</tr>'."\n";
$i++;
}
@ -2141,6 +2141,17 @@ if ($resql) {
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);

View File

@ -272,6 +272,7 @@ if (empty($reshook)) {
$object->ref_client = GETPOST('ref_client', 'alpha');
$object->model_pdf = GETPOST('model');
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'alpha');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->availability_id = GETPOST('availability_id');
@ -571,7 +572,7 @@ if (empty($reshook)) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setconditions' && $usercancreate) {
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'), GETPOST('cond_reglement_id_deposit_percent', 'alpha'));
if ($result < 0) {
dol_print_error($db, $object->error);
} else {
@ -628,6 +629,13 @@ if (empty($reshook)) {
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) {
// Define remise_percent
$remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0);
$remise_percent = str_replace('*', '', $remise_percent);
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && $usercancreate) { // Add a new line
$langs->load('errors');
$error = 0;
@ -1169,28 +1177,76 @@ if (empty($reshook)) {
}
if (!$error) {
$locationTarget = '';
$db->begin();
$result = $object->valid($user, $idwarehouse);
if ($result >= 0) {
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model = $object->model_pdf;
$ret = $object->fetch($id); // Reload to get new records
$error = 0;
$deposit = null;
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
$deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id);
if (
GETPOST('generate_deposit', 'alpha') == 'on' && ! empty($deposit_percent_from_payment_terms)
&& ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer)
) {
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
$date = dol_mktime(0, 0, 0, GETPOST('datefmonth', 'int'), GETPOST('datefday', 'int'), GETPOST('datefyear', 'int'));
$forceFields = array();
if (GETPOSTISSET('date_pointoftax')) {
$forceFields['date_pointoftax'] = dol_mktime(0, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'));
}
$deposit = Facture::createDepositFromOrigin($object, $date, GETPOST('cond_reglement_id', 'int'), $user, 0, GETPOST('validate_generated_deposit', 'alpha') == 'on', $forceFields);
if ($deposit) {
setEventMessage('DepositGenerated');
$locationTarget = DOL_URL_ROOT . '/compta/facture/card.php?id=' . $deposit->id;
} else {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
// Define output language
if (! $error) {
$db->commit();
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model = $object->model_pdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($deposit) {
$deposit->fetch($deposit->id); // Reload to get new records
$deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
if ($locationTarget) {
header('Location: ' . $locationTarget);
exit;
}
} else {
$db->rollback();
}
} else {
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
}
@ -1453,6 +1509,10 @@ if ($action == 'create' && $usercancreate) {
$currency_code = $conf->currency;
$cond_reglement_id = GETPOST('cond_reglement_id', 'int');
$deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'alpha');
$mode_reglement_id = GETPOST('mode_reglement_id', 'int');
if (!empty($origin) && !empty($originid)) {
// Parse element/subelement (ex: project_task)
$element = $subelement = $origin;
@ -1468,6 +1528,9 @@ if ($action == 'create' && $usercancreate) {
if (!$cond_reglement_id) {
$cond_reglement_id = $soc->cond_reglement_id;
}
if (!$deposit_percent) {
$deposit_percent = $soc->deposit_percent;
}
if (!$mode_reglement_id) {
$mode_reglement_id = $soc->mode_reglement_id;
}
@ -1508,6 +1571,7 @@ if ($action == 'create' && $usercancreate) {
$soc = $objectsrc->thirdparty;
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); // TODO maybe add default value option
$deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent : null));
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
$fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
$availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
@ -1540,6 +1604,7 @@ if ($action == 'create' && $usercancreate) {
}
} else {
$cond_reglement_id = $soc->cond_reglement_id;
$deposit_percent = $soc->deposit_percent;
$mode_reglement_id = $soc->mode_reglement_id;
$fk_account = $soc->fk_account;
$availability_id = 0;
@ -1670,8 +1735,8 @@ if ($action == 'create' && $usercancreate) {
// Terms of the settlement
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
print img_picto('', 'payment', 'class="pictofixedwidth"');
$form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1);
print img_picto('', 'paiment', 'class="pictofixedwidth"');
$form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', $deposit_percent);
print '</td></tr>';
// Payment mode
@ -1960,6 +2025,111 @@ if ($action == 'create' && $usercancreate) {
if ($nbMandated > 0 ) $text .= '<div><span class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'</span></div>';
$deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id);
if (! empty($deposit_percent_from_payment_terms) && ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer)) {
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
$object->fetchObjectLinked();
$eligibleForDepositGeneration = true;
if (array_key_exists('facture', $object->linkedObjects)) {
foreach ($object->linkedObjects['facture'] as $invoice) {
if ($invoice->type == Facture::TYPE_DEPOSIT) {
$eligibleForDepositGeneration = false;
break;
}
}
}
if ($eligibleForDepositGeneration && array_key_exists('propal', $object->linkedObjects)) {
foreach ($object->linkedObjects['propal'] as $proposal) {
$proposal->fetchObjectLinked();
if (array_key_exists('facture', $proposal->linkedObjects)) {
foreach ($proposal->linkedObjects['facture'] as $invoice) {
if ($invoice->type == Facture::TYPE_DEPOSIT) {
$eligibleForDepositGeneration = false;
break 2;
}
}
}
}
}
if ($eligibleForDepositGeneration) {
$formquestion[] = array(
'type' => 'checkbox',
'tdclass' => '',
'name' => 'generate_deposit',
'label' => $form->textwithpicto($langs->trans('GenerateDeposit', $object->deposit_percent), $langs->trans('DepositGenerationPermittedByThePaymentTermsSelected'))
);
$formquestion[] = array(
'type' => 'date',
'tdclass' => 'fieldrequired showonlyifgeneratedeposit',
'name' => 'datef',
'label' => $langs->trans('DateInvoice'),
'value' => dol_now(),
'datenow' => true
);
if (! empty($conf->global->INVOICE_POINTOFTAX_DATE)) {
$formquestion[] = array(
'type' => 'date',
'tdclass' => 'fieldrequired showonlyifgeneratedeposit',
'name' => 'date_pointoftax',
'label' => $langs->trans('DatePointOfTax'),
'value' => dol_now(),
'datenow' => true
);
}
ob_start();
$form->select_conditions_paiements(0, 'cond_reglement_id', -1, 0, 0, 'minwidth200');
$paymentTermsSelect = ob_get_clean();
$formquestion[] = array(
'type' => 'other',
'tdclass' => 'fieldrequired showonlyifgeneratedeposit',
'name' => 'cond_reglement_id',
'label' => $langs->trans('PaymentTerm'),
'value' => $paymentTermsSelect
);
$formquestion[] = array(
'type' => 'checkbox',
'tdclass' => 'showonlyifgeneratedeposit',
'name' => 'validate_generated_deposit',
'label' => $langs->trans('ValidateGeneratedDeposit')
);
$formquestion[] = array(
'type' => 'onecolumn',
'value' => '
<script>
$(document).ready(function() {
$("[name=generate_deposit]").change(function () {
let $self = $(this);
let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
$target.show();
} else {
$target.hide();
}
return true;
});
});
</script>
'
);
}
}
if (!$error) {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220);
}
@ -2263,9 +2433,9 @@ if ($action == 'create' && $usercancreate) {
print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable);
print '</td><td class="valuefield">';
if ($action == 'editconditions') {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1);
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1, '', 1, $object->deposit_percent);
} else {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1);
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1, '', 1, $object->deposit_percent);
}
print '</td>';

View File

@ -134,6 +134,11 @@ class Commande extends CommonOrder
*/
public $cond_reglement_code;
/**
* @var double Deposit % for payment terms
*/
public $deposit_percent;
/**
* @var int bank account ID
*/
@ -332,6 +337,7 @@ class Commande extends CommonOrder
'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>1, 'visible'=>-1, 'position'=>170),
'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'MulticurrencyID', 'enabled'=>1, 'visible'=>-1, 'position'=>175),
'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>180),
'deposit_percent' =>array('type'=>'varchar(63)', 'label'=>'DepositPercent', 'enabled'=>1, 'visible'=>-1, 'position'=>181),
'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'PaymentMode', 'enabled'=>1, 'visible'=>-1, 'position'=>185),
'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>190),
'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>195),
@ -940,7 +946,7 @@ class Commande extends CommonOrder
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande (";
$sql .= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client, ref_int";
$sql .= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address";
$sql .= ", model_pdf, fk_cond_reglement, deposit_percent, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address";
$sql .= ", fk_shipping_method";
$sql .= ", fk_warehouse";
$sql .= ", remise_absolue, remise_percent";
@ -961,6 +967,7 @@ class Commande extends CommonOrder
$sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null");
$sql .= ", '".$this->db->escape($this->model_pdf)."'";
$sql .= ", ".($this->cond_reglement_id > 0 ? ((int) $this->cond_reglement_id) : "null");
$sql .= ", ".(! empty($this->deposit_percent) ? "'".$this->db->escape($this->deposit_percent)."'" : "null");
$sql .= ", ".($this->mode_reglement_id > 0 ? ((int) $this->mode_reglement_id) : "null");
$sql .= ", ".($this->fk_account > 0 ? ((int) $this->fk_account) : 'NULL');
$sql .= ", ".($this->availability_id > 0 ? ((int) $this->availability_id) : "null");
@ -1212,6 +1219,7 @@ class Commande extends CommonOrder
if ($objsoc->fetch($socid) > 0) {
$this->socid = $objsoc->id;
$this->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
$this->deposit_percent = (!empty($objsoc->deposit_percent) ? $objsoc->deposit_percent : null);
$this->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
$this->fk_project = 0;
$this->fk_delivery_address = 0;
@ -1354,6 +1362,7 @@ class Commande extends CommonOrder
$this->socid = $object->socid;
$this->fk_project = $object->fk_project;
$this->cond_reglement_id = $object->cond_reglement_id;
$this->deposit_percent = $object->deposit_percent;
$this->mode_reglement_id = $object->mode_reglement_id;
$this->fk_account = $object->fk_account;
$this->availability_id = $object->availability_id;
@ -1811,7 +1820,7 @@ class Commande extends CommonOrder
}
$sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_user_modif, c.fk_statut';
$sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
$sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.deposit_percent, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
$sql .= ', c.fk_account';
$sql .= ', c.date_commande, c.date_valid, c.tms';
$sql .= ', c.date_livraison as delivery_date';
@ -1904,6 +1913,7 @@ class Commande extends CommonOrder
$this->cond_reglement_code = $obj->cond_reglement_code;
$this->cond_reglement = $obj->cond_reglement_libelle;
$this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
$this->deposit_percent = $obj->deposit_percent;
$this->fk_account = $obj->fk_account;
$this->availability_id = $obj->fk_availability;
$this->availability_code = $obj->availability_code;
@ -3340,6 +3350,7 @@ class Commande extends CommonOrder
$sql .= " fk_user_valid=".(isset($this->user_valid) ? $this->user_valid : "null").",";
$sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").",";
$sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").",";
$sql .= " deposit_percent=".(! empty($this->deposit_percent) ? strval($this->deposit_percent) : "null").",";
$sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->mode_reglement_id : "null").",";
$sql .= " date_livraison=".(strval($this->delivery_date) != '' ? "'".$this->db->idate($this->delivery_date)."'" : 'null').",";
$sql .= " fk_shipping_method=".(isset($this->shipping_method_id) ? $this->shipping_method_id : "null").",";

View File

@ -267,7 +267,7 @@ if (empty($reshook)) {
$search_project = '';
$search_status = '';
$search_billed = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
$search_categ_cus = 0;
$search_datecloture_start = '';
@ -787,7 +787,7 @@ $sql .= ' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_l
$sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,';
$sql .= ' c.fk_cond_reglement,c.fk_mode_reglement,c.fk_shipping_method,';
$sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
$sql .= ' c.fk_input_reason, c.import_key';
if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
$sql .= ", cc.fk_categorie, cc.fk_soc";
@ -1321,7 +1321,7 @@ if ($resql) {
$moreforfilter = '';
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) {
if ($user->rights->user->user->lire) {
$langs->load("commercial");
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
@ -1479,7 +1479,7 @@ if ($resql) {
// Payment term
if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
print '<td class="liste_titre">';
$form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', -1, 1, 1);
$form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1);
print '</td>';
}
// Payment mode
@ -2032,7 +2032,7 @@ if ($resql) {
// Payment terms
if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
print '<td>';
$form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none');
$form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@ -2290,8 +2290,8 @@ if ($resql) {
// Note public
if (!empty($arrayfields['c.note_public']['checked'])) {
print '<td align="center" class="nowrap">';
print dol_escape_htmltag($obj->note_public);
print '<td class="center">';
print dol_string_nohtmltag($obj->note_public);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@ -2300,8 +2300,8 @@ if ($resql) {
// Note private
if (!empty($arrayfields['c.note_private']['checked'])) {
print '<td align="center" class="nowrap">';
print dol_escape_htmltag($obj->note_private);
print '<td class="center">';
print dol_string_nohtmltag($obj->note_private);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;

View File

@ -214,7 +214,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_thirdparty_user = '';
$search_num_releve = '';
$search_conciliated = '';
$toselect = '';
$toselect = array();
$search_account = "";
if ($id > 0 || !empty($ref)) {

View File

@ -40,7 +40,6 @@ $socid = GETPOST("socid", "int");
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'banque', '', '', '');
$optioncss = GETPOST('optioncss', 'alpha');
@ -173,6 +172,11 @@ $arrayfields = array(
$arrayfields = dol_sort_array($arrayfields, 'position');
$object = new PaymentVarious($db);
$result = restrictedArea($user, 'banque', '', '', '');
/*
* Actions
*/
@ -271,19 +275,19 @@ if ($search_all) {
$sql .= $db->order($sortfield, $sortorder);
$totalnboflines = 0;
$result = $db->query($sql);
if ($result) {
$totalnboflines = $db->num_rows($result);
$resql = $db->query($sql);
if ($resql) {
$totalnboflines = $db->num_rows($resql);
}
$sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
// Direct jump if only one record found
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
$obj = $db->fetch_object($result);
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$id);
exit;
@ -541,7 +545,7 @@ if ($result) {
$totalarray = array();
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($result);
$obj = $db->fetch_object($resql);
$variousstatic->id = $obj->rowid;
$variousstatic->ref = $obj->rowid;
@ -704,7 +708,7 @@ if ($result) {
$totalarray['nbfield']++;
}
print "</tr>";
print '</tr>'."\n";
$i++;
}
@ -712,11 +716,27 @@ if ($result) {
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print "</table>";
print '</div>';
print '</form>';
// If no record found
if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
$db->free($result);
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>'."\n";
print '</div>'."\n";
print '</form>'."\n";
} else {
dol_print_error($db);
}

View File

@ -165,7 +165,7 @@ if (empty($reshook)) {
$search[$key.'_dtend'] = '';
}
}
$toselect = '';
$toselect = array();
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')

View File

@ -641,7 +641,7 @@ if (empty($reshook)) {
setEventMessages($mesg, null, 'errors');
} else {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice);
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, -1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice);
if ($result > 0) {
// Define output language and generate document
@ -1034,21 +1034,11 @@ if ($action == 'create') {
// Payment mode
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
print img_picto('', 'payment', 'class="pictofixedwidth"');
print $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 0, 0, 1, '', 1);
//$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', '', 1);
print "</td></tr>";
// Project
if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) {
$projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
$langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td>';
print img_picto('', 'project');
$numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->thirdparty->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$object->thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').'</a>';
print '</td></tr>';
}
// Bank account
if ($object->fk_account > 0) {
print "<tr><td>".$langs->trans('BankAccount')."</td><td>";
@ -1056,10 +1046,22 @@ if ($action == 'create') {
print "</td></tr>";
}
// Project
if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) {
$projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
$langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td>';
print img_picto('', 'project', 'class="pictofixedwidth"');
$numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->thirdparty->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$object->thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').'</a>';
print '</td></tr>';
}
// Model pdf
print "<tr><td>".$langs->trans('Model')."</td><td>";
include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
$list = ModelePDFFactures::liste_modeles($db);
print img_picto('', 'generic', 'class="pictofixedwidth"');
print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF);
print "</td></tr>";
@ -1605,19 +1607,19 @@ if ($action == 'create') {
// Lines
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#add' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
<input type="hidden" name="token" value="' . newToken().'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id.'">
';
print '<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#add' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">';
print '<input type="hidden" name="token" value="' . newToken().'">';
print '<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">';
print '<input type="hidden" name="mode" value="">';
print '<input type="hidden" name="id" value="' . $object->id.'">';
print '<input type="hidden" name="page_y" value="">';
if (!empty($conf->use_javascript_ajax) && $object->statut == 0) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
}
print '<div class="div-table-responsive-no-min">';
print '<table id="tablelines" class="noborder noshadow" width="100%">';
print '<table id="tablelines" class="noborder noshadow centpercent">';
// Show object lines
if (!empty($object->lines)) {
$canchangeproduct = 1;

View File

@ -987,6 +987,10 @@ if (empty($reshook)) {
}
$selectedLines = GETPOST('toselect', 'array');
if (GETPOST('type', 'int') === '') {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
}
$db->begin();
$error = 0;
@ -1571,8 +1575,15 @@ if (empty($reshook)) {
0,
0,
0,
0
//,$langs->trans('Deposit') //Deprecated
0,
'',
0,
100,
0,
null,
0,
'',
1
);
}
@ -1739,7 +1750,10 @@ if (empty($reshook)) {
$array_options,
$lines[$i]->situation_percent,
$lines[$i]->fk_prev_id,
$lines[$i]->fk_unit
$lines[$i]->fk_unit,
0,
'',
1
);
if ($result > 0) {
@ -1762,6 +1776,8 @@ if (empty($reshook)) {
}
}
$object->update_price(1, 'auto', 0, $mysoc);
// Now we create same links to contact than the ones found on origin object
/* Useless, already into the create
if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN))
@ -1809,9 +1825,11 @@ if (empty($reshook)) {
$product->fetch(GETPOST('idprod'.$i, 'int'));
$startday = dol_mktime(12, 0, 0, GETPOST('date_start'.$i.'month'), GETPOST('date_start'.$i.'day'), GETPOST('date_start'.$i.'year'));
$endday = dol_mktime(12, 0, 0, GETPOST('date_end'.$i.'month'), GETPOST('date_end'.$i.'day'), GETPOST('date_end'.$i.'year'));
$result = $object->addline($product->description, $product->price, price2num(GETPOST('qty'.$i), 'MS'), $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, GETPOST('idprod'.$i, 'int'), price2num(GETPOST('remise_percent'.$i), '', 2), $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit);
$result = $object->addline($product->description, $product->price, price2num(GETPOST('qty'.$i), 'MS'), $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, GETPOST('idprod'.$i, 'int'), price2num(GETPOST('remise_percent'.$i), '', 2), $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit, 0, '', 1);
}
}
$object->update_price(1, 'auto', 0, $mysoc);
}
}
}
@ -1976,6 +1994,13 @@ if (empty($reshook)) {
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) {
// Define vat_rate
$remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0);
$remise_percent = str_replace('*', '', $remise_percent);
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && $usercancreate) { // Add a new line
$langs->load('errors');
$error = 0;
@ -3162,6 +3187,9 @@ if ($action == 'create') {
$i++;
}
print '</select>';
print ajax_combobox("fac_rec");
// Option to reload page to retrieve customer informations. Note, this clear other input
if (empty($conf->global->RELOAD_PAGE_ON_TEMPLATE_CHANGE_DISABLED)) {
print '<script type="text/javascript">
@ -3189,7 +3217,7 @@ if ($action == 'create') {
// Standard invoice
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp = '<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOST('type') == 0 ? ' checked' : '').'> ';
$tmp = '<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOST('type', 'int') ? '' : ' checked').'> ';
$tmp = $tmp.'<label for="radio_standard" >'.$langs->trans("InvoiceStandardAsk").'</label>';
$desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3);
print '<table class="nobordernopadding"><tr>';
@ -3259,10 +3287,21 @@ if ($action == 'create') {
'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit')),
'variablealllines' => $langs->transnoentitiesnoconv('VarAmountAllLines')
);
print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit', 'aZ09'), 0, 0, 0, '', 1);
$typedeposit = GETPOST('typedeposit', 'aZ09');
$valuedeposit = GETPOST('valuedeposit', 'int');
if (empty($typedeposit) && ! empty($objectsrc->deposit_percent)) {
$origin_payment_conditions_deposit_percent = getDictionaryValue('c_payment_term', 'deposit_percent', $objectsrc->cond_reglement_id);
if (! empty($origin_payment_conditions_deposit_percent)) {
$typedeposit = 'variable';
}
}
if (empty($valuedeposit) && $typedeposit == 'variable' && ! empty($objectsrc->deposit_percent)) {
$valuedeposit = $objectsrc->deposit_percent;
}
print $form->selectarray('typedeposit', $arraylist, $typedeposit, 0, 0, 0, '', 1);
print '</td>';
print '<td class="nowrap" style="padding-left: 5px">';
print '<span class="opacitymedium paddingleft">'.$langs->trans("AmountOrPercent").'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="'.GETPOST('valuedeposit', 'int').'"/>';
print '<span class="opacitymedium paddingleft">'.$langs->trans("AmountOrPercent").'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="'.$valuedeposit.'"/>';
print '</td>';
}
print '</tr></table>';
@ -3383,7 +3422,6 @@ if ($action == 'create') {
print '</div></div>';
}
if (empty($origin)) {
if ($socid > 0) {
// Credit note
@ -3520,7 +3558,6 @@ if ($action == 'create') {
}
print '</td></tr>';
if ($socid > 0) {
@ -3608,8 +3645,8 @@ if ($action == 'create') {
// Payment mode
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">';
print img_picto('', 'bank', 'class="pictofixedwidth"');
$form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx');
print img_picto('', 'payment', 'class="pictofixedwidth"');
print $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1);
print '</td></tr>';
// Bank Account
@ -3682,6 +3719,7 @@ if ($action == 'create') {
print '<tr>';
print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>';
print '<td colspan="2" class="maxwidthonsmartphone">';
print img_picto('', 'currency', 'class="pictofixedwidth"');
print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print '</td></tr>';
}

View File

@ -945,6 +945,13 @@ class FactureRec extends CommonInvoice
$product_type = $product->type;
}
// Rank to use
$ranktouse = $rang;
if ($ranktouse == -1) {
$rangmax = $this->line_max(0);
$ranktouse = $rangmax + 1;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet_rec (";
$sql .= "fk_facture";
$sql .= ", label";
@ -1003,7 +1010,7 @@ class FactureRec extends CommonInvoice
$sql .= ", ".($fk_fournprice > 0 ? $fk_fournprice : 'null');
$sql .= ", ".($pa_ht ? price2num($pa_ht) : 0);
$sql .= ", ".((int) $info_bits);
$sql .= ", ".((int) $rang);
$sql .= ", ".((int) $ranktouse);
$sql .= ", ".((int) $special_code);
$sql .= ", ".($fk_unit ? ((int) $fk_unit) : "null");
$sql .= ", ".(int) $this->fk_multicurrency;

View File

@ -519,8 +519,11 @@ class Facture extends CommonInvoice
// Define some dates
$originaldatewhen = $_facrec->date_when;
$nextdatewhen = dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency);
$previousdaynextdatewhen = dol_time_plus_duree($nextdatewhen, -1, 'd');
$nextdatewhen = null; $previousdaynextdatewhen = null;
if ($originaldatewhen) {
$nextdatewhen = dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency);
$previousdaynextdatewhen = dol_time_plus_duree($nextdatewhen, -1, 'd');
}
if (!empty($_facrec->frequency)) { // Invoice are created on same thirdparty than template when there is a recurrence, but not necessarly when there is no recurrence.
$this->socid = $_facrec->socid;
@ -610,9 +613,9 @@ class Facture extends CommonInvoice
$substitutionarray['__INVOICE_YEAR__'] = dol_print_date($this->date, '%Y');
$substitutionarray['__INVOICE_NEXT_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y');
// Only for template invoice
$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = dol_print_date($originaldatewhen, 'dayhour');
$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($nextdatewhen, 'dayhour');
$substitutionarray['__INVOICE_PREVIOUS_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($previousdaynextdatewhen, 'dayhour');
$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = (isset($originaldatewhen) ? dol_print_date($originaldatewhen, 'dayhour') : '');
$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = (isset($nextdatewhen) ? dol_print_date($nextdatewhen, 'dayhour') : '');
$substitutionarray['__INVOICE_PREVIOUS_DATE_NEXT_INVOICE_AFTER_GEN__'] = (isset($previousdaynextdatewhen) ? dol_print_date($previousdaynextdatewhen, 'dayhour') : '');
$substitutionarray['__INVOICE_COUNTER_CURRENT__'] = $_facrec->nb_gen_done;
$substitutionarray['__INVOICE_COUNTER_MAX__'] = $_facrec->nb_gen_max;
@ -854,7 +857,9 @@ class Facture extends CommonInvoice
$newinvoiceline->situation_percent,
$newinvoiceline->fk_prev_id,
$newinvoiceline->fk_unit,
$newinvoiceline->multicurrency_subprice
$newinvoiceline->multicurrency_subprice,
$newinvoiceline->ref_ext,
1
);
// Defined the new fk_parent_line
@ -938,7 +943,8 @@ class Facture extends CommonInvoice
$line->fk_prev_id,
$line->fk_unit,
$line->multicurrency_subprice,
$line->ref_ext
$line->ref_ext,
1
);
if ($result < 0) {
$this->error = $this->db->lasterror();
@ -1035,7 +1041,9 @@ class Facture extends CommonInvoice
$_facrec->lines[$i]->situation_percent,
'',
$_facrec->lines[$i]->fk_unit,
$_facrec->lines[$i]->multicurrency_subprice
$_facrec->lines[$i]->multicurrency_subprice,
$_facrec->lines[$i]->ref_ext,
1
);
if ($result_insert < 0) {
@ -1047,7 +1055,7 @@ class Facture extends CommonInvoice
}
if (!$error) {
$result = $this->update_price(1);
$result = $this->update_price(1, 'auto', 0, $mysoc);
if ($result > 0) {
$action = 'create';
@ -1455,6 +1463,292 @@ class Facture extends CommonInvoice
}
}
/**
* Creates a deposit from a proposal or an order by grouping lines by VAT rates
*
* @param Propal|Commande $origin The original proposal or order
* @param int $date Invoice date
* @param int $payment_terms_id Invoice payment terms
* @param User $user Object user
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @param bool $autoValidateDeposit Whether to aumatically validate the deposit created
* @param array $overrideFields Array of fields to force values
* @return Facture|null The deposit created, or null if error (populates $origin->error in this case)
*/
static public function createDepositFromOrigin(CommonObject $origin, $date, $payment_terms_id, User $user, $notrigger = 0, $autoValidateDeposit = false, $overrideFields = array())
{
global $conf, $langs, $hookmanager, $action;
if (! in_array($origin->element, array('propal', 'commande'))) {
$origin->error = 'ErrorCanOnlyAutomaticallyGenerateADepositFromProposalOrOrder';
return null;
}
if (empty($date)) {
$origin->error = $langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice'));
return null;
}
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
if ($date > (dol_get_last_hour(dol_now('tzuserrel')) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
$origin->error = 'ErrorDateIsInFuture';
return null;
}
if ($payment_terms_id <= 0) {
$origin->error = $langs->trans('ErrorFieldRequired', $langs->transnoentities('PaymentConditionsShort'));
return null;
}
$payment_conditions_deposit_percent = getDictionaryValue('c_payment_term', 'deposit_percent', $origin->cond_reglement_id);
if (empty($payment_conditions_deposit_percent)) {
$origin->error = 'ErrorPaymentConditionsNotEligibleToDepositCreation';
return null;
}
if (empty($origin->deposit_percent)) {
$origin->error = $langs->trans('ErrorFieldRequired', $langs->transnoentities('DepositPercent'));
return null;
}
$deposit = new self($origin->db);
$deposit->socid = $origin->socid;
$deposit->type = self::TYPE_DEPOSIT;
$deposit->fk_project = $origin->fk_project;
$deposit->ref_client = $origin->ref_client;
$deposit->date = $date;
$deposit->mode_reglement_id = $origin->mode_reglement_id;
$deposit->cond_reglement_id = $payment_terms_id;
$deposit->availability_id = $origin->availability_id;
$deposit->demand_reason_id = $origin->demand_reason_id;
$deposit->fk_account = $origin->fk_account;
$deposit->fk_incoterms = $origin->fk_incoterms;
$deposit->location_incoterms = $origin->location_incoterms;
$deposit->fk_multicurrency = $origin->fk_multicurrency;
$deposit->multicurrency_code = $origin->multicurrency_code;
$deposit->multicurrency_tx = $origin->multicurrency_tx;
$deposit->module_source = $origin->module_source;
$deposit->pos_source = $origin->pos_source;
$deposit->model_pdf = 'crabe';
$modelByTypeConfName = 'FACTURE_ADDON_PDF_' . $deposit->type;
if (!empty($conf->global->$modelByTypeConfName)) {
$deposit->model_pdf = $conf->global->$modelByTypeConfName;
} elseif (!empty($conf->global->FACTURE_ADDON_PDF)) {
$deposit->model_pdf = $conf->global->FACTURE_ADDON_PDF;
}
if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN)) {
$deposit->note_private = $origin->note_private;
$deposit->note_public = $origin->note_public;
}
$deposit->origin = $origin->element;
$deposit->origin_id = $origin->id;
$origin->fetch_optionals();
foreach ($origin->array_options as $extrakey => $value) {
$deposit->array_options[$extrakey] = $value;
}
$deposit->linked_objects[$deposit->origin] = $deposit->origin_id;
foreach ($overrideFields as $key => $value) {
$deposit->$key = $value;
}
$deposit->context['createdepositfromorigin'] = 'createdepositfromorigin';
$origin->db->begin();
// Facture::create() also imports contact from origin
$createReturn = $deposit->create($user, $notrigger);
if ($createReturn <= 0) {
$origin->db->rollback();
$origin->error = $deposit->error;
$origin->errors = $deposit->errors;
return null;
}
$amount_ttc_diff = 0;
$amountdeposit = array();
$descriptions = array();
if (! empty($conf->global->MAIN_DEPOSIT_MULTI_TVA)) {
$amount = $origin->total_ttc * ($origin->deposit_percent / 100);
$TTotalByTva = array();
foreach ($origin->lines as &$line) {
if (!empty($line->special_code)) {
continue;
}
$TTotalByTva[$line->tva_tx] += $line->total_ttc;
$descriptions[$line->tva_tx] .= '<li>' . (! empty($line->product_ref) ? $line->product_ref . ' - ' : '');
$descriptions[$line->tva_tx] .= (! empty($line->product_label) ? $line->product_label . ' - ' : '');
$descriptions[$line->tva_tx] .= $langs->trans('Qty') . ' : ' . $line->qty;
$descriptions[$line->tva_tx] .= ' - ' . $langs->trans('TotalHT') . ' : ' . price($line->total_ht) . '</li>';
}
foreach ($TTotalByTva as $tva => &$total) {
$coef = $total / $origin->total_ttc; // Calc coef
$am = $amount * $coef;
$amount_ttc_diff += $am;
$amountdeposit[$tva] += $am / (1 + $tva / 100); // Convert into HT for the addline
}
} else {
$totalamount = 0;
$lines = $origin->lines;
$numlines = count($lines);
for ($i = 0; $i < $numlines; $i++) {
if (empty($lines[$i]->qty)) {
continue; // We discard qty=0, it is an option
}
if (!empty($lines[$i]->special_code)) {
continue; // We discard special_code (frais port, ecotaxe, option, ...)
}
$totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ?
$tva_tx = $lines[$i]->tva_tx;
$amountdeposit[$tva_tx] += ($lines[$i]->total_ht * $origin->deposit_percent) / 100;
$descriptions[$tva_tx] .= '<li>' . (! empty($lines[$i]->product_ref) ? $lines[$i]->product_ref . ' - ' : '');
$descriptions[$tva_tx] .= (! empty($lines[$i]->product_label) ? $lines[$i]->product_label . ' - ' : '');
$descriptions[$tva_tx] .= $langs->trans('Qty') . ' : ' . $lines[$i]->qty;
$descriptions[$tva_tx] .= ' - ' . $langs->trans('TotalHT') . ' : ' . price($lines[$i]->total_ht) . '</li>';
}
if ($totalamount == 0) {
$amountdeposit[0] = 0;
}
$amount_ttc_diff = $amountdeposit[0];
}
foreach ($amountdeposit as $tva => $amount) {
if (empty($amount)) {
continue;
}
$descline = '(DEPOSIT) ('. $origin->deposit_percent .'%) - '.$origin->ref;
// Hidden conf
if (! empty($conf->global->INVOICE_DEPOSIT_VARIABLE_MODE_DETAIL_LINES_IN_DESCRIPTION) && ! empty($descriptions[$tva])) {
$descline .= '<ul>' . $descriptions[$tva] . '</ul>';
}
$addlineResult = $deposit->addline(
$descline,
$amount, // subprice
1, // quantity
$tva, // vat rate
0, // localtax1_tx
0, // localtax2_tx
(empty($conf->global->INVOICE_PRODUCTID_DEPOSIT) ? 0 : $conf->global->INVOICE_PRODUCTID_DEPOSIT), // fk_product
0, // remise_percent
0, // date_start
0, // date_end
0,
$lines[$i]->info_bits, // info_bits
0,
'HT',
0,
0, // product_type
1,
$lines[$i]->special_code,
$deposit->origin,
0,
0,
0,
0
//,$langs->trans('Deposit') //Deprecated
);
if ($addlineResult < 0) {
$origin->db->rollback();
$origin->error = $deposit->error;
$origin->errors = $deposit->errors;
return null;
}
}
$diff = $deposit->total_ttc - $amount_ttc_diff;
if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA) && $diff != 0) {
$deposit->fetch_lines();
$subprice_diff = $deposit->lines[0]->subprice - $diff / (1 + $deposit->lines[0]->tva_tx / 100);
$updatelineResult = $deposit->updateline(
$deposit->lines[0]->id,
$deposit->lines[0]->desc,
$subprice_diff,
$deposit->lines[0]->qty,
$deposit->lines[0]->remise_percent,
$deposit->lines[0]->date_start,
$deposit->lines[0]->date_end,
$deposit->lines[0]->tva_tx,
0,
0,
'HT',
$deposit->lines[0]->info_bits,
$deposit->lines[0]->product_type,
0,
0,
0,
$deposit->lines[0]->pa_ht,
$deposit->lines[0]->label,
0,
array(),
100
);
if ($updatelineResult < 0) {
$origin->db->rollback();
$origin->error = $deposit->error;
$origin->errors = $deposit->errors;
return null;
}
}
if (! is_object($hookmanager)) {
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($origin->db);
}
$hookmanager->initHooks(array('invoicedao'));
$parameters = array('objFrom' => $origin);
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $deposit, $action); // Note that $action and $object may have been
// modified by hook
if ($reshook < 0) {
$origin->db->rollback();
$origin->error = $hookmanager->error;
$origin->errors = $hookmanager->errors;
return null;
}
if (! empty($autoValidateDeposit)) {
$validateReturn = $deposit->validate($user, '', 0, $notrigger);
if ($validateReturn < 0) {
$origin->db->rollback();
$origin->error = $deposit->error;
$origin->errors = $deposit->errors;
return null;
}
}
unset($deposit->context['createdepositfromorigin']);
$origin->db->commit();
return $deposit;
}
/**
* Return clicable link of object (with eventually picto)
*
@ -3237,7 +3531,7 @@ class Facture extends CommonInvoice
* @param string $price_base_type 'HT' or 'TTC'
* @param double $pu_ttc Unit price with tax (> 0 even for credit note)
* @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used.
* @param int $rang Position of line
* @param int $rang Position of line (-1 means last value + 1)
* @param int $special_code Special code (also used by externals modules!)
* @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'....
* @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id
@ -3251,6 +3545,7 @@ class Facture extends CommonInvoice
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_ht_devise Unit price in foreign currency
* @param string $ref_ext External reference of the line
* @param int $noupdateafterinsertline No update after insert of line
* @return int <0 if KO, Id of line if OK
*/
public function addline(
@ -3283,7 +3578,8 @@ class Facture extends CommonInvoice
$fk_prev_id = 0,
$fk_unit = null,
$pu_ht_devise = 0,
$ref_ext = ''
$ref_ext = '',
$noupdateafterinsertline = 0
) {
// Deprecation warning
if ($label) {
@ -3492,7 +3788,9 @@ class Facture extends CommonInvoice
}
// Mise a jour informations denormalisees au niveau de la facture meme
$result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode.
if (empty($noupdateafterinsertline)) {
$result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode.
}
if ($result > 0) {
$this->db->commit();
@ -5209,11 +5507,11 @@ class Facture extends CommonInvoice
if (!empty($recipient->email)) {
$to = $recipient->email;
} else {
$errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->fk_soc.". No email defined for user.";
$errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->socid.". No email defined for user.";
$error++;
}
} else {
$errormesg = "Failed to load recipient with thirdparty id=".$tmpinvoice->fk_soc;
$errormesg = "Failed to load recipient with thirdparty id=".$tmpinvoice->socid;
$error++;
}

View File

@ -366,7 +366,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter',
$search_fac_rec_source_title = '';
$option = '';
$filter = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
$search_categ_cus = 0;
}
@ -1185,7 +1185,7 @@ if ($resql) {
// If the user can view prospects other than his'
$moreforfilter = '';
if ($user->rights->societe->client->voir || $socid) {
if ($user->rights->user->user->lire) {
$langs->load("commercial");
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
@ -1193,7 +1193,7 @@ if ($resql) {
$moreforfilter .= '</div>';
}
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) {
if ($user->rights->user->user->lire) {
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('LinkedToSpecificUsers');
$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250');
@ -2415,16 +2415,27 @@ if ($resql) {
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
}
// If no record found
if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "</table>\n";
print '</div>';
print '</table>'."\n";
print '</div>'."\n";
print "</form>\n";
print '</form>'."\n";
// Show the file area only when this page is not opend from the Extended POS
if ($contextpage != 'poslist') {

View File

@ -102,7 +102,7 @@ if ($mode == 'customer') {
$stats->where .= ' AND f.fk_statut IN ('.$db->sanitize($object_status).')';
}
if (is_array($custcats) && !empty($custcats)) {
$stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat OmdN (f.fk_soc = cat.fk_soc)';
$stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat ON (f.fk_soc = cat.fk_soc)';
$stats->where .= ' AND cat.fk_categorie IN ('.$db->sanitize(implode(',', $custcats)).')';
}
}

View File

@ -527,9 +527,8 @@ if (!empty($conf->tax->enabled) && !empty($user->rights->tax->charges->lire)) {
if ($i >= $max) {
$othernb += 1;
$tot_ttc += $obj->amount;
$i++;
$total_ht += $obj->total_ht;
$total_ttc += $obj->total_ttc;
continue;
}

View File

@ -148,7 +148,7 @@ if (empty($reshook)) {
$search_company = '';
$search_status = '';
$option = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
}
}

View File

@ -713,16 +713,35 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
print '</tr>';
print '</tr>'."\n";
$i++;
}
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print '</table>';
print '</div>';
print '</form>';
// If no record found
if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>'."\n";
print '</div>'."\n";
print '</form>'."\n";
// End of page
llxFooter();

View File

@ -80,7 +80,7 @@ $result = restrictedArea($user, 'tax', '', 'chargesociales', 'charges');
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$search_sc_type = '';
//$toselect = '';
//$toselect = array();
//$search_array_options = array();
}

View File

@ -190,8 +190,8 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
// if total resultset is smaller then paging size (filtering), goto and load page 0
if (($page * $limit) > $nbtotalofrecords) {
@ -202,15 +202,15 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql);
if (!$result) {
$resql = $db->query($sql);
if (!$resql) {
dol_print_error($db);
llxFooter();
$db->close();
exit;
}
$num = $db->num_rows($result);
$num = $db->num_rows($resql);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) {
@ -429,7 +429,7 @@ print '</tr>';
$i = 0;
$totalarray = array();
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($result);
$obj = $db->fetch_object($resql);
$tva_static->id = $obj->rowid;
$tva_static->ref = $obj->rowid;
@ -549,11 +549,27 @@ $totalarray['nbfield']++;
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print '</table>';
print '</div>';
print '</form>';
// If no record found
if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
$db->free($result);
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>'."\n";
print '</div>'."\n";
print '</form>'."\n";
// End of page
llxFooter();

View File

@ -355,7 +355,7 @@ if (empty($elementTypeArray) && !$object->thirdparty->client && !$object->thirdp
// Define type of elements
$typeElementString = $form->selectarray("type_element", $elementTypeArray, GETPOST('type_element'), $showempty, 0, 0, '', 0, 0, $disabled, '', 'maxwidth150onsmartphone');
$button = '<input type="submit" class="button" name="button_third" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
$button = '<input type="submit" class="button small" name="button_third" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
$param = '';
$param .= "&sref=".urlencode($sref);

View File

@ -1309,19 +1309,31 @@ while ($i < min($num, $limit)) {
$i++;
}
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "</table>";
print "</div>";
//if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit, 1);
print '</form>';
print '</table>'."\n";
print '</div>'."\n";
print '</form>'."\n";
// End of page
llxFooter();
$db->close();

View File

@ -203,7 +203,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_date_end = '';
$sall = "";
$search_status = "";
$toselect = '';
$toselect = array();
$search_type_thirdparty = '';
$search_array_options = array();
}
@ -312,6 +312,9 @@ if ($search_zip) {
if ($search_town) {
$sql .= natural_search(array('s.town'), $search_town);
}
if ($search_country && $search_country != '-1') {
$sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
}
if ($search_sale > 0) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
}
@ -489,6 +492,9 @@ if ($search_user > 0) {
if ($search_type_thirdparty > 0) {
$param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
}
if ($search_country != '') {
$param .= "&search_country=".urlencode($search_country);
}
if ($search_product_category > 0) {
$param .= '&search_product_category='.urlencode($search_product_category);
}
@ -550,7 +556,7 @@ if ($sall) {
$moreforfilter = '';
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) {
if ($user->rights->user->user->lire) {
$langs->load("commercial");
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');

View File

@ -201,7 +201,7 @@ if (empty($reshook)) {
$filter_opcloture = "";
$mode = '';
$filter = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
}
}

View File

@ -147,7 +147,7 @@ if ($action == 'add') {
if (!$error) {
// attrname must be alphabetical and lower case only
if (GETPOSTISSET("attrname") && preg_match("/^[a-z0-9-_]+$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09'))) {
if (GETPOSTISSET("attrname") && preg_match("/^[a-z0-9_]+$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09'))) {
// Construct array for parameter (value of select list)
$default_value = GETPOST('default_value', 'alpha');
$parameters = $param;

View File

@ -30,7 +30,7 @@
if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) {
if (($id > 0 && is_numeric($id)) || !empty($ref)) { // To discard case when id is list of ids like '1,2,3...'
$ret = $object->fetch($id, $ref);
$ret = $object->fetch($id, (empty($ref)? '' : $ref));
if ($ret > 0) {
$object->fetch_thirdparty();
$id = $object->id;

View File

@ -327,29 +327,51 @@ if (!$error && $massaction == 'confirm_presend') {
// TODO Set subdir to be compatible with multi levels dir trees
// $subdir = get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element)
$filedir = $uploaddir.'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
$file = $filedir.'/'.$filename;
$filepath = $filedir.'/'.$filename;
// For supplier invoices, we use the file provided by supplier, not the one we generate
if ($objectobj->element == 'invoice_supplier') {
$fileparams = dol_most_recent_file($uploaddir.'/'.get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref, '/').'([^\-])+');
$file = $fileparams['fullname'];
$filepath = $fileparams['fullname'];
}
$mime = dol_mimetype($file);
// try to find other files generated for this object (last_main_doc)
$filename_found = '';
$filepath_found = '';
$file_check_list = array();
$file_check_list[] = array(
'name' => $filename,
'path' => $filepath,
);
if (!empty($conf->global->MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND) && !empty($objectobj->last_main_doc)) {
$file_check_list[] = array(
'name' => basename($objectobj->last_main_doc),
'path' => DOL_DATA_ROOT . '/' . $objectobj->last_main_doc,
);
}
foreach ($file_check_list as $file_check_arr) {
if (dol_is_file($file_check_arr['path'])) {
$filename_found = $file_check_arr['name'];
$filepath_found = $file_check_arr['path'];
break;
}
}
if (dol_is_file($file)) {
if ($filepath_found) {
// Create form object
$attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
'paths'=>array($file),
'names'=>array($filename),
'mimes'=>array($mime)
'paths'=>array($filepath_found),
'names'=>array($filename_found),
'mimes'=>array(dol_mimetype($filepath_found))
);
} else {
$nbignored++;
$langs->load("errors");
$resaction .= '<div class="error">'.$langs->trans('ErrorCantReadFile', $file).'</div><br>';
dol_syslog('Failed to read file: '.$file, LOG_WARNING);
continue;
$nbignored++;
$langs->load("errors");
foreach ($file_check_list as $file_check_arr) {
$resaction .= '<div class="error">'.$langs->trans('ErrorCantReadFile', $file_check_arr['path']).'</div><br>';
dol_syslog('Failed to read file: '.$file_check_arr['path'], LOG_WARNING);
}
continue;
}
}
@ -1280,6 +1302,49 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm ==
}
}
if (!$error && $action == 'confirm_edit_value_extrafields' && $confirm == 'yes' && $permissiontoadd) {
$db->begin();
$objecttmp = new $objectclass($db);
$e = new ExtraFields($db);// fetch optionals attributes and labels
$e->fetch_name_optionals_label($objecttmp->table_element);
$nbok = 0;
$extrafieldKeyToUpdate = GETPOST('extrafield-key-to-update');
foreach ($toselect as $toselectid) {
/** @var CommonObject $objecttmp */
$objecttmp = new $objectclass($db); // to avoid ghost data
$result = $objecttmp->fetch($toselectid);
if ($result>0) {
// Fill array 'array_options' with data from add form
$ret = $e->setOptionalsFromPost(null, $objecttmp, $extrafieldKeyToUpdate);
if ($ret > 0) {
$objecttmp->insertExtraFields();
} else {
$error++;
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
}
} else {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
}
}
if (!$error) {
if ($nbok > 1) {
setEventMessages($langs->trans("RecordsDisabled", $nbok), null, 'mesgs');
} else {
setEventMessages($langs->trans("save"), null, 'mesgs');
}
$db->commit();
} else {
$db->rollback();
}
}
if (!$error && ($massaction == 'affectcommercial' || ($action == 'affectcommercial' && $confirm == 'yes')) && $permissiontoadd) {
$db->begin();

View File

@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php";
class box_graph_nb_ticket_last_x_days extends ModeleBoxes
{
public $boxcode = "box_nb_ticket_last_x_days";
public $boxcode = "box_graph_nb_ticket_last_x_days";
public $boximg = "ticket";
public $boxlabel;
public $depends = array("ticket");
@ -102,18 +102,17 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes
'text' => $text,
'limit' => dol_strlen($text)
);
$today = date_time_set(date_create(), 0, 0);
$todayformat = date('Y-m-d', date_timestamp_get($today));
$intervaltosub = new DateInterval('P'.dol_escape_htmltag($days - 1).'D');
$intervaltoadd = new DateInterval('P1D');
$minimumdatec = date_sub($today, $intervaltosub);
$minimumdatecformated = date('Y-m-d', date_timestamp_get($minimumdatec));
$today = dol_now();
$intervaltoadd = 1;
$minimumdatec = dol_time_plus_duree($today, -1 * ($days - 1), 'd');
$minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc');
if ($user->rights->ticket->read) {
$sql = "SELECT CAST(t.datec AS DATE) as datec, COUNT(t.datec) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."ticket as t";
$sql .= " WHERE CAST(t.datec AS DATE) > DATE_SUB(CURRENT_DATE, INTERVAL ".$days." DAY)";
$sql .= " WHERE CAST(t.datec AS DATE) > '".$this->db->idate($minimumdatec)."'";
$sql .= " GROUP BY CAST(t.datec AS DATE)";
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
@ -122,18 +121,18 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes
$objp = $this->db->fetch_object($resql);
while ($minimumdatecformated < $objp->datec) {
$dataseries[] = array('label' => dol_print_date($minimumdatecformated, 'day'), 'data' => 0);
$minimumdatec = date_add($minimumdatec, $intervaltoadd);
$minimumdatecformated = date('Y-m-d', date_timestamp_get($minimumdatec));
$minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd');
$minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc');
}
$dataseries[] = array('label' => dol_print_date($objp->datec, 'day'), 'data' => $objp->nb);
$minimumdatec = date_add($minimumdatec, $intervaltoadd);
$minimumdatecformated = date('Y-m-d', date_timestamp_get($minimumdatec));
$minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd');
$minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc');
$i++;
}
while (count($dataseries) < $days) {
$dataseries[] = array('label' => dol_print_date($minimumdatecformated, 'day'), 'data' => 0);
$minimumdatec = date_add($minimumdatec, $intervaltoadd);
$minimumdatecformated = date('Y-m-d', date_timestamp_get($minimumdatec));
$minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd');
$minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc');
$i++;
}
} else {

View File

@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php";
class box_graph_nb_tickets_type extends ModeleBoxes
{
public $boxcode = "box_nb_tickets_type";
public $boxcode = "box_graph_nb_tickets_type";
public $boximg = "ticket";
public $boxlabel;
public $depends = array("ticket");
@ -171,7 +171,7 @@ class box_graph_nb_tickets_type extends ModeleBoxes
}
$stringtoprint .= '</div>';
$this->info_box_contents[][]=array(
'td' => 'center',
'td' => 'class="center"',
'text' => $stringtoprint
);
} else {

View File

@ -191,19 +191,19 @@ class box_graph_ticket_by_severity extends ModeleBoxes
}
$stringtoprint .= '</div>';
$this->info_box_contents[][]=array(
'td' => 'center',
'td' => 'class="center"',
'text' => $stringtoprint
);
} else {
$this->info_box_contents[0][0] = array(
'td' => 'class="center opacitymedium"',
'text' => $langs->trans("BoxNoTicketSeverity")
'td' => '',
'text' => '<span class="opacitymedium">'.$langs->trans("BoxNoTicketSeverity").'</span>'
);
}
} else {
$this->info_box_contents[0][0] = array(
'td' => 'class="left"',
'text' => $langs->trans("ReadPermissionNotAllowed"),
'td' => '',
'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>',
);
}
}

View File

@ -177,15 +177,15 @@ class box_last_modified_ticket extends ModeleBoxes
}
if ($num == 0) {
$this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets"));
$this->info_box_contents[$i][0] = array('td' => '', 'text'=>'<span class="opacitymedium">'.$langs->trans("BoxLastModifiedTicketNoRecordedTickets").'</span>');
}
} else {
dol_print_error($this->db);
}
} else {
$this->info_box_contents[0][0] = array(
'td' => 'class="left"',
'text' => $langs->trans("ReadPermissionNotAllowed"),
'td' => '',
'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>',
);
}
}

View File

@ -85,9 +85,9 @@ class box_last_ticket extends ModeleBoxes
);
if ($user->rights->ticket->read) {
$sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email ";
$sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label";
$sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur";
$sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut as status, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email,";
$sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label,";
$sql .= " s.nom as company_name, s.email as socemail, s.client, s.fournisseur";
$sql .= " FROM ".MAIN_DB_PREFIX."ticket as t";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code";
@ -113,6 +113,7 @@ class box_last_ticket extends ModeleBoxes
while ($i < $num) {
$objp = $this->db->fetch_object($resql);
$datec = $this->db->jdate($objp->datec);
//$dateterm = $this->db->jdate($objp->fin_validite);
//$dateclose = $this->db->jdate($objp->date_close);
@ -122,7 +123,8 @@ class box_last_ticket extends ModeleBoxes
$ticket->id = $objp->id;
$ticket->track_id = $objp->track_id;
$ticket->ref = $objp->ref;
$ticket->fk_statut = $objp->fk_statut;
$ticket->fk_statut = $objp->status;
$ticket->status = $objp->status;
$ticket->subject = $objp->subject;
if ($objp->fk_soc > 0) {
$thirdparty = new Societe($this->db);
@ -149,8 +151,8 @@ class box_last_ticket extends ModeleBoxes
// Subject
$this->info_box_contents[$i][$r] = array(
'td' => 'class="tdoverflowmax200"',
'text' => '<span title="'.$objp->subject.'">'.$objp->subject.'</span>', // Some event have no ref
'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id,
'text' => '<span title="'.dol_escape_htmltag($objp->subject).'">'.dol_escape_htmltag($objp->subject).'</span>', // Some event have no ref
'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".urlencode($objp->track_id),
);
$r++;
@ -180,14 +182,14 @@ class box_last_ticket extends ModeleBoxes
}
if ($num == 0) {
$this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text' => $langs->trans("BoxLastTicketNoRecordedTickets"));
$this->info_box_contents[$i][0] = array('td' => '', 'text' => '<span class="opacitymedium">'.$langs->trans("BoxLastTicketNoRecordedTickets").'</span>');
}
} else {
dol_print_error($this->db);
}
} else {
$this->info_box_contents[0][0] = array('td' => 'class="left"',
'text' => $langs->trans("ReadPermissionNotAllowed"));
$this->info_box_contents[0][0] = array('td' => '',
'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>');
}
}

View File

@ -173,27 +173,34 @@ class box_members_by_type extends ModeleBoxes
$line = 0;
$this->info_box_contents[$line][] = array(
'td' => 'class=""',
'text' => $langs->trans("MembersTypes"),
'text' => '',
);
$labelstatus = $staticmember->LibStatut($staticmember::STATUS_DRAFT, 0, 0, 1);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => $langs->trans("MembersStatusToValid"), // Draft
'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"',
'text' => $labelstatus
);
$labelstatus = $langs->trans("UpToDate");
$labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() + 86400, 1);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => $langs->trans("UpToDate"),
'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"',
'text' => $labelstatus,
);
$labelstatus = $langs->trans("OutOfDate");
$labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() - 86400, 1);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => $langs->trans("OutOfDate"),
'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"',
'text' => $labelstatus
);
$labelstatus = $staticmember->LibStatut($staticmember::STATUS_EXCLUDED, 0, 0, 1);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => $langs->trans("MembersStatusExcluded"),
'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"',
'text' => $labelstatus
);
$labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => $langs->trans("MembersStatusResiliated"),
'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"',
'text' => $labelstatus
);
$line++;
foreach ($AdherentType as $key => $adhtype) {

View File

@ -222,7 +222,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
// Show box title
if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto'])) {
$out .= '<tr class="liste_titre box_titre">';
$out .= '<td';
$out .= '<th';
if ($nbcol > 0) {
$out .= ' colspan="'.$nbcol.'"';
}
@ -268,7 +268,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
$out .= '</div>';
}
$out .= "</td>";
$out .= "</th>";
$out .= "</tr>\n";
}

View File

@ -2588,12 +2588,13 @@ abstract class CommonObject
/**
* Change the payments terms
*
* @param int $id Id of new payment terms
* @return int >0 if OK, <0 if KO
* @param int $id Id of new payment terms
* @param string $deposit_percent % of deposit if needed by payment terms
* @return int >0 if OK, <0 if KO
*/
public function setPaymentTerms($id)
public function setPaymentTerms($id, $deposit_percent = null)
{
dol_syslog(get_class($this).'::setPaymentTerms('.$id.')');
dol_syslog(get_class($this).'::setPaymentTerms('.$id.', '.var_export($deposit_percent, true).')');
if ($this->statut >= 0 || $this->element == 'societe') {
// TODO uniformize field name
$fieldname = 'fk_cond_reglement';
@ -2604,8 +2605,17 @@ abstract class CommonObject
$fieldname = 'cond_reglement_supplier';
}
if (empty($deposit_percent) || $deposit_percent < 0) {
$deposit_percent = getDictionaryValue('c_payment_term', 'deposit_percent', $id);
}
if ($deposit_percent > 100) {
$deposit_percent = 100;
}
$sql = 'UPDATE '.$this->db->prefix().$this->table_element;
$sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL');
$sql .= " , deposit_percent = " . (! empty($deposit_percent) ? "'".$this->db->escape($deposit_percent)."'" : 'NULL');
$sql .= ' WHERE rowid='.((int) $this->id);
if ($this->db->query($sql)) {
@ -2615,6 +2625,7 @@ abstract class CommonObject
$this->cond_reglement_supplier_id = $id;
}
$this->cond_reglement = $id; // for compatibility
$this->deposit_percent = $deposit_percent;
return 1;
} else {
dol_syslog(get_class($this).'::setPaymentTerms Error '.$sql.' - '.$this->db->error());
@ -3391,9 +3402,9 @@ abstract class CommonObject
* Must be called at end of methods addline or updateline.
*
* @param int $exclspec >0 = Exclude special product (product_type=9)
* @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force mode total of rounding, '1'=Force mode rounding of total
* @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force mode Total of rounding, '1'=Force mode Rounding of total
* @param int $nodatabaseupdate 1=Do not update database. Update only properties of object.
* @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object.
* @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object (used to analyze lines to check corrupted data).
* @return int <0 if KO, >0 if OK
*/
public function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null)
@ -7923,16 +7934,22 @@ abstract class CommonObject
// Convert date into timestamp format (value in memory must be a timestamp)
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date'))) {
$datenotinstring = $this->array_options['options_'.$key];
if (!is_numeric($this->array_options['options_'.$key])) { // For backward compatibility
$datenotinstring = $this->db->jdate($datenotinstring);
$datenotinstring = null;
if (array_key_exists('options_'.$key, $this->array_options)) {
$datenotinstring = $this->array_options['options_'.$key];
if (!is_numeric($this->array_options['options_'.$key])) { // For backward compatibility
$datenotinstring = $this->db->jdate($datenotinstring);
}
}
$value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(12, 0, 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring;
}
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('datetime'))) {
$datenotinstring = $this->array_options['options_'.$key];
if (!is_numeric($this->array_options['options_'.$key])) { // For backward compatibility
$datenotinstring = $this->db->jdate($datenotinstring);
$datenotinstring = null;
if (array_key_exists('options_'.$key, $this->array_options)) {
$datenotinstring = $this->array_options['options_'.$key];
if (!is_numeric($this->array_options['options_'.$key])) { // For backward compatibility
$datenotinstring = $this->db->jdate($datenotinstring);
}
}
$value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."sec", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3), 'tzuserrel') : $datenotinstring;
}
@ -7952,14 +7969,14 @@ abstract class CommonObject
$helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]);
if ($display_type == 'card') {
$out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="valuefieldcreate '.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >';
$out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="field_options_'.$key.' '.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >';
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER) && ($action == 'view' || $action == 'valid' || $action == 'editline')) {
$out .= '<td></td>';
}
$out .= '<td class="wordbreak';
$out .= '<td class="titlefieldcreate wordbreak';
} elseif ($display_type == 'line') {
$out .= '<div '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="valuefieldlinecreate '.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >';
$out .= '<div style="display: inline-block; padding-right:4px" class="wordbreak';
$out .= '<div '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="fieldline_options_'.$key.' '.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >';
$out .= '<div style="display: inline-block; padding-right:4px" class="titlefieldcreate wordbreak';
}
//$out .= "titlefield";
//if (GETPOST('action', 'restricthtml') == 'create') $out.='create';
@ -7992,9 +8009,9 @@ abstract class CommonObject
$html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : '';
if ($display_type == 'card') {
// a first td column was already output (and may be another on before if MAIN_VIEW_LINE_NUMBER set), so this td is the next one
$out .= '<td '.($html_id ? 'id="'.$html_id.'" ' : '').' class="'.$this->element.'_extras_'.$key.'" '.($colspan ? ' colspan="'.$colspan.'"' : '').'>';
$out .= '<td '.($html_id ? 'id="'.$html_id.'" ' : '').' class="valuefieldcreate '.$this->element.'_extras_'.$key.'" '.($colspan ? ' colspan="'.$colspan.'"' : '').'>';
} elseif ($display_type == 'line') {
$out .= '<div '.($html_id ? 'id="'.$html_id.'" ' : '').' style="display: inline-block" class="'.$this->element.'_extras_'.$key.'">';
$out .= '<div '.($html_id ? 'id="'.$html_id.'" ' : '').' style="display: inline-block" class="valuefieldcreate '.$this->element.'_extras_'.$key.'">';
}
switch ($mode) {

View File

@ -956,6 +956,8 @@ class ExtraFields
$morecss = 'minwidth400';
} elseif ($type == 'boolean') {
$morecss = '';
} elseif ($type == 'radio') {
$morecss = 'width25';
} else {
if (empty($size) || round($size) < 12) {
$morecss = 'minwidth100';
@ -1147,7 +1149,7 @@ class ExtraFields
$sql = "SELECT ".$keyList;
$sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
if (!empty($InfoFieldList[4])) {
// can use curent entity filter
// can use current entity filter
if (strpos($InfoFieldList[4], '$ENTITY$') !== false) {
$InfoFieldList[4] = str_replace('$ENTITY$', $conf->entity, $InfoFieldList[4]);
}
@ -1262,7 +1264,7 @@ class ExtraFields
$out .= ' value="'.$keyopt.'"';
$out .= ' id="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'"';
$out .= ($value == $keyopt ? 'checked' : '');
$out .= '/><label for="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'">'.$val.'</label><br>';
$out .= '/><label for="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'">'.$langs->trans($val).'</label><br>';
}
} elseif ($type == 'chkbxlst') {
if (is_array($value)) {
@ -1315,6 +1317,10 @@ class ExtraFields
$sql = "SELECT ".$keyList;
$sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
if (!empty($InfoFieldList[4])) {
// can use current entity filter
if (strpos($InfoFieldList[4], '$ENTITY$') !== false) {
$InfoFieldList[4] = str_replace('$ENTITY$', $conf->entity, $InfoFieldList[4]);
}
// can use SELECT request
if (strpos($InfoFieldList[4], '$SEL$') !== false) {
$InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]);
@ -1666,7 +1672,7 @@ class ExtraFields
dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
}
} elseif ($type == 'radio') {
$value = $param['options'][$value];
$value = $langs->trans($param['options'][$value]);
} elseif ($type == 'checkbox') {
$value_arr = explode(',', $value);
$value = '';

View File

@ -234,7 +234,7 @@ class Form
if (preg_match('/^(string|safehtmlstring|email)/', $typeofdata)) {
$tmp = explode(':', $typeofdata);
$ret .= '<input type="text" id="'.$htmlname.'" name="'.$htmlname.'" value="'.($editvalue ? $editvalue : $value).'"'.($tmp[1] ? ' size="'.$tmp[1].'"' : '').' autofocus>';
} elseif (preg_match('/^(numeric|amount)/', $typeofdata)) {
} elseif (preg_match('/^(numeric|amount|integer)/', $typeofdata)) {
$tmp = explode(':', $typeofdata);
$valuetoshow = price2num($editvalue ? $editvalue : $value);
$ret .= '<input type="text" id="'.$htmlname.'" name="'.$htmlname.'" value="'.($valuetoshow != '' ? price($valuetoshow) : '').'"'.($tmp[1] ? ' size="'.$tmp[1].'"' : '').' autofocus>';
@ -1587,6 +1587,8 @@ class Form
}
}
print '</select>';
print ajax_combobox('select_'.$htmlname);
return $qualifiedlines;
} else {
dol_print_error($this->db);
@ -3727,7 +3729,7 @@ class Form
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = "SELECT rowid, code, libelle as label";
$sql = "SELECT rowid, code, libelle as label, deposit_percent";
$sql .= " FROM ".$this->db->prefix().'c_payment_term';
$sql .= " WHERE entity IN (".getEntity('c_payment_term').")";
$sql .= " AND active > 0";
@ -3744,6 +3746,7 @@ class Form
$label = ($langs->trans("PaymentConditionShort".$obj->code) != ("PaymentConditionShort".$obj->code) ? $langs->trans("PaymentConditionShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
$this->cache_conditions_paiements[$obj->rowid]['code'] = $obj->code;
$this->cache_conditions_paiements[$obj->rowid]['label'] = $label;
$this->cache_conditions_paiements[$obj->rowid]['deposit_percent'] = $obj->deposit_percent;
$i++;
}
@ -3989,39 +3992,45 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* print list of payment modes.
* Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
* See instead to force the default value by the caller.
* print list of payment modes.
* Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
* See instead to force the default value by the caller.
*
* @param int $selected Id of payment term to preselect by default
* @param string $htmlname Nom de la zone select
* @param int $filtertype Not used
* @param int $addempty Add an empty entry
* @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
* @param string $morecss Add more CSS on select tag
* @return void
* @param int $selected Id of payment term to preselect by default
* @param string $htmlname Nom de la zone select
* @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates)
* @param int $addempty Add an empty entry
* @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
* @param string $morecss Add more CSS on select tag
* @param string $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters)
* 0 : use default deposit percentage from entry
* > 0 : force deposit percentage (for example, from company object)
* @return void
*/
public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '')
public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '', $deposit_percent = -1)
{
// phpcs:enable
print $this->getSelectConditionsPaiements($selected, $htmlname, $filtertype, $addempty, $noinfoadmin, $morecss);
print $this->getSelectConditionsPaiements($selected, $htmlname, $filtertype, $addempty, $noinfoadmin, $morecss, $deposit_percent = -1);
}
/**
* Return list of payment modes.
* Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
* See instead to force the default value by the caller.
* Return list of payment modes.
* Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
* See instead to force the default value by the caller.
*
* @param int $selected Id of payment term to preselect by default
* @param string $htmlname Nom de la zone select
* @param int $filtertype Not used
* @param int $addempty Add an empty entry
* @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
* @param string $morecss Add more CSS on select tag
* @return void
* @param int $selected Id of payment term to preselect by default
* @param string $htmlname Nom de la zone select
* @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates)
* @param int $addempty Add an empty entry
* @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
* @param string $morecss Add more CSS on select tag
* @param string $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters)
* 0 : use default deposit percentage from entry
* > 0 : force deposit percentage (for example, from company object)
* @return string
*/
public function getSelectConditionsPaiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '')
public function getSelectConditionsPaiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '', $deposit_percent = -1)
{
global $langs, $user, $conf;
@ -4039,20 +4048,59 @@ class Form
if ($addempty) {
$out.= '<option value="0">&nbsp;</option>';
}
$selectedDepositPercent = null;
foreach ($this->cache_conditions_paiements as $id => $arrayconditions) {
if ($selected == $id) {
$out.= '<option value="'.$id.'" selected>';
} else {
$out.= '<option value="'.$id.'">';
if ($filtertype <= 0 && ! empty($arrayconditions['deposit_percent'])) {
continue;
}
$out.= $arrayconditions['label'];
$out.= '</option>';
if ($selected == $id) {
$selectedDepositPercent = $deposit_percent > 0 ? $deposit_percent : $arrayconditions['deposit_percent'];
$out .= '<option value="'.$id.'" data-deposit_percent="' . $arrayconditions['deposit_percent'] . '" selected>';
} else {
$out .= '<option value="'.$id.'" data-deposit_percent="' . $arrayconditions['deposit_percent'] . '">';
}
$label = $arrayconditions['label'];
if (! empty($arrayconditions['deposit_percent'])) {
$label = str_replace('__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $arrayconditions['deposit_percent'], $label);
}
$out.= $label;
$out.= '</option>';
}
$out.= '</select>';
if ($user->admin && empty($noinfoadmin)) {
$out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
$out.= ajax_combobox($htmlname);
if ($deposit_percent >= 0) {
$out .= ' <span id="'.$htmlname.'_deposit_percent_container"' . (empty($selectedDepositPercent) ? ' style="display: none"' : '') . '>';
$out .= $langs->trans('DepositPercent') . ' : ';
$out .= '<input id="'.$htmlname.'_deposit_percent" name="'.$htmlname.'_deposit_percent" class="maxwidth50" value="' . strval($deposit_percent) . '" />';
$out .= '</span>';
$out .= '
<script>
$(document).ready(function () {
$("#' . $htmlname . '").change(function () {
let $selected = $(this).find("option:selected");
let depositPercent = $selected.attr("data-deposit_percent");
if (depositPercent.length > 0) {
$("#'.$htmlname.'_deposit_percent_container").show().find("#'.$htmlname.'_deposit_percent").val(depositPercent);
} else {
$("#'.$htmlname.'_deposit_percent_container").hide();
}
return true;
});
});
</script>';
}
return $out;
}
@ -5007,8 +5055,8 @@ class Form
$autoOpen = false;
$dialogconfirm .= '-'.$button;
}
$pageyes = $page.(preg_match('/\?/', $page) ? '&' : '?').'action='.$action.'&confirm=yes';
$pageno = ($useajax == 2 ? $page.(preg_match('/\?/', $page) ? '&' : '?').'confirm=no' : '');
$pageyes = $page.(preg_match('/\?/', $page) ? '&' : '?').'action='.urlencode($action).'&confirm=yes';
$pageno = ($useajax == 2 ? $page.(preg_match('/\?/', $page) ? '&' : '?').'action='.urlencode($action).'&confirm=no' : '');
// Add input fields into list of fields to read during submit (inputok and inputko)
if (is_array($formquestion)) {
@ -5243,14 +5291,18 @@ class Form
/**
* Show a form to select payment conditions
*
* @param int $page Page
* @param string $selected Id condition pre-selectionne
* @param string $htmlname Name of select html field
* @param int $addempty Add empty entry
* @param string $type Type ('direct-debit' or 'bank-transfer')
* @param int $page Page
* @param string $selected Id condition pre-selectionne
* @param string $htmlname Name of select html field
* @param int $addempty Add empty entry
* @param string $type Type ('direct-debit' or 'bank-transfer')
* @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates)
* @param string $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters)
* 0 : use default deposit percentage from entry
* > 0 : force deposit percentage (for example, from company object)
* @return void
*/
public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0, $type = '')
public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0, $type = '', $filtertype = -1, $deposit_percent = -1)
{
// phpcs:enable
global $langs;
@ -5261,14 +5313,20 @@ class Form
if ($type) {
print '<input type="hidden" name="type" value="'.dol_escape_htmltag($type).'">';
}
$this->select_conditions_paiements($selected, $htmlname, -1, $addempty, 0, '');
$this->select_conditions_paiements($selected, $htmlname, $filtertype, $addempty, 0, '', $deposit_percent);
print '<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans("Modify").'">';
print '</form>';
} else {
if ($selected) {
$this->load_cache_conditions_paiements();
if (isset($this->cache_conditions_paiements[$selected])) {
print $this->cache_conditions_paiements[$selected]['label'];
$label = $this->cache_conditions_paiements[$selected]['label'];
if (! empty($this->cache_conditions_paiements[$selected]['deposit_percent'])) {
$label = str_replace('__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $this->cache_conditions_paiements[$selected]['deposit_percent'], $label);
}
print $label;
} else {
$langs->load('errors');
print $langs->trans('ErrorNotInDictionaryPaymentConditions');
@ -5633,6 +5691,7 @@ class Form
if ($filter) {
$newfilter .= ' AND ('.$filter.')';
}
// output the combo of discounts
$nbqualifiedlines = $this->select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue);
if ($nbqualifiedlines > 0) {
print ' &nbsp; <input type="submit" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans("UseLine")).'"';
@ -7213,15 +7272,18 @@ class Form
if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
$placeholder = '';
$urloption = '';
if ($selected && empty($selected_input_value)) {
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$adherenttmpselect = new Member($this->db);
$adherenttmpselect = new Adherent($this->db);
$adherenttmpselect->fetch($selected);
$selected_input_value = $adherenttmpselect->ref;
unset($adherenttmpselect);
}
$urloption = '';
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/adherents/ajax/adherents.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel").' : ';
@ -7236,7 +7298,9 @@ class Form
$out .= img_picto($langs->trans("Search"), 'search');
}
} else {
$out .= $this->selectMembersList($selected, $htmlname, $filtertype, $limit, $status, 0, $socid, $showempty, $forcecombo, $morecss);
$filterkey = '';
$out .= $this->selectMembersList($selected, $htmlname, $filtertype, $limit, $filterkey, $status, 0, $showempty, $forcecombo, $morecss);
}
if (empty($nooutput)) print $out;
@ -7251,8 +7315,8 @@ class Form
* @param string $htmlname Name of select html
* @param string $filtertype Filter on adherent type
* @param int $limit Limit on number of returned lines
* @param string $filterkey Filter on adherent ref or subject
* @param int $status Ticket status
* @param string $filterkey Filter on member status
* @param int $status Member status
* @param int $outputmode 0=HTML select string, 1=Array
* @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text.
* @param int $forcecombo Force to use combo box
@ -7266,7 +7330,7 @@ class Form
$out = '';
$outarray = array();
$selectFields = " p.rowid, p.ref";
$selectFields = " p.rowid, p.ref, p.firstname, p.lastname";
$sql = "SELECT ";
$sql .= $selectFields;
@ -7276,21 +7340,23 @@ class Form
// Add criteria on ref/label
if ($filterkey != '') {
$sql .= ' AND (';
$prefix = empty($conf->global->TICKET_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
$prefix = empty($conf->global->MEMBER_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
// For natural search
$scrit = explode(' ', $filterkey);
$i = 0;
if (count($scrit) > 1) $sql .= "(";
foreach ($scrit as $crit) {
if ($i > 0) $sql .= " AND ";
$sql .= "p.ref LIKE '".$this->db->escape($prefix.$crit)."%'";
$sql .= "";
$sql .= "(p.firstname LIKE '".$this->db->escape($prefix.$crit)."%'";
$sql .= " OR p.lastname LIKE '".$this->db->escape($prefix.$crit)."%')";
$i++;
}
if (count($scrit) > 1) $sql .= ")";
$sql .= ')';
}
if ($status != -1) {
$sql .= ' AND statut = '.((int) $status);
}
$sql .= $this->db->plimit($limit, 0);
// Build output string
@ -7320,7 +7386,9 @@ class Form
} else {
if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
}
if ($showempty) $out .= '<option value="0" selected>'.$textifempty.'</option>';
if ($showempty) {
$out .= '<option value="-1" selected>'.$textifempty.'</option>';
}
$i = 0;
while ($num && $i < $num) {
@ -7329,6 +7397,7 @@ class Form
$objp = $this->db->fetch_object($result);
$this->constructMemberListOption($objp, $opt, $optJson, $selected, $filterkey);
// Add new entry
// "key" value of json key array is used by jQuery automatically as selected value
// "label" value of json key array is used by jQuery automatically as text for combo box
@ -7363,28 +7432,23 @@ class Form
protected function constructMemberListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
{
$outkey = '';
$outval = '';
$outref = '';
$outlabel = '';
$outtype = '';
$label = $objp->label;
$outkey = $objp->rowid;
$outref = $objp->ref;
$outlabel = $objp->label;
$outtype = $objp->fk_product_type;
$outlabel = dolGetFirstLastname($objp->firstname, $objp->lastname);
$outtype = $objp->fk_adherent_type;
$opt = '<option value="'.$objp->rowid.'"';
$opt .= ($objp->rowid == $selected) ? ' selected' : '';
$opt .= '>';
$opt .= $objp->ref;
$objRef = $objp->ref;
if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
$outval .= $objRef;
if (!empty($filterkey) && $filterkey != '') {
$outlabel = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $outlabel, 1);
}
$opt .= $outlabel;
$opt .= "</option>\n";
$optJson = array('key'=>$outkey, 'value'=>$outref, 'type'=>$outtype);
$optJson = array('key'=>$outkey, 'value'=>$outlabel, 'type'=>$outtype);
}
/**
@ -7417,7 +7481,7 @@ class Form
// Bom:bom/class/bom.class.php:0:t.status=1:ref
// Bom:bom/class/bom.class.php:0:(t.status:=:1):ref
$InfoFieldList = explode(":", $objectdesc, 4);
$vartmp = $InfoFieldList[3];
$vartmp = (empty($InfoFieldList[3]) ? '' : $InfoFieldList[3]);
$reg = array();
if (preg_match('/^.*:(\w*)$/', $vartmp, $reg)) {
$InfoFieldList[4] = $reg[1]; // take the sort field

View File

@ -72,7 +72,10 @@ class FormCategory extends Form
{
global $conf;
$sql = "SELECT cp.fk_categorie as cat_index, cat.label FROM `llx_categorie_product` as cp INNER JOIN llx_categorie as cat ON cat.rowid = cp.fk_categorie GROUP BY cp.fk_categorie;";
$sql = "SELECT cp.fk_categorie as cat_index, cat.label";
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_product as cp";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."categorie as cat ON cat.rowid = cp.fk_categorie";
$sql .= " GROUP BY cp.fk_categorie, cat.label";
dol_syslog(get_class($this)."::selectProductCategory", LOG_DEBUG);
$resql = $this->db->query($sql);

View File

@ -7,7 +7,7 @@
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
* Copyright (C) 2016-2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2022 Frédéric France <frederic.france@netlogic.fr>
*
* 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
@ -986,6 +986,8 @@ class FormFile
$out .= '<td class="right">';
$out .= dol_print_date($file->datea, 'dayhour');
$out .= '</td>';
// for share link of files
$out .= '<td></td>';
if ($delallowed || $printer || $morepicto) {
$out .= '<td></td>';
}

View File

@ -781,7 +781,11 @@ class FormMail extends Form
} elseif ($this->withmaindocfile == -1) {
$out .= '<input type="checkbox" id="addmaindocfile" name="addmaindocfile" value="1" checked="checked" />';
}
$out .= ' <label for="addmaindocfile">'.$langs->trans("JoinMainDoc").'.</label><br>';
if (!empty($conf->global->MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND)) {
$out .= ' <label for="addmaindocfile">'.$langs->trans("JoinMainDocOrLastGenerated").'.</label><br>';
} else {
$out .= ' <label for="addmaindocfile">'.$langs->trans("JoinMainDoc").'.</label><br>';
}
}
if (is_numeric($this->withfile)) {
@ -1257,9 +1261,9 @@ class FormMail extends Form
* @param string $type_template Get message for model/type=$type_template, type='all' also included.
* @param User $user Get template public or limited to this user
* @param Translate $outputlangs Output lang object
* @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found)
* @param int $id Id of template to get, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found)
* @param int $active 1=Only active template, 0=Only disabled, -1=All
* @param string $label Label of template
* @param string $label Label of template to get
* @return ModelMail|integer One instance of ModelMail or -1 if error
*/
public function getEMailTemplate($dbs, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '')

View File

@ -1083,12 +1083,14 @@ class FormOther
* @param int $invert Invert
* @param string $option Option
* @param string $morecss More CSS
* @param bool $addjscombo Add js combo
* @return string
* @deprecated
*/
public function select_year($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle maxwidth75imp')
public function select_year($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle maxwidth75imp', $addjscombo = false)
{
// phpcs:enable
print $this->selectyear($selected, $htmlname, $useempty, $min_year, $max_year, $offset, $invert, $option, $morecss);
print $this->selectyear($selected, $htmlname, $useempty, $min_year, $max_year, $offset, $invert, $option, $morecss, $addjscombo);
}
/**

View File

@ -234,7 +234,7 @@ class Ldap
}
}
if (is_resource($this->connection)) {
if (is_resource($this->connection) || is_object($this->connection)) {
// Upgrade connexion to TLS, if requested by the configuration
if (!empty($conf->global->LDAP_SERVER_USE_TLS)) {
// For test/debug

View File

@ -1089,11 +1089,12 @@ class Translate
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso) != "Currency".$obj->code_iso ? $this->trans("Currency".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
$this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true);
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
if ($obj) {
// If a translation exists, we use it lese we use the default label
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso) != "Currency".$obj->code_iso ? $this->trans("Currency".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
$this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true);
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
}
$i++;
}
if (empty($currency_code)) {

View File

@ -502,8 +502,8 @@ interface Database
/**
* Returns the current line (as an object) for the resultset cursor
*
* @param resource $resultset Cursor of the desired request
* @return Object Object result line or false if KO or end of cursor
* @param resource|Connection $resultset Handler of the desired request
* @return Object Object result line or false if KO or end of cursor
*/
public function fetch_object($resultset);
// phpcs:enable

View File

@ -116,7 +116,7 @@ class DoliDBPgsql extends DoliDB
$this->connected = false;
$this->ok = false;
$this->error = 'Host, login or password incorrect';
dol_syslog(get_class($this)."::DoliDBPgsql : Erreur Connect ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::DoliDBPgsql : Erreur Connect ".$this->error.'. Failed to connect to host='.$host.' port='.$port.' user='.$user, LOG_ERR);
}
// Si connexion serveur ok et si connexion base demandee, on essaie connexion base
@ -423,7 +423,7 @@ class DoliDBPgsql extends DoliDB
}
// if local connection failed or not requested, use TCP/IP
if (!$this->db) {
if (empty($this->db)) {
if (!$host) {
$host = "localhost";
}
@ -432,7 +432,11 @@ class DoliDBPgsql extends DoliDB
}
$con_string = "host='".$host."' port='".$port."' dbname='".$name."' user='".$login."' password='".$passwd."'";
$this->db = @pg_connect($con_string);
try {
$this->db = @pg_connect($con_string);
} catch (Exception $e) {
print $e->getMessage();
}
}
// now we test if at least one connect method was a success
@ -580,7 +584,7 @@ class DoliDBPgsql extends DoliDB
{
// phpcs:enable
// If resultset not provided, we take the last used by connexion
if (!is_resource($resultset)) {
if (!is_resource($resultset) && !is_object($resultset)) {
$resultset = $this->_results;
}
return pg_fetch_object($resultset);
@ -597,7 +601,7 @@ class DoliDBPgsql extends DoliDB
{
// phpcs:enable
// If resultset not provided, we take the last used by connexion
if (!is_resource($resultset)) {
if (!is_resource($resultset) && !is_object($resultset)) {
$resultset = $this->_results;
}
return pg_fetch_array($resultset);
@ -614,7 +618,7 @@ class DoliDBPgsql extends DoliDB
{
// phpcs:enable
// Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion
if (!is_resource($resultset)) {
if (!is_resource($resultset) && !is_object($resultset)) {
$resultset = $this->_results;
}
return pg_fetch_row($resultset);
@ -632,7 +636,7 @@ class DoliDBPgsql extends DoliDB
{
// phpcs:enable
// If resultset not provided, we take the last used by connexion
if (!is_resource($resultset)) {
if (!is_resource($resultset) && !is_object($resultset)) {
$resultset = $this->_results;
}
return pg_num_rows($resultset);
@ -650,7 +654,7 @@ class DoliDBPgsql extends DoliDB
{
// phpcs:enable
// If resultset not provided, we take the last used by connexion
if (!is_resource($resultset)) {
if (!is_resource($resultset) && !is_object($resultset)) {
$resultset = $this->_results;
}
// pgsql necessite un resultset pour cette fonction contrairement
@ -668,11 +672,11 @@ class DoliDBPgsql extends DoliDB
public function free($resultset = null)
{
// If resultset not provided, we take the last used by connexion
if (!is_resource($resultset)) {
if (!is_resource($resultset) && !is_object($resultset)) {
$resultset = $this->_results;
}
// Si resultset en est un, on libere la memoire
if (is_resource($resultset)) {
if (is_resource($resultset) || is_object($resultset)) {
pg_free_result($resultset);
}
}
@ -916,7 +920,8 @@ class DoliDBPgsql extends DoliDB
// Test charset match LC_TYPE (pgsql error otherwise)
//print $charset.' '.setlocale(LC_CTYPE,'0'); exit;
$sql = "CREATE DATABASE '".$this->escape($database)."' OWNER '".$this->escape($owner)."' ENCODING '".$this->escape($charset)."'";
// NOTE: Do not use ' around the database name
$sql = "CREATE DATABASE ".$this->escape($database)." OWNER '".$this->escape($owner)."' ENCODING '".$this->escape($charset)."'";
dol_syslog($sql, LOG_DEBUG);
$ret = $this->query($sql);
return $ret;

View File

@ -230,7 +230,7 @@ print '
}
);
jQuery(\'.clipboardCPButton, .clipboardCPValueToPrint\').click(function() {
jQuery(\'.clipboardCPValue, .clipboardCPButton, .clipboardCPValueToPrint\').click(function() {
/* console.log(this.parentNode); */
console.log("We click on a clipboardCPButton or clipboardCPValueToPrint class and we want to copy content of clipboardCPValue class");

View File

@ -127,6 +127,19 @@ $langs->trans("FridayMin"),
$langs->trans("SaturdayMin")
);
$dec = ',';
$thousand = ' ';
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") {
$dec = $langs->transnoentitiesnoconv("SeparatorDecimal");
}
if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") {
$thousand = $langs->transnoentitiesnoconv("SeparatorThousand");
}
if ($thousand == 'Space') {
$thousand = ' ';
}
?>
// Javascript libraries for Dolibarr ERP CRM (https://www.dolibarr.org)
@ -136,6 +149,7 @@ var tradMonthsShort = <?php echo json_encode($tradMonthsShort) ?>;
var tradDays = <?php echo json_encode($tradDays) ?>;
var tradDaysShort = <?php echo json_encode($tradDaysShort) ?>;
var tradDaysMin = <?php echo json_encode($tradDaysMin) ?>;
var currencyCache = <?php echo json_encode($langs->cache_currencies) ?>;
// For JQuery date picker
$(document).ready(function() {
@ -623,6 +637,18 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke
url = url + "?dol_resetcache=1";
}
}
var page_y = $(document).scrollTop();
url = url.replace(/page_y=\d+/g, '');
if (page_y > 0) {
if (url.indexOf('?') > -1) {
url = url + "&page_y="+page_y;
} else {
url = url + "?page_y="+page_y;
}
}
url = url.replace(/&&+/, '&');
console.log("url ro redirect = "+url);
window.location.href = url;
//location.reload();
return false;
@ -704,6 +730,18 @@ function delConstant(url, code, input, entity, strict, forcereload, userid, toke
url = url + "?dol_resetcache=1";
}
}
var page_y = $(document).scrollTop();
url = url.replace(/page_y=\d+/g, '');
if (page_y > 0) {
if (url.indexOf('?') > -1) {
url = url + "&page_y="+page_y;
} else {
url = url + "?page_y="+page_y;
}
}
url = url.replace(/&&+/, '&');
console.log("url ro redirect = "+url);
window.location.href = url;
//location.reload();
return false;
@ -990,6 +1028,7 @@ function document_preview(file, type, title)
img.src = file;
}
function show_preview(mode) {
/* console.log("mode="+mode+" file="+file+" type="+type+" width="+width+" height="+height); */
var newElem = '<object name="objectpreview" data="'+file+'" type="'+type+'" width="'+object_width+'" height="'+object_height+'" param="noparam"></object>';
@ -1004,6 +1043,7 @@ function document_preview(file, type, title)
}
$("#dialogforpopup").html(newElem);
$("#dialogforpopup").dialog({
closeOnEscape: true,
resizable: true,
@ -1089,22 +1129,87 @@ function getParameterByName(name, valueifnotfound)
// Another solution, easier, to build a javascript rounding function
function dolroundjs(number, decimals) { return +(Math.round(number + "e+" + decimals) + "e-" + decimals); }
/**
* Function similar to PHP price()
*
* Example use:
* pricejs(13312.448, 'MT', 'EUR', 'fr_FR')
* // (depending on conf for 'MT'): '13 312.45 €'
*
* pricejs(343000.121, 'MT')
* // assuming conf for 'MT' is 2 and $langs->defaultlang is 'en_US': '343,000.12'
*
* @param {number|string} amount The amount to show
* @param {string} mode 'MT' or 'MU'
* @param {string} currency_code ISO code of currency (empty by default)
* @param {string} force_locale ISO code locale to use (if empty, will use Dolibarr's current locale code)
* @return {string} The amount with digits
*
*/
function pricejs(amount, mode) {
function pricejs(amount, mode = 'MT', currency_code = '', force_locale = '') {
var main_max_dec_shown = <?php echo (int) str_replace('.', '', $conf->global->MAIN_MAX_DECIMALS_SHOWN); ?>;
var main_rounding_unit = <?php echo (int) $conf->global->MAIN_MAX_DECIMALS_UNIT; ?>;
var main_rounding_tot = <?php echo (int) $conf->global->MAIN_MAX_DECIMALS_TOT; ?>;
var main_decimal_separator = <?php echo json_encode($dec) ?>;
var main_thousand_separator = <?php echo json_encode($thousand) ?>;
var locale_code = force_locale || <?php echo json_encode($langs->defaultlang) ?>;
var amountAsLocalizedString;
var useIntl = Boolean(Intl && Intl.NumberFormat);
var nDigits;
if (currency_code === 'auto') currency_code = <?php echo json_encode($conf->currency) ?>;
if (mode == 'MU') return amount.toFixed(main_rounding_unit);
if (mode == 'MT') return amount.toFixed(main_rounding_tot);
return 'Bad value for parameter mode';
if (mode === 'MU') nDigits = main_rounding_unit;
else if (mode === 'MT') nDigits = main_rounding_tot;
else return 'Bad value for parameter mode';
if (useIntl) {
// simple version: let the browser decide how to format the number using the provided language / currency
// parameters
var formattingOptions = {
minimumFractionDigits: nDigits,
maximumFractionDigits: nDigits
};
if (currency_code) {
formattingOptions['style'] = 'currency';
formattingOptions['currency'] = currency_code;
}
return Intl.NumberFormat(locale_code.replace('_', '-'), formattingOptions).format(amount);
}
// No Intl -> attempt to format the number in a way similar to Dolibarr PHP's `price()` function
amountAsLocalizedString = amount.toFixed(nDigits).replace(
/((?!^)(?:\d{3})*)(?:\.(\d+))?$/,
(fullMatch, digitsByThree, decimals) =>
digitsByThree.replace(
/\d{3}/g,
(groupOfThree) => main_thousand_separator + groupOfThree
) + (decimals !== undefined ? main_decimal_separator + decimals : '')
).replace(/ /, '');
if (!currency_code) return amountAsLocalizedString;
// print with currency
var currency_symbol = currency_code;
// codes of languages / currencies where the symbol must be placed before the amount
var currencyBeforeAmountCodes = {
currency: ['AUD', 'CAD', 'CNY', 'COP', 'CLP', 'GBP', 'HKD', 'MXN', 'PEN', 'USD'],
language: ['nl_NL']
};
if (currencyCache[currency_code]
&& currencyCache[currency_code]['unicode']
&& currencyCache[currency_code]['unicode'].length) {
currency_symbol = currencyCache[currency_code]['unicode'].reduce(function (res, cur) {return res + cur}, '');
}
if (currencyBeforeAmountCodes.currency.indexOf(currency_code) >= 0
|| currencyBeforeAmountCodes.language.indexOf(locale_code)) {
// if we use a language or a currency where the symbol is placed before the amount
return currency_symbol + amountAsLocalizedString;
}
// by default: currency symbol after the amount
return amountAsLocalizedString + '' + currency_symbol;
}
/**
@ -1117,20 +1222,8 @@ function pricejs(amount, mode) {
function price2numjs(amount) {
if (amount == '') return '';
<?php
$dec = ',';
$thousand = ' ';
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") {
$dec = $langs->transnoentitiesnoconv("SeparatorDecimal");
}
if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") {
$thousand = $langs->transnoentitiesnoconv("SeparatorThousand");
}
if ($thousand == 'Space') {
$thousand = ' ';
}
print "var dec='".dol_escape_js($dec)."'; var thousand='".dol_escape_js($thousand)."';\n"; // Set var in javascript
?>
var dec = <?php echo json_encode($dec) ?>;
var thousand = <?php echo json_encode($thousand) ?>;
var main_max_dec_shown = <?php echo (int) str_replace('.', '', $conf->global->MAIN_MAX_DECIMALS_SHOWN); ?>;
var main_rounding_unit = <?php echo (int) $conf->global->MAIN_MAX_DECIMALS_UNIT; ?>;

View File

@ -2223,7 +2223,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs
$ret = '';
$countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR', 'CN'); // See also MAIN_FORCE_STATE_INTO_ADDRESS
$sep = "\n";
// See format of addresses on https://en.wikipedia.org/wiki/Address
// Address
if (empty($mode)) {
@ -2233,12 +2233,13 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs
if (isset($object->country_code) && in_array($object->country_code, array('AU', 'CA', 'US', 'CN')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) {
// US: title firstname name \n address lines \n town, state, zip \n country
$town = ($extralangcode ? $object->array_languages['town'][$extralangcode] : (empty($object->town) ? '' : $object->town));
$ret .= ($ret ? $sep : '').$town;
$ret .= (($ret && $town) ? $sep : '').$town;
if (!empty($object->state)) {
$ret .= ($ret ? ", " : '').$object->state;
$ret .= ($ret ? ($town ? ", " : $sep) : '').$object->state;
}
if (!empty($object->zip)) {
$ret .= ($ret ? ", " : '').$object->zip;
$ret .= ($ret ? (($town || $object->state) ? ", " : $sep) : '').$object->zip;
}
} elseif (isset($object->country_code) && in_array($object->country_code, array('GB', 'UK'))) {
// UK: title firstname name \n address lines \n town state \n zip \n country
@ -7140,7 +7141,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__TICKET_USER_ASSIGN__'] = '__TICKET_USER_ASSIGN__';
}
if (!empty($conf->recruitment->enabled) && (!is_object($object) || $object->element == 'candidature')) {
if (!empty($conf->recruitment->enabled) && (!is_object($object) || $object->element == 'recruitmentcandidature')) {
$substitutionarray['__CANDIDATE_FULLNAME__'] = '__CANDIDATE_FULLNAME__';
$substitutionarray['__CANDIDATE_FIRSTNAME__'] = '__CANDIDATE_FIRSTNAME__';
$substitutionarray['__CANDIDATE_LASTNAME__'] = '__CANDIDATE_LASTNAME__';
@ -7289,8 +7290,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if (is_object($object) && $object->element == 'recruitmentcandidature') {
$substitutionarray['__CANDIDATE_FULLNAME__'] = $object->getFullName($outputlangs);
$substitutionarray['__CANDIDATE_FIRSTNAME__'] = $object->firstname;
$substitutionarray['__CANDIDATE_LASTNAME__'] = $object->lastname;
$substitutionarray['__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : '';
$substitutionarray['__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : '';
}
if (is_object($object->project)) {
@ -8350,7 +8351,7 @@ function verifCond($strToEvaluate)
* @param string $s String to evaluate
* @param int $returnvalue 0=No return (used to execute eval($a=something)). 1=Value of eval is returned (used to eval($something)).
* @param int $hideerrors 1=Hide errors
* @param string $onlysimplestring 0=Accept all chars, 1=Accept only simple string with char 'a-z0-9\s^$_->&|=!?():"\',/' and restrict use of (, 2=Accept also ';' and no restriction on (.
* @param string $onlysimplestring 0=Accept all chars, 1=Accept only simple string with char 'a-z0-9\s^$_+-.*\/>&|=!?():"\',/';', 2=Accept also ';[]'
* @return mixed Nothing or return result of eval
*/
function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1')
@ -8369,7 +8370,7 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1'
if ($onlysimplestring == '1') {
// We must accept: '1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL'
// We must accept: '$conf->barcode->enabled && preg_match(\'/^(AAA|BBB)/\',$leftmenu)'
if (preg_match('/[^a-z0-9\s'.preg_quote('^$_+-*>&|=!?():"\',/', '/').']/i', $s)) {
if (preg_match('/[^a-z0-9\s'.preg_quote('^$_+-.*>&|=!?():"\',/', '/').']/i', $s)) {
if ($returnvalue) {
return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
} else {
@ -8381,7 +8382,7 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1'
}
} elseif ($onlysimplestring == '2') {
// We must accept: (($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found"
if (preg_match('/[^a-z0-9\s'.preg_quote('^$_+-*>&|=!?():"\',/;[]', '/').']/i', $s)) {
if (preg_match('/[^a-z0-9\s'.preg_quote('^$_+-.*>&|=!?():"\',/;[]', '/').']/i', $s)) {
if ($returnvalue) {
return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
} else {
@ -8406,7 +8407,7 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1'
return '';
}
}
if (strpos($s, '.') !== false) {
if (preg_match('/[^0-9]+\.[^0-9]+/', $s)) { // We refuse . if not between 2 numbers
if ($returnvalue) {
return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
} else {
@ -8990,6 +8991,9 @@ function printCommonFooter($zone = 'private')
print 'jQuery("select[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";
print 'jQuery("select[name=\''.$paramkey.'\'] option[value=\'-1\']").prop(\'value\', \'\');'."\n";
print 'jQuery("select[name=\''.$paramkey.'\'] option[value=\'0\']").prop(\'value\', \'\');'."\n";
// Add 'field required' class on closest td for all input elements : input, textarea and select
print 'jQuery(":input[name=\'' . $paramkey . '\']").closest("tr").find("td:first").addClass("fieldrequired");' . "\n";
}
}
}
@ -9858,7 +9862,7 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
* Return the value of a filed into a dictionary for the record $id.
* This also set all the values into a cache for a next search.
*
* @param string $tablename Name of dictionary
* @param string $tablename Name of table dictionary (without the MAIN_DB_PREFIX, example: 'c_holiday_types')
* @param string $field The name of field where to find the value to return
* @param int $id Id of line record
* @param bool $checkentity Add filter on entity
@ -9869,12 +9873,14 @@ function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowi
{
global $conf, $db;
$tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename); // Clean name of table for backward compatibility.
$dictvalues = (isset($conf->cache['dictvalues_'.$tablename]) ? $conf->cache['dictvalues_'.$tablename] : null);
if (is_null($dictvalues)) {
$dictvalues = array();
$sql = "SELECT * FROM ".$tablename." WHERE 1 = 1"; // Here select * is allowed as it is generic code and we don't have list of fields
$sql = "SELECT * FROM ".MAIN_DB_PREFIX.$tablename." WHERE 1 = 1"; // Here select * is allowed as it is generic code and we don't have list of fields
if ($checkentity) {
$sql .= ' AND entity IN (0,'.getEntity($tablename).')';
}

View File

@ -37,13 +37,13 @@
* '6' : local tax apply on services including vat (localtax is calculated on amount + tax)
*
* @param int $qty Quantity
* @param float $pu Unit price (HT or TTC selon price_base_type)
* @param float $pu Unit price (HT or TTC depending on price_base_type. TODO Add also mode 'INCT' when pu is price HT+VAT+LT1+LT2)
* @param float $remise_percent_ligne Discount for line
* @param float $txtva 0=do not apply VAT tax, VAT rate=apply (this is VAT rate only without text code, we don't need text code because we alreaydy have all tax info into $localtaxes_array)
* @param float $uselocaltax1_rate 0=do not use localtax1, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1.
* @param float $uselocaltax2_rate 0=do not use localtax2, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1.
* @param float $remise_percent_global 0
* @param string $price_base_type HT=Unit price parameter is HT, TTC=Unit price parameter is TTC
* @param string $price_base_type 'HT'=Unit price parameter $pu is HT, 'TTC'=Unit price parameter $pu is TTC (HT+VAT but not Localtax. TODO Add also mode 'INCT' when pu is price HT+VAT+LT1+LT2)
* @param int $info_bits Miscellaneous informations on line
* @param int $type 0/1=Product/service
* @param Societe $seller Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc.

View File

@ -29,10 +29,10 @@
/**
* Prepare array with list of tabs
*
* @param Object $object Object related to tabs
* @param User $object Object related to tabs
* @return array Array of tabs to show
*/
function user_prepare_head($object)
function user_prepare_head(User $object)
{
global $langs, $conf, $user, $db;

View File

@ -260,7 +260,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
** 53 - Account inactive (manually locked out by administrator)
*/
dol_syslog("functions_ldap::check_user_password_ldap Authentication KO failed to connect to LDAP for '".$usertotest."'", LOG_NOTICE);
if (is_resource($ldap->connection)) { // If connection ok but bind ko
if (is_resource($ldap->connection) || is_object($ldap->connection)) { // If connection ok but bind ko
$ldap->ldapErrorCode = ldap_errno($ldap->connection);
$ldap->ldapErrorText = ldap_error($ldap->connection);
dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorCode." ".$ldap->ldapErrorText);

View File

@ -64,10 +64,10 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout
// Show/Hide vertical menu. The hamburger icon for .menuhider action.
if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$showmode = 1;
$classname = 'class="tmenu menuhider"';
$classname = 'class="tmenu menuhider nohover"';
$idsel = 'menu';
$menu->add('#', (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '<span class="fa fa-bars"></span>' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
$menu->add('#', (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1 ? '<span class="fa fa-bars"></span>' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
}
$num = count($newTabMenu);
@ -231,22 +231,31 @@ function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $cla
{
global $langs;
$classnameimg = str_replace('class="', 'class="tmenuimage ', $classname);
$classnametxt = str_replace('class="', 'class="tmenulabel ', $classname);
if ($showmode == 1) {
print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<div class="'.$id.' '.$idsel.' topmenuimage"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</a>';
print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '<a '.$classnametxt.' tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<div class="'.$id.' '.$idsel.' topmenuimage"><span class="'.$id.' tmenuimageforpng" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</a>';
if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
print '<a '.$classnameimg.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</a>';
}
} elseif ($showmode == 2) {
print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</a>';
print '<div '.$classnameimg.' title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled"><span class="'.$id.' tmenuimageforpng tmenudisabled" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</div>';
if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
print '<span '.$classnametxt.' id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</span>';
}
}
}

View File

@ -64,10 +64,10 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
// Show/Hide vertical menu. The hamburger icon for .menuhider action.
if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$showmode = 1;
$classname = 'class="tmenu menuhider"';
$classname = 'class="tmenu menuhider nohover"';
$idsel = 'menu';
$menu->add('#', (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '<span class="fa fa-bars"></span>' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
$menu->add('#', (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1 ? '<span class="fa fa-bars"></span>' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
}
$menu_arr = array();
@ -626,26 +626,31 @@ function print_text_menu_entry($text, $showmode, $url, $id, $idsel, $classname,
{
global $conf, $langs;
$classnameimg = str_replace('class="', 'class="tmenuimage ', $classname);
$classnametxt = str_replace('class="', 'class="tmenulabel ', $classname);
//$conf->global->THEME_TOPMENU_DISABLE_TEXT=1;
if ($showmode == 1) {
print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<div class="'.$id.' '.$idsel.' topmenuimage"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
print '<a '.$classnameimg.' tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<div class="'.$id.' '.$idsel.' topmenuimage"><span class="'.$id.' tmenuimageforpng" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</a>';
if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<a '.$classnametxt.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</a>';
}
} elseif ($showmode == 2) {
print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
print '<div '.$classnameimg.' title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled"><span class="'.$id.' tmenuimageforpng tmenudisabled" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</div>';
if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
print '<span class="mainmenuaspan">';
print '<span '.$classnametxt.' id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
print '<span class="mainmenuaspan tmenudisabled">';
print $text;
print '</span>';
print '</a>';
print '</span>';
}
}
}

View File

@ -102,7 +102,7 @@ class MenuManager
// Show/Hide vertical menu
if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$showmode = 1;
$classname = 'class="tmenu menuhider"';
$classname = 'class="tmenu menuhider nohover"';
$idsel = 'menu';
$this->menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
@ -513,19 +513,32 @@ function print_text_menu_entry_empty($text, $showmode, $url, $id, $idsel, $class
{
global $conf, $langs;
$classnameimg = str_replace('class="', 'class="tmenuimage ', $classname);
$classnametxt = str_replace('class="', 'class="tmenulabel ', $classname);
if ($showmode == 1) {
print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>';
print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</a>';
print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '<a '.$classnameimg.' tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<div class="'.$id.' '.$idsel.' topmenuimage"><span class="'.$id.' tmenuimageforpng" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</a>';
if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
print '<a '.$classnametxt.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</a>';
}
}
if ($showmode == 2) {
print '<div class="'.$id.' '.$idsel.' tmenudisabled"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
print '<div '.$classnameimg.' title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled"><span class="'.$id.' tmenuimageforpng tmenudisabled" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</div>';
if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
print '<span '.$classnametxt.' id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</span>';
}
}
}

View File

@ -826,7 +826,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
}
/**
* Tells if module is core or external
* Tells if module is core or external.
* 'dolibarr' and 'dolibarr_deprecated' is core
* 'experimental' and 'development' is core
*
* @return string 'core', 'external' or 'unknown'
*/
@ -954,11 +956,11 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$err++;
} else {
$obj = $this->db->fetch_object($resql);
$tmp = array();
if ($obj->note) {
$tmp = json_decode($obj->note, true);
}
if ($obj) {
$tmp = array();
if ($obj->note) {
$tmp = json_decode($obj->note, true);
}
return array(
'authorid' => $tmp['authorid'],
'ip' => $tmp['ip'],
@ -1052,16 +1054,16 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Create tables and keys required by module:
* - Files module.sql with create table instructions
* - Then modules.key.sql with create keys instructions
* - Files table.sql or table-module.sql with create table instructions
* - Then table.key.sql or table-module.key.sql with create keys instructions
* - Then data_xxx.sql (usualy provided by external modules only)
* - Then update_xxx.sql (usualy provided by external modules only)
* Files must be stored in directory defined by reldir (Example: '/install/mysql/tables' or '/module/sql/')
* Files must be stored in subdirectory 'tables' or 'data' into directory $reldir (Example: '/install/mysql/' or '/module/sql/')
* This function may also be called by :
* - _load_tables('/install/mysql/tables/', 'modulename') into the this->init() of core module descriptors.
* - _load_tables('/install/mysql/', 'modulename') into the this->init() of core module descriptors.
* - _load_tables('/mymodule/sql/') into the this->init() of external module descriptors.
*
* @param string $reldir Relative directory where to scan files. Example: '/install/mysql/tables' or '/module/sql/'
* @param string $reldir Relative directory where to scan files. Example: '/install/mysql/' or '/module/sql/'
* @param string $onlywithsuffix Only with the defined suffix
* @return int <=0 if KO, >0 if OK
*/
@ -1082,112 +1084,147 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$ok = 1;
foreach ($conf->file->dol_document_root as $dirroot) {
if ($ok) {
$dir = $dirroot.$reldir;
$dirsql = $dirroot.$reldir;
$ok = 0;
$handle = @opendir($dir); // Dir may not exists
if (is_resource($handle)) {
$dirfound++;
// We will loop on xxx/, xxx/tables/, xxx/data/
$listofsubdir = array('', 'tables/', 'data/');
if ($this->db->type == 'pgsql') {
$listofsubdir[] = '../pgsql/functions/';
}
// Run llx_mytable.sql files, then llx_mytable_*.sql
$files = array();
while (($file = readdir($handle)) !== false) {
$files[] = $file;
}
sort($files);
foreach ($files as $file) {
if ($onlywithsuffix) {
if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {
//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";
continue;
} else {
//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";
foreach ($listofsubdir as $subdir) {
$dir = $dirsql.$subdir;
$handle = @opendir($dir); // Dir may not exists
if (is_resource($handle)) {
$dirfound++;
// Run llx_mytable.sql files, then llx_mytable_*.sql
$files = array();
while (($file = readdir($handle)) !== false) {
$files[] = $file;
}
sort($files);
foreach ($files as $file) {
if ($onlywithsuffix) {
if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {
//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";
continue;
} else {
//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";
}
}
if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_') {
$result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);
if ($result <= 0) {
$error++;
}
}
}
if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') {
$result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);
if ($result <= 0) {
$error++;
rewinddir($handle);
// Run llx_mytable.key.sql files (Must be done after llx_mytable.sql) then then llx_mytable_*.key.sql
$files = array();
while (($file = readdir($handle)) !== false) {
$files[] = $file;
}
sort($files);
foreach ($files as $file) {
if ($onlywithsuffix) {
if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {
//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";
continue;
} else {
//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";
}
}
if (preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_') {
$result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);
if ($result <= 0) {
$error++;
}
}
}
}
rewinddir($handle);
rewinddir($handle);
// Run llx_mytable.key.sql files (Must be done after llx_mytable.sql) then then llx_mytable_*.key.sql
$files = array();
while (($file = readdir($handle)) !== false) {
$files[] = $file;
}
sort($files);
foreach ($files as $file) {
if ($onlywithsuffix) {
if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {
//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";
continue;
} else {
//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";
// Run functions-xxx.sql files (Must be done after llx_mytable.key.sql)
$files = array();
while (($file = readdir($handle)) !== false) {
$files[] = $file;
}
sort($files);
foreach ($files as $file) {
if ($onlywithsuffix) {
if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {
//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";
continue;
} else {
//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";
}
}
if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 9) == 'functions') {
$result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);
if ($result <= 0) {
$error++;
}
}
}
if (preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') {
$result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);
if ($result <= 0) {
$error++;
rewinddir($handle);
// Run data_xxx.sql files (Must be done after llx_mytable.key.sql)
$files = array();
while (($file = readdir($handle)) !== false) {
$files[] = $file;
}
sort($files);
foreach ($files as $file) {
if ($onlywithsuffix) {
if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {
//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";
continue;
} else {
//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";
}
}
if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'data') {
$result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);
if ($result <= 0) {
$error++;
}
}
}
}
rewinddir($handle);
rewinddir($handle);
// Run data_xxx.sql files (Must be done after llx_mytable.key.sql)
$files = array();
while (($file = readdir($handle)) !== false) {
$files[] = $file;
}
sort($files);
foreach ($files as $file) {
if ($onlywithsuffix) {
if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {
//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";
continue;
} else {
//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";
// Run update_xxx.sql files
$files = array();
while (($file = readdir($handle)) !== false) {
$files[] = $file;
}
sort($files);
foreach ($files as $file) {
if ($onlywithsuffix) {
if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {
//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";
continue;
} else {
//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";
}
}
if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 6) == 'update') {
$result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);
if ($result <= 0) {
$error++;
}
}
}
if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'data') {
$result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);
if ($result <= 0) {
$error++;
}
}
}
rewinddir($handle);
// Run update_xxx.sql files
$files = array();
while (($file = readdir($handle)) !== false) {
$files[] = $file;
closedir($handle);
}
sort($files);
foreach ($files as $file) {
if ($onlywithsuffix) {
if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {
//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";
continue;
} else {
//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";
}
}
if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 6) == 'update') {
$result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);
if ($result <= 0) {
$error++;
}
}
}
closedir($handle);
}
if ($error == 0) {
@ -2247,6 +2284,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$entity = $conf->entity;
if (is_array($this->module_parts) && !empty($this->module_parts)) {
dol_syslog(get_class($this)."::delete_module_parts", LOG_DEBUG);
foreach ($this->module_parts as $key => $value) {
// If entity is defined
if (is_array($value) && isset($value['entity'])) {
@ -2257,7 +2296,6 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$sql .= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->db->escape($this->const_name)."_".strtoupper($key)."'";
$sql .= " AND entity = ".((int) $entity);
dol_syslog(get_class($this)."::delete_const_".$key."", LOG_DEBUG);
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
$err++;

View File

@ -742,6 +742,9 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetXY($posxval, $posy);
$lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
if ($object->deposit_percent > 0) {
$lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
}
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
$posy = $pdf->GetY() + 3;

View File

@ -960,6 +960,9 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->SetXY($posxval, $posy);
$lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
if ($object->deposit_percent > 0) {
$lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
}
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
$posy = $pdf->GetY() + 3;

View File

@ -240,7 +240,7 @@ class modAsset extends DolibarrModules
*/
public function init($options = '')
{
$result = $this->_load_tables('/install/mysql/tables/', 'asset');
$result = $this->_load_tables('/install/mysql/', 'asset');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}

View File

@ -159,7 +159,7 @@ class modDeplacement extends DolibarrModules
*/
public function init($options = '')
{
$result = $this->_load_tables('/install/mysql/tables/', 'deplacement');
$result = $this->_load_tables('/install/mysql/', 'deplacement');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}

View File

@ -155,7 +155,7 @@ class modDon extends DolibarrModules
{
global $conf;
$result = $this->_load_tables('/install/mysql/tables/', 'deplacement');
$result = $this->_load_tables('/install/mysql/', 'don');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}

View File

@ -280,7 +280,7 @@ class modHRM extends DolibarrModules
// Permissions
$this->remove($options);
$result = $this->_load_tables('/install/mysql/tables/', 'hrm');
$result = $this->_load_tables('/install/mysql/', 'hrm');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}

View File

@ -50,7 +50,7 @@ class modIntracommreport extends DolibarrModules
$this->description = "Intracomm report management (Support for French DEB/DES format)";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
$this->version = 'experimental';
$this->version = 'development';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->picto = 'intracommreport';
@ -138,7 +138,7 @@ class modIntracommreport extends DolibarrModules
{
global $conf;
$result = $this->_load_tables('/install/mysql/tables/', 'intracommreport');
$result = $this->_load_tables('/install/mysql/', 'intracommreport');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}

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