diff --git a/ChangeLog b/ChangeLog index 555258f3901..a458f7eea74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/README.md b/README.md index 4e120a4cb91..5559613eaa2 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 91d8257ea7f..f2137d84af9 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -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 '
'."\n"; print ''; @@ -368,7 +368,7 @@ if ($action == 'create') { // View mode $linkback = ''.$langs->trans("BackToList").''; - 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'); diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index c99503f95f6..6d7d92ce22b 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -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 ''; + print '' . img_picto('', 'bill', 'class="pictofixedwidth"') . $langs->trans("UseAuxiliaryAccountOnCustomerDeposit") . ''; + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; +} print "\n"; print "\n"; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 8a8ca0ecf46..1a682636077 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -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 { diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 511b12de3c2..61e131ff47d 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -431,12 +431,12 @@ if ($action == 'create') { // Account movement print ''; print ''.$langs->trans("NumMvts").''; - print ''.$object->piece_num.''; + print ''.($mode == '_tmp' ? ''.$langs->trans("Draft").'' : $object->piece_num).''; print ''; // Date print ''; - print ''; } } - print ''; print ''; $obj = new stdClass(); @@ -742,7 +793,7 @@ if ($action == 'add') { $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); } foreach ($fieldsforcontent as $tmpfieldlist) { - print ''; - if ($tmpfieldlist == 'topic') { - print ''; - } - // else print ''; print ''; } print '
'; + print ''; if ($action != 'editdate') { diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index bc7ea7c7072..ce0714d5651 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -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. diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 5650cce8767..80b2efe7050 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -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 diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 21b723b003b..1a43a999ea1 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -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) { diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 7cc7f0effbc..426bc6d7795 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -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 ""; // Subledger account print "'; $companystatic->id = $tabcompany[$key]['id']; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 9fa02f1c01b..c2ef4583bdc 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -215,7 +215,7 @@ if (empty($reshook)) { $search_status = ""; $catid = ""; $sall = ""; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index aed531d86b4..d96adbc3b82 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -135,7 +135,7 @@ if (empty($reshook)) { $search_note = ""; $search_amount = ""; $search_account = ""; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } } diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php index 3e878b9398b..8195683c5ab 100644 --- a/htdocs/admin/debugbar.php +++ b/htdocs/admin/debugbar.php @@ -93,15 +93,17 @@ print ''; print "\n"; -print ''; -print ''; +print ''; -print ''; -print ''; +print ''; print '
'; print $langs->trans('Docdate'); print '"; - if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { - if (($accountoshow == "") || $accountoshow == 'NotDefined') { - print ''.$langs->trans("ThirdpartyAccountNotDefined").''; - } 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 '' . $langs->trans("ThirdpartyAccountNotDefined") . ''; } print ''.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").''; // This slow seriously output -print ' '.$langs->trans("WarningValueHigherSlowsDramaticalyOutput"); +print '
'.$langs->trans("DEBUGBAR_USE_LOG_FILE").''; +print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1); +print ''; +print ' '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower").''; print '
'.$langs->trans("DEBUGBAR_USE_LOG_FILE").''; -print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1); -print ' '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower"); +print '
'.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").''; // This slow seriously output +print ''; +print ''.$langs->trans("WarningValueHigherSlowsDramaticalyOutput").''; print '
'; diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 58a72250d64..088c84de3f0 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -101,7 +101,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $defaulturl = ''; $defaultkey = ''; $defaultvalue = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index cd8ab4c1836..493203231b5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -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).
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).
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 ''; // Line for title + print ''; $tdsoffields = ''; 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 ''; 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 .= ''; + $tdsoffields .= ''; if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { $tdsoffields .= ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; } elseif (!empty($tabhelp[$id][$value])) { @@ -1513,29 +1494,29 @@ if ($id) { } else { $tdsoffields .= $valuetoshow; } - $tdsoffields .= ''; + $tdsoffields .= ''; } } if ($id == 4) { - $tdsoffields .= ''; - $tdsoffields .= ''; + $tdsoffields .= ''; + $tdsoffields .= ''; } - $tdsoffields .= ''; - $tdsoffields .= ''; + $tdsoffields .= ''; + $tdsoffields .= ''; + $tdsoffields .= ''; $tdsoffields .= ''; print $tdsoffields; // Line to enter new values - print ''; + print ''; print ''; $obj = new stdClass(); @@ -1606,6 +1587,7 @@ if ($id) { print '
 '; + $tdsoffields .= ''; $tdsoffields .= ''; if (!is_null($withentity)) { $tdsoffields .= ''; } - $tdsoffields .= ''; - $tdsoffields .= '
'; // Title line with search input fields + print ''."\n"; print ''; $filterfound = 0; foreach ($fieldlist as $field => $value) { @@ -1650,6 +1632,7 @@ if ($id) { print ''; // Title of lines + print ''."\n"; print ''; 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 ''.$actl[$obj->eec].''; } else { - print $langs->trans("AlwaysActive"); + print ''.$langs->trans("AlwaysActive").''; } print ''; print ''; } @@ -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 ''.$langs->trans("AlwaysActive").''; } } print ""; @@ -2283,7 +2273,7 @@ if ($id) { print ''; print ''; print ''; print ''; $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 ''; - } 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 ''; - } elseif ($value == 'source') { - // The source of the element (for contact types) - print ''; } 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 ''; - } 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 ''; - } elseif ($value == 'type' && $tabname == MAIN_DB_PREFIX.'c_paiement') { + } elseif ($value == 'type' && $tabname == 'c_paiement') { print ''; } 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 ''; } 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); } diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 5a23133923e..521a24f490d 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -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); diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 7a4faa989d0..d01b160ca31 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -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 '
'; print '
'; @@ -2182,7 +2172,7 @@ if ($id) { if ($iserasable) { print ''.$actl[$obj->favorite].''; } else { - print $langs->trans("AlwaysActive"); + print ''.$langs->trans("AlwaysActive").''; } print ''; - print $form->textwithpicto('', $langs->trans("Table").': '.$tabname[$i]); + print $form->textwithpicto('', $langs->trans("Table").': '.MAIN_DB_PREFIX.$tabname[$i]); print '
'; print ''; @@ -2369,15 +2359,9 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'lang'); print ''; - print $form->selectarray('element', $elementList, (!empty($obj->{$value}) ? $obj->{$value}:'')); - print ''; - print $form->selectarray('source', $sourceList, (!empty($obj->{$value}) ? $obj->{$value}:'')); + print $form->selectarray($value, $elementList, (!empty($obj->{$value}) ? $obj->{$value}:'')); print ''; print $form->selectyesno("private", (!empty($obj->{$value}) ? $obj->{$value}:'')); print ''; print $type.''; print ''; $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 '
'; print ''; - print ''; + print ''; print ''; // Add filter print ''; @@ -647,7 +653,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp')); } print ''; - print '
'.img_picto('', 'filter', 'class="pictofixedwidth"').$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).''.img_picto('', 'filter', 'class="pictofixedwidth opacitymedium"').$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'
'; + print ''; if ($action == 'editoperation' && $ruleaction['id'] == $operationid) { print '
'; print ''; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 799012b5448..32b55d0a612 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -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 ''; +print ''."\n"; if ($optioncss != '') { print ''; } @@ -408,25 +430,43 @@ print ''; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} 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 ''; } @@ -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 ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; +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 ''."\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 ''; - 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 ''; } - - 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 ''; - if ($key == 'status') { - print $object->getLibStatut(5); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); + } else { + // Show here line of result + $j = 0; + print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; - 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 ''; - 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 ''."\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 ''; + 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 ''; + 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 ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print ''."\n"; + } $i++; } @@ -582,7 +670,7 @@ if ($num == 0) { $colspan++; } } - print ''; + print ''; } @@ -596,16 +684,18 @@ print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; 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 ''; + 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 '
'; + print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + } 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 ''; } print '
'; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + print '
'; } - - 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 '
'; + print '
'; + 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 ''; } print ''; - 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 ''; - } - print '
'; + 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 ''; + } + print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'."\n"; print ''."\n"; print load_fiche_titre($langs->trans("Other"), '', ''); + + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; print ''; -print ''; print "\n"; // Hide e-mail headers from collected messages -print ''; +print ''; print ''; -print ''; print ''; -print '
'.$langs->trans("Parameter").'
'.$langs->trans("EmailCollectorHideMailHeaders").'
'.$form->textwithpicto($langs->trans("EmailCollectorHideMailHeaders"), $langs->transnoentitiesnoconv("EmailCollectorHideMailHeadersHelp")).''; 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 ''; -print $form->textwithpicto('', $langs->trans("EmailCollectorHideMailHeadersHelp"), 1, 'help'); -print '

'; +print '
'; +print ''; + +print '
'; + print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 254f7d3c8d4..ee6c2ae6b52 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -220,7 +220,7 @@ if ($action == 'edit') { foreach ($arrayofparameters as $constname => $val) { if ($val['enabled']==1) { $setupnotempty++; - print '
aa'; + print '
'; $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '

'."\n".$langs->trans($constname . 'Tooltip2') : ''); print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; @@ -457,7 +457,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print '
'; $constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $file) { + if (getDolGlobalString($constforvar) == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -597,7 +597,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Default print ''; $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 'scandir.'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 1146232dca3..62fb097841b 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -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' } } diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index aea86069f4d..f5bbb5c648f 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -279,7 +279,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print ''; $constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $file) { + if (getDolGlobalString($constforvar) == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -421,7 +421,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Default print ''; $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 'scandir.'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index bf486ea3d4e..5605fa4fb63 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -323,130 +323,6 @@ print '
'; clearstatcache(); -if ($mode == 'template') { - // Themes and themes options - showSkins(null, 1); -} - -if ($mode == 'dashboard') { - print '
'; - print ''; - - // Message of the day on home page - $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount')); - complete_substitutions_array($substitutionarray, $langs); - - print '' . "\n"; - - /* no more need for this option. It is now a widget already controlled by end user - print ''; - print ''; - */ - - print '
'; - $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted") . '
'; - foreach ($substitutionarray as $key => $val) { - $texthelp .= $key . '
'; - } - print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday'); - - print '
'; - - $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 '
' . $langs->trans('BoxstatsDisableGlobal') . ''; - print ajax_constantonoff("MAIN_DISABLE_GLOBAL_BOXSTATS", array(), $conf->entity, 0, 0, 1, 0); - print '
'; - print '
'; - - print '
'; - - print '
'; - print ''; - - print ''; - - print ''; - print ''; - - if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { - // Block meteo - print ''; - print ''; - - // Block agenda - print ''; - print ''; - - // Block agenda - print ''; - print ''; - - // Block customer - print ''; - print ''; - - // Block supplier - print ''; - print ''; - - // Block contract - print ''; - print ''; - - // Block ticket - print ''; - print ''; - - // Block bank - print ''; - print ''; - - // Block adherent - print ''; - print ''; - - // Block expense report - print ''; - print ''; - - // Block holiday - print ''; - print ''; - } - - print '
'; - print $langs->trans("DashboardDisableBlocks"); - print ''; - print '
' . $langs->trans('DashboardDisableGlobal') . ''; - print ajax_constantonoff("MAIN_DISABLE_GLOBAL_WORKBOARD", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); - print '
' . $langs->trans('MAIN_DISABLE_METEO') . ''; - print ajax_constantonoff("MAIN_DISABLE_METEO", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); - print '
' . $langs->trans('DashboardDisableBlockAgenda') . ''; - print ajax_constantonoff("MAIN_DISABLE_BLOCK_AGENDA", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); - print '
' . $langs->trans('DashboardDisableBlockProject') . ''; - print ajax_constantonoff("MAIN_DISABLE_BLOCK_PROJECT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); - print '
' . $langs->trans('DashboardDisableBlockCustomer') . ''; - print ajax_constantonoff("MAIN_DISABLE_BLOCK_CUSTOMER", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); - print '
' . $langs->trans('DashboardDisableBlockSupplier') . ''; - print ajax_constantonoff("MAIN_DISABLE_BLOCK_SUPPLIER", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); - print '
' . $langs->trans('DashboardDisableBlockContract') . ''; - print ajax_constantonoff("MAIN_DISABLE_BLOCK_CONTRACT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); - print '
' . $langs->trans('DashboardDisableBlockTicket') . ''; - print ajax_constantonoff("MAIN_DISABLE_BLOCK_TICKET", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); - print '
' . $langs->trans('DashboardDisableBlockBank') . ''; - print ajax_constantonoff("MAIN_DISABLE_BLOCK_BANK", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); - print '
' . $langs->trans('DashboardDisableBlockAdherent') . ''; - print ajax_constantonoff("MAIN_DISABLE_BLOCK_ADHERENT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); - print '
' . $langs->trans('DashboardDisableBlockExpenseReport') . ''; - print ajax_constantonoff("MAIN_DISABLE_BLOCK_EXPENSEREPORT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); - print '
' . $langs->trans('DashboardDisableBlockHoliday') . ''; - print ajax_constantonoff("MAIN_DISABLE_BLOCK_HOLIDAY", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); - print '
' . "\n"; - print '
'; -} - if ($mode == 'other') { print '
'; print ''; @@ -587,6 +463,133 @@ if ($mode == 'other') { print ''; } + +if ($mode == 'template') { + // Themes and themes options + showSkins(null, 1); +} + + +if ($mode == 'dashboard') { + print '
'; + print '
'; + + // Message of the day on home page + $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount')); + complete_substitutions_array($substitutionarray, $langs); + + print '' . "\n"; + + /* no more need for this option. It is now a widget already controlled by end user + print ''; + print ''; + */ + + print '
'; + $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted") . '
'; + foreach ($substitutionarray as $key => $val) { + $texthelp .= $key . '
'; + } + print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday'); + + print '
'; + + $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 '
' . $langs->trans('BoxstatsDisableGlobal') . ''; + print ajax_constantonoff("MAIN_DISABLE_GLOBAL_BOXSTATS", array(), $conf->entity, 0, 0, 1, 0); + print '
'; + print '
'; + + print '
'; + + print '
'; + print ''; + + print ''; + + print ''; + print ''; + + if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { + // Block meteo + print ''; + print ''; + + // Block agenda + print ''; + print ''; + + // Block agenda + print ''; + print ''; + + // Block customer + print ''; + print ''; + + // Block supplier + print ''; + print ''; + + // Block contract + print ''; + print ''; + + // Block ticket + print ''; + print ''; + + // Block bank + print ''; + print ''; + + // Block adherent + print ''; + print ''; + + // Block expense report + print ''; + print ''; + + // Block holiday + print ''; + print ''; + } + + print '
'; + print $langs->trans("DashboardDisableBlocks"); + print ''; + print '
' . $langs->trans('DashboardDisableGlobal') . ''; + print ajax_constantonoff("MAIN_DISABLE_GLOBAL_WORKBOARD", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
' . $langs->trans('MAIN_DISABLE_METEO') . ''; + print ajax_constantonoff("MAIN_DISABLE_METEO", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
' . $langs->trans('DashboardDisableBlockAgenda') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_AGENDA", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
' . $langs->trans('DashboardDisableBlockProject') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_PROJECT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
' . $langs->trans('DashboardDisableBlockCustomer') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_CUSTOMER", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
' . $langs->trans('DashboardDisableBlockSupplier') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_SUPPLIER", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
' . $langs->trans('DashboardDisableBlockContract') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_CONTRACT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
' . $langs->trans('DashboardDisableBlockTicket') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_TICKET", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
' . $langs->trans('DashboardDisableBlockBank') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_BANK", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
' . $langs->trans('DashboardDisableBlockAdherent') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_ADHERENT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
' . $langs->trans('DashboardDisableBlockExpenseReport') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_EXPENSEREPORT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
' . $langs->trans('DashboardDisableBlockHoliday') . ''; + print ajax_constantonoff("MAIN_DISABLE_BLOCK_HOLIDAY", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '_red', 'dashboard'); + print '
' . "\n"; + print '
'; +} + + if ($mode == 'login') { // Other print '
'; diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index c2440bbb885..041216014b0 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -403,7 +403,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print '
'; $constforvar = 'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $file) { + if (getDolGlobalString($constforvar) == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -545,7 +545,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Default print ''; $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 'scandir.'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index d3441cf2e21..8e31d0e6d62 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -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') diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index e308d27b2b2..d96e0706223 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -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 ''; + print ''; if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; } elseif (!empty($tabhelp[$id][$value])) { @@ -693,12 +744,12 @@ if ($action == 'add') { } else { print $valuetoshow; } - print ''; + print ''; + print ''; print ''; - print ''; + print '
'; + print '
'; // Label if ($tmpfieldlist == 'topic') { @@ -773,24 +824,33 @@ if ($action == 'add') { print $doleditor->Create(1); } print ''; - if ($action != 'edit') { - print '
'; - print ''; - } - print '
'; + + if ($action != 'edit') { + print '
'; + print ' '; + print ''; + print '
'; + } + print ''; print ''; - print '
'; + print '

'; } // 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 '
'; print ''; print ''; @@ -798,157 +858,155 @@ print ''; print ''; -// 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 ''; - } +// There is several pages +if ($num > $listlimit) { + print ''; +} - // Title line with search boxes - print ''; +// Title line with search boxes +print ''; - foreach ($fieldlist as $field => $value) { - if ($value == 'label') { - print ''; - } elseif ($value == 'lang') { - print ''; - } elseif ($value == 'fk_user') { - print ''; - } elseif ($value == 'topic') { - print ''; - } elseif ($value == 'type_template') { - print ''; - } elseif (!in_array($value, array('content', 'content_lines'))) { - print ''; - } - } - - if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { +foreach ($fieldlist as $field => $value) { + if ($value == 'label') { + print ''; + } elseif ($value == 'lang') { + print ''; + } elseif ($value == 'fk_user') { + print ''; + } elseif ($value == 'topic') { + print ''; + } elseif ($value == 'type_template') { + print ''; + } elseif (!in_array($value, array('content', 'content_lines'))) { print ''; } +} - // Action column - print ''; - print ''; +if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { + print ''; +} - // Title of lines - print ''; - 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 ''; +print ''; - 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 ''; +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 ''; + 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 ''; + +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 ''; @@ -1018,6 +1076,8 @@ if ($resql) { } print "\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 ''; $tmpaction = 'view'; @@ -1155,13 +1217,16 @@ if ($resql) { print "\n"; } - - - $i++; } + + $i++; } -} else { - dol_print_error($db); +} + +// If no record found +if ($nbqualified == 0) { + $colspan = 10; + print ''; } print '
'; - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); - print '
'; + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); + print '
'; - print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth150'); - print ''; - print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth150'); - print ''; - print $form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1); - print ''; + print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth150'); + print ''; + print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth150'); + print ''; + print $form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1); + print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print '
'; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
'.$langs->trans("NoRecordFound").'
'; diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 716dbc32ca7..0c53bebfc52 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -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].'
'; @@ -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 .= '
'.$langs->trans("LastActivationAuthor").': '; $text .= $tmpuser->getNomUrl(1); } -$ip = $tmp['ip']; +$ip = (empty($tmp['ip']) ? '' : $tmp['ip']); if ($ip) { $text .= '
'.$langs->trans("LastActivationIP").': '; $text .= $ip; } -$lastactivationversion = $tmp['lastactivationversion']; +$lastactivationversion = (empty($tmp['lastactivationversion']) ? '' : $tmp['lastactivationversion']); if ($lastactivationversion) { $text .= '
'.$langs->trans("LastActivationVersion").': '; $text .= $lastactivationversion; diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index ac51ce33dc3..c9324565e5b 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -183,6 +183,22 @@ print "".$name.""; print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); print ""; +$functions = ["easter_date"]; +$name = "Calendar"; + +print ""; +print "".$name.""; +print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); +print ""; + +$functions = ["simplexml_load_string"]; +$name = "Xml"; + +print ""; +print "".$name.""; +print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); +print ""; + if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') { $functions = ["locale_get_primary_language", "locale_get_region"]; $name = "Intl"; diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index f257b040636..f902c3fb39b 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -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 '
'; -print "\n"; -print "\n"; +print '
'."\n"; +print ''."\n"; print ''; print ''; print '\n"; @@ -502,13 +477,14 @@ foreach ($dirmodels as $reldir) { print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."
'; print '

'; -if (empty($conf->use_javascript_ajax)) { - print ''; - print ''; - print ''; -} + +print ''; +print ''; +print ''; +print ''; print load_fiche_titre($langs->trans("Other"), '', ''); +print '
'; print ''; print ''; @@ -563,34 +539,24 @@ print $formcategory->textwithpicto('', $langs->trans("TicketsAutoNotifyCloseHelp print ''; print ''; -// Choose which product category is used for tickets -if ($conf->use_javascript_ajax) { - print ''; - print ''; - print ''; +if (! empty($conf->product->enabled)) { + print ''; + print ''; + print ''; + print ''; } -print ''; -print ''; -print ''; -print ''; - -// Define wanted maximum time elapsed before answers to tickets -print ''; -print ''; - print ''; print '"; print ''; print ''; print ''; print '"; print ''; print ''; print '
'.$langs->trans("TicketChooseProductCategory").''; + $formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id'); + if ($conf->use_javascript_ajax) { + print ajax_combobox('select_'.$htmlname); + } + print ''; + print $formcategory->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help'); + print '
'.$langs->trans("TicketChooseProductCategory").''; -$formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id'); -if ($conf->use_javascript_ajax) { - print ajax_combobox('select_'.$htmlname); -} -print ''; -print $formcategory->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help'); -print '
'.$langs->trans("TicketsDelayBeforeFirstAnswer")." - - + '; print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help'); @@ -600,8 +566,7 @@ print '
'.$langs->trans("TicketsDelayBetweenAnswers")." - - + '; print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help'); @@ -610,9 +575,7 @@ print '

'; -print '
'; -print ''; -print '
'; +print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition'); print ''; @@ -622,9 +585,10 @@ print load_fiche_titre($langs->trans("Notification"), '', ''); print ''; -print ''; +print ''; print ''; print ''; +print ''; print ''; print ''; @@ -699,7 +663,7 @@ print ''; print '
'.$langs->trans("Email").'
'; -print $formcategory->buttonsSaveCancel("Save", ''); +print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition'); print ''; diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index ea9ca86e994..902e68b381e 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -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").' : '.$langs->trans("ErrorFunctionNotAvailableInPHP", 'simplexml_load_string').'
'; + } elseif ($sfurl) { $i = 0; while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) { $title = $sfurl->channel[0]->item[$i]->title; diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 10f0f8375e3..18ce707c839 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -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(); } diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php index 58118827ed4..6ac7a425246 100644 --- a/htdocs/admin/workstation.php +++ b/htdocs/admin/workstation.php @@ -295,7 +295,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print ''; $constforvar = 'WORKSTATION_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $file) { + if (getDolGlobalString($constforvar) == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -437,7 +437,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Default print ''; $constforvar = 'WORKSTATION_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $name) { + if (getDolGlobalString($constforvar) == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index afa4777de3d..29ee4b074fb 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -266,7 +266,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print ''; $constforvar = 'ASSET_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $file) { + if (getDolGlobalString($constforvar) == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -408,7 +408,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Default print ''; $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 'scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index ef3c23eff2b..1a5f99b27ee 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -286,7 +286,7 @@ if ($conf->product->enabled || $conf->product->service) { print ''; $moretags2 = (($nbno == $nbtotal) ? ' disabled' : ''); print '   '; - print ''; + print ''; print '



'; } diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 4698222bda8..4490b3897df 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -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(); } diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 327876f17c2..7d12f571c06 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -734,9 +734,9 @@ if ($type == Categorie::TYPE_MEMBER) { print ''; print ''; print ''; + print ''; print ''; print '
'; - print $langs->trans("AddMemberIntoCategory").'  '; + print $langs->trans("AssignCategoryTo").'  '; print $form->selectMembers('', 'elemid'); - print '
'; print ''; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index f6932cc4bef..86b8a3b5ce5 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -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(); } diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 4aca208681b..411efc5ae93 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -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 ''; print ''; 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 ""; print ''; diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index be458d41fe3..ecde836c428 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -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') diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 07e041a8fd1..22a816acc1d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -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 ''; // Reference - print ''; + print ''; // Ref customer - print ''; print ''; // Third party - print ''; - print ''; + print ''; + print ''; $shipping_method_id = 0; if ($socid > 0) { - print ''; @@ -1600,7 +1661,7 @@ if ($action == 'create') { } //$warehouse_id = $soc->warehouse_id; } else { - print ''; // Third party discounts info line - print ''; // Validaty duration - print ''; + print ''; // Terms of payment - print ''; // Mode of payment - print ''; // Bank Account if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) { - print ''; } // Source / Channel - What trigger creation - print ''; // Delivery delay - print ''; @@ -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 ''; @@ -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 ''; } // Delivery date (or manufacturing) - print ''; - print ''; + print ''; - print ''; + print ''; @@ -1730,17 +1791,17 @@ if ($action == 'create') { // Incoterms if (!empty($conf->incoterm->enabled)) { - print ''; - print ''; - print ''; + print ''; + print ''; } // Template to use by default - print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; } // Public note - print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print '
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('RefCustomer').''; + print '
'.$langs->trans('RefCustomer').''; print '
'.$langs->trans('Customer').'
'.$langs->trans('Customer').''; + print ''; print $soc->getNomUrl(1); print ''; print ''; + print ''; 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 "
".$langs->trans("DefaultContact").''; + print '
'.$langs->trans("DefaultContact").''; print img_picto('', 'contact'); print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, '', '', 0, 'minwidth300'); print '
'.$langs->trans('Discounts').''; + print '
'.$langs->trans('Discounts').''; $absolute_discount = $soc->getAvailableDiscounts(); @@ -1641,44 +1702,44 @@ if ($action == 'create') { } // Date - print '
'.$langs->trans('DatePropal').''; + print '
'.$langs->trans('DatePropal').''; print $form->selectDate('', '', '', '', '', "addprop", 1, 1); print '
'.$langs->trans("ValidityDuration").''.img_picto('', 'clock', 'class="paddingright"').' '.$langs->trans("days").'
'.$langs->trans("ValidityDuration").''.img_picto('', 'clock', 'class="paddingright"').' '.$langs->trans("days").'
'.$langs->trans('PaymentConditionsShort').''; - 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 '
'.$langs->trans('PaymentConditionsShort').''; + 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 '
'.$langs->trans('PaymentMode').''; + print '
'.$langs->trans('PaymentMode').''; 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 '
'.$langs->trans('BankAccount').''; + print '
'.$langs->trans('Source').''; + print '
'.$langs->trans('Source').''; print img_picto('', 'question', 'class="pictofixedwidth"'); $form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1, 'maxwidth200 widthcentpercentminusx'); print '
'.$langs->trans('AvailabilityPeriod'); + print '
'.$langs->trans('AvailabilityPeriod'); if (!empty($conf->commande->enabled)) { print ' ('.$langs->trans('AfterOrder').')'; } - print ''; + print ''; print img_picto('', 'clock', 'class="pictofixedwidth"'); $form->selectAvailabilityDelay('', 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); print '
'.$langs->trans('SendingMethod').''; + print '
'.$langs->trans('SendingMethod').''; print img_picto('', 'object_dollyrevert', 'class="pictofixedwidth"'); print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print '
'.$langs->trans('Warehouse').''; + print '
'.$langs->trans('Warehouse').''; print img_picto('', 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx'); print '
'.$langs->trans("DeliveryDate").''; + print '
'.$langs->trans("DeliveryDate").''; 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 '
'.$langs->trans("Project").''; + print '
'.$langs->trans("Project").''; 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 ' id).'">'; print '
'; + print '
'; print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms) ? $soc->location_incoterms : '')); print '
'.$langs->trans("DefaultModel").''; + print '
'.$langs->trans("DefaultModel").''; 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 '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; + print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0); print '
'.$langs->trans('NotePublic').''; + print '
'.$langs->trans('NotePublic').''; $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 '
'.$langs->trans('NotePrivate').''; + print '
'.$langs->trans('NotePrivate').''; $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' => ' + + ' + ); + } + } + 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 '
'; print ''; 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 ''; print ''; // Payment mode - print ''; - print ''; - print ''; + print ''; + } else { + print ''; + } + } else { + //if (! empty($conf->modules)) + if (!empty($conf->modules_parts['hooks'])) { // If there is at least one module with one hook, we show message to say nothing was done + print ''; + } + } + } + $db->close(); - - // Copy directory medias - $srcroot = DOL_DOCUMENT_ROOT.'/install/medias'; - $destroot = DOL_DATA_ROOT.'/medias'; - dolCopyDir($srcroot, $destroot, 0, 0); - - - // Actions for all versions (no database change but delete some files and directories) - migrate_delete_old_files($db, $langs, $conf); - migrate_delete_old_dir($db, $langs, $conf); - // Actions for all versions (no database change but create some directories) - dol_mkdir(DOL_DATA_ROOT.'/bank'); - // Actions for all versions (no database change but rename some directories) - migrate_rename_directories($db, $langs, $conf, '/banque/bordereau', '/bank/checkdeposits'); - $silent = 0; if (!$silent) { print '
'; + print '
'; + print ''; if ($action != 'editmode' && $usercancreate && $caneditfield) { @@ -2193,7 +2377,7 @@ if ($action == 'create') { $langs->load('deliveries'); print ''; print ''; @@ -2224,7 +2408,7 @@ if ($action == 'create') { // Shipping Method if (!empty($conf->expedition->enabled)) { print ''."\n"; + } - migrate_relationship_tables($db, $langs, $conf, 'co_exp', 'fk_commande', 'commande', 'fk_expedition', 'shipping'); + // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE + // Version to install is DOL_VERSION + $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : '')); - migrate_relationship_tables($db, $langs, $conf, 'pr_exp', 'fk_propal', 'propal', 'fk_expedition', 'shipping'); + // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec + // dans la 1ere colonne, la description de l'action a faire + // dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error' - migrate_relationship_tables($db, $langs, $conf, 'pr_liv', 'fk_propal', 'propal', 'fk_livraison', 'delivery'); + $versiontoarray = explode('.', $versionto); + $versionranarray = explode('.', DOL_VERSION); - migrate_relationship_tables($db, $langs, $conf, 'co_liv', 'fk_commande', 'commande', 'fk_livraison', 'delivery'); - migrate_relationship_tables($db, $langs, $conf, 'co_pr', 'fk_propale', 'propal', 'fk_commande', 'commande'); + $afterversionarray = explode('.', '2.0.0'); + $beforeversionarray = explode('.', '2.7.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + // Script pour V2 -> V2.1 + migrate_paiements($db, $langs, $conf); - migrate_relationship_tables($db, $langs, $conf, 'fa_pr', 'fk_propal', 'propal', 'fk_facture', 'facture'); + migrate_contracts_det($db, $langs, $conf); - migrate_relationship_tables($db, $langs, $conf, 'co_fa', 'fk_commande', 'commande', 'fk_facture', 'facture'); + migrate_contracts_date1($db, $langs, $conf); - migrate_project_user_resp($db, $langs, $conf); + migrate_contracts_date2($db, $langs, $conf); - migrate_project_task_actors($db, $langs, $conf); - } + migrate_contracts_date3($db, $langs, $conf); - // Script for 2.9 - $afterversionarray = explode('.', '2.8.9'); - $beforeversionarray = explode('.', '2.9.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_project_task_time($db, $langs, $conf); + migrate_contracts_open($db, $langs, $conf); - migrate_customerorder_shipping($db, $langs, $conf); + migrate_modeles($db, $langs, $conf); - migrate_shipping_delivery($db, $langs, $conf); + migrate_price_propal($db, $langs, $conf); - migrate_shipping_delivery2($db, $langs, $conf); - } + migrate_price_commande($db, $langs, $conf); - // Script for 3.0 - $afterversionarray = explode('.', '2.9.9'); - $beforeversionarray = explode('.', '3.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - // No particular code - } + migrate_price_commande_fournisseur($db, $langs, $conf); - // Script for 3.1 - $afterversionarray = explode('.', '3.0.9'); - $beforeversionarray = explode('.', '3.1.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_rename_directories($db, $langs, $conf, '/rss', '/externalrss'); + migrate_price_contrat($db, $langs, $conf); - migrate_actioncomm_element($db, $langs, $conf); - } + migrate_paiementfourn_facturefourn($db, $langs, $conf); - // Script for 3.2 - $afterversionarray = explode('.', '3.1.9'); - $beforeversionarray = explode('.', '3.2.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_price_contrat($db, $langs, $conf); - migrate_mode_reglement($db, $langs, $conf); + // Script pour V2.1 -> V2.2 + migrate_paiements_orphelins_1($db, $langs, $conf); - migrate_clean_association($db, $langs, $conf); - } + migrate_paiements_orphelins_2($db, $langs, $conf); - // Script for 3.3 - $afterversionarray = explode('.', '3.2.9'); - $beforeversionarray = explode('.', '3.3.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_categorie_association($db, $langs, $conf); - } + migrate_links_transfert($db, $langs, $conf); - // Script for 3.4 - // No specific scripts - // Tasks to do always and only into last targeted version - $afterversionarray = explode('.', '3.6.9'); // target is after this - $beforeversionarray = explode('.', '3.7.9'); // target is before this - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_event_assignement($db, $langs, $conf); - } + // Script pour V2.2 -> V2.4 + migrate_commande_expedition($db, $langs, $conf); - // Scripts for 3.9 - $afterversionarray = explode('.', '3.7.9'); - $beforeversionarray = explode('.', '3.8.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - // No particular code - } + migrate_commande_livraison($db, $langs, $conf); - // Scripts for 4.0 - $afterversionarray = explode('.', '3.9.9'); - $beforeversionarray = explode('.', '4.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_rename_directories($db, $langs, $conf, '/fckeditor', '/medias'); - } + migrate_detail_livraison($db, $langs, $conf); - // Scripts for 5.0 - $afterversionarray = explode('.', '4.0.9'); - $beforeversionarray = explode('.', '5.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - // Migrate to add entity value into llx_societe_remise - migrate_remise_entity($db, $langs, $conf); - // Migrate to add entity value into llx_societe_remise_except - migrate_remise_except_entity($db, $langs, $conf); - } + // Script pour V2.5 -> V2.6 + migrate_stocks($db, $langs, $conf); - // Scripts for 6.0 - $afterversionarray = explode('.', '5.0.9'); - $beforeversionarray = explode('.', '6.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - if (!empty($conf->multicompany->enabled)) { - global $multicompany_transverse_mode; - // Only if the transverse mode is not used - if (empty($multicompany_transverse_mode)) { - // Migrate to add entity value into llx_user_rights - migrate_user_rights_entity($db, $langs, $conf); + // Script pour V2.6 -> V2.7 + migrate_menus($db, $langs, $conf); - // Migrate to add entity value into llx_usergroup_rights - migrate_usergroup_rights_entity($db, $langs, $conf); + migrate_commande_deliveryaddress($db, $langs, $conf); + + migrate_restore_missing_links($db, $langs, $conf); + + migrate_rename_directories($db, $langs, $conf, '/compta', '/banque'); + + migrate_rename_directories($db, $langs, $conf, '/societe', '/mycompany'); + } + + // Script for 2.8 + $afterversionarray = explode('.', '2.7.9'); + $beforeversionarray = explode('.', '2.8.9'); + //print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx + + migrate_relationship_tables($db, $langs, $conf, 'co_exp', 'fk_commande', 'commande', 'fk_expedition', 'shipping'); + + migrate_relationship_tables($db, $langs, $conf, 'pr_exp', 'fk_propal', 'propal', 'fk_expedition', 'shipping'); + + migrate_relationship_tables($db, $langs, $conf, 'pr_liv', 'fk_propal', 'propal', 'fk_livraison', 'delivery'); + + migrate_relationship_tables($db, $langs, $conf, 'co_liv', 'fk_commande', 'commande', 'fk_livraison', 'delivery'); + + migrate_relationship_tables($db, $langs, $conf, 'co_pr', 'fk_propale', 'propal', 'fk_commande', 'commande'); + + migrate_relationship_tables($db, $langs, $conf, 'fa_pr', 'fk_propal', 'propal', 'fk_facture', 'facture'); + + migrate_relationship_tables($db, $langs, $conf, 'co_fa', 'fk_commande', 'commande', 'fk_facture', 'facture'); + + migrate_project_user_resp($db, $langs, $conf); + + migrate_project_task_actors($db, $langs, $conf); + } + + // Script for 2.9 + $afterversionarray = explode('.', '2.8.9'); + $beforeversionarray = explode('.', '2.9.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_project_task_time($db, $langs, $conf); + + migrate_customerorder_shipping($db, $langs, $conf); + + migrate_shipping_delivery($db, $langs, $conf); + + migrate_shipping_delivery2($db, $langs, $conf); + } + + // Script for 3.0 + $afterversionarray = explode('.', '2.9.9'); + $beforeversionarray = explode('.', '3.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + // No particular code + } + + // Script for 3.1 + $afterversionarray = explode('.', '3.0.9'); + $beforeversionarray = explode('.', '3.1.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_rename_directories($db, $langs, $conf, '/rss', '/externalrss'); + + migrate_actioncomm_element($db, $langs, $conf); + } + + // Script for 3.2 + $afterversionarray = explode('.', '3.1.9'); + $beforeversionarray = explode('.', '3.2.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_price_contrat($db, $langs, $conf); + + migrate_mode_reglement($db, $langs, $conf); + + migrate_clean_association($db, $langs, $conf); + } + + // Script for 3.3 + $afterversionarray = explode('.', '3.2.9'); + $beforeversionarray = explode('.', '3.3.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_categorie_association($db, $langs, $conf); + } + + // Script for 3.4 + // No specific scripts + + // Tasks to do always and only into last targeted version + $afterversionarray = explode('.', '3.6.9'); // target is after this + $beforeversionarray = explode('.', '3.7.9'); // target is before this + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_event_assignement($db, $langs, $conf); + } + + // Scripts for 3.9 + $afterversionarray = explode('.', '3.7.9'); + $beforeversionarray = explode('.', '3.8.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + // No particular code + } + + // Scripts for 4.0 + $afterversionarray = explode('.', '3.9.9'); + $beforeversionarray = explode('.', '4.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_rename_directories($db, $langs, $conf, '/fckeditor', '/medias'); + } + + // Scripts for 5.0 + $afterversionarray = explode('.', '4.0.9'); + $beforeversionarray = explode('.', '5.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + // Migrate to add entity value into llx_societe_remise + migrate_remise_entity($db, $langs, $conf); + + // Migrate to add entity value into llx_societe_remise_except + migrate_remise_except_entity($db, $langs, $conf); + } + + // Scripts for 6.0 + $afterversionarray = explode('.', '5.0.9'); + $beforeversionarray = explode('.', '6.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + if (!empty($conf->multicompany->enabled)) { + global $multicompany_transverse_mode; + + // Only if the transverse mode is not used + if (empty($multicompany_transverse_mode)) { + // Migrate to add entity value into llx_user_rights + migrate_user_rights_entity($db, $langs, $conf); + + // Migrate to add entity value into llx_usergroup_rights + migrate_usergroup_rights_entity($db, $langs, $conf); + } } } - } - // Scripts for 7.0 - $afterversionarray = explode('.', '6.0.9'); - $beforeversionarray = explode('.', '7.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - // Migrate contact association - migrate_event_assignement_contact($db, $langs, $conf); + // Scripts for 7.0 + $afterversionarray = explode('.', '6.0.9'); + $beforeversionarray = explode('.', '7.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + // Migrate contact association + migrate_event_assignement_contact($db, $langs, $conf); - migrate_reset_blocked_log($db, $langs, $conf); - } - - // Scripts for 8.0 - $afterversionarray = explode('.', '7.0.9'); - $beforeversionarray = explode('.', '8.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_rename_directories($db, $langs, $conf, '/contracts', '/contract'); - } - - // Scripts for 9.0 - $afterversionarray = explode('.', '8.0.9'); - $beforeversionarray = explode('.', '9.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_user_photospath(); - } - - // Scripts for 11.0 - $afterversionarray = explode('.', '10.0.9'); - $beforeversionarray = explode('.', '11.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_users_socialnetworks(); - migrate_members_socialnetworks(); - migrate_contacts_socialnetworks(); - migrate_thirdparties_socialnetworks(); - } - - // Scripts for 14.0 - $afterversionarray = explode('.', '13.0.9'); - $beforeversionarray = explode('.', '14.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_export_import_profiles('export'); - migrate_export_import_profiles('import'); - } - - // Scripts for 16.0 - $afterversionarray = explode('.', '15.0.9'); - $beforeversionarray = explode('.', '16.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_user_photospath2(); - } - } - - - // Code executed only if migration is LAST ONE. Must always be done. - if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3) { - // Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version) - $listofmodule = array( - 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', - 'MAIN_MODULE_AGENDA'=>'newboxdefonly', - 'MAIN_MODULE_BOM'=>'menuonly', - 'MAIN_MODULE_BANQUE'=>'menuonly', - 'MAIN_MODULE_BARCODE'=>'newboxdefonly', - 'MAIN_MODULE_CRON'=>'newboxdefonly', - 'MAIN_MODULE_COMMANDE'=>'newboxdefonly', - 'MAIN_MODULE_BLOCKEDLOG'=>'noboxes', - 'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly', - 'MAIN_MODULE_DON'=>'newboxdefonly', - 'MAIN_MODULE_ECM'=>'newboxdefonly', - 'MAIN_MODULE_EXTERNALSITE'=>'newboxdefonly', - 'MAIN_MODULE_EXPENSEREPORT'=>'newboxdefonly', - 'MAIN_MODULE_FACTURE'=>'newboxdefonly', - 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', - 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', - 'MAIN_MODULE_MARGIN'=>'menuonly', - 'MAIN_MODULE_MRP'=>'menuonly', - 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly', - 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', - 'MAIN_MODULE_PRINTING'=>'newboxdefonly', - 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', - 'MAIN_MODULE_RECRUITMENT'=>'menuonly', - 'MAIN_MODULE_RESOURCE'=>'noboxes', - 'MAIN_MODULE_SALARIES'=>'newboxdefonly', - 'MAIN_MODULE_SERVICE'=>'newboxdefonly', - 'MAIN_MODULE_SYSLOG'=>'newboxdefonly', - 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', - 'MAIN_MODULE_STRIPE'=>'menuonly', - 'MAIN_MODULE_TICKET'=>'newboxdefonly', - 'MAIN_MODULE_TAKEPOS'=>'newboxdefonly', - 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) - 'MAIN_MODULE_VARIANTS'=>'newboxdefonly', - 'MAIN_MODULE_WEBSITE'=>'newboxdefonly', - ); - - $result = migrate_reload_modules($db, $langs, $conf, $listofmodule); - if ($result < 0) { - $error++; - } - // Reload menus (this must be always and only into last targeted version) - $result = migrate_reload_menu($db, $langs, $conf); - if ($result < 0) { - $error++; - } - } - - // Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' - // In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line. - if (!$error && $enablemodules) { - // Reload modules (this must be always done and only into last targeted version) - $listofmodules = array(); - $enablemodules = preg_replace('/enablemodules=/', '', $enablemodules); - $tmplistofmodules = explode(',', $enablemodules); - foreach ($tmplistofmodules as $value) { - $listofmodules[$value] = 'forceactivate'; - } - - $resultreloadmodules = migrate_reload_modules($db, $langs, $conf, $listofmodules, 1); - if ($resultreloadmodules < 0) { - $error++; - } - } - - - // Can call a dedicated external upgrade process - if (!$error) { - $parameters = array('versionfrom' => $versionfrom, 'versionto' => $versionto); - $object = new stdClass(); - $action = "upgrade"; - $reshook = $hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if ($hookmanager->resNbOfHooks > 0) { - if ($reshook < 0) { - print ''; - } else { - print ''; + migrate_reset_blocked_log($db, $langs, $conf); } - } else { - //if (! empty($conf->modules)) - if (!empty($conf->modules_parts['hooks'])) { // If there is at least one module with one hook, we show message to say nothing was done - print ''; + + // Scripts for 8.0 + $afterversionarray = explode('.', '7.0.9'); + $beforeversionarray = explode('.', '8.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_rename_directories($db, $langs, $conf, '/contracts', '/contract'); + } + + // Scripts for 9.0 + $afterversionarray = explode('.', '8.0.9'); + $beforeversionarray = explode('.', '9.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_user_photospath(); + } + + // Scripts for 11.0 + $afterversionarray = explode('.', '10.0.9'); + $beforeversionarray = explode('.', '11.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_users_socialnetworks(); + migrate_members_socialnetworks(); + migrate_contacts_socialnetworks(); + migrate_thirdparties_socialnetworks(); + } + + // Scripts for 14.0 + $afterversionarray = explode('.', '13.0.9'); + $beforeversionarray = explode('.', '14.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_export_import_profiles('export'); + migrate_export_import_profiles('import'); + } + + // Scripts for 16.0 + $afterversionarray = explode('.', '15.0.9'); + $beforeversionarray = explode('.', '16.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_user_photospath2(); + } + } + + + // Code executed only if migration is LAST ONE. Must always be done. + if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3) { + // Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version) + $listofmodule = array( + 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', + 'MAIN_MODULE_AGENDA'=>'newboxdefonly', + 'MAIN_MODULE_BOM'=>'menuonly', + 'MAIN_MODULE_BANQUE'=>'menuonly', + 'MAIN_MODULE_BARCODE'=>'newboxdefonly', + 'MAIN_MODULE_CRON'=>'newboxdefonly', + 'MAIN_MODULE_COMMANDE'=>'newboxdefonly', + 'MAIN_MODULE_BLOCKEDLOG'=>'noboxes', + 'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly', + 'MAIN_MODULE_DON'=>'newboxdefonly', + 'MAIN_MODULE_ECM'=>'newboxdefonly', + 'MAIN_MODULE_EXTERNALSITE'=>'newboxdefonly', + 'MAIN_MODULE_EXPENSEREPORT'=>'newboxdefonly', + 'MAIN_MODULE_FACTURE'=>'newboxdefonly', + 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', + 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', + 'MAIN_MODULE_MARGIN'=>'menuonly', + 'MAIN_MODULE_MRP'=>'menuonly', + 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly', + 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', + 'MAIN_MODULE_PRINTING'=>'newboxdefonly', + 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', + 'MAIN_MODULE_RECRUITMENT'=>'menuonly', + 'MAIN_MODULE_RESOURCE'=>'noboxes', + 'MAIN_MODULE_SALARIES'=>'newboxdefonly', + 'MAIN_MODULE_SERVICE'=>'newboxdefonly', + 'MAIN_MODULE_SYSLOG'=>'newboxdefonly', + 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', + 'MAIN_MODULE_STRIPE'=>'menuonly', + 'MAIN_MODULE_TICKET'=>'newboxdefonly', + 'MAIN_MODULE_TAKEPOS'=>'newboxdefonly', + 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) + 'MAIN_MODULE_VARIANTS'=>'newboxdefonly', + 'MAIN_MODULE_WEBSITE'=>'newboxdefonly', + ); + + $result = migrate_reload_modules($db, $langs, $conf, $listofmodule); + if ($result < 0) { + $error++; + } + // Reload menus (this must be always and only into last targeted version) + $result = migrate_reload_menu($db, $langs, $conf); + if ($result < 0) { + $error++; + } + } + + // Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' + // In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line. + if (!$error && $enablemodules) { + // Reload modules (this must be always done and only into last targeted version) + $listofmodules = array(); + $enablemodules = preg_replace('/enablemodules=/', '', $enablemodules); + $tmplistofmodules = explode(',', $enablemodules); + foreach ($tmplistofmodules as $value) { + $listofmodules[$value] = 'forceactivate'; + } + + $resultreloadmodules = migrate_reload_modules($db, $langs, $conf, $listofmodules, 1); + if ($resultreloadmodules < 0) { + $error++; + } + } + + + // Can call a dedicated external upgrade process with hook doUpgradeAfterDB() + if (!$error) { + $parameters = array('versionfrom' => $versionfrom, 'versionto' => $versionto, 'conf'=>$conf); + $object = new stdClass(); + $action = "upgrade"; + $reshook = $hookmanager->executeHooks('doUpgradeAfterDB', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($hookmanager->resNbOfHooks > 0) { + if ($reshook < 0) { + print ''; + } else { + print ''; + } + } else { + //if (! empty($conf->modules)) + if (!empty($conf->modules_parts['hooks'])) { // If there is at least one module with one hook, we show message to say nothing was done + print ''; + } } } } print '
'; print $langs->trans('PaymentMode'); print '
'; print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker'); - print ''; + print ''; print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker'); print '
'; - print ''; print ''; + print ''; print ''; + print ''; print '
'; + print ''; 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 '"; - // 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 ''; - } - // Bank account if ($object->fk_account > 0) { print ""; } + // 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 ''; + } + // Model pdf print ""; @@ -1605,19 +1607,19 @@ if ($action == 'create') { // Lines - print ' - - - - - '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
'; - print '
'; print $langs->trans('SendingMethod'); print '
'; + print '
'; $editenable = $usercancreate; print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); print ''; @@ -2261,7 +2445,7 @@ if ($action == 'create') { // Origin of demand print '
'; - print ''; + } - $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 '
'; + print ''; if ($action != 'editdemandreason' && $usercancreate) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index cfe2a15f2db..0d7c301f7b0 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -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").","; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 561682ba02f..c989cd34d39 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -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 .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); @@ -1051,9 +1051,9 @@ 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) { $moreforfilter .= '
'; - $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 .= '
'; } @@ -1224,7 +1224,7 @@ if ($resql) { // Payment term if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { print ''; } // Payment mode @@ -1821,7 +1821,7 @@ if ($resql) { // Payment terms if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; @@ -2097,7 +2097,7 @@ if ($resql) { // Note public if (!empty($arrayfields['p.note_public']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; @@ -2106,7 +2106,7 @@ if ($resql) { // Note private if (!empty($arrayfields['p.note_private']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; @@ -2133,7 +2133,7 @@ if ($resql) { $totalarray['nbfield']++; } - print "\n"; + print ''."\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 ''; + } + $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index d33ea387947..b1d0cdb9223 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -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 ''; // Payment mode @@ -1960,6 +2025,111 @@ if ($action == 'create' && $usercancreate) { if ($nbMandated > 0 ) $text .= '
'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'
'; + $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' => ' + + ' + ); + } + } + 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 ''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 58395162f87..ca149d1f681 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -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").","; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 38d79aa9698..b2bf9615d17 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -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 .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); @@ -1479,7 +1479,7 @@ if ($resql) { // Payment term if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { print '
'; } // Payment mode @@ -2032,7 +2032,7 @@ if ($resql) { // Payment terms if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; @@ -2290,8 +2290,8 @@ if ($resql) { // Note public if (!empty($arrayfields['c.note_public']['checked'])) { - print ''; if (!$i) { $totalarray['nbfield']++; @@ -2300,8 +2300,8 @@ if ($resql) { // Note private if (!empty($arrayfields['c.note_private']['checked'])) { - print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 4d133c50dda..05b30d69668 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -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)) { diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index bbec4f23fc6..92d38d95274 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -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 ""; + print ''."\n"; $i++; } @@ -712,11 +716,27 @@ if ($result) { // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - print "
'; print $langs->trans('Source'); print ''; - $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 ''; - $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 ''; - print dol_escape_htmltag($obj->note_public); + print dol_string_nohtmltag($obj->note_public); print ''; - print dol_escape_htmltag($obj->note_private); + print dol_string_nohtmltag($obj->note_private); print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans('PaymentConditionsShort').''; - 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 '
'; 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 ''; - $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 ''; - $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 ''; - print dol_escape_htmltag($obj->note_public); + print ''; + print dol_string_nohtmltag($obj->note_public); print ''; - print dol_escape_htmltag($obj->note_private); + print ''; + print dol_string_nohtmltag($obj->note_private); print '
"; - print ''; - print ''; + // If no record found + if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print '
'.$langs->trans("NoRecordFound").'
'."\n"; + print ''."\n"; + + print ''."\n"; } else { dol_print_error($db); } diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 7822819c06a..2315f12757a 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -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') diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 6d7f7f6010e..6300e387067 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -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 "
".$langs->trans("PaymentMode").""; + 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 "
'.$langs->trans('Project').''; - print img_picto('', 'project'); - $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, ''); - print '   thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').''; - print '
".$langs->trans('BankAccount').""; @@ -1056,10 +1046,22 @@ if ($action == 'create') { print "
'.$langs->trans('Project').''; + 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 '   thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').''; + print '
".$langs->trans('Model').""; 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 "
'; + print '
'; // Show object lines if (!empty($object->lines)) { $canchangeproduct = 1; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 10a9429fbe2..7de827ff1d2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -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 ''; + + 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 ''; + } + 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 ''; } - $this->select_conditions_paiements($selected, $htmlname, -1, $addempty, 0, ''); + $this->select_conditions_paiements($selected, $htmlname, $filtertype, $addempty, 0, '', $deposit_percent); print ''; print ''; } 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 '   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 .= ''; + if ($showempty) { + $out .= ''; + } $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 = '\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 diff --git a/htdocs/core/class/html.formcategory.class.php b/htdocs/core/class/html.formcategory.class.php index 707b5d5d0ac..c0e07b6bb7a 100644 --- a/htdocs/core/class/html.formcategory.class.php +++ b/htdocs/core/class/html.formcategory.class.php @@ -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); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index acb7d5b5f2a..75f35e39bec 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Bahfir Abbes * Copyright (C) 2016-2017 Ferran Marcet - * Copyright (C) 2019-2021 Frédéric France + * Copyright (C) 2019-2022 Frédéric France * * 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 .= ''; + // for share link of files + $out .= ''; if ($delallowed || $printer || $morepicto) { $out .= ''; } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 818c3b19c7b..244da59b5ff 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -781,7 +781,11 @@ class FormMail extends Form } elseif ($this->withmaindocfile == -1) { $out .= ''; } - $out .= '
'; + if (!empty($conf->global->MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND)) { + $out .= '
'; + } else { + $out .= '
'; + } } 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 = '') diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 1107c3b8d34..4e0d3da467e 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -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); } /** diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 9e2c45fd634..6f54229c993 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -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 diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 27f3ca1c836..94bd36799fc 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -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)) { diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index e349072ddec..1d24b058614 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -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 diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 74abf7a1e36..5a2a1c1b753 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -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; diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 997132ca132..9167e08e599 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -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"); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 3fe6dee8820..8c4d958abac 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -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 = ; var tradDays = ; var tradDaysShort = ; var tradDaysMin = ; +var currencyCache = 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 = ''; @@ -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 = global->MAIN_MAX_DECIMALS_SHOWN); ?>; var main_rounding_unit = global->MAIN_MAX_DECIMALS_UNIT; ?>; var main_rounding_tot = global->MAIN_MAX_DECIMALS_TOT; ?>; + var main_decimal_separator = ; + var main_thousand_separator = ; + var locale_code = force_locale || defaultlang) ?>; + var amountAsLocalizedString; + var useIntl = Boolean(Intl && Intl.NumberFormat); + var nDigits; + if (currency_code === 'auto') currency_code = 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 ''; - 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 = ; + var thousand = ; var main_max_dec_shown = global->MAIN_MAX_DECIMALS_SHOWN); ?>; var main_rounding_unit = global->MAIN_MAX_DECIMALS_UNIT; ?>; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5eef1b43bec..34d4120db24 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -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).')'; } diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 4375d14430b..6b85e837b07 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -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. diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 9bc0a59cf86..e14302da340 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -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; diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index 1d86bd19549..022186b8de1 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -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); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 6b415aec7a2..556ee3e609a 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -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) ? '' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); + $menu->add('#', (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1 ? '' : ''), 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 ''; - print '
'; - print '
'; - print ''; - print ''; - print $text; - print ''; + print ''; + print '
'; print '
'; + if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { + print ''; + print ''; + print $text; + print ''; + print ''; + } } elseif ($showmode == 2) { - print '
'; - print ''; - print ''; - print $text; - print ''; - print ''; + print '
'; + print '
'; + print '
'; + if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { + print ''; + print ''; + print $text; + print ''; + print ''; + } } } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7d7317979cd..f81fc3ae482 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -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) ? '' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); + $menu->add('#', (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1 ? '' : ''), 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 ''; - print '
'; + print '
'; + print '
'; print '
'; if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { - print ''; + print ''; print ''; print $text; print ''; print ''; } } elseif ($showmode == 2) { - print '
'; + print '
'; + print '
'; + print '
'; if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { - print ''; - print ''; + print ''; + print ''; print $text; print ''; - print ''; + print ''; } } } diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 9a45a9b7fc2..cc9db4cb769 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -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 ''; - print '
'; - print '
'; - print ''; - print ''; - print $text; - print ''; + print ''; + print '
'; print '
'; + if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { + print ''; + print ''; + print $text; + print ''; + print ''; + } } if ($showmode == 2) { - print '
'; - print ''; + print '
'; + print '
'; + print '
'; + if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { + print ''; + print ''; + print $text; + print ''; + print ''; + } } } diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 9f2676dfd72..b579c9b0059 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -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
'."\n"; - continue; - } else { - //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
'."\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
'."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
'."\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
'."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
'."\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
'."\n"; - continue; - } else { - //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
'."\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
'."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
'."\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
'."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
'."\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
'."\n"; - continue; - } else { - //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
'."\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
'."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
'."\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
'."\n"; - continue; - } else { - //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
'."\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++; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index db961962ba6..fa9d83ea926 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -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; diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 560344a9eeb..b5f2ee5af43 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -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; diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index 2146de367e1..a217cb8d72c 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -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') } diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index bceb313e120..450aa76258e 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -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') } diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php index f2564cd3cc6..c5c790ca28c 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/core/modules/modDon.class.php @@ -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') } diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index bd81f06dae7..7df3bcc6dcf 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -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') } diff --git a/htdocs/core/modules/modIntracommreport.class.php b/htdocs/core/modules/modIntracommreport.class.php index 817c893934b..25f26050ed0 100644 --- a/htdocs/core/modules/modIntracommreport.class.php +++ b/htdocs/core/modules/modIntracommreport.class.php @@ -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') } diff --git a/htdocs/core/modules/modKnowledgeManagement.class.php b/htdocs/core/modules/modKnowledgeManagement.class.php index 93b44f31204..434cc9d6faf 100644 --- a/htdocs/core/modules/modKnowledgeManagement.class.php +++ b/htdocs/core/modules/modKnowledgeManagement.class.php @@ -442,7 +442,7 @@ class modKnowledgeManagement extends DolibarrModules { global $conf, $langs; - $result = $this->_load_tables('/install/mysql/tables/', 'knowledgemanagement'); + $result = $this->_load_tables('/install/mysql/', 'knowledgemanagement'); 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') } diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index e19ec1b81f8..8f9de88b83f 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -160,7 +160,7 @@ class modLoan extends DolibarrModules { global $conf; - $result = $this->_load_tables('/install/mysql/tables/', 'loan'); + $result = $this->_load_tables('/install/mysql/', 'loan'); 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') } diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index 1a31aad9c8b..7e3d4b6aeb1 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -159,7 +159,7 @@ class modMailing extends DolibarrModules */ public function init($options = '') { - $result = $this->_load_tables('/install/mysql/tables/', 'mailing'); + $result = $this->_load_tables('/install/mysql/', 'mailing'); 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') } diff --git a/htdocs/core/modules/modOpenSurvey.class.php b/htdocs/core/modules/modOpenSurvey.class.php index 9cc9310cd19..04a8cd54082 100644 --- a/htdocs/core/modules/modOpenSurvey.class.php +++ b/htdocs/core/modules/modOpenSurvey.class.php @@ -184,7 +184,7 @@ class modOpenSurvey extends DolibarrModules { global $conf, $langs; - $result = $this->_load_tables('/install/mysql/tables/', 'opensurvey'); + $result = $this->_load_tables('/install/mysql/', 'opensurvey'); 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') } diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index c08cf66db06..f37d7d2403d 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -410,7 +410,7 @@ class modPartnership extends DolibarrModules { global $conf, $langs; - $result = $this->_load_tables('/install/mysql/tables/', 'partnership'); + $result = $this->_load_tables('/install/mysql/', 'partnership'); 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') } diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index f18a55ff6d8..f8b82e8faa3 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -152,7 +152,7 @@ class modProjet extends DolibarrModules $r++; $this->rights[$r][0] = 41; // id de la permission - $this->rights[$r][1] = "Read projects and tasks (shared projects or projects I am contact for). Can also enter time consumed on assigned tasks (timesheet)"; // libelle de la permission + $this->rights[$r][1] = "Read projects and tasks (shared projects or projects I am contact for)"; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; @@ -188,7 +188,7 @@ class modProjet extends DolibarrModules $r++; $this->rights[$r][0] = 142; // id de la permission - $this->rights[$r][1] = "Create/modify all projects and tasks (also private projects I am not contact for). Can also enter time consumed on assigned tasks (timesheet)"; // libelle de la permission + $this->rights[$r][1] = "Create/modify all projects and tasks (also private projects I am not contact for)"; // libelle de la permission $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'all'; @@ -202,6 +202,12 @@ class modProjet extends DolibarrModules $this->rights[$r][4] = 'all'; $this->rights[$r][5] = 'supprimer'; + $r++; + $this->rights[$r][0] = 145; // id de la permission + $this->rights[$r][1] = "Can enter time consumed on assigned tasks (timesheet)"; // libelle de la permission + $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'time'; // Menus //------- diff --git a/htdocs/core/modules/modRecruitment.class.php b/htdocs/core/modules/modRecruitment.class.php index c4bbd573fa9..fb64e43486d 100644 --- a/htdocs/core/modules/modRecruitment.class.php +++ b/htdocs/core/modules/modRecruitment.class.php @@ -403,7 +403,7 @@ class modRecruitment extends DolibarrModules { global $conf, $langs; - $result = $this->_load_tables('/install/mysql/tables/', 'recruitment'); + $result = $this->_load_tables('/install/mysql/', 'recruitment'); 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') } diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 839a62325f3..52a3843fd12 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -434,7 +434,7 @@ class modStock extends DolibarrModules { global $conf, $langs; - $result = $this->_load_tables('/install/mysql/tables/', 'stock'); + $result = $this->_load_tables('/install/mysql/', 'stock'); 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') } diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 86a657c0509..fc7e72388ea 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -171,8 +171,8 @@ class modTicket extends DolibarrModules 0=>array('file'=>'box_last_ticket.php', 'enabledbydefaulton'=>'Home'), 1=>array('file'=>'box_last_modified_ticket.php', 'enabledbydefaulton'=>'Home'), 2=>array('file'=>'box_ticket_by_severity.php', 'enabledbydefaulton'=>'ticketindex'), - 3=>array('file'=>'box_nb_ticket_last_x_days.php', 'enabledbydefaulton'=>'ticketindex'), - 4=>array('file'=>'box_nb_tickets_type.php', 'enabledbydefaulton'=>'ticketindex'), + 3=>array('file'=>'box_graph_nb_ticket_last_x_days.php', 'enabledbydefaulton'=>'ticketindex'), + 4=>array('file'=>'box_graph_nb_tickets_type.php', 'enabledbydefaulton'=>'ticketindex'), 5=>array('file'=>'box_new_vs_close_ticket.php', 'enabledbydefaulton'=>'ticketindex') ); // Boxes list @@ -331,7 +331,7 @@ class modTicket extends DolibarrModules { global $conf, $langs; - $result = $this->_load_tables('/install/mysql/tables/', 'ticket'); + $result = $this->_load_tables('/install/mysql/', 'ticket'); 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') } diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index 7ea6b5a890c..e27e7a2f6b0 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -164,7 +164,7 @@ class modWebsite extends DolibarrModules { global $conf, $langs; - $result = $this->_load_tables('/install/mysql/tables/', 'website'); + $result = $this->_load_tables('/install/mysql/', 'website'); 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') } diff --git a/htdocs/core/modules/modWorkstation.class.php b/htdocs/core/modules/modWorkstation.class.php index 854dd45b969..80a401b4846 100644 --- a/htdocs/core/modules/modWorkstation.class.php +++ b/htdocs/core/modules/modWorkstation.class.php @@ -390,7 +390,7 @@ class modWorkstation extends DolibarrModules { global $conf, $langs; - $result = $this->_load_tables('/install/mysql/tables/', 'workstation'); + $result = $this->_load_tables('/install/mysql/', 'workstation'); 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') } diff --git a/htdocs/core/modules/modZapier.class.php b/htdocs/core/modules/modZapier.class.php index e638d906693..b6ef25e150e 100644 --- a/htdocs/core/modules/modZapier.class.php +++ b/htdocs/core/modules/modZapier.class.php @@ -281,7 +281,7 @@ class modZapier extends DolibarrModules */ public function init($options = '') { - $result = $this->_load_tables('/install/mysql/tables/', 'zapier'); + $result = $this->_load_tables('/install/mysql/', 'zapier'); 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') } diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index e2e3ffd2a21..1327c2e27a2 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; /** diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 5135a1708af..c6bb975092d 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -964,6 +964,9 @@ class pdf_azur extends ModelePDFPropales $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; diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 26ee429f97e..8651a9e720f 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1083,6 +1083,9 @@ class pdf_cyan extends ModelePDFPropales $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; diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 438e3d3f93e..1dbc0861adb 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -147,7 +147,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con
- +'; +print ''; // Fields for situation invoice if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) { diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 7ee64ec2c6f..1072f68b48f 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -115,7 +115,7 @@ if (empty($reshook)) { $search_label = ''; $search_status = -1; $search_lastresult = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') diff --git a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php index 5fd339918fa..d21cdd6233f 100644 --- a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php @@ -73,7 +73,7 @@ class DolLogsCollector extends MessagesCollector { global $conf; - $uselogfile = getDolGlobalInt('DEBUGBAR_USE_LOGFILE'); + $uselogfile = getDolGlobalInt('DEBUGBAR_USE_LOG_FILE'); if ($uselogfile) { $this->getStorageLogs($this->path); diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php index 2d9f70a1eb5..082e45e4f43 100644 --- a/htdocs/debugbar/class/TraceableDB.php +++ b/htdocs/debugbar/class/TraceableDB.php @@ -684,10 +684,10 @@ class TraceableDB extends DoliDB // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoie la ligne courante (comme un objet) pour le curseur resultset + * Returns the current line (as an object) for the resultset cursor * - * @param resource $resultset Curseur de la requete voulue - * @return Object Object result line or false if KO or end of cursor + * @param resource|Connection $resultset Handler of the desired SQL request + * @return Object Object result line or false if KO or end of cursor */ public function fetch_object($resultset) { diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 345f62656c0..9f1d921691c 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -110,10 +110,10 @@ class EmailCollector extends CommonObject public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1'), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>'Example: My Email collector'), - 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1), - 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>90, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com'), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1', 'csslist'=>'tdoverflowmax150'), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>'Example: My Email collector', 'csslist'=>'tdoverflowmax150'), + 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1, 'csslist'=>'small'), + 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>90, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com', 'csslist'=>'tdoverflow125'), 'hostcharset' => array('type'=>'varchar(16)', 'label'=>'HostCharset', 'visible'=>-1, 'enabled'=>1, 'position'=>91, 'notnull'=>0, 'searchall'=>0, 'comment'=>"IMAP server charset", 'help'=>'Example: "UTF-8" (May be "US-ASCII" with some Office365)'), 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>101, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'), 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'comment'=>"IMAP password", 'help'=>'WithGMailYouCanCreateADedicatedPassword'), @@ -122,10 +122,10 @@ class EmailCollector extends CommonObject //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'help'=>"EmailCollectorTargetDir"), 'maxemailpercollect' => array('type'=>'integer', 'label'=>'MaxEmailCollectPerCollect', 'visible'=>-1, 'enabled'=>1, 'position'=>111, 'default'=>100), - 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastCollectResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1,), + 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastCollectResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1, 'csslist'=>'nowraponall'), 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), - 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), - 'datelastok' => array('type'=>'datetime', 'label'=>'DateLastcollectResultOk', 'visible'=>1, 'enabled'=>'$action != "create"', 'position'=>125, 'notnull'=>-1,), + 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1, 'csslist'=>'small'), + 'datelastok' => array('type'=>'datetime', 'label'=>'DateLastcollectResultOk', 'visible'=>1, 'enabled'=>'$action != "create"', 'position'=>125, 'notnull'=>-1, 'csslist'=>'nowraponall'), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 15493425231..fb608eca8ba 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -105,7 +105,7 @@ class ConferenceOrBooth extends ActionComm public $fields = array( 'id' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'integer', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'help'=>"Help text", 'showoncombobox'=>'1',), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax125', 'help'=>"Help text", 'showoncombobox'=>'1',), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500'), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:t.usage_organize_event=1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'picto'=>'project', 'css'=>'tdoverflowmax150 maxwidth500'), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1), diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index bdd81660a12..2f0c54ef2d4 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -105,7 +105,9 @@ class ConferenceOrBoothAttendee extends CommonObject 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>2, 'index'=>1, 'comment'=>"Reference of object"), 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>0, 'index'=>1, 'picto'=>'agenda'), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>0, 'index'=>1, 'picto'=>'project', 'css'=>'tdoverflowmax150 maxwidth500'), - 'email' => array('type'=>'mail', 'label'=>'EmailAttendee', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'autofocusoncreate'=>1), + 'email' => array('type'=>'mail', 'label'=>'EmailAttendee', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'autofocusoncreate'=>1, 'searchall'=>1), + 'firstname' => array('type'=>'varchar(100)', 'label'=>'Firstname', 'enabled'=>'1', 'position'=>31, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'searchall'=>1), + 'lastname' => array('type'=>'varchar(100)', 'label'=>'Lastname', 'enabled'=>'1', 'position'=>32, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'searchall'=>1), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status = 1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>40, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500'), 'date_subscription' => array('type'=>'datetime', 'label'=>'DateOfRegistration', 'enabled'=>'1', 'position'=>56, 'notnull'=>1, 'visible'=>1, 'showoncombobox'=>'1',), 'fk_invoice' => array('type'=>'integer:Facture:compta/facture/class/facture.class.php', 'label'=>'Invoice', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>-1, 'index'=>0, 'picto'=>'bill', 'css'=>'tdoverflowmax150 maxwidth500'), @@ -126,6 +128,8 @@ class ConferenceOrBoothAttendee extends CommonObject public $fk_soc; public $fk_actioncomm; public $email; + public $firstname; + public $lastname; public $date_subscription; public $fk_invoice; public $amount; diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 943205adca2..88dad1bbac0 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -205,7 +205,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') @@ -375,46 +375,52 @@ if ($projectid > 0) { print '
'; $out .= dol_print_date($file->datea, 'dayhour'); $out .= '
trans("LabelOrTranslationKey"); ?>
trans("AttributeCode"); ?> (trans("AlphaNumOnlyLowerCharsAndNoSpace"); ?>)
trans("AttributeCode"); ?> (trans("AlphaNumOnlyLowerCharsAndNoSpace"); ?>)
trans("Type"); ?> selectarray('type', $type2label, GETPOST('type', 'alpha'), 0, 0, 0, '', 0, 0, 0, '', '', 1); ?> diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php index 00c2739e3f8..aeafac07962 100644 --- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php @@ -39,6 +39,9 @@ if (!empty($extrafieldsobjectkey) && !empty($extrafields->attributes[$extrafield //var_dump($obj); //var_dump($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]); $value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1, 1, '0'); + if (is_numeric(price2num($value)) && $extrafields->attributes[$extrafieldsobjectkey]['totalizable'][$key]) { + $obj->$tmpkey = price2num($value); + } //var_dump($value); } diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 4e138b0f1dc..207dc1b7265 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -211,6 +211,59 @@ if ($massaction == 'presend') { print dol_get_fiche_end(); } +if ($massaction == 'edit_extrafields') { + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $elementtype = $objecttmp->element; + /** @var CommonObject $objecttmp */ + $extrafields = new ExtraFields($db); + $keysuffix = ''; + $extrafields->fetch_name_optionals_label($elementtype); + $extrafields_list = $extrafields->attributes[$elementtype]['label']; + + $formquestion = array(); + if (!empty($extrafields_list)) { + $myParamExtra = $object->showOptionals($extrafields, 'create'); + + $formquestion[] = array( + 'type' => 'other', + 'value' => $form->selectarray('extrafield-key-to-update', $extrafields_list, GETPOST('extrafield-key-to-update'), 1) + ); + + + $outputShowOutputFields = '
'; + + foreach ($extrafields_list as $extraKey => $extraLabel) { + $outputShowOutputFields.= ''; + } + $outputShowOutputFields.= ''; + $outputShowOutputFields.= '
'; + + + + $formquestion[] = array( + 'type' => 'other', + 'value' => $outputShowOutputFields + ); + + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmEditExtrafield"), $langs->trans("ConfirmEditExtrafieldQuestion", count($toselect)), "confirm_edit_value_extrafields", $formquestion, 1, 0, 200, 500, 1); + } else { + setEventMessage($langs->trans("noExtrafields")); + } +} + if ($massaction == 'preenable') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassEnabling"), $langs->trans("ConfirmMassEnablingQuestion", count($toselect)), "enable", null, 'yes', 0, 200, 500, 1); } diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index e8dbec2ac77..0071b37ab9b 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -105,7 +105,24 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { } // Reduction short -print '
'.$langs->trans('ReductionShort').''; +print $langs->trans('ReductionShort'); + +if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) { + global $mysoc; + + if (empty($disableedit)) { + print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').''; + } + //print ''; + if (GETPOST('mode', 'aZ09') == 'remiseforalllines') { + print '
'; + print ''; + print ''; + print '
'; + } +} +print '
'; // Description - print ''; // Categories if ($conf->categorie->enabled) { - print '"; } - print '"; - print '"; - print '"; - print '"; - print '"; + + print '"; // Link to the submit vote/register page - print ''; // Link to the subscribe - print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index a20e586e2ee..2665f987a10 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -108,7 +108,7 @@ if (empty($reshook)) { $search_field2 = ''; $search_date_creation = ''; $search_date_update = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index d0bed943429..1e11e81f543 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -704,7 +704,7 @@ class Holiday extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error = 0; - $checkBalance = getDictionaryValue(MAIN_DB_PREFIX.'c_holiday_types', 'block_if_negative', $this->fk_type); + $checkBalance = getDictionaryValue('c_holiday_types', 'block_if_negative', $this->fk_type); if ($checkBalance > 0) { $balance = $this->getCPforUser($this->fk_user, $this->fk_type); @@ -817,7 +817,7 @@ class Holiday extends CommonObject global $conf, $langs; $error = 0; - $checkBalance = getDictionaryValue(MAIN_DB_PREFIX.'c_holiday_types', 'block_if_negative', $this->fk_type); + $checkBalance = getDictionaryValue('c_holiday_types', 'block_if_negative', $this->fk_type); if ($checkBalance > 0) { $balance = $this->getCPforUser($this->fk_user, $this->fk_type); @@ -936,7 +936,7 @@ class Holiday extends CommonObject global $conf, $langs; $error = 0; - $checkBalance = getDictionaryValue(MAIN_DB_PREFIX.'c_holiday_types', 'block_if_negative', $this->fk_type); + $checkBalance = getDictionaryValue('c_holiday_types', 'block_if_negative', $this->fk_type); if ($checkBalance > 0 && $this->statut != self::STATUS_DRAFT) { $balance = $this->getCPforUser($this->fk_user, $this->fk_type); diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 12a32ba3f50..dedc7d1da0f 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -111,7 +111,7 @@ 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 $search_name = ''; $search_supervisor = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index efafac7f823..5dc05d1c617 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -200,7 +200,7 @@ if (empty($reshook)) { $search_valideur = ""; $search_status = ""; $search_type = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index e76d316bf6c..67c860e6f70 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -95,7 +95,7 @@ if (empty($reshook)) { $search_employee = ''; $search_type = ''; $search_description = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 1a621d55a98..7dffc0adbfe 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -133,7 +133,7 @@ if (empty($reshook)) { $search_type = ''; $search_prev_solde = ''; $search_new_solde = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } diff --git a/htdocs/hrm/admin/evaluation_extrafields.php b/htdocs/hrm/admin/evaluation_extrafields.php index a9614ccd03f..133be0c0f08 100644 --- a/htdocs/hrm/admin/evaluation_extrafields.php +++ b/htdocs/hrm/admin/evaluation_extrafields.php @@ -91,6 +91,8 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ +$textobject = $langs->transnoentitiesnoconv("Evaluation"); + $help_url = ''; $page_name = "HrmSetup"; diff --git a/htdocs/hrm/admin/job_extrafields.php b/htdocs/hrm/admin/job_extrafields.php index 4b0d76e5187..f521b8addb4 100644 --- a/htdocs/hrm/admin/job_extrafields.php +++ b/htdocs/hrm/admin/job_extrafields.php @@ -91,6 +91,8 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ +$textobject = $langs->transnoentitiesnoconv("Job"); + $help_url = ''; $page_name = "HrmSetup"; diff --git a/htdocs/hrm/admin/skill_extrafields.php b/htdocs/hrm/admin/skill_extrafields.php index f8d123cce74..e77feaa5002 100644 --- a/htdocs/hrm/admin/skill_extrafields.php +++ b/htdocs/hrm/admin/skill_extrafields.php @@ -91,6 +91,8 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ +$textobject = $langs->transnoentitiesnoconv("Skills"); + $help_url = ''; $page_name = "HrmSetup"; diff --git a/htdocs/install/check.php b/htdocs/install/check.php index f260be4f9fb..e9023b6389c 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -118,10 +118,28 @@ if (!function_exists("session_id")) { } +// Check for mbstring extension +if (!extension_loaded("mbstring")) { + $langs->load("errors"); + print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "MBString")."
\n"; + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +} else { + print 'Ok '.$langs->trans("PHPSupport", "MBString")."
\n"; +} + +// Check for json extension +if (!extension_loaded("json")) { + $langs->load("errors"); + print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "JSON")."
\n"; + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +} else { + print 'Ok '.$langs->trans("PHPSupport", "JSON")."
\n"; +} + // Check if GD is supported (we need GD for image conversion) if (!function_exists("imagecreate")) { $langs->load("errors"); - print 'Error '.$langs->trans("ErrorPHPDoesNotSupportGD")."
\n"; + print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "GD")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "GD")."
\n"; @@ -131,7 +149,7 @@ if (!function_exists("imagecreate")) { // Check if Curl is supported if (!function_exists("curl_init")) { $langs->load("errors"); - print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCurl")."
\n"; + print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "Curl")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "Curl")."
\n"; @@ -139,41 +157,49 @@ if (!function_exists("curl_init")) { // Check if PHP calendar extension is available if (!function_exists("easter_date")) { - print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCalendar")."
\n"; + print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "Calendar")."
\n"; } else { print 'Ok '.$langs->trans("PHPSupport", "Calendar")."
\n"; } +// Check if Curl is supported +if (!function_exists("simplexml_load_string")) { + $langs->load("errors"); + print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "Xml")."
\n"; + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +} else { + print 'Ok '.$langs->trans("PHPSupport", "Xml")."
\n"; +} // Check if UTF8 is supported if (!function_exists("utf8_encode")) { $langs->load("errors"); - print 'Error '.$langs->trans("ErrorPHPDoesNotSupportUTF8")."
\n"; + print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "UTF8")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "UTF8")."
\n"; } -// Check for mbstring extension -if (!extension_loaded("mbstring")) { - $langs->load("errors"); - print 'Error '.$langs->trans("ErrorPHPDoesNotSupportMbstring")."
\n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) -} else { - print 'Ok '.$langs->trans("PHPSupport", "mbstring")."
\n"; -} - // Check if intl methods are supported if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') { if (!function_exists("locale_get_primary_language") || !function_exists("locale_get_region")) { $langs->load("errors"); - print 'Error '.$langs->trans("ErrorPHPDoesNotSupportIntl")."
\n"; + print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "Intl")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "Intl")."
\n"; } } +// Check if Curl is supported +if (!function_exists("imap_open")) { + $langs->load("errors"); + print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "IMAP")."
\n"; + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +} else { + print 'Ok '.$langs->trans("PHPSupport", "IMAP")."
\n"; +} + if (!class_exists('ZipArchive')) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "ZIP")."
\n"; diff --git a/htdocs/install/index.php b/htdocs/install/index.php index 09300a75721..a7ce50c819f 100644 --- a/htdocs/install/index.php +++ b/htdocs/install/index.php @@ -49,6 +49,12 @@ $formadmin = new FormAdmin(''); // Note: $db does not exist yet but we don't nee pHeader("", "check"); // Next step = check +if (!is_readable($conffile)) { + print '
'; + print ''.$langs->trans("NoReadableConfFileSoStartInstall").''; +} + + // Ask installation language print '

'; print '
'.$langs->trans("Description").''; + print '
'.$langs->trans("Description").''; print nl2br($project->description); print '
'.$langs->trans("Categories").''; + print '
'.$langs->trans("Categories").''; print $form->showCategories($project->id, Categorie::TYPE_PROJECT, 1); print "
'; + print '
'; $typeofdata = 'checkbox:'.($project->accept_conference_suggestions ? ' checked="checked"' : ''); $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); - print ''; + print ''; print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); print "
'; + print '
'; $typeofdata = 'checkbox:'.($project->accept_booth_suggestions ? ' checked="checked"' : ''); $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); - print ''; + print ''; print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); print "
'; + print '
'; print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); - print ''; + print ''; print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'; + print '
'; print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); - print ''; + print ''; print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'.$langs->trans("EventOrganizationICSLink").''; + print '
'; + print $form->editfieldkey($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', '', $project, $permissiontoadd, 'integer:3', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', $project->max_attendees, $project, $permissiontoadd, 'integer:3', '', 0, 0, '', 0, '', 'projectid'); + print "
'.$langs->trans("EventOrganizationICSLink").''; // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; @@ -427,11 +433,11 @@ if ($projectid > 0) { print "
'; + print '
'; //print ''; print $form->textwithpicto($langs->trans("SuggestOrVoteForConfOrBooth"), $langs->trans("EvntOrgRegistrationHelpMessage")); //print ''; - print ''; + print ''; $linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.((int) $project->id); $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $project->id), 'md5'); $linksuggest .= '&securekey='.urlencode($encodedsecurekey); @@ -444,11 +450,11 @@ if ($projectid > 0) { print '
'; + print '
'; //print ''; print $langs->trans("PublicAttendeeSubscriptionGlobalPage"); //print ''; - print ''; + print ''; $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_new.php?id='.((int) $project->id).'&type=global'; $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $project->id), 'md5'); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); @@ -699,15 +705,16 @@ print ''; foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); $searchkey = (empty($search[$key]) ? '' : $search[$key]); + + $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')) && !in_array($key, array('rowid', 'ref')) && $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'])) { diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index be24d7b6797..ee7fe97421a 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -206,7 +206,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') diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 0d079f5dbdc..6b67f419da5 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -196,7 +196,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_datereceipt_start = ''; $search_datereceipt_end = ''; $search_status = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); $search_categ_cus = 0; } @@ -560,11 +560,11 @@ 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 .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); - $moreforfilter .= img_picto($tmptitle, 'user'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"'); $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200'); $moreforfilter .= '
'; } @@ -572,7 +572,7 @@ if ($user->rights->societe->client->voir || $socid) { if ($user->rights->user->user->lire) { $moreforfilter .= '
'; $tmptitle = $langs->trans('LinkedToSpecificUsers'); - $moreforfilter .= img_picto($tmptitle, 'user'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"'); $moreforfilter .= $form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '
'; } diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index ab763dc8a11..551957d0a69 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -224,7 +224,7 @@ if (empty($reshook)) { $search_date_endendyear = ''; $search_date_end = ''; $search_date_endend = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 9ec00d62b8e..f0e028ea92f 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -171,7 +171,7 @@ if (empty($reshook)) { $search_contrat_ref = ""; $search_desc = ""; $search_status = ""; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index e14322a62e9..c2962836fa2 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -34,7 +34,7 @@ if (!defined('DOL_APPLICATION_TITLE')) { define('DOL_APPLICATION_TITLE', 'Dolibarr'); } if (!defined('DOL_VERSION')) { - define('DOL_VERSION', '16.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '16.0.0-beta'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { @@ -115,6 +115,13 @@ if (!$result && !empty($_SERVER["GATEWAY_INTERFACE"])) { // If install not do } header("Location: ".$path."install/index.php"); + + /* + print '
'; + print 'The conf/conf.php file was not found or is not readable by the web server. If this is your first access, click here to start the Dolibarr installation process to create it...'; + print '

'; + */ + exit; } diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 9298c67ad9f..8ad44d198a8 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -266,7 +266,7 @@ if ($object->id > 0) { print '
'; print '
'; if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_supplier_id, 'cond_reglement_supplier_id', -1, 1); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_supplier_id, 'cond_reglement_supplier_id', 1); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_supplier_id, 'none'); } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 128c2ab3356..1d26fb5cfab 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2084,7 +2084,12 @@ class CommandeFournisseur extends CommonOrder // $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on) $mouv->origin = &$this; $mouv->setOrigin($this->element, $this->id); - $result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch); + // Method change if qty < 0 + if (!empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN) && $qty < 0) { + $result = $mouv->livraison($user, $product, $entrepot, $qty*(-1), $price, $comment, $now, $eatby, $sellby, $batch); + } else { + $result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch); + } if ($result < 0) { $this->error = $mouv->error; $this->errors = $mouv->errors; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 166da07ab03..362741e1641 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -802,7 +802,7 @@ if ($id > 0 || !empty($ref)) { $nbfreeproduct++; } else { $remaintodispatch = price2num($objp->qty - ((float) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched - if ($remaintodispatch < 0) { + if ($remaintodispatch < 0 && empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN)) { $remaintodispatch = 0; } diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 3ddb1350a8b..224a36e4acd 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -291,7 +291,7 @@ if (empty($reshook)) { $search_date_approve_end = ''; $billed = ''; $search_billed = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') @@ -1195,7 +1195,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 .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index ce4065815d9..a851e95e089 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -290,7 +290,7 @@ if (empty($reshook)) { $search_datelimit_endyear = ''; $search_datelimit_start = ''; $search_datelimit_end = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); $filter = ''; $option = ''; @@ -877,15 +877,15 @@ 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 .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); - $moreforfilter .= img_picto($tmptitle, 'company', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200'); $moreforfilter .= '
'; } // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) { + if ($user->rights->user->user->lire) { $moreforfilter .= '
'; $tmptitle = $langs->trans('LinkedToSpecificUsers'); $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); @@ -1474,7 +1474,7 @@ if ($resql) { // Payment condition if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { print '
'; - $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', '', -1); + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 1); print '
'; @@ -61,7 +67,9 @@ print ''; print '
'; -print '

'.$langs->trans("SomeTranslationAreUncomplete").''; + + +//print '

'.$langs->trans("SomeTranslationAreUncomplete").''; // If there's no error, we display the next step button if ($err == 0) { diff --git a/htdocs/install/mysql/data/llx_c_partnership_type.sql b/htdocs/install/mysql/data/llx_c_partnership_type-partnership.sql similarity index 100% rename from htdocs/install/mysql/data/llx_c_partnership_type.sql rename to htdocs/install/mysql/data/llx_c_partnership_type-partnership.sql diff --git a/htdocs/install/mysql/data/llx_c_payment_term.sql b/htdocs/install/mysql/data/llx_c_payment_term.sql index b5ff008912b..5a48e57a443 100644 --- a/htdocs/install/mysql/data/llx_c_payment_term.sql +++ b/htdocs/install/mysql/data/llx_c_payment_term.sql @@ -26,17 +26,18 @@ -- Do not include comments at end of line, this file is parsed during install and string '--' are removed. -- -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (1 ,'RECEP', 1,1, 'Due upon receipt','Due upon receipt',0,1); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (2 ,'30D', 2,1, '30 days','Due in 30 days',0,30); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (3 ,'30DENDMONTH', 3,1, '30 days end of month','Due in 30 days, end of month',1,30); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (4 ,'60D', 4,1, '60 days','Due in 60 days, end of month',0,60); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (5 ,'60DENDMONTH', 5,1, '60 days end of month','Due in 60 days, end of month',1,60); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (6 ,'PT_ORDER', 6,1, 'Due on order','Due on order',0,1); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (7 ,'PT_DELIVERY', 7,1, 'Due on delivery','Due on delivery',0,1); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (8 ,'PT_5050', 8,1, '50 and 50','50% on order, 50% on delivery',0,1); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (1 ,'RECEP', 1,1, 'Due upon receipt','Due upon receipt',0,1,NULL); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (2 ,'30D', 2,1, '30 days','Due in 30 days',0,30,NULL); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (3 ,'30DENDMONTH', 3,1, '30 days end of month','Due in 30 days, end of month',1,30,NULL); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (4 ,'60D', 4,1, '60 days','Due in 60 days, end of month',0,60,NULL); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (5 ,'60DENDMONTH', 5,1, '60 days end of month','Due in 60 days, end of month',1,60,NULL); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (6 ,'PT_ORDER', 6,1, 'Due on order','Due on order',0,1,NULL); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (7 ,'PT_DELIVERY', 7,1, 'Due on delivery','Due on delivery',0,1,NULL); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (8 ,'PT_5050', 8,1, '50 and 50','50% on order, 50% on delivery',0,1,NULL); -- Add additional payment terms often needed in Austria -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (9 ,'10D', 9,1, '10 days','Due in 10 days',0,10); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (10,'10DENDMONTH', 10,1, '10 days end of month','Due in 10 days, end of month',1,10); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (11,'14D', 11,1, '14 days','Due in 14 days',0,14); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (12,'14DENDMONTH', 12,1, '14 days end of month','Due in 14 days, end of month',1,14); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (9 ,'10D', 9,1, '10 days','Due in 10 days',0,10,NULL); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (10,'10DENDMONTH', 10,1, '10 days end of month','Due in 10 days, end of month',1,10,NULL); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (11,'14D', 11,1, '14 days','Due in 14 days',0,14,NULL); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (12,'14DENDMONTH', 12,1, '14 days end of month','Due in 14 days, end of month',1,14,NULL); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values (13,'DEP30PCTDEL', 13,0, '__DEPOSIT_PERCENT__% deposit','__DEPOSIT_PERCENT__% deposit, remainder on delivery',0,1,'30'); diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index bef32bc7fe7..a945f078bbb 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -538,6 +538,21 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, -- VMYSQL4.3 ALTER TABLE llx_user MODIFY COLUMN fk_soc integer NULL; -- VPGSQL8.2 ALTER TABLE llx_user ALTER COLUMN fk_soc DROP NOT NULL; +CREATE TABLE llx_element_tag +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_categorie integer NOT NULL, + fk_element integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +ALTER TABLE llx_element_tag ADD COLUMN fk_categorie integer; +ALTER TABLE llx_element_tag ADD COLUMN fk_element integer; + +ALTER TABLE llx_element_tag ADD UNIQUE INDEX idx_element_tag_uk (fk_categorie, fk_element); + +ALTER TABLE llx_element_tag ADD CONSTRAINT fk_element_tag_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); + -- Add column to help to fix a very critical bug when transferring into accounting bank record of a bank account into another currency. -- Idea is to update this column manually in v15 with value in currency of company for bank that are not into the main currency and the transfer -- into accounting will use it in priority if value is not null. The script repair.sql contains the sequence to fix datas in llx_bank. diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 7170ebb62f4..501aa0fe751 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -105,6 +105,8 @@ ALTER TABLE llx_bank ADD COLUMN amount_main_currency double(24,8) NULL; -- v16 +ALTER TABLE llx_societe_account DROP FOREIGN KEY llx_societe_account_fk_website; + UPDATE llx_cronjob set label = 'RecurringInvoicesJob' where label = 'RecurringInvoices'; UPDATE llx_cronjob set label = 'RecurringSupplierInvoicesJob' where label = 'RecurringSupplierInvoices'; @@ -325,6 +327,15 @@ UPDATE llx_c_availability SET type_duration = 'w', qty = 2 WHERE code = 'AV_2W'; UPDATE llx_c_availability SET type_duration = 'w', qty = 3 WHERE code = 'AV_3W'; UPDATE llx_c_availability SET type_duration = 'w', qty = 4 WHERE code = 'AV_4W'; + +-- Deposit generation helper with specific payment terms +ALTER TABLE llx_c_payment_term ADD COLUMN deposit_percent VARCHAR(63) DEFAULT NULL AFTER decalage; +ALTER TABLE llx_societe ADD COLUMN deposit_percent VARCHAR(63) DEFAULT NULL AFTER cond_reglement; +ALTER TABLE llx_propal ADD COLUMN deposit_percent VARCHAR(63) DEFAULT NULL AFTER fk_cond_reglement; +ALTER TABLE llx_commande ADD COLUMN deposit_percent VARCHAR(63) DEFAULT NULL AFTER fk_cond_reglement; +INSERT INTO llx_c_payment_term(code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values ('DEP30PCTDEL', 13, 0, '__DEPOSIT_PERCENT__% deposit', '__DEPOSIT_PERCENT__% deposit, remainder on delivery', 0, 1, '30'); + + ALTER TABLE llx_boxes_def ADD COLUMN fk_user integer DEFAULT 0 NOT NULL; ALTER TABLE llx_contratdet ADD COLUMN rang integer DEFAULT 0 AFTER info_bits; @@ -339,3 +350,15 @@ ALTER TABLE llx_takepos_floor_tables ADD UNIQUE(entity,label); ALTER TABLE llx_partnership ADD COLUMN url_to_check varchar(255); ALTER TABLE llx_c_partnership_type ADD COLUMN keyword varchar(128); + +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN firstname varchar(100); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN lastname varchar(100); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN email_company varchar(128) after email; + + +ALTER TABLE llx_c_email_template ADD COLUMN email_from varchar(255); +ALTER TABLE llx_c_email_template ADD COLUMN email_to varchar(255); +ALTER TABLE llx_c_email_template ADD COLUMN email_tocc varchar(255); +ALTER TABLE llx_c_email_template ADD COLUMN email_tobcc varchar(255); + + diff --git a/htdocs/install/mysql/tables/llx_c_email_templates.sql b/htdocs/install/mysql/tables/llx_c_email_templates.sql index 04130a208fe..4d22767bc58 100644 --- a/htdocs/install/mysql/tables/llx_c_email_templates.sql +++ b/htdocs/install/mysql/tables/llx_c_email_templates.sql @@ -32,6 +32,10 @@ create table llx_c_email_templates position smallint, -- Position enabled varchar(255) DEFAULT '1', -- Condition to have this module visible active tinyint DEFAULT 1 NOT NULL, + email_from varchar(255), -- default email from + email_to varchar(255), -- default email to + email_tocc varchar(255), -- default email to cc + email_tobcc varchar(255), -- default email to bcc topic text, -- Predefined topic joinfiles text, -- Files to attach content mediumtext, -- Predefined text diff --git a/htdocs/install/mysql/tables/llx_c_payment_term.sql b/htdocs/install/mysql/tables/llx_c_payment_term.sql index 087ab63c184..e7b2b606b65 100644 --- a/htdocs/install/mysql/tables/llx_c_payment_term.sql +++ b/htdocs/install/mysql/tables/llx_c_payment_term.sql @@ -30,6 +30,7 @@ create table llx_c_payment_term type_cdr tinyint, -- Type of change date reckoning. 1=Payment at end of current month, 2=the Nth of next month nbjour smallint, decalage smallint, + deposit_percent varchar(63) DEFAULT NULL, module varchar(32) NULL, position integer NOT NULL DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 5b8a78c7bf8..94b1f38227d 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -63,6 +63,7 @@ create table llx_commande fk_account integer, -- bank account fk_currency varchar(3), -- currency code fk_cond_reglement integer, -- condition de reglement + deposit_percent varchar(63) DEFAULT NULL, -- default deposit % if payment term needs it fk_mode_reglement integer, -- mode de reglement date_livraison datetime default NULL, diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql index d6139f48f21..973c738a076 100644 --- a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql +++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql @@ -1,4 +1,4 @@ --- Copyright (C) ---Put here your own copyright and developer email--- +-- Copyright (C) 2021-2022 Laurent Destailleur -- -- 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 @@ -22,7 +22,10 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee( fk_actioncomm integer, fk_project integer NOT NULL, fk_invoice integer NULL, - email varchar(100), + email varchar(128), + email_company varchar(128), + firstname varchar(100), + lastname varchar(100), date_subscription datetime, amount double DEFAULT NULL, note_public text, diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 80e3f90b828..83e8882caa7 100644 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -40,8 +40,8 @@ create table llx_product customcode varchar(32), -- Optionnal custom code fk_country integer DEFAULT NULL, -- Optionnal id of original country fk_state integer DEFAULT NULL, -- Optionnal id of original state/province - price double(24,8) DEFAULT 0, - price_ttc double(24,8) DEFAULT 0, + price double(24,8) DEFAULT 0, -- price without tax + price_ttc double(24,8) DEFAULT 0, -- price inc vat (but not localtax1 nor localtax2) price_min double(24,8) DEFAULT 0, price_min_ttc double(24,8) DEFAULT 0, price_base_type varchar(3) DEFAULT 'HT', diff --git a/htdocs/install/mysql/tables/llx_product_price.sql b/htdocs/install/mysql/tables/llx_product_price.sql index 77a00939428..2a64fc92c30 100644 --- a/htdocs/install/mysql/tables/llx_product_price.sql +++ b/htdocs/install/mysql/tables/llx_product_price.sql @@ -29,8 +29,8 @@ create table llx_product_price fk_product integer NOT NULL, date_price datetime NOT NULL, price_level smallint NULL DEFAULT 1, - price double(24,8) DEFAULT NULL, - price_ttc double(24,8) DEFAULT NULL, + price double(24,8) DEFAULT NULL, -- price without tax + price_ttc double(24,8) DEFAULT NULL, -- price inc vat (but not localtax1 nor localtax2) price_min double(24,8) default NULL, price_min_ttc double(24,8) default NULL, price_base_type varchar(3) DEFAULT 'HT', diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql index 3499a51e8b8..a8f0aa3e2c9 100644 --- a/htdocs/install/mysql/tables/llx_propal.sql +++ b/htdocs/install/mysql/tables/llx_propal.sql @@ -58,6 +58,7 @@ create table llx_propal fk_account integer, -- bank account fk_currency varchar(3), -- currency code fk_cond_reglement integer, -- condition de reglement (30 jours, fin de mois ...) + deposit_percent varchar(63) DEFAULT NULL, -- default deposit % if payment term needs it fk_mode_reglement integer, -- mode de reglement (Virement, Prelevement) online_sign_ip varchar(48), diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index c27a0fb2910..3c2f8a67be1 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -52,15 +52,6 @@ create table llx_societe email varchar(128), -- socialnetworks text DEFAULT NULL, -- json with socialnetworks - --skype varchar(255), -- deprecated - --twitter varchar(255), -- deprecated - --facebook varchar(255), -- deprecated - --linkedin varchar(255), -- deprecated - --instagram varchar(255), -- deprecated - --snapchat varchar(255), -- deprecated - --googleplus varchar(255), -- deprecated - --youtube varchar(255), -- deprecated - --whatsapp varchar(255), -- deprecated fk_effectif integer DEFAULT 0, -- fk_typent integer DEFAULT NULL, -- type ent @@ -93,6 +84,7 @@ create table llx_societe remise_supplier real DEFAULT 0, -- discount by default granted by this supplier mode_reglement tinyint, -- payment mode customer cond_reglement tinyint, -- payment term customer + deposit_percent varchar(63) DEFAULT NULL, -- default deposit % if payment term needs it transport_mode tinyint, -- transport mode customer (Intracomm report) mode_reglement_supplier tinyint, -- payment mode supplier cond_reglement_supplier tinyint, -- payment term supplier diff --git a/htdocs/install/mysql/tables/llx_societe_account.key.sql b/htdocs/install/mysql/tables/llx_societe_account.key.sql index e86c12aa306..e889a38d527 100644 --- a/htdocs/install/mysql/tables/llx_societe_account.key.sql +++ b/htdocs/install/mysql/tables/llx_societe_account.key.sql @@ -25,6 +25,8 @@ ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_fk_soc (fk_soc); ALTER TABLE llx_societe_account ADD UNIQUE INDEX uk_societe_account_login_website_soc(entity, fk_soc, login, site, fk_website); ALTER TABLE llx_societe_account ADD UNIQUE INDEX uk_societe_account_key_account_soc(entity, fk_soc, key_account, site, fk_website); -ALTER TABLE llx_societe_account ADD CONSTRAINT llx_societe_account_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); +-- Table website does not always exists +--ALTER TABLE llx_societe_account ADD CONSTRAINT llx_societe_account_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); + ALTER TABLE llx_societe_account ADD CONSTRAINT llx_societe_account_fk_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); diff --git a/htdocs/install/mysql/tables/llx_webhook_target-webhook.key.sql b/htdocs/install/mysql/tables/llx_webhook_target-webhook.key.sql new file mode 100644 index 00000000000..04a0dbb306a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_webhook_target-webhook.key.sql @@ -0,0 +1,27 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_webhook_target ADD INDEX idx_webhook_target_rowid (rowid); +ALTER TABLE llx_webhook_target ADD INDEX idx_webhook_target_ref (ref); +ALTER TABLE llx_webhook_target ADD CONSTRAINT llx_webhook_target_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_webhook_target ADD INDEX idx_webhook_target_status (status); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_webhook_target ADD UNIQUE INDEX uk_webhook_target_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_webhook_target ADD CONSTRAINT llx_webhook_target_fk_field FOREIGN KEY (fk_field) REFERENCES llx_webhook_myotherobject(rowid); + diff --git a/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql b/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql new file mode 100644 index 00000000000..1e0cc0fdbac --- /dev/null +++ b/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql @@ -0,0 +1,34 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +CREATE TABLE llx_webhook_target( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) NOT NULL, + label varchar(255), + description text, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status integer DEFAULT 0 NOT NULL, + url varchar(255) NOT NULL, + trigger_codes text NOT NULL + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_website.sql b/htdocs/install/mysql/tables/llx_website-website.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_website.sql rename to htdocs/install/mysql/tables/llx_website-website.sql diff --git a/htdocs/install/pgsql/functions/functions-don.sql b/htdocs/install/pgsql/functions/functions-don.sql new file mode 100644 index 00000000000..a1a51b57e6d --- /dev/null +++ b/htdocs/install/pgsql/functions/functions-don.sql @@ -0,0 +1,20 @@ +-- ============================================================================ +-- Copyright (C) 2010 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); diff --git a/htdocs/install/pgsql/functions/functions-loan.sql b/htdocs/install/pgsql/functions/functions-loan.sql new file mode 100644 index 00000000000..d63e394e5c9 --- /dev/null +++ b/htdocs/install/pgsql/functions/functions-loan.sql @@ -0,0 +1,19 @@ +-- ============================================================================ +-- Copyright (C) 2010 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_loan FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); diff --git a/htdocs/install/pgsql/functions/functions-mailing.sql b/htdocs/install/pgsql/functions/functions-mailing.sql new file mode 100644 index 00000000000..d45d620399f --- /dev/null +++ b/htdocs/install/pgsql/functions/functions-mailing.sql @@ -0,0 +1,20 @@ +-- ============================================================================ +-- Copyright (C) 2010 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_mailing FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_mailing_cibles FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); diff --git a/htdocs/install/pgsql/functions/functions-opensurvey.sql b/htdocs/install/pgsql/functions/functions-opensurvey.sql new file mode 100644 index 00000000000..d42a8311cb2 --- /dev/null +++ b/htdocs/install/pgsql/functions/functions-opensurvey.sql @@ -0,0 +1,21 @@ +-- ============================================================================ +-- Copyright (C) 2010 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_opensurvey_comments FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_opensurvey_sondage FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_opensurvey_user_studs FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); diff --git a/htdocs/install/pgsql/functions/functions-partnership.sql b/htdocs/install/pgsql/functions/functions-partnership.sql new file mode 100644 index 00000000000..61e991e1197 --- /dev/null +++ b/htdocs/install/pgsql/functions/functions-partnership.sql @@ -0,0 +1,20 @@ +-- ============================================================================ +-- Copyright (C) 2010 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_partnership FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_partnership_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); diff --git a/htdocs/install/pgsql/functions/functions-recruitment.sql b/htdocs/install/pgsql/functions/functions-recruitment.sql new file mode 100644 index 00000000000..9fa6023be1a --- /dev/null +++ b/htdocs/install/pgsql/functions/functions-recruitment.sql @@ -0,0 +1,23 @@ +-- ============================================================================ +-- Copyright (C) 2010 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_recruitment_recruitmentjobposition FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_recruitment_recruitmentjobposition_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_recruitment_recruitmentcandidature FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_recruitment_recruitmentcandidature_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); + diff --git a/htdocs/install/pgsql/functions/functions-website.sql b/htdocs/install/pgsql/functions/functions-website.sql new file mode 100644 index 00000000000..a5597837466 --- /dev/null +++ b/htdocs/install/pgsql/functions/functions-website.sql @@ -0,0 +1,21 @@ +-- ============================================================================ +-- Copyright (C) 2010 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website_page FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); + diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index d73678bcbab..35bc4e05c11 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -100,9 +100,6 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_contratdet_extrafiel CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_contratdet_log FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_subscription FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_cronjob FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_deplacement FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_directories FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_files FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_element_resources FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); @@ -126,19 +123,13 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_fichinter FOR EACH R CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_fichinter_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_fichinterdet_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_delivery FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_loan FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_localtax FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_mailing FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_mailing_cibles FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_menu FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_mrp_mo FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_mrp_mo_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_mrp_production FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_notify FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_notify_def FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_opensurvey_comments FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_opensurvey_sondage FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_opensurvey_user_studs FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_paiement FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_paiementcharge FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_paiementfourn FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); @@ -165,10 +156,6 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_propal_extrafields F CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_propal_merge_pdf_product FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_propaldet_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_resource FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_recruitment_recruitmentjobposition FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_recruitment_recruitmentjobposition_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_recruitment_recruitmentcandidature FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_recruitment_recruitmentcandidature_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_salary FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_societe FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_societe_address FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); @@ -187,5 +174,3 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_user FOR EACH ROW EX CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_user_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_usergroup FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_usergroup_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website_page FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 63b8d66539b..9613e1a86b5 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -261,6 +261,7 @@ if (!$error) { $error++; } } + // If we need simple access if (!$error && (empty($db_create_database) && empty($db_create_user))) { $db = getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, $db_port); diff --git a/htdocs/install/step4.php b/htdocs/install/step4.php index e1890656f4b..c8be975c19f 100644 --- a/htdocs/install/step4.php +++ b/htdocs/install/step4.php @@ -82,9 +82,9 @@ if ($db->ok) { print '
'; print '
'; - print '
'; - print '
'; if (isset($_GET["error"]) && $_GET["error"] == 1) { diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 924d251702c..cda8fc0bc13 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -167,20 +167,17 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; - // Chargement config - if (!$error) { - $conf->setValues($db); - // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) { - $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); - } - $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; - } + + $listofentities = array(1); // Create the global $hookmanager object include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); - $hookmanager->initHooks(array('upgrade')); + $reshook = $hookmanager->initHooks(array('doUpgradeBefore')); + if ($reshook >= 0 && is_array($hookmanager->resArray)) { + // Example: $hookmanager->resArray = array(2, 3, 10); + $listofentities = array_unique(array_merge($listofentities, $hookmanager->resArray)); + } /*************************************************************************************** @@ -188,385 +185,399 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ * Migration of data * ***************************************************************************************/ + + // Force to execute this at begin to avoid the new core code into Dolibarr to be broken. + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN birth date'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemployment date'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemploymentend date'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_range integer'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_c_exp_tax_cat integer'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN langs varchar(24)'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fieldcomputed text'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fielddefault varchar(255)'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX."extrafields ADD COLUMN enabled varchar(255) DEFAULT '1'"; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN help text'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL'; + $db->query($sql, 1); + + $db->begin(); - if (!$error) { - // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE - // Version to install is DOL_VERSION - $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : '')); - - // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec - // dans la 1ere colonne, la description de l'action a faire - // dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error' - - $versiontoarray = explode('.', $versionto); - $versionranarray = explode('.', DOL_VERSION); - - - // Force to execute this at begin to avoid the new core code into Dolibarr to be broken. - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN birth date'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemployment date'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemploymentend date'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_range integer'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_c_exp_tax_cat integer'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN langs varchar(24)'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fieldcomputed text'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fielddefault varchar(255)'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX."extrafields ADD COLUMN enabled varchar(255) DEFAULT '1'"; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN help text'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL'; - $db->query($sql, 1); - - - $afterversionarray = explode('.', '2.0.0'); - $beforeversionarray = explode('.', '2.7.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - // Script pour V2 -> V2.1 - migrate_paiements($db, $langs, $conf); - - migrate_contracts_det($db, $langs, $conf); - - migrate_contracts_date1($db, $langs, $conf); - - migrate_contracts_date2($db, $langs, $conf); - - migrate_contracts_date3($db, $langs, $conf); - - migrate_contracts_open($db, $langs, $conf); - - migrate_modeles($db, $langs, $conf); - - migrate_price_propal($db, $langs, $conf); - - migrate_price_commande($db, $langs, $conf); - - migrate_price_commande_fournisseur($db, $langs, $conf); - - migrate_price_contrat($db, $langs, $conf); - - migrate_paiementfourn_facturefourn($db, $langs, $conf); - - - // Script pour V2.1 -> V2.2 - migrate_paiements_orphelins_1($db, $langs, $conf); - - migrate_paiements_orphelins_2($db, $langs, $conf); - - migrate_links_transfert($db, $langs, $conf); - - - // Script pour V2.2 -> V2.4 - migrate_commande_expedition($db, $langs, $conf); - - migrate_commande_livraison($db, $langs, $conf); - - migrate_detail_livraison($db, $langs, $conf); - - - // Script pour V2.5 -> V2.6 - migrate_stocks($db, $langs, $conf); - - - // Script pour V2.6 -> V2.7 - migrate_menus($db, $langs, $conf); - - migrate_commande_deliveryaddress($db, $langs, $conf); - - migrate_restore_missing_links($db, $langs, $conf); - - migrate_rename_directories($db, $langs, $conf, '/compta', '/banque'); - - migrate_rename_directories($db, $langs, $conf, '/societe', '/mycompany'); + foreach ($listofentities as $entity) { + // Set $conf context for entity + $conf->setEntityValues($db, $entity); + // Reset forced setup after the setValues + if (defined('SYSLOG_FILE')) { + $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); } + $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; - // Script for 2.8 - $afterversionarray = explode('.', '2.7.9'); - $beforeversionarray = explode('.', '2.8.9'); - //print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx + if (!$error) { + if (count($listofentities) > 1) { + print '
*** '.$langs->trans("Entity").' '.$entity.'
'; - print ''.$langs->trans('UpgradeExternalModule').': '; - print $hookmanager->error; - print ""; - print '
'; - print ''.$langs->trans('UpgradeExternalModule').': OK'; - print ""; - print '
'; - print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("None"); - print '
'; + print ''.$langs->trans('UpgradeExternalModule').': '; + print $hookmanager->error; + print ""; + print '
'; + print ''.$langs->trans('UpgradeExternalModule').' (DB): OK'; + print ""; + print '
'; + print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("NodoUpgradeAfterDB"); + print '
'; - if (!$error) { // Set constant to ask to remake a new ping to inform about upgrade (if first ping was done and OK) $sql = 'UPDATE '.MAIN_DB_PREFIX."const SET VALUE = 'torefresh' WHERE name = 'MAIN_FIRST_PING_OK_ID'"; @@ -576,23 +587,68 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // We always commit. // Process is designed so we can run it several times whatever is situation. $db->commit(); + + + /*************************************************************************************** + * + * Migration of files + * + ***************************************************************************************/ + + foreach ($listofentities as $entity) { + // Set $conf context for entity + $conf->setEntityValues($db, $entity); + // Reset forced setup after the setValues + if (defined('SYSLOG_FILE')) { + $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); + } + $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; + + + // Copy directory medias + $srcroot = DOL_DOCUMENT_ROOT.'/install/medias'; + $destroot = DOL_DATA_ROOT.'/medias'; + dolCopyDir($srcroot, $destroot, 0, 0); + + + // Actions for all versions (no database change but delete some files and directories) + migrate_delete_old_files($db, $langs, $conf); + migrate_delete_old_dir($db, $langs, $conf); + // Actions for all versions (no database change but create some directories) + dol_mkdir(DOL_DATA_ROOT.'/bank'); + // Actions for all versions (no database change but rename some directories) + migrate_rename_directories($db, $langs, $conf, '/banque/bordereau', '/bank/checkdeposits'); + + + $parameters = array('versionfrom' => $versionfrom, 'versionto' => $versionto, 'conf'=>$conf); + $object = new stdClass(); + $action = "upgrade"; + $reshook = $hookmanager->executeHooks('doUpgradeAfterFiles', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($hookmanager->resNbOfHooks > 0) { + if ($reshook < 0) { + print '
'; + print ''.$langs->trans('UpgradeExternalModule').': '; + print $hookmanager->error; + print ""; + print '
'; + print ''.$langs->trans('UpgradeExternalModule').' (Files): OK'; + print ""; + print '
'; + print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("NodoUpgradeAfterFiles"); + print '
'; diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index c769b89f9b8..e801416d63d 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -23,7 +23,8 @@ */ -/** Terms +/** + * Terms * * DEB = Declaration d'Exchanges de Biens (FR) = Declaration of Exchange of Goods (EN) * DES = Déclaration Européenne de Services (FR) = European Declaration of Services (EN) @@ -32,7 +33,6 @@ * */ - require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/intracommreport/class/intracommreport.class.php $langs->loadLangs(array("intracommreport")); +$id = GETPOST('id', 'int'); $action = GETPOST('action'); $exporttype = GETPOSTISSET('exporttype') ? GETPOST('exporttype', 'alphanohtml') : 'deb'; // DEB or DES $year = GETPOSTINT('year'); @@ -65,9 +66,13 @@ $formother = new FormOther($db); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('intracommcard', 'globalcard')); +$error = 0; + + /* * Actions */ + $parameters = array('id' => $id); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); @@ -132,6 +137,7 @@ if ($action == 'add' && $user->rights->intracommreport->write) { } } + /* * View */ @@ -151,7 +157,7 @@ if ($action == 'create') { print '
'; // Label - print ''; + print ''; // Declaration print ''; print ''; print ''; diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index feadd8d9800..b644546d8b9 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -189,7 +189,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') diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 568263b0ca5..0f85c4b1c33 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -182,6 +182,7 @@ DONATION_ACCOUNTINGACCOUNT=Accounting account to register donations ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT=Accounting account to register subscriptions ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT=Accounting account by default to register customer deposit +UseAuxiliaryAccountOnCustomerDeposit=Use sub-accounts on customer deposit lines ACCOUNTING_PRODUCT_BUY_ACCOUNT=Accounting account by default for the bought products (used if not defined in the product sheet) ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT=Accounting account by default for the bought products in EEC (used if not defined in the product sheet) @@ -278,10 +279,10 @@ DescVentilExpenseReportMore=If you setup accounting account on type of expense r DescVentilDoneExpenseReport=Consult here the list of the lines of expenses reports and their fees accounting account Closure=Annual closure -DescClosure=Consult here the number of movements by month who are not validated & fiscal years already open -OverviewOfMovementsNotValidated=Step 1/ Overview of movements not validated. (Necessary to close a fiscal year) -AllMovementsWereRecordedAsValidated=All movements were recorded as validated -NotAllMovementsCouldBeRecordedAsValidated=Not all movements could be recorded as validated +DescClosure=Consult here the number of movements by month who are not yet validated & locked +OverviewOfMovementsNotValidated=Overview of movements not validated and locked +AllMovementsWereRecordedAsValidated=All movements were recorded as validated and locked +NotAllMovementsCouldBeRecordedAsValidated=Not all movements could be recorded as validated and locked ValidateMovements=Validate and lock record... DescValidateMovements=Any modification or deletion of writing, lettering and deletes will be prohibited. All entries for an exercise must be validated otherwise closing will not be possible @@ -289,7 +290,7 @@ ValidateHistory=Bind Automatically AutomaticBindingDone=Automatic bindings done (%s) - Automatic binding not possible for some record (%s) ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used -MvtNotCorrectlyBalanced=Movement not correctly balanced. Debit = %s | Credit = %s +MvtNotCorrectlyBalanced=Movement not correctly balanced. Debit = %s & Credit = %s Balancing=Balancing FicheVentilation=Binding card GeneralLedgerIsWritten=Transactions are written in the Ledger diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index f1761e93786..c3b5c89be21 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -718,7 +718,8 @@ Permission34=Delete products Permission36=See/manage hidden products Permission38=Export products Permission39=Ignore minimum price -Permission41=Read projects and tasks (shared project and projects I'm contact for). Can also enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet) +Permission41=Read projects and tasks (shared project and projects I'm contact for). +Permission145=Can enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet) Permission42=Create/modify projects (shared project and projects I'm contact for). Can also create tasks and assign users to project and tasks Permission44=Delete projects (shared project and projects I'm contact for) Permission45=Export projects @@ -2071,8 +2072,8 @@ ConfirmCloneEmailCollector=Are you sure you want to clone the Email collector %s DateLastCollectResult=Date of latest collect try DateLastcollectResultOk=Date of latest collect success LastResult=Latest result -EmailCollectorHideMailHeaders=Hide headers of collected e-mails -EmailCollectorHideMailHeadersHelp=When enabled, e-mail headers are ignored during the collection +EmailCollectorHideMailHeaders=Do not include the content of email header into the saved content of collected e-mails +EmailCollectorHideMailHeadersHelp=When enabled, e-mail headers are not added at the end of the email content that is saved as events. EmailCollectorConfirmCollectTitle=Email collect confirmation EmailCollectorConfirmCollect=Do you want to run this collector now? EmailCollectorExampleToCollectTicketRequestsDesc=Collect emails that match some rules and create automatically a ticket (Module Ticket must be enabled) with the email informations. You can use this collector if you provide some support by email, so your ticket request will be automatically generated. Activate also Collect_Responses to collect answers of your client directly on the ticket view (you must reply from Dolibarr). @@ -2254,4 +2255,7 @@ Settings = Settings WebhookSetupPage = Webhook setup page ShowQuickAddLink=Show a button to quickly add an element in top right menu HashForPing=Hash used for ping - +ReadOnlyMode=Is instance in "Read Only" mode +DEBUGBAR_USE_LOG_FILE=Use the dolibarr.log file to trap Logs +UsingLogFileShowAllRecordOfSubrequestButIsSlower=Use the dolibarr.log file to trap Logs instead of live memory catching. It allows to catch all logs instead of only log of current process (so including the one of ajax subrequests pages) but will make your instance very very slow. Not recommended. +FixedOrPercent=Fixed (use keyword 'fixed') or percent (use keyword 'percent') diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index a70d2eb8f21..22ca3f4cec1 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -429,10 +429,19 @@ PaymentConditionShort14D=14 days PaymentCondition14D=14 days PaymentConditionShort14DENDMONTH=14 days of month-end PaymentCondition14DENDMONTH=Within 14 days following the end of the month +PaymentConditionShortDEP30PCTDEL=__DEPOSIT_PERCENT__%% deposit +PaymentConditionDEP30PCTDEL=__DEPOSIT_PERCENT__%% deposit, remainder on delivery FixAmount=Fixed amount - 1 line with label '%s' VarAmount=Variable amount (%% tot.) VarAmountOneLine=Variable amount (%% tot.) - 1 line with label '%s' VarAmountAllLines=Variable amount (%% tot.) - all lines from origin +DepositPercent=Deposit %% +DepositGenerationPermittedByThePaymentTermsSelected=This is permitted by the payment terms selected +GenerateDeposit=Generate a %s%% deposit invoice +ValidateGeneratedDeposit=Validate the generated deposit +DepositGenerated=Deposit generated +ErrorCanOnlyAutomaticallyGenerateADepositFromProposalOrOrder=You can only automatically generate a deposit from a proposal or an order +ErrorPaymentConditionsNotEligibleToDepositCreation=The chose payment conditions are not eligible for automatic deposit generation # PaymentType PaymentTypeVIR=Bank transfer PaymentTypeShortVIR=Bank transfer diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index cf0de898bdb..a2d05767cae 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -90,6 +90,7 @@ CategorieRecursivHelp=If option is on, when you add a product into a subcategory AddProductServiceIntoCategory=Add the following product/service AddCustomerIntoCategory=Assign category to customer AddSupplierIntoCategory=Assign category to supplier +AssignCategoryTo=Assign category to ShowCategory=Show tag/category ByDefaultInList=By default in list ChooseCategory=Choose category diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 9cd52930714..858e0937788 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -165,4 +165,5 @@ EmailAttendee=Attendee email EmailCompanyForInvoice=Company email (for invoice, if different of attendee email) ErrorSeveralCompaniesWithEmailContactUs=Several companies with this email has been found so we can't validate automaticaly your registration. Please contact us at %s for a manual validation ErrorSeveralCompaniesWithNameContactUs=Several companies with this name has been found so we can't validate automaticaly your registration. Please contact us at %s for a manual validation -NoPublicActionsAllowedForThisEvent=No public actions are open to public for this event \ No newline at end of file +NoPublicActionsAllowedForThisEvent=No public actions are open to public for this event +MaxNbOfAttendees=Max number of attendees diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 989f6aa9793..9d76ad15d43 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -8,6 +8,7 @@ ConfFileIsNotWritable=Configuration file %s is not writable. Check permis ConfFileIsWritable=Configuration file %s is writable. ConfFileMustBeAFileNotADir=Configuration file %s must be a file, not a directory. ConfFileReload=Reloading parameters from configuration file. +NoReadableConfFileSoStartInstall=The configuration file conf/conf.php does not exists or is not reabable. We will run the installation process to try to initialize it. PHPSupportPOSTGETOk=This PHP supports variables POST and GET. PHPSupportPOSTGETKo=It's possible your PHP setup does not support variables POST and/or GET. Check the parameter variables_order in php.ini. PHPSupportSessions=This PHP supports sessions. @@ -16,13 +17,6 @@ PHPMemoryOK=Your PHP max session memory is set to %s. This should be enou PHPMemoryTooLow=Your PHP max session memory is set to %s bytes. This is too low. Change your php.ini to set memory_limit parameter to at least %s bytes. Recheck=Click here for a more detailed test ErrorPHPDoesNotSupportSessions=Your PHP installation does not support sessions. This feature is required to allow Dolibarr to work. Check your PHP setup and permissions of the sessions directory. -ErrorPHPDoesNotSupportGD=Your PHP installation does not support GD graphical functions. No graphs will be available. -ErrorPHPDoesNotSupportCurl=Your PHP installation does not support Curl. -ErrorPHPDoesNotSupportCalendar=Your PHP installation does not support php calendar extensions. -ErrorPHPDoesNotSupportUTF8=Your PHP installation does not support UTF8 functions. Dolibarr cannot work correctly. Resolve this before installing Dolibarr. -ErrorPHPDoesNotSupportIntl=Your PHP installation does not support Intl functions. -ErrorPHPDoesNotSupportMbstring=Your PHP installation does not support mbstring functions. -ErrorPHPDoesNotSupportxDebug=Your PHP installation does not support extend debug functions. ErrorPHPDoesNotSupport=Your PHP installation does not support %s functions. ErrorDirDoesNotExists=Directory %s does not exist. ErrorGoBackAndCorrectParameters=Go back and check/correct the parameters. diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index b39124c7c53..530f3b6af0e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -621,6 +621,7 @@ MonthVeryShort11=N MonthVeryShort12=D AttachedFiles=Attached files and documents JoinMainDoc=Join main document +JoinMainDocOrLastGenerated=Send the main document or the last generated one if not found DateFormatYYYYMM=YYYY-MM DateFormatYYYYMMDD=YYYY-MM-DD DateFormatYYYYMMDDHHMM=YYYY-MM-DD HH:SS @@ -1172,4 +1173,4 @@ AddLineOnPosition=Add line on position (at the end if empty) ConfirmAllocateCommercial=Assign sales representative confirmation ConfirmAllocateCommercialQuestion=Are you sure you want to assign the %s selected record(s)? CommercialsAffected=Sales representatives affected -CommercialAffected=Sales representative affected \ No newline at end of file +CommercialAffected=Sales representative affected diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 2d8ef240ef1..4b38515924b 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -424,3 +424,6 @@ PMPExpected=Expected PMP ExpectedValuation=Expected Valuation PMPReal=Real PMP RealValuation=Real Valuation +ConfirmEditExtrafield = Select the extrafield you want modify +ConfirmEditExtrafieldQuestion = Are you sure you want to modify this extrafield? +ModifyValueExtrafields = Modify value of an extrafield diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang index fa9e2203eea..4c3ee5f939f 100644 --- a/htdocs/langs/fr_FR/accountancy.lang +++ b/htdocs/langs/fr_FR/accountancy.lang @@ -289,7 +289,7 @@ ValidateHistory=Lier automatiquement AutomaticBindingDone=Liaisons automatiques effectuées (%s) - Liaison automatique impossible pour certains enregistrements (%s) ErrorAccountancyCodeIsAlreadyUse=Erreur, vous ne pouvez pas détruire de compte comptable car il est utilisé -MvtNotCorrectlyBalanced=Mouvement non équilibré. Débit = %s| Crédit = %s +MvtNotCorrectlyBalanced=Mouvement non équilibré. Débit = %s & Crédit = %s Balancing=Équilibrage FicheVentilation=Fiche lien GeneralLedgerIsWritten=Les transactions sont enregistrées dans le grand livre diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 034f105f6d8..8aa317ca305 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -718,7 +718,8 @@ Permission34=Supprimer les produits Permission36=Voir/gérer les produits cachés Permission38=Exporter les produits Permission39=Ignorer le prix minimum -Permission41=Lire les projets et tâches (partagés ou dont vous n'êtes pas contact). Permet la saisie de temps passé, pour vous-même et votre hiérarchie (vos subordonnés), sur les tâches assignées (Feuilles de temps). +Permission41=Lire les projets et tâches (partagés ou dont vous n'êtes pas contact). +Permission145=Permet la saisie de temps passé, pour vous-même et votre hiérarchie (vos subordonnés), sur les tâches assignées (Feuilles de temps). Permission42=Créer/modifier les projets (projets partagés et projets pour lesquels je suis contact). Permet aussi de créer des tâches et d'assigner des utilisateurs aux projets et tâches. Permission44=Supprimer les projets et tâches (partagés ou dont je suis contact) Permission45=Exporter les projets diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 12778f337dd..bc2ce45f8db 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -418,7 +418,7 @@ TotalLT2IN=Total SGST HT=HT TTC=TTC INCVATONLY=TVA incluse -INCT=TTC +INCT=TVA+Taxes locales incluses VAT=TVA VATIN=IGST VATs=TVA @@ -620,6 +620,7 @@ MonthVeryShort11=N MonthVeryShort12=D AttachedFiles=Fichiers et documents joints JoinMainDoc=Joindre le document principal +JoinMainDocOrLastGenerated=Joindre le document principal ou le dernier généré s'il n'a pas été trouvé DateFormatYYYYMM=YYYY-MM DateFormatYYYYMMDD=YYYY-MM-DD DateFormatYYYYMMDDHHMM=YYYY-MM-DD HH:SS diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 7e2cb072913..21218f099fe 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2083,6 +2083,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead print "\n"; // end div class="login_block" print ''; + //print '
 
'; print '
'; print "\n\n"; @@ -2149,7 +2150,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $dropdownBody .= '
'.$langs->transcountry("ProfId6", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_PROFID6"), 6).''; } $dropdownBody .= '
'.$langs->trans("VATIntraShort").': '.dol_print_profids(getDolGlobalString("MAIN_INFO_TVAINTRA"), 'VAT').''; - $dropdownBody .= '
'.$langs->trans("Country").': '.$langs->trans("Country".$mysoc->country_code).''; + $dropdownBody .= '
'.$langs->trans("Country").': '.($mysoc->country_code ? $langs->trans("Country".$mysoc->country_code) : '').''; $dropdownBody .= ''; diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php index 01a02d0c7dd..e7c42578bd6 100644 --- a/htdocs/modulebuilder/admin/setup.php +++ b/htdocs/modulebuilder/admin/setup.php @@ -89,7 +89,8 @@ if (preg_match('/del_(.*)/', $action, $reg)) { $form = new Form($db); -llxHeader('', $langs->trans("ModulebuilderSetup")); +$help_url = ''; +llxHeader('', $langs->trans("ModulebuilderSetup"), $help_url); $linkback = ''.$langs->trans("BackToModuleList").''; diff --git a/htdocs/modulebuilder/template/admin/myobject_extrafields.php b/htdocs/modulebuilder/template/admin/myobject_extrafields.php index 5ce224c8528..e5ed6469fa2 100644 --- a/htdocs/modulebuilder/template/admin/myobject_extrafields.php +++ b/htdocs/modulebuilder/template/admin/myobject_extrafields.php @@ -91,6 +91,8 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ +$textobject = $langs->transnoentitiesnoconv("MyObject"); + $help_url = ''; $page_name = "MyModuleSetup"; diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index fe92596d228..84b394da808 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -531,7 +531,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print ''; } print ''; - print ''; if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { print ''; print ''; + print ''; print ''; print ''; + } else { + print ''; } if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { // Actions or link to stock movement @@ -1020,7 +1023,13 @@ if ($object->id > 0) { if (!empty($conf->productbatch->enabled)) { print ''; } @@ -1041,7 +1050,6 @@ if ($object->id > 0) { // Real quantity if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { - print ''; if (! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { //PMP Expected if (! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; @@ -1066,6 +1069,14 @@ if ($object->id > 0) { print ''; + + print ''; + //PMP Real print ''; } // Picto delete line print ''; } else { - print ''; if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { //PMP Expected if (! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; @@ -1105,6 +1120,10 @@ if ($object->id > 0) { print price($pmp_valuation); print ''; + print ''; + //PMP Real print ''; + print ''; } - - print ''; print ''; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 7d28edb1dc9..a620bd02d39 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -84,6 +84,7 @@ $error = 0; $errors = array(); $action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); @@ -135,16 +136,6 @@ $upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object-> // Security check $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); -/* -if ($object->id > 0) { - if ($object->client == 0 && $object->fournisseur > 0) { - if (!empty($user->rights->fournisseur->lire)) { - accessforbidden(); - } - } -} -*/ - /* @@ -413,11 +404,11 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdPartyName")), null, 'errors'); $error++; } - if (GETPOST('client') < 0) { + if (GETPOST('client', 'int') && GETPOST('client', 'int') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProspectCustomer")), null, 'errors'); $error++; } - if (GETPOST('fournisseur') < 0) { + if (GETPOSTISSET('fournisseur') && GETPOST('fournisseur', 'int') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Supplier")), null, 'errors'); $error++; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 25d2831f853..1d32063c27b 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -209,6 +209,7 @@ class Societe extends CommonObject //'remise_supplier' =>array('type'=>'double', 'label'=>'SupplierDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>290, 'isameasure'=>1), 'mode_reglement' =>array('type'=>'tinyint(4)', 'label'=>'Mode reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>295), 'cond_reglement' =>array('type'=>'tinyint(4)', 'label'=>'Cond reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>300), + 'deposit_percent' =>array('type'=>'varchar(63)', 'label'=>'DepositPercent', 'enabled'=>1, 'visible'=>-1, 'position'=>301), 'mode_reglement_supplier' =>array('type'=>'integer', 'label'=>'Mode reglement supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>305), 'cond_reglement_supplier' =>array('type'=>'integer', 'label'=>'Cond reglement supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>308), 'outstanding_limit' =>array('type'=>'double(24,8)', 'label'=>'OutstandingBill', 'enabled'=>1, 'visible'=>-1, 'position'=>310, 'isameasure'=>1), @@ -482,6 +483,9 @@ class Societe extends CommonObject public $remise_percent; public $remise_supplier_percent; + public $mode_reglement_id; + public $cond_reglement_id; + public $deposit_percent; public $mode_reglement_supplier_id; public $cond_reglement_supplier_id; public $transport_mode_supplier_id; @@ -1462,6 +1466,7 @@ class Societe extends CommonObject $sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape($this->mode_reglement_id)."'" : "null"); $sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape($this->cond_reglement_id)."'" : "null"); + $sql .= ",deposit_percent = ".(!empty($this->deposit_percent) ? "'".$this->db->escape($this->deposit_percent)."'" : "null"); $sql .= ",transport_mode = ".(!empty($this->transport_mode_id) ? "'".$this->db->escape($this->transport_mode_id)."'" : "null"); $sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape($this->mode_reglement_supplier_id)."'" : "null"); $sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape($this->cond_reglement_supplier_id)."'" : "null"); @@ -1691,7 +1696,7 @@ class Societe extends CommonObject $sql .= ', spe.accountancy_code_customer as code_compta, spe.accountancy_code_supplier as code_compta_fournisseur, spe.accountancy_code_buy, spe.accountancy_code_sell'; } $sql .= ', s.code_client, s.code_fournisseur, s.parent, s.barcode'; - $sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.mode_reglement, s.cond_reglement, s.transport_mode'; + $sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.mode_reglement, s.cond_reglement, s.deposit_percent, s.transport_mode'; $sql .= ', s.fk_account, s.tva_assuj'; $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.transport_mode_supplier'; $sql .= ', s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo, s.logo_squarred'; @@ -1869,6 +1874,7 @@ class Societe extends CommonObject $this->mode_reglement_id = $obj->mode_reglement; $this->cond_reglement_id = $obj->cond_reglement; + $this->deposit_percent = $obj->deposit_percent; $this->transport_mode_id = $obj->transport_mode; $this->mode_reglement_supplier_id = $obj->mode_reglement_supplier; $this->cond_reglement_supplier_id = $obj->cond_reglement_supplier; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 5884679950f..e7b9e5097ea 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -365,7 +365,7 @@ if (empty($reshook)) { $search_level = ''; $search_parent_name = ''; $search_import_key = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } @@ -863,9 +863,6 @@ $arrayofmassactions = array( // 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->societe->supprimer) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} if ($user->rights->societe->creer) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } @@ -881,6 +878,9 @@ if ($user->rights->societe->creer) { if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) { $arrayofmassactions = array(); } +if ($user->rights->societe->supprimer) { + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $typefilter = ''; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 974b3d9b891..2d346282c4c 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -144,7 +144,7 @@ if (empty($reshook)) { foreach ($objectwebsiteaccount->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') diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 33f0c4693f8..55fdaf6f413 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -620,7 +620,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 .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); @@ -628,7 +628,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) { $moreforfilter .= '
'; $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'); diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 4621423eb02..d5bd8e4405f 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -232,7 +232,12 @@ function PrintCategories(first) { continue; } $("#catdivdesc"+i).show(); - $("#catdesc"+i).html(categories[parseInt(i)+parseInt(first)]['label']); + + $("#catdesc"+i).html(categories[parseInt(i)+parseInt(first)]['label'].bold() + ' - ' + categories[parseInt(i)+parseInt(first)]['description']); + + $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']); + $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']); $("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']); $("#catdiv"+i).attr('class', 'wrapper'); @@ -266,7 +271,12 @@ function MoreCategories(moreorless) { continue; } $("#catdivdesc"+i).show(); - $("#catdesc"+i).html(categories[i+( * pagecategories)]['label']); + + $("#catdesc"+i).html(categories[i+( * pagecategories)]['label'].bold() + ' - ' + categories[i+( * pagecategories)]['description']); + + $("#catdesc"+i).text(categories[i+( * pagecategories)]['label']); + $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+( * pagecategories)]['rowid']); $("#catdiv"+i).data("rowid",categories[i+( * pagecategories)]['rowid']); $("#catwatermark"+i).show(); @@ -295,8 +305,13 @@ function LoadProducts(position, issubcat) { jQuery.each(subcategories, function(i, val) { if (currentcat==val.fk_parent) { $("#prodivdesc"+ishow).show(); - $("#prodesc"+ishow).html(val.label); - $("#probutton"+ishow).html(val.label); + + $("#prodesc"+ishow).html(val.label.bold() + ' - ' + val.description); + $("#probutton"+ishow).html(val.label); + + $("#prodesc"+ishow).text(val.label); + $("#probutton"+ishow).text(val.label); + $("#probutton"+ishow).show(); $("#proprice"+ishow).attr("class", "hidden"); $("#proprice"+ishow).html(""); @@ -361,6 +376,13 @@ function LoadProducts(position, issubcat) { $("#prodiv"+ishow).attr("class","wrapper2"); $("#prowatermark"+ishow).hide(); ishow++; //Next product to show after print data product + executeHooks('completeJSProductDisplay', $parameters); + print $hookmanager->resPrint; + ?> } //console.log("Hide the prowatermark for ishow="+ishow); idata++; //Next data everytime @@ -570,6 +592,18 @@ function Search2(keyCodeForEnter, moreorless) { search_start = $('#search_start_'+moreorless).val(); } + if (search_term == '') { + $("[id^=prowatermark]").html(""); + $("[id^=prodesc]").text(""); + $("[id^=probutton]").text(""); + $("[id^=probutton]").hide(); + $("[id^=proprice]").attr("class", "hidden"); + $("[id^=proprice]").html(""); + $("[id^=proimg]").attr("src", "genimg/empty.png"); + $("[id^=prodiv]").data("rowid", ""); + return; + } + var search = false; var eventKeyCode = window.event.keyCode; if (keyCodeForEnter == '' || eventKeyCode == keyCodeForEnter) { @@ -591,6 +625,7 @@ function Search2(keyCodeForEnter, moreorless) { $.getJSON('/takepos/ajax/ajax.php?action=search&term=' + search_term + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { for (i = 0; i < ; i++) { if (typeof (data[i]) == "undefined") { + $("#prowatermark" + i).html(""); $("#prodesc" + i).text(""); $("#probutton" + i).text(""); $("#probutton" + i).hide(); @@ -627,6 +662,15 @@ function Search2(keyCodeForEnter, moreorless) { } $("#prodiv" + i).data("rowid", data[i]['rowid']); $("#prodiv" + i).data("iscat", 0); + + executeHooks('completeJSProductDisplay', $parameters); + print $hookmanager->resPrint; + ?> + nbsearchresults++; } }).always(function (data) { diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index de780d92a64..eec8ab7d363 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -49,6 +49,8 @@ if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +$hookmanager->initHooks(array('takeposinvoice')); global $mysoc; @@ -168,11 +170,6 @@ if ($invoice->socid > 0) { $soc->fetch(getDolGlobalString("$constforcompanyid")); } - -/* - * Actions - */ - // Change the currency of invoice if it was modified if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercurrency"])) { if ($invoice->multicurrency_code != $_SESSION["takeposcustomercurrency"]) { @@ -180,730 +177,748 @@ if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercu } } +/* + * Actions + */ -// Action to record a payment on a TakePOS invoice -if ($action == 'valid' && $user->rights->facture->creer) { - $bankaccount = 0; - $error = 0; +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) { - $bankaccount = GETPOST('accountid', 'int'); - } else { - if ($pay == 'LIQ') { - $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]}; // For backward compatibility - } elseif ($pay == "CHQ") { - $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility +if (empty($reshook)) { + // Action to record a payment on a TakePOS invoice + if ($action == 'valid' && $user->rights->facture->creer) { + $bankaccount = 0; + $error = 0; + + if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) { + $bankaccount = GETPOST('accountid', 'int'); } else { - $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"]; - $bankaccount = $conf->global->$accountname; + if ($pay == 'LIQ') { + $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]}; // For backward compatibility + } elseif ($pay == "CHQ") { + $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility + } else { + $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"]; + $bankaccount = $conf->global->$accountname; + } } - } - if ($bankaccount <= 0 && $pay != "delayed") { - $errormsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")); - $error++; - } + if ($bankaccount <= 0 && $pay != "delayed") { + $errormsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")); + $error++; + } - $now = dol_now(); - $res = 0; + $now = dol_now(); + $res = 0; - $invoice = new Facture($db); - $invoice->fetch($placeid); + $invoice = new Facture($db); + $invoice->fetch($placeid); - if ($invoice->total_ttc < 0) { - $invoice->type = $invoice::TYPE_CREDIT_NOTE; + if ($invoice->total_ttc < 0) { + $invoice->type = $invoice::TYPE_CREDIT_NOTE; - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE"; - $sql .= " fk_soc = ".((int) $invoice->socid); - $sql .= " AND type <> ".Facture::TYPE_CREDIT_NOTE; - $sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED; - $sql .= " ORDER BY rowid DESC"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE"; + $sql .= " fk_soc = ".((int) $invoice->socid); + $sql .= " AND type <> ".Facture::TYPE_CREDIT_NOTE; + $sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED; + $sql .= " ORDER BY rowid DESC"; - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - $fk_source = $obj->rowid; - if ($fk_source == null) { + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $fk_source = $obj->rowid; + if ($fk_source == null) { + fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer")); + } + } else { fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer")); } - } else { - fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer")); - } - $invoice->fk_facture_source = $fk_source; - $invoice->update($user); - } - - //$sav_FACTURE_ADDON = ''; - //if (!empty($conf->global->TAKEPOS_ADDON)) { - // $sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON; - // if ($conf->global->TAKEPOS_ADDON == "terminal") $conf->global->FACTURE_ADDON = $conf->global->{'TAKEPOS_ADDON'.$_SESSION["takeposterminal"]}; - // else $conf->global->FACTURE_ADDON = $conf->global->TAKEPOS_ADDON; - //} - - $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if ($error) { - dol_htmloutput_errors($errormsg, null, 1); - } elseif ($invoice->statut != Facture::STATUS_DRAFT) { - //If invoice is validated but it is not fully paid is not error and make the payment - if ($invoice->getRemainToPay() > 0) { - $res = 1; - } else { - dol_syslog("Sale already validated"); - dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); - } - } elseif (count($invoice->lines) == 0) { - $error++; - dol_syslog('Sale without lines'); - dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1); - } elseif (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { - $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; - $conf->global->STOCK_CALCULATE_ON_BILL = 1; - - $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); - $batch_rule = 0; - if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; - $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; - } - $res = $invoice->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); - - $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; - } else { - $res = $invoice->validate($user); - if ($res < 0) { - $error++; - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } - } - - // Restore save values - //if (!empty($sav_FACTURE_ADDON)) - //{ - // $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; - //} - - // Add the payment - if (!$error && $res >= 0) { - $remaintopay = $invoice->getRemainToPay(); - if ($remaintopay > 0) { - $payment = new Paiement($db); - $payment->datepaye = $now; - $payment->fk_account = $bankaccount; - $payment->amounts[$invoice->id] = $amountofpayment; - if ($pay == 'LIQ') { - $payment->pos_change = price2num(GETPOST('excess', 'alpha')); - } - - // If user has not used change control, add total invoice payment - // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay - if ($amountofpayment == 0 || $amountofpayment > $remaintopay) { - $payment->amounts[$invoice->id] = $remaintopay; - } - - $payment->paiementid = $paiementid; - $payment->num_payment = $invoice->ref; - - if ($pay != "delayed") { - $payment->create($user); - $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded - } + $invoice->fk_facture_source = $fk_source; + $invoice->update($user); } - if ($remaintopay == 0) { - dol_syslog("Invoice is paid, so we set it to status Paid"); - $result = $invoice->setPaid($user); - if ($result > 0) { - $invoice->paye = 1; - } - // set payment method - $invoice->setPaymentMethods($paiementid); - } else { - dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay); - } - } else { - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } -} + //$sav_FACTURE_ADDON = ''; + //if (!empty($conf->global->TAKEPOS_ADDON)) { + // $sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON; + // if ($conf->global->TAKEPOS_ADDON == "terminal") $conf->global->FACTURE_ADDON = $conf->global->{'TAKEPOS_ADDON'.$_SESSION["takeposterminal"]}; + // else $conf->global->FACTURE_ADDON = $conf->global->TAKEPOS_ADDON; + //} -if ($action == 'creditnote' && $user->rights->facture->creer) { - $creditnote = new Facture($db); - $creditnote->socid = $invoice->socid; - $creditnote->date = dol_now(); - $creditnote->module_source = 'takepos'; - $creditnote->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; - $creditnote->type = Facture::TYPE_CREDIT_NOTE; - $creditnote->fk_facture_source = $placeid; - $creditnote->remise_absolue = $invoice->remise_absolue; - $creditnote->remise_percent = $invoice->remise_percent; - $creditnote->create($user); - - foreach ($invoice->lines as $line) { - // Extrafields - if (method_exists($line, 'fetch_optionals')) { - // load extrafields - $line->fetch_optionals(); - } - // Reset fk_parent_line for no child products and special product - if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { - $fk_parent_line = 0; - } - if ($invoice->type == Facture::TYPE_SITUATION) { - $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id - $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from - if (!empty($invoice->tab_previous_situation_invoice)) { - // search the last standard invoice in cycle and the possible credit note between this last and invoice - // TODO Move this out of loop of $invoice->lines - $tab_jumped_credit_notes = array(); - $lineIndex = count($invoice->tab_previous_situation_invoice) - 1; - $searchPreviousInvoice = true; - while ($searchPreviousInvoice) { - if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) { - $searchPreviousInvoice = false; // find, exit; - break; - } else { - if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { - $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id; - } - $lineIndex--; // go to previous invoice in cycle - } - } - - $maxPrevSituationPercent = 0; - foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { - if ($prevLine->id == $source_fk_prev_id) { - $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); - - //$line->subprice = $line->subprice - $prevLine->subprice; - $line->total_ht = $line->total_ht - $prevLine->total_ht; - $line->total_tva = $line->total_tva - $prevLine->total_tva; - $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; - $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; - $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; - - $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; - } - } - - // prorata - $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; - - //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; - - // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) - $maxPrevSituationPercent = 0; - foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { - foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) { - if ($prevLine->fk_prev_id == $source_fk_prev_id) { - $maxPrevSituationPercent = $prevLine->situation_percent; - - $line->total_ht -= $prevLine->total_ht; - $line->total_tva -= $prevLine->total_tva; - $line->total_ttc -= $prevLine->total_ttc; - $line->total_localtax1 -= $prevLine->total_localtax1; - $line->total_localtax2 -= $prevLine->total_localtax2; - - $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; - } - } - } - - // prorata - $line->situation_percent += $maxPrevSituationPercent; - - //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; - } - } - - $line->fk_facture = $creditnote->id; - $line->fk_parent_line = $fk_parent_line; - - $line->subprice = -$line->subprice; // invert price for object - $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here - $line->total_ht = -$line->total_ht; - $line->total_tva = -$line->total_tva; - $line->total_ttc = -$line->total_ttc; - $line->total_localtax1 = -$line->total_localtax1; - $line->total_localtax2 = -$line->total_localtax2; - - $line->multicurrency_subprice = -$line->multicurrency_subprice; - $line->multicurrency_total_ht = -$line->multicurrency_total_ht; - $line->multicurrency_total_tva = -$line->multicurrency_total_tva; - $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; - - $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked - - $creditnote->lines[] = $line; // insert new line in current object - - // Defined the new fk_parent_line - if ($result > 0 && $line->product_type == 9) { - $fk_parent_line = $result; - } - } - $creditnote->update_price(1); - - $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { - $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; - $conf->global->STOCK_CALCULATE_ON_BILL = 1; - $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); - $batch_rule = 0; - if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; - $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; - } - $res = $creditnote->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); - $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; - } else { - $res = $creditnote->validate($user); - } -} - -if ($action == 'history' || $action == 'creditnote') { - if ($action == 'creditnote') { - $placeid = $creditnote->id; - } else { - $placeid = (int) GETPOST('placeid', 'int'); - } - $invoice = new Facture($db); - $invoice->fetch($placeid); -} - -if (($action == "addline" || $action == "freezone") && $placeid == 0) { - $invoice->socid = getDolGlobalString("$constforcompanyid"); - $invoice->date = dol_now(); - $invoice->module_source = 'takepos'; - $invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; - $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity; - - if ($invoice->socid <= 0) { - $langs->load('errors'); - dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1); - } else { - $placeid = $invoice->create($user); - if ($placeid < 0) { - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid); - $db->query($sql); - } -} - -if ($action == "addline") { - $prod = new Product($db); - $prod->fetch($idproduct); - - $customer = new Societe($db); - $customer->fetch($invoice->socid); - - $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); - - $qty = GETPOSTISSET('qty') ? GETPOST('qty', 'int') : 1; - $price = $datapriceofproduct['pu_ht']; - $price_ttc = $datapriceofproduct['pu_ttc']; - //$price_min = $datapriceofproduct['price_min']; - $price_base_type = $datapriceofproduct['price_base_type']; - $tva_tx = $datapriceofproduct['tva_tx']; - $tva_npr = $datapriceofproduct['tva_npr']; - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); - $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); - - if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $cat = new Categorie($db); - $categories = $cat->containing($idproduct, 'product'); - $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id'))); - if ($found !== false) { // If this product is a supplement - $sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline"; - $resql = $db->query($sql); - $row = $db->fetch_array($resql); - if ($row[0] == null) { - $parent_line = $selectedline; + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; + if ($error) { + dol_htmloutput_errors($errormsg, null, 1); + } elseif ($invoice->statut != Facture::STATUS_DRAFT) { + //If invoice is validated but it is not fully paid is not error and make the payment + if ($invoice->getRemainToPay() > 0) { + $res = 1; } else { - $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product + dol_syslog("Sale already validated"); + dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); + } + } elseif (count($invoice->lines) == 0) { + $error++; + dol_syslog('Sale without lines'); + dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1); + } elseif (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { + $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; + $conf->global->STOCK_CALCULATE_ON_BILL = 1; + + $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); + $batch_rule = 0; + if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; + } + $res = $invoice->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); + + $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; + } else { + $res = $invoice->validate($user); + if ($res < 0) { + $error++; + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); } } - } - $idoflineadded = 0; - // Group if enabled. Skip group if line already sent to the printer - if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT) && $line->special_code != "4") { - foreach ($invoice->lines as $line) { - if ($line->product_ref == $prod->ref) { - if ($line->special_code==4) continue; // If this line is sended to printer create new line - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty + $qty, $line->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); - if ($result < 0) { - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } else { - $idoflineadded = $line->id; + // Restore save values + //if (!empty($sav_FACTURE_ADDON)) + //{ + // $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; + //} + + // Add the payment + if (!$error && $res >= 0) { + $remaintopay = $invoice->getRemainToPay(); + if ($remaintopay > 0) { + $payment = new Paiement($db); + $payment->datepaye = $now; + $payment->fk_account = $bankaccount; + $payment->amounts[$invoice->id] = $amountofpayment; + if ($pay == 'LIQ') { + $payment->pos_change = price2num(GETPOST('excess', 'alpha')); } - break; + + // If user has not used change control, add total invoice payment + // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay + if ($amountofpayment == 0 || $amountofpayment > $remaintopay) { + $payment->amounts[$invoice->id] = $remaintopay; + } + + $payment->paiementid = $paiementid; + $payment->num_payment = $invoice->ref; + + if ($pay != "delayed") { + $payment->create($user); + $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); + $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded + } + } + + if ($remaintopay == 0) { + dol_syslog("Invoice is paid, so we set it to status Paid"); + $result = $invoice->setPaid($user); + if ($result > 0) { + $invoice->paye = 1; + } + // set payment method + $invoice->setPaymentMethods($paiementid); + } else { + dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay); + } + } else { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } + } + + if ($action == 'creditnote' && $user->rights->facture->creer) { + $creditnote = new Facture($db); + $creditnote->socid = $invoice->socid; + $creditnote->date = dol_now(); + $creditnote->module_source = 'takepos'; + $creditnote->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; + $creditnote->type = Facture::TYPE_CREDIT_NOTE; + $creditnote->fk_facture_source = $placeid; + $creditnote->remise_absolue = $invoice->remise_absolue; + $creditnote->remise_percent = $invoice->remise_percent; + $creditnote->create($user); + + foreach ($invoice->lines as $line) { + // Extrafields + if (method_exists($line, 'fetch_optionals')) { + // load extrafields + $line->fetch_optionals(); + } + // Reset fk_parent_line for no child products and special product + if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { + $fk_parent_line = 0; + } + if ($invoice->type == Facture::TYPE_SITUATION) { + $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id + $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from + if (!empty($invoice->tab_previous_situation_invoice)) { + // search the last standard invoice in cycle and the possible credit note between this last and invoice + // TODO Move this out of loop of $invoice->lines + $tab_jumped_credit_notes = array(); + $lineIndex = count($invoice->tab_previous_situation_invoice) - 1; + $searchPreviousInvoice = true; + while ($searchPreviousInvoice) { + if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) { + $searchPreviousInvoice = false; // find, exit; + break; + } else { + if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { + $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id; + } + $lineIndex--; // go to previous invoice in cycle + } + } + + $maxPrevSituationPercent = 0; + foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { + if ($prevLine->id == $source_fk_prev_id) { + $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); + + //$line->subprice = $line->subprice - $prevLine->subprice; + $line->total_ht = $line->total_ht - $prevLine->total_ht; + $line->total_tva = $line->total_tva - $prevLine->total_tva; + $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; + $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; + $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; + + $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; + } + } + + // prorata + $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; + + //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; + + // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) + $maxPrevSituationPercent = 0; + foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { + foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) { + if ($prevLine->fk_prev_id == $source_fk_prev_id) { + $maxPrevSituationPercent = $prevLine->situation_percent; + + $line->total_ht -= $prevLine->total_ht; + $line->total_tva -= $prevLine->total_tva; + $line->total_ttc -= $prevLine->total_ttc; + $line->total_localtax1 -= $prevLine->total_localtax1; + $line->total_localtax2 -= $prevLine->total_localtax2; + + $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; + } + } + } + + // prorata + $line->situation_percent += $maxPrevSituationPercent; + + //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; + } + } + + $line->fk_facture = $creditnote->id; + $line->fk_parent_line = $fk_parent_line; + + $line->subprice = -$line->subprice; // invert price for object + $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here + $line->total_ht = -$line->total_ht; + $line->total_tva = -$line->total_tva; + $line->total_ttc = -$line->total_ttc; + $line->total_localtax1 = -$line->total_localtax1; + $line->total_localtax2 = -$line->total_localtax2; + + $line->multicurrency_subprice = -$line->multicurrency_subprice; + $line->multicurrency_total_ht = -$line->multicurrency_total_ht; + $line->multicurrency_total_tva = -$line->multicurrency_total_tva; + $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; + + $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked + + $creditnote->lines[] = $line; // insert new line in current object + + // Defined the new fk_parent_line + if ($result > 0 && $line->product_type == 9) { + $fk_parent_line = $result; } } - } - if ($idoflineadded <= 0) { - $invoice->fetch_thirdparty(); - $idoflineadded = $invoice->addline($prod->description, $price, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', 0, 100, '', null, 0); - if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) { - $CUSTOMER_DISPLAY_line1 = $prod->label; - $CUSTOMER_DISPLAY_line2 = price($price_ttc); + $creditnote->update_price(1); + + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; + if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { + $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; + $conf->global->STOCK_CALCULATE_ON_BILL = 1; + $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); + $batch_rule = 0; + if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; + } + $res = $creditnote->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); + $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; + } else { + $res = $creditnote->validate($user); } } - $invoice->fetch($placeid); -} - -if ($action == "freezone") { - $customer = new Societe($db); - $customer->fetch($invoice->socid); - - $tva_tx = GETPOST('tva_tx', 'alpha'); - if ($tva_tx != '') { - if (!preg_match('/\((.*)\)/', $tva_tx)) { - $tva_tx = price2num($tva_tx); + if ($action == 'history' || $action == 'creditnote') { + if ($action == 'creditnote') { + $placeid = $creditnote->id; + } else { + $placeid = (int) GETPOST('placeid', 'int'); } - } else { - $tva_tx = get_default_tva($mysoc, $customer); - } - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); - $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); - - $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); - $invoice->fetch($placeid); -} - -if ($action == "addnote") { - $desc = GETPOST('addnote', 'alpha'); - if ($idline==0) { - $invoice->update_note($desc, '_public'); - } else foreach ($invoice->lines as $line) { - if ($line->id == $idline) { - $result = $invoice->updateline($line->id, $desc, $line->subprice, $line->qty, $line->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); - } - } - $invoice->fetch($placeid); -} - -if ($action == "deleteline") { - if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected. - $invoice->deleteline($idline); - $invoice->fetch($placeid); - } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line. - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".((int) $placeid)." ORDER BY rowid DESC"; - $resql = $db->query($sql); - $row = $db->fetch_array($resql); - $deletelineid = $row[0]; - $invoice->deleteline($deletelineid); + $invoice = new Facture($db); $invoice->fetch($placeid); } - if (count($invoice->lines) == 0) { - $invoice->delete($user); - header("Location: ".DOL_URL_ROOT."/takepos/invoice.php"); - exit; + + if (($action == "addline" || $action == "freezone") && $placeid == 0) { + $invoice->socid = getDolGlobalString("$constforcompanyid"); + $invoice->date = dol_now(); + $invoice->module_source = 'takepos'; + $invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; + $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity; + + if ($invoice->socid <= 0) { + $langs->load('errors'); + dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1); + } else { + $placeid = $invoice->create($user); + if ($placeid < 0) { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid); + $db->query($sql); + } } -} -// Action to delete or discard an invoice -if ($action == "delete") { - // $placeid is the invoice id (it differs from place) and is defined if the place is set and the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')', so the fetch at begining of page works. - if ($placeid > 0) { - $result = $invoice->fetch($placeid); + if ($action == "addline") { + $prod = new Product($db); + $prod->fetch($idproduct); - if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) { - $db->begin(); + $customer = new Societe($db); + $customer->fetch($invoice->socid); - // We delete the lines - $resdeletelines = 1; + $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); + + $qty = GETPOSTISSET('qty') ? GETPOST('qty', 'int') : 1; + $price = $datapriceofproduct['pu_ht']; + $price_ttc = $datapriceofproduct['pu_ttc']; + //$price_min = $datapriceofproduct['price_min']; + $price_base_type = $datapriceofproduct['price_base_type']; + $tva_tx = $datapriceofproduct['tva_tx']; + $tva_npr = $datapriceofproduct['tva_npr']; + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); + + if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $cat = new Categorie($db); + $categories = $cat->containing($idproduct, 'product'); + $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id'))); + if ($found !== false) { // If this product is a supplement + $sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline"; + $resql = $db->query($sql); + $row = $db->fetch_array($resql); + if ($row[0] == null) { + $parent_line = $selectedline; + } else { + $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product + } + } + } + + $idoflineadded = 0; + // Group if enabled. Skip group if line already sent to the printer + if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT) && $line->special_code != "4") { foreach ($invoice->lines as $line) { - $tmpres = $invoice->deleteline($line->id); - if ($tmpres < 0) { - $resdeletelines = 0; + if ($line->product_ref == $prod->ref) { + if ($line->special_code==4) continue; // If this line is sended to printer create new line + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty + $qty, $line->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); + if ($result < 0) { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } else { + $idoflineadded = $line->id; + } break; } } + } + if ($idoflineadded <= 0) { + $invoice->fetch_thirdparty(); + $array_options = array(); - $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; - $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; - $sql .= " SET fk_soc = ".((int) $conf->global->$varforconst).", "; - $sql .= " datec = '".$db->idate(dol_now())."'"; - $sql .= " WHERE ref = '(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'"; - $resql1 = $db->query($sql); + // complete line by hook + $parameters = array('prod' => $prod); + $reshook=$hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if ($resdeletelines && $resql1) { - $db->commit(); - } else { - $db->rollback(); + if (empty($reshook)) { + $idoflineadded = $invoice->addline($prod->description, $price, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', $array_options, 100, '', null, 0); } + if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) { + $CUSTOMER_DISPLAY_line1 = $prod->label; + $CUSTOMER_DISPLAY_line2 = price($price_ttc); + } + } + + $invoice->fetch($placeid); + } + + if ($action == "freezone") { + $customer = new Societe($db); + $customer->fetch($invoice->socid); + + $tva_tx = GETPOST('tva_tx', 'alpha'); + if ($tva_tx != '') { + if (!preg_match('/\((.*)\)/', $tva_tx)) { + $tva_tx = price2num($tva_tx); + } + } else { + $tva_tx = get_default_tva($mysoc, $customer); + } + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); + + $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); + $invoice->fetch($placeid); + } + + if ($action == "addnote") { + $desc = GETPOST('addnote', 'alpha'); + if ($idline==0) { + $invoice->update_note($desc, '_public'); + } else foreach ($invoice->lines as $line) { + if ($line->id == $idline) { + $result = $invoice->updateline($line->id, $desc, $line->subprice, $line->qty, $line->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); + } + } + $invoice->fetch($placeid); + } + + if ($action == "deleteline") { + if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected. + $invoice->deleteline($idline); + $invoice->fetch($placeid); + } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line. + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".((int) $placeid)." ORDER BY rowid DESC"; + $resql = $db->query($sql); + $row = $db->fetch_array($resql); + $deletelineid = $row[0]; + $invoice->deleteline($deletelineid); $invoice->fetch($placeid); } + if (count($invoice->lines) == 0) { + $invoice->delete($user); + header("Location: ".DOL_URL_ROOT."/takepos/invoice.php"); + exit; + } } -} -if ($action == "updateqty") { - foreach ($invoice->lines as $line) { - if ($line->id == $idline) { - if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) { - dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); - } else { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->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); + // Action to delete or discard an invoice + if ($action == "delete") { + // $placeid is the invoice id (it differs from place) and is defined if the place is set and the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')', so the fetch at begining of page works. + if ($placeid > 0) { + $result = $invoice->fetch($placeid); + + if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) { + $db->begin(); + + // We delete the lines + $resdeletelines = 1; + foreach ($invoice->lines as $line) { + $tmpres = $invoice->deleteline($line->id); + if ($tmpres < 0) { + $resdeletelines = 0; + break; + } + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; + $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; + $sql .= " SET fk_soc = ".((int) $conf->global->$varforconst).", "; + $sql .= " datec = '".$db->idate(dol_now())."'"; + $sql .= " WHERE ref = '(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'"; + $resql1 = $db->query($sql); + + if ($resdeletelines && $resql1) { + $db->commit(); + } else { + $db->rollback(); + } + + $invoice->fetch($placeid); } } } - $invoice->fetch($placeid); -} - -if ($action == "updateprice") { - $customer = new Societe($db); - $customer->fetch($invoice->socid); - - foreach ($invoice->lines as $line) { - if ($line->id == $idline) { - $prod = new Product($db); - $prod->fetch($line->fk_product); - $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); - $price_min = $datapriceofproduct['price_min']; - $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); - $pu_ht = price2num($number / (1 + ($line->tva_tx / 100)), 'MU'); - //Check min price - if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) { - echo $langs->trans("CantBeLessThanMinPrice"); - } else { - if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { + if ($action == "updateqty") { + foreach ($invoice->lines as $line) { + if ($line->id == $idline) { + if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) { dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); - } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) { - $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->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); } else { - $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $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); + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->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); } } } + + $invoice->fetch($placeid); } - // Reload data - $invoice->fetch($placeid); -} + if ($action == "updateprice") { + $customer = new Societe($db); + $customer->fetch($invoice->socid); -if ($action == "updatereduction") { - $customer = new Societe($db); - $customer->fetch($invoice->socid); - - foreach ($invoice->lines as $line) { - if ($line->id == $idline) { - dol_syslog("updatereduction Process line ".$line->id.' to apply discount of '.$number.'%'); - - $prod = new Product($db); - $prod->fetch($line->fk_product); - - $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); - $price_min = $datapriceofproduct['price_min']; - $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); - - $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU'); - - // Check min price - if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) { - echo $langs->trans("CantBeLessThanMinPrice"); - } else { - if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { - dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + foreach ($invoice->lines as $line) { + if ($line->id == $idline) { + $prod = new Product($db); + $prod->fetch($line->fk_product); + $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); + $price_min = $datapriceofproduct['price_min']; + $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); + $pu_ht = price2num($number / (1 + ($line->tva_tx / 100)), 'MU'); + //Check min price + if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) { + echo $langs->trans("CantBeLessThanMinPrice"); } else { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $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); + if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { + dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) { + $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->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); + } else { + $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $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); + } } } } + + // Reload data + $invoice->fetch($placeid); } - // Reload data - $invoice->fetch($placeid); -} elseif ($action == 'update_reduction_global') { - foreach ($invoice->lines as $line) { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $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); - } + if ($action == "updatereduction") { + $customer = new Societe($db); + $customer->fetch($invoice->socid); - $invoice->fetch($placeid); -} + foreach ($invoice->lines as $line) { + if ($line->id == $idline) { + dol_syslog("updatereduction Process line ".$line->id.' to apply discount of '.$number.'%'); -if ($action == "order" and $placeid != 0) { - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { - require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; - $printer = new dolReceiptPrinter($db); - } + $prod = new Product($db); + $prod->fetch($line->fk_product); - $sql = "SELECT label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); - $resql = $db->query($sql); - $row = $db->fetch_object($resql); - $headerorder = '
'.$langs->trans('Place').' '.$row->label.'
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Declaration")."\n"; @@ -164,8 +170,8 @@ if ($action == 'create') { print $langs->trans("AnalysisPeriod"); print ''; - print $formother->select_month($month ? date('M') : $month, 'month', 0, 1, 'widthauto valignmiddle '); - print $formother->select_year($year ? date('Y') : $year, 'year', 0, 3, 3); + print $formother->select_month($month ? date('M') : $month, 'month', 0, 1, 'widthauto valignmiddle ', true); + print $formother->selectyear($year ? date('Y') : $year, 'year', 0, 3, 3, 0, 0, '', '', true); print '
'; $constforvar = 'MYMODULE_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $file) { + if (getDolGlobalString($constforvar) == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -673,7 +673,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Default print ''; $constforvar = 'MYMODULE_'.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 'scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index d843687157a..b6327e230fb 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -428,7 +428,7 @@ class modMyModule extends DolibarrModules { global $conf, $langs; - //$result = $this->_load_tables('/install/mysql/tables/', 'mymodule'); + //$result = $this->_load_tables('/install/mysql/', 'mymodule'); $result = $this->_load_tables('/mymodule/sql/'); 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') diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 050c99bfed0..9638eb4ce7f 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -88,6 +88,9 @@ require_once __DIR__.'/class/myobject.class.php'; // Load translation files required by the page $langs->loadLangs(array("mymodule@mymodule", "other")); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); + $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? @@ -99,8 +102,6 @@ $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'); - // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -540,8 +541,12 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, 'left'); // This also change content of $arrayfields +} else { + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +} + $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''."\n"; @@ -550,6 +555,13 @@ print '
'; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -566,7 +578,7 @@ foreach ($object->fields as $key => $val) { if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { 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); + print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print '
'; print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -595,10 +607,12 @@ print $hookmanager->resPrint; print '
'; }*/ // Action column -print ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; $totalarray = array(); @@ -607,6 +621,9 @@ $totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; +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['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -618,6 +635,7 @@ foreach ($object->fields as $key => $val) { } 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']++; @@ -634,7 +652,9 @@ print $hookmanager->resPrint; $totalarray['nbfield']++; }*/ // Action column -print getTitleFieldOfList(($mode != 'kanban' ? $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 ''."\n"; @@ -680,6 +700,18 @@ while ($i < $imaxinloop) { // Show here line of result $j = 0; print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } 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'))) { @@ -700,7 +732,11 @@ while ($i < $imaxinloop) { //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; + print ''; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { @@ -736,15 +772,17 @@ while ($i < $imaxinloop) { print ''; }*/ // Action column - print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } @@ -773,7 +811,7 @@ if ($num == 0) { $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 +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + 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 ''; + } + print ''.$obj->anotherfield.''; - 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; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + 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 ''; } - print ''; + print '
'."\n"; diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 10e430479cf..7bb040abe1f 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -193,7 +193,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_batch = ""; $search_qty = ''; $sall = ""; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index b0fafc9e357..0e22c524529 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -137,7 +137,7 @@ if (empty($reshook)) { $search_status = ''; $search_title = ''; $search_ref = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') diff --git a/htdocs/partnership/admin/partnership_extrafields.php b/htdocs/partnership/admin/partnership_extrafields.php index 573f3f1cbba..04f75cf20b2 100644 --- a/htdocs/partnership/admin/partnership_extrafields.php +++ b/htdocs/partnership/admin/partnership_extrafields.php @@ -65,6 +65,8 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ +$textobject = $langs->transnoentitiesnoconv("Partnership"); + $help_url = ''; $title = $langs->trans("PartnershipSetup"); diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 2eaa8cc5dd2..42d4354516e 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -185,7 +185,7 @@ if (empty($reshook)) { $search[$key.'_dtend'] = ''; } } - $toselect = ''; + $toselect = array(); $search_array_options = array(); $search_filter = ""; } diff --git a/htdocs/product/admin/inventory_extrafields.php b/htdocs/product/admin/inventory_extrafields.php index d21328da336..0dd5be8bfae 100644 --- a/htdocs/product/admin/inventory_extrafields.php +++ b/htdocs/product/admin/inventory_extrafields.php @@ -73,6 +73,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ +$textobject = $langs->transnoentitiesnoconv("Inventory"); llxHeader('', $langs->trans("InventorySetup"), $help_url); diff --git a/htdocs/product/admin/stock_mouvement_extrafields.php b/htdocs/product/admin/stock_mouvement_extrafields.php index 23e5aadc9cc..e7fcf2382f8 100644 --- a/htdocs/product/admin/stock_mouvement_extrafields.php +++ b/htdocs/product/admin/stock_mouvement_extrafields.php @@ -73,6 +73,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ +$textobject = $langs->transnoentitiesnoconv("StockMovement"); llxHeader('', $langs->trans("StockSetup"), $help_url); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5bcde058907..a6cac07d7e1 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2065,7 +2065,7 @@ class Product extends CommonObject /** - * Modify customer price of a product/Service + * Modify customer price of a product/Service for a given level * * @param double $newprice New price * @param string $newpricebase HT or TTC diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 5351c55334e..2e157de504a 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -28,6 +28,7 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php'; include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; +include_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; // Load translation files required by the page $langs->loadLangs(array("stocks", "other", "productbatch")); @@ -186,25 +187,6 @@ if (empty($reshook)) { break; } - if (!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { - $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product SET pmp = '.((float) $line->pmp_real).' WHERE rowid = '.((int) $line->fk_product); - $resqlpmp = $db->query($sqlpmp); - if (! $resqlpmp) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; - } - if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product_perentity SET pmp = '.((float) $line->pmp_real).' WHERE fk_product = '.((int) $line->fk_product).' AND entity='.$conf->entity; - $resqlpmp = $db->query($sqlpmp); - if (! $resqlpmp) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; - } - } - } - // Update line with id of stock movement (and the start quantity if it has changed this last recording) $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet"; $sqlupdate .= " SET fk_movement = ".((int) $idstockmove); @@ -219,6 +201,25 @@ if (empty($reshook)) { break; } } + + if (!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product SET pmp = '.((float) $line->pmp_real).' WHERE rowid = '.((int) $line->fk_product); + $resqlpmp = $db->query($sqlpmp); + if (! $resqlpmp) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product_perentity SET pmp = '.((float) $line->pmp_real).' WHERE fk_product = '.((int) $line->fk_product).' AND entity='.$conf->entity; + $resqlpmp = $db->query($sqlpmp); + if (! $resqlpmp) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + } } $i++; } @@ -910,14 +911,16 @@ if ($object->id > 0) { print '
'.$langs->trans("ExpectedQty").''; - print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); - print ''.$langs->trans('PMPExpected').''.$langs->trans('ExpectedValuation').''.$form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")).''.$langs->trans('PMPReal').''.$langs->trans('RealValuation').''; + print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); + print ''; - print dol_escape_htmltag($obj->batch); + $batch_static = new Productlot($db); + $res = $batch_static->fetch(0, $product_static->id, $obj->batch); + if ($res) { + print $batch_static->getNomUrl(1); + } else { + print dol_escape_htmltag($obj->batch); + } print ''; $qty_view = GETPOST("id_".$obj->rowid) && price2num(GETPOST("id_".$obj->rowid), 'MS') >= 0 ? GETPOST("id_".$obj->rowid) : $obj->qty_view; //if (!$hasinput && $qty_view !== null && $obj->qty_stock != $qty_view) { @@ -1049,11 +1057,6 @@ if ($object->id > 0) { $hasinput = true; } - print ''; - print img_picto('', 'eraser', 'class="opacitymedium"'); - print ''; - print ''; - print ''; print price($pmp_valuation); print ''; + print ''; + print img_picto('', 'eraser', 'class="opacitymedium"'); + print ''; + print ''; + print ''; @@ -1081,18 +1092,22 @@ if ($object->id > 0) { $totalExpectedValuation += $pmp_valuation; $totalRealValuation += $pmp_valuation_real; + } else { + print ''; + print ''; + print img_picto('', 'eraser', 'class="opacitymedium"'); + print ''; + print ''; + print ''; print ''.img_delete().''; $qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view; - print ''; + print ''; print ''; - print $obj->qty_view; // qty found - print ''; + print $obj->qty_view; // qty found + print ''; if (! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; @@ -1115,12 +1134,15 @@ if ($object->id > 0) { print ''; print price($pmp_valuation_real); print ''; $totalExpectedValuation += $pmp_valuation; $totalRealValuation += $pmp_valuation_real; + } else { + print ''; + print $obj->qty_view; // qty found + print ''; if ($obj->fk_movement > 0) { $stockmovment = new MouvementStock($db); $stockmovment->fetch($obj->fk_movement); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index de5e4f278b7..2938e524377 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -727,6 +727,7 @@ if ($resql) { // List of mass actions available $arrayofmassactions = array( 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), + 'edit_extrafields'=>img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("ModifyValueExtrafields"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); @@ -739,7 +740,7 @@ if ($resql) { $arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus"); $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } - if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { + if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_extrafields'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 47322e2c692..ab3086bfd0b 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -192,15 +192,50 @@ if (empty($reshook)) { } if (!$error) { - // Force the update of the price of the product to 0 if error + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { + // Force the update of the price of the product using the new VAT + if ($object->multiprices_base_type[$i] == 'HT') { + $oldprice = $object->multiprices[$i]; + $oldminprice = $object->multiprices_min[$i]; + } else { + $oldprice = $object->multiprices_ttc[$i]; + $oldminprice = $object->multiprices_min_ttc[$i]; + } + $oldpricebasetype = $object->multiprices_base_type[$i]; + $oldnpr = $object->multiprices_recuperableonly[$i]; - //$localtaxarray=array('0'=>$localtax1_type,'1'=>$localtax1,'2'=>$localtax2_type,'3'=>$localtax2); - $localtaxarray = array(); // We do not store localtaxes into product, we will use instead the "vat code" to retrieve them. - $ret = $object->updatePrice(0, $object->price_base_type, $user, $tva_tx, '', 0, $npr, 0, 0, $localtaxarray, $vatratecode); + //$localtaxarray=array('0'=>$localtax1_type,'1'=>$localtax1,'2'=>$localtax2_type,'3'=>$localtax2); + $localtaxarray = array(); // We do not store localtaxes into product, we will use instead the "vat code" to retrieve them. + $level = $i; + $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode); - if ($ret < 0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); + if ($ret < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } else { + // Force the update of the price of the product using the new VAT + if ($object->price_base_type == 'HT') { + $oldprice = $object->price; + $oldminprice = $object->price_min; + } else { + $oldprice = $object->price_ttc; + $oldminprice = $object->price_min_ttc; + } + $oldpricebasetype = $object->price_base_type; + $oldnpr = $object->tva_npr; + + //$localtaxarray=array('0'=>$localtax1_type,'1'=>$localtax1,'2'=>$localtax2_type,'3'=>$localtax2); + $localtaxarray = array(); // We do not store localtaxes into product, we will use instead the "vat code" to retrieve them. + $level = 0; + $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode); + + if ($ret < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } } } @@ -1602,6 +1637,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul } $sql .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; // $sql .= $db->plimit(); + //print $sql; $result = $db->query($sql); if ($result) { @@ -1640,8 +1676,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul print_barre_liste($langs->trans("PriceByCustomerLog"), 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, $num, 'title_accountancy.png'); } - print '
'; - print ''; + print ''."\n"; + print '
'."\n"; + print '
'."\n"; print ''; print ''; @@ -1659,6 +1696,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul } print ''; print ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { + print ''; + } if (!empty($conf->dynamicprices->enabled)) { print ''; } @@ -1725,6 +1765,24 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul print ""; } + // Line for default price + if ($objp->price_base_type == 'HT') { + $pu = $objp->price; + } else { + $pu = $objp->price_ttc; + } + + // Local tax was not saved into table llx_product on old version. So we will use value linked to VAT code. + $localtaxarray = getLocalTaxesFromRate($objp->tva_tx.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), 0, $mysoc, $mysoc); + // Define part of HT, VAT, TTC + $resultarray = calcul_price_total(1, $pu, 0, $objp->tva_tx, 1, 1, 0, $objp->price_base_type, $objp->recuperableonly, $object->type, $mysoc, $localtaxarray); + // Calcul du total ht sans remise + $total_ht = $resultarray[0]; + $total_vat = $resultarray[1]; + $total_localtax1 = $resultarray[9]; + $total_localtax2 = $resultarray[10]; + $total_ttc = $resultarray[2]; + // Price if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) { $price_expression = new PriceExpression($db); @@ -1732,32 +1790,46 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul $title = $price_expression->title; print ''; print ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { + print ''; + } print '"; } else { + // Price HT print '"; + // Price TTC print '"; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { + print ''; + } if (!empty($conf->dynamicprices->enabled)) { //Only if module is enabled print ''; } } + // Price min print ''; + // Price min inc tax print ''; @@ -2042,11 +2114,9 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; print ''; + print ''; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { - //print ''; print ''; - } else { - print ''; } print ''; print ''; @@ -2107,11 +2177,9 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ""; print '"; + print '"; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { - //print '"; print ''; - } else { - print '"; } print ''; @@ -2154,12 +2222,15 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; - print '
'; - print '
'.$langs->trans("AppliedPricesFrom").''.$langs->trans("HT").''.$langs->trans("TTC").''.$langs->trans("INCT").''.$langs->trans("PriceExpressionSelected").''.$title."'; if (empty($objp->price_by_qty)) { print price($objp->price); } print "'; if (empty($objp->price_by_qty)) { - print price($objp->price_ttc); + $price_ttc = $objp->price_ttc; + print price($price_ttc); } print "'; + print $resultarray[2]; + print ''; if (empty($objp->price_by_qty)) { print price($objp->price_min); } print ''; if (empty($objp->price_by_qty)) { - print price($objp->price_min_ttc); + $price_min_ttc = $objp->price_min_ttc; + print price($price_min_ttc); } print ''.$langs->trans("PriceBase").''.$langs->trans("DefaultTaxRate").''.$langs->trans("HT").''.$langs->trans("TTC").'' . $langs->trans("INCVATONLY") . ''.$langs->trans("INCT").''.$langs->trans("TTC").''.$langs->trans("MinPrice").' '.$langs->trans("HT").''.$langs->trans("MinPrice").' '.$langs->trans("TTC").''.price($line->price)."'.price($line->price_ttc)."' . price($line->price_ttc) . "'.price($resultarray[2]).''.price($line->price_ttc)."'.price($line->price_min).'
'; + print ''."\n"; + print '
'."\n"; + print '
'."\n"; if (count($prodcustprice->lines) > 0 || $search_soc) { $colspan = 9; - //if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { + $colspan++; + } print ''; print ''; @@ -2179,13 +2250,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; print ''; + print ''; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { - //print ''; print ''; - } else { - print ''; } - print ''; print ''; print ''; @@ -2199,7 +2267,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $pu = $object->price_ttc; } - // Local tax is not saved into table of product. We use value linked to VAT code. + // Local tax was not saved into table llx_product on old version. So we will use value linked to VAT code. $localtaxarray = getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), 0, $mysoc, $mysoc); // Define part of HT, VAT, TTC $resultarray = calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray); @@ -2237,14 +2305,12 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print '"; + print '"; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '"; print ''; - } else { - print '"; } - print ''; print ''; print '"; print '"; + print '"; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '"; print ''; - } else { - print '"; } print ''; diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index abcc5f7da42..e31420b7f21 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -161,7 +161,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_batch = ""; $search_qty = ''; $sall = ""; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 73c6751262a..2ad77fca49e 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -223,7 +223,7 @@ if (empty($reshook)) { $search_qty = ''; $search_fk_projet=0; $sall = ""; - $toselect = ''; + $toselect = array(); $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 74abbad9140..565b309b113 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -168,7 +168,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') diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 510d7e23e62..98f2fed52b4 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -150,6 +150,11 @@ class Project extends CommonObject */ public $price_booth; + /** + * @var float Max attendees + */ + public $max_attendees; + public $statuts_short; public $statuts_long; @@ -248,6 +253,7 @@ class Project extends CommonObject 'accept_booth_suggestions' =>array('type'=>'integer', 'label'=>'AllowUnknownPeopleSuggestBooth', 'enabled'=>1, 'visible'=>-1, 'position'=>147), 'price_registration' =>array('type'=>'double(24,8)', 'label'=>'PriceOfRegistration', 'enabled'=>1, 'visible'=>-1, 'position'=>148), 'price_booth' =>array('type'=>'double(24,8)', 'label'=>'PriceOfBooth', 'enabled'=>1, 'visible'=>-1, 'position'=>149), + 'max_attendees' =>array('type'=>'integer', 'label'=>'MaxNbOfAttendees', 'enabled'=>1, 'visible'=>-1, 'position'=>150), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreationShort', 'enabled'=>1, 'visible'=>-2, 'position'=>200), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModificationShort', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>205), 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserCreation', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>210), @@ -372,6 +378,7 @@ class Project extends CommonObject $sql .= ", accept_booth_suggestions"; $sql .= ", price_registration"; $sql .= ", price_booth"; + $sql .= ", max_attendees"; $sql .= ", email_msgid"; $sql .= ", note_private"; $sql .= ", note_public"; @@ -399,6 +406,7 @@ class Project extends CommonObject $sql .= ", ".($this->accept_booth_suggestions ? 1 : 0); $sql .= ", ".(strcmp($this->price_registration, '') ? price2num($this->price_registration) : 'null'); $sql .= ", ".(strcmp($this->price_booth, '') ? price2num($this->price_booth) : 'null'); + $sql .= ", ".(strcmp($this->max_attendees, '') ? ((int) $this->max_attendees) : 'null'); $sql .= ", ".($this->email_msgid ? "'".$this->db->escape($this->email_msgid)."'" : 'null'); $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : 'null'); $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : 'null'); @@ -509,6 +517,7 @@ class Project extends CommonObject $sql .= ", accept_booth_suggestions = ".($this->accept_booth_suggestions ? 1 : 0); $sql .= ", price_registration = ".(strcmp($this->price_registration, '') ? price2num($this->price_registration) : "null"); $sql .= ", price_booth = ".(strcmp($this->price_booth, '') ? price2num($this->price_booth) : "null"); + $sql .= ", max_attendees = ".(strcmp($this->max_attendees, '') ? price2num($this->max_attendees) : "null"); $sql .= ", entity = ".((int) $this->entity); $sql .= " WHERE rowid = ".((int) $this->id); @@ -595,7 +604,7 @@ class Project extends CommonObject $sql = "SELECT rowid, entity, ref, title, description, public, datec, opp_amount, budget_amount,"; $sql .= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut as status, fk_opp_status, opp_percent,"; $sql .= " note_private, note_public, model_pdf, usage_opportunity, usage_task, usage_bill_time, usage_organize_event, email_msgid,"; - $sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth"; + $sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth, max_attendees"; $sql .= " FROM ".MAIN_DB_PREFIX."projet"; if (!empty($id)) { $sql .= " WHERE rowid = ".((int) $id); @@ -653,6 +662,7 @@ class Project extends CommonObject $this->accept_booth_suggestions = (int) $obj->accept_booth_suggestions; $this->price_registration = $obj->price_registration; $this->price_booth = $obj->price_booth; + $this->max_attendees = $obj->max_attendees; $this->email_msgid = $obj->email_msgid; $this->db->free($resql); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 9decf78f55a..10d4afcd9a7 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -920,6 +920,7 @@ class Task extends CommonObjectLine // Add where from extra fields $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; + global $db; // needed for extrafields_list_search_sql.tpl include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 93c92231bfd..0d5c4964003 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -285,7 +285,7 @@ if (empty($reshook)) { $search_accept_booth_suggestions = ''; $search_price_registration = ''; $search_price_booth = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); $search_category_array = array(); } @@ -830,7 +830,7 @@ $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form- $moreforfilter .= ''; // If the user can view thirdparties other than his' -if ($user->rights->societe->client->voir || $socid) { +if ($user->rights->user->user->lire) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 364fcfe49f1..aabca026f20 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -209,7 +209,7 @@ if (empty($reshook)) { $search_progresscalc = ''; $search_progressdeclare = ''; $search_task_budget_amount = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); $search_date_start_startmonth = ""; $search_date_start_startyear = ""; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 4374ffb2d37..53d0e6c7f91 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -164,12 +164,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_task_label = ''; $search_user = 0; $search_valuebilled = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); $action = ''; } -if ($action == 'addtimespent' && $user->rights->projet->lire) { +if ($action == 'addtimespent' && $user->rights->projet->time) { $error = 0; $timespent_durationhour = GETPOST('timespent_durationhour', 'int'); @@ -313,7 +313,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } } -if ($action == 'confirm_deleteline' && $confirm == "yes" && $user->rights->projet->lire) { +if ($action == 'confirm_deleteline' && $confirm == "yes" && $user->rights->projet->supprimer) { $object->fetchTimeSpent(GETPOST('lineid', 'int')); // load properties like $object->timespent_id if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) { @@ -888,7 +888,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $linktocreatetimeBtnStatus = 0; $linktocreatetimeUrl = ''; $linktocreatetimeHelpText = ''; - if ($user->rights->projet->all->lire || $user->rights->projet->lire) { // To enter time, read permission is enough + if ($user->rights->projet->all->lire || $user->rights->projet->time) { if ($projectstatic->public || $userRead > 0) { $linktocreatetimeBtnStatus = 1; @@ -1032,6 +1032,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($projectstatic->id > 0 || $allprojectforuser > 0) { + if ($action == 'deleteline' && !empty($projectidforalltimes)) { + print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST('lineid', 'int').($withproject ? '&withproject=1' : ''), $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_deleteline", '', '', 1); + } + // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('tasktimelist')); @@ -1129,7 +1133,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; } elseif ($action == 'splitline') { print ''; - } elseif ($action == 'createtime' && $user->rights->projet->lire) { + } elseif ($action == 'createtime' && $user->rights->projet->time) { print ''; } elseif ($massaction == 'generateinvoice' && $user->rights->facture->lire) { print ''; @@ -1403,7 +1407,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser /* * Form to add a new line of time spent */ - if ($action == 'createtime' && $user->rights->projet->lire) { + if ($action == 'createtime' && $user->rights->projet->time) { print ''."\n"; if (!empty($id)) { print ''; @@ -1863,8 +1867,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; print '
'; print ''; - } elseif ($user->rights->projet->lire || $user->rights->projet->all->creer) { // Read project and enter time consumed on assigned tasks - if (in_array($task_time->fk_user, $childids) || $user->rights->projet->all->creer) { + } elseif ($user->rights->projet->time || $user->rights->projet->all->creer) { // Read project and enter time consumed on assigned tasks + if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids) || $user->rights->projet->all->creer) { if ($conf->MAIN_FEATURES_LEVEL >= 2) { print ' '; print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index a7cdd1ceda8..70bad2a31dc 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -262,6 +262,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen $confattendee->fk_project = $project->id; $confattendee->fk_actioncomm = $id; $confattendee->note_public = $note_public; + $resultconfattendee = $confattendee->create($user); if ($resultconfattendee < 0) { $error++; @@ -277,7 +278,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen $securekeyurl = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 'master'); $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.((int) $id).'&securekey='.urlencode($securekeyurl); - $mesg = $langs->trans("RegistrationAndPaymentWereAlreadyRecorder", $email); + $mesg = $langs->trans("RegistrationAndPaymentWereAlreadyRecorded", $email); setEventMessages($mesg, null, 'mesgs'); $db->commit(); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 0ee6fa10bc7..c03aeb4b526 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -1267,21 +1267,25 @@ if ($ispaymentok) { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang); // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); + $outputlangs->loadLangs(array("main", "members", "eventorganization")); // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; + $idoftemplatetouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; // Email to send for Event organization registration - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, ''); + if (!empty($idoftemplatetouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1, ''); } - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; + } else { + $subject = '['.$object->ref.' - '.$outputlangs->trans("NewRegistration").']'; + $msg = $outputlangs->trans("OrganizationEventPaymentOfRegistrationWasReceived"); } + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); complete_substitutions_array($substitutionarray, $outputlangs, $object); @@ -1294,13 +1298,28 @@ if ($ispaymentok) { $ishtml = dol_textishtml($texttosend); // May contain urls - $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); + // Attach a file ? + $file = ''; + $listofpaths = array(); + $listofnames = array(); + $listofmimes = array(); + if (is_object($object)) { + $invoicediroutput = $conf->facture->dir_output; + $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->ref, preg_quote($object->ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; + + $listofpaths = array($file); + $listofnames = array(basename($file)); + $listofmimes = array(dol_mimetype($file)); + } + + $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, '', '', 0, $ishtml); $result = $mailfile->sendfile(); if ($result) { dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); } else { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + dol_syslog("Failed to send EMail to ".$sendto.' - '.$mailfile->error, LOG_ERR, 0, '_payment'); } } } @@ -1452,18 +1471,22 @@ if ($ispaymentok) { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang); // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); + $outputlangs->loadLangs(array("main", "members", "eventorganization")); // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, ''); + $idoftemplatetouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH; // Email sent after registration for a Booth + + if (!empty($idoftemplatetouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1, ''); } - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; + } else { + $subject = '['.$booth->ref.' - '.$outputlangs->trans("NewRegistration").']'; + $msg = $outputlangs->trans("OrganizationEventPaymentOfBoothWasReceived"); } $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); diff --git a/htdocs/public/recruitment/index.php b/htdocs/public/recruitment/index.php index 286b5af55ba..ce30306eb2f 100644 --- a/htdocs/public/recruitment/index.php +++ b/htdocs/public/recruitment/index.php @@ -199,7 +199,7 @@ if (is_array($results)) { $text .= '   -   '.$mysoc->name.''; $text .= '   -   '.dol_print_date($object->date_creation).''; $text .= '
'."\n"; - $text .= ''."\n"; + $text .= ''."\n"; } print $text; diff --git a/htdocs/public/recruitment/view.php b/htdocs/public/recruitment/view.php index 955dbd4b586..97997830150 100644 --- a/htdocs/public/recruitment/view.php +++ b/htdocs/public/recruitment/view.php @@ -250,7 +250,7 @@ if (empty($text)) { $text .= '   -   '.$mysoc->name.''; $text .= '   -   '.dol_print_date($object->date_creation).''; $text .= ''."\n"; - $text .= ''."\n"; + $text .= ''."\n"; } print $text; diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index dff6a0b2484..371789edc62 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -264,7 +264,7 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('save', 'alpha')) { $infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl').'

'; $message .= $infos_new_ticket; - $message .= getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE') ? getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE') : $langs->transnoentities('TicketMessageMailSignatureText', $mysoc->name); + $message .= getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE', $langs->transnoentities('TicketMessageMailSignatureText', $mysoc->name)); $sendto = GETPOST('email', 'alpha'); diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index 227dcf3867b..f7abe746832 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -28,11 +28,11 @@ if (!defined('NOCSRFCHECK')) { if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } -if (!defined("NOLOGIN")) { - define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) +if (!defined('NOLOGIN')) { + define('NOLOGIN', '1'); // If this page is public (can be called outside logged session) } if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip + define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip } if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); diff --git a/htdocs/recruitment/admin/candidature_extrafields.php b/htdocs/recruitment/admin/candidature_extrafields.php index efb68e5ff2c..1977c4b11fe 100644 --- a/htdocs/recruitment/admin/candidature_extrafields.php +++ b/htdocs/recruitment/admin/candidature_extrafields.php @@ -59,7 +59,9 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ +$textobject = $langs->transnoentitiesnoconv("Candidature"); +$help_url = ''; llxHeader('', $langs->trans("RecruitmentSetup"), $help_url); diff --git a/htdocs/recruitment/admin/jobposition_extrafields.php b/htdocs/recruitment/admin/jobposition_extrafields.php index d1b0651da64..641b8b96cd0 100644 --- a/htdocs/recruitment/admin/jobposition_extrafields.php +++ b/htdocs/recruitment/admin/jobposition_extrafields.php @@ -59,7 +59,9 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ +$textobject = $langs->transnoentitiesnoconv("JobPosition"); +$help_url = ''; llxHeader('', $langs->trans("RecruitmentSetup"), $help_url); diff --git a/htdocs/recruitment/admin/public_interface.php b/htdocs/recruitment/admin/public_interface.php index b091cdea7a0..b951f440005 100644 --- a/htdocs/recruitment/admin/public_interface.php +++ b/htdocs/recruitment/admin/public_interface.php @@ -96,6 +96,7 @@ print dol_get_fiche_head($head, 'publicurl', '', -1, ''); print ''.$langs->trans("PublicInterfaceRecruitmentDesc").'

'; +$param = ''; $enabledisablehtml = $langs->trans("EnablePublicRecruitmentPages").' '; if (empty($conf->global->RECRUITMENT_ENABLE_PUBLIC_INTERFACE)) { diff --git a/htdocs/recruitment/admin/setup.php b/htdocs/recruitment/admin/setup.php index 30434b207fc..1ef8fa544ad 100644 --- a/htdocs/recruitment/admin/setup.php +++ b/htdocs/recruitment/admin/setup.php @@ -330,7 +330,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print '
'; - $texte .= ''; + $texte .= ''; $texte .= ''; @@ -132,7 +132,7 @@ class mod_recruitmentjobposition_advanced extends ModeleNumRefRecruitmentJobPosi require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // We get cursor rule - $mask = $conf->global->RECRUITMENT_RECRUITMENTJOBPOSITION_ADVANCED_MASK; + $mask = getDolGlobalString('RECRUITMENT_RECRUITMENTJOBPOSITION_ADVANCED_MASK'); if (!$mask) { $this->error = 'NotConfigured'; diff --git a/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php b/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php index 3d3b59a9253..28e6128452d 100644 --- a/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php +++ b/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php @@ -41,12 +41,23 @@ function recruitmentjobpositionPrepareHead($object) $head[$h][2] = 'card'; $h++; - if ($conf->global->MAIN_FEATURES_LEVEL >= 1) { - $head[$h][0] = dol_buildpath("/recruitment/recruitmentjobposition_applications.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans("Candidatures"); - $head[$h][2] = 'candidatures'; - $h++; + $head[$h][0] = dol_buildpath("/recruitment/recruitmentcandidature_list.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Candidatures"); + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature WHERE fk_recruitmentjobposition = ".((int) $object->id); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj) { + $nCandidature = $obj->nb; + if ($nCandidature > 0) { + $head[$h][1] .= ''.$nCandidature.''; + } + } + } else { + dol_print_error($db); } + $head[$h][2] = 'candidatures'; + $h++; if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { $nbNote = 0; diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index 9cc259c21e1..74a48994f71 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -23,36 +23,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require_once '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index 42145f66c43..eca3a497e61 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -42,36 +42,7 @@ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require_once '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; diff --git a/htdocs/recruitment/recruitmentcandidature_document.php b/htdocs/recruitment/recruitmentcandidature_document.php index 792b413b5e4..22e011daf42 100644 --- a/htdocs/recruitment/recruitmentcandidature_document.php +++ b/htdocs/recruitment/recruitmentcandidature_document.php @@ -23,36 +23,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require_once '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 05cf56636ea..2f3c73c16c4 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- * * 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 @@ -42,42 +41,14 @@ //if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL', '1'); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require_once '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - -// load recruitment libraries -require_once __DIR__.'/class/recruitmentcandidature.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; // for other modules //dol_include_once('/othermodule/class/otherobject.class.php'); @@ -85,17 +56,19 @@ require_once __DIR__.'/class/recruitmentcandidature.class.php'; // Load translation files required by the page $langs->loadLangs(array("recruitment", "other")); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); + $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'recruitmentcandidaturelist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : ((empty($id) && empty($ref)) ? 'recruitmentcandidaturelist' : 'recruitmentjobposition_candidature'); // 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') - -$id = GETPOST('id', 'int'); +$mode = GETPOST('mode', 'aZ'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -103,8 +76,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')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 or if we click on clear filters +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -123,10 +97,10 @@ $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"; + $sortorder = "DESC"; } // Initialize array of search criterias @@ -136,6 +110,10 @@ 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" @@ -146,23 +124,33 @@ foreach ($object->fields as $key => $val) { } } -// Definition of fields for list +// Definition of array of fields for columns $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, 1, '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'] + 'position'=>$val['position'], + 'help'=> isset($val['help']) ? $val['help'] : '' ); } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; +// Load object +$jobposition = new RecruitmentJobPosition($db); +if ($id > 0 || !empty($ref)) { + $jobposition->fetch($id, $ref); + $id = $jobposition->id; +} + +//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -174,7 +162,12 @@ $permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); -$result = restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentcandidature', 'recruitmentjobposition'); +if ($jobposition->id > 0) { + $isdraft = (($jobposition->status == $jobposition::STATUS_DRAFT) ? 1 : 0); + $result = restrictedArea($user, 'recruitment', $jobposition->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft); +} else { + $result = restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentcandidature', 'recruitmentjobposition'); +} @@ -183,7 +176,8 @@ $result = restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentcandid */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -203,8 +197,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') @@ -232,6 +230,8 @@ $now = dol_now(); //$help_url="EN:Module_RecruitmentCandidature|FR:Module_RecruitmentCandidature_FR|ES:Módulo_RecruitmentCandidature"; $help_url = ''; $title = $langs->trans('ListOfCandidatures'); +$morejs = array(); +$morecss = array(); // Build and execute select @@ -241,7 +241,7 @@ $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 @@ -253,29 +253,50 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; if ($object->ismultientitymanaged == 1) { $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; } else { $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) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } +if (!empty($id)) { + $sql .= " AND t.fk_recruitmentjobposition = ".((int) $id); +} //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -286,9 +307,8 @@ $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'])) { @@ -298,40 +318,39 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { } // 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('/,\s*$/', '', $sql); +$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters); // 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; } + $db->free($resql); } -// 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); +// 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) { $obj = $db->fetch_object($resql); @@ -344,11 +363,152 @@ 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, '', ''); + + +// Part to show record + +if ($jobposition->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + $savobject = $object; + + $object = $jobposition; + + $res = $object->fetch_optionals(); + + $head = recruitmentjobpositionPrepareHead($object); + print dol_get_fiche_head($head, 'candidatures', $langs->trans("RecruitmentCandidatures"), -1, $object->picto); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentJobPosition'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); + } + // Confirmation to delete line + if ($action == 'deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + } + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') { + $formquestion = array(); + /* + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); + */ + // Project + if (!empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= $langs->trans('Project').' '; + if ($permissiontoadd) { + if ($action != 'classify') { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).''; + } + $morehtmlref .= ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ': '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } + } + $morehtmlref .= '
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print '
'.$langs->trans("PriceBase").''.$langs->trans("DefaultTaxRate").''.$langs->trans("HT").''.$langs->trans("TTC").'' . $langs->trans("INCVATONLY") . ''.$langs->trans("INCT").''.$langs->trans("TTC").''.$langs->trans("MinPrice").' '.$langs->trans("HT").''.$langs->trans("MinPrice").' '.$langs->trans("TTC").''.$langs->trans("ChangedBy").''.price($object->price)."'.price($object->price_ttc)."' . price($object->price_ttc) . "'.price($resultarray[2]).''.price($object->price_ttc)."'.price($object->price_min).''.price($object->price_min_ttc).''; @@ -2315,11 +2381,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print "'.price($line->price)."'.price($line->price_ttc)."' . price($line->price_ttc) . "'.price($resultarray[2]).''.price($line->price_ttc)."'.price($line->price_min).'

'.$object->label.'

'.$object->label.'

'.$object->label.'


'.$object->label.'


'; $constforvar = 'RECRUITMENT_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $file) { + if (getDolGlobalString($constforvar) == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -473,7 +473,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Default print ''; $constforvar = 'RECRUITMENT_'.strtoupper($myTmpObjectKey).'_ADDON_PDF'; - 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 'scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; diff --git a/htdocs/recruitment/admin/setup_candidatures.php b/htdocs/recruitment/admin/setup_candidatures.php index 726e24e89b1..58172c2e767 100644 --- a/htdocs/recruitment/admin/setup_candidatures.php +++ b/htdocs/recruitment/admin/setup_candidatures.php @@ -328,7 +328,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print ''; $constforvar = 'RECRUITMENT_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $file) { + if (getDolGlobalString($constforvar) == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -471,7 +471,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Default print ''; $constforvar = 'RECRUITMENT_'.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 'scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index e93e9af1178..77b5b5b21ae 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -106,7 +106,7 @@ class RecruitmentCandidature extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'comment'=>"Id"), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of candidature"), - 'fk_recruitmentjobposition' => array('type'=>'integer:RecruitmentJobPosition:recruitment/class/recruitmentjobposition.class.php', 'label'=>'Job', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'picto'=>'recruitmentjobposition', 'css'=>'maxwidth500'), + 'fk_recruitmentjobposition' => array('type'=>'integer:RecruitmentJobPosition:recruitment/class/recruitmentjobposition.class.php', 'label'=>'Job', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'picto'=>'recruitmentjobposition', 'css'=>'maxwidth500', 'csslist'=>'minwidth125'), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index e2b7c545aa9..c28bd4a9589 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -130,7 +130,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi // List of directories area $texte .= '
'; $texttitle = $langs->trans("ListOfDirectories"); - $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->RECRUITMENT_RECRUITMENTJOBPOSITION_ADDON_PDF_ODT_PATH))); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim(getDolGlobalString('RECRUITMENT_RECRUITMENTJOBPOSITION_ADDON_PDF_ODT_PATH')))); $listoffiles = array(); foreach ($listofdir as $key => $tmpdir) { $tmpdir = trim($tmpdir); @@ -155,7 +155,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); $texte .= '
'; $texte .= ''; $texte .= '
'; $texte .= ''; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index cc215a855ff..ba1d0a8d9f5 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -849,8 +849,8 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK); + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->RECRUITMENT_RECRUITMENTJOBPOSITION_DRAFT_WATERMARK))) { + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->RECRUITMENT_RECRUITMENTJOBPOSITION_DRAFT_WATERMARK); } $pdf->SetTextColor(0, 0, 60); diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php index fcc476abacf..e4a07c63633 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php @@ -79,7 +79,7 @@ class mod_recruitmentjobposition_advanced extends ModeleNumRefRecruitmentJobPosi // Parametrage du prefix $texte .= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).' 
'."\n"; + + // Common attributes + $keyforbreak = 'description'; // We change column just after this field + unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_soc']); // Hide field already shown in banner + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + print ''; + + print '
'; + + print dol_get_fiche_end(); + + print '
'; + + $object = $savobject; +} + $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($id)) { + $param .= '&id='.urlencode($id); +} +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -358,9 +518,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]); } } @@ -369,6 +531,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( @@ -396,8 +562,10 @@ print ''; print ''; //print ''; print ''; +print ''; +print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.((int) $id)), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -446,23 +614,34 @@ print ''; 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 ''; @@ -482,12 +661,14 @@ print $searchpicto; print ''; print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; 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'))) { @@ -508,7 +689,8 @@ $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$ $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"; +print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +$totalarray['nbfield']++; print ''."\n"; @@ -526,9 +708,11 @@ if (isset($extrafields->attributes[$object->table_element]['computed']) && is_ar // Loop on record // -------------------------------------------------------------------- $i = 0; +$savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; -while ($i < ($limit ? min($num, $limit) : $num)) { +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { break; // Should not happen @@ -537,73 +721,89 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Store properties in $object $object->setVarsFromFetchObj($obj); - // Show here line of result - print ''; - 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'; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; } - - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - if ($key == 'status') { - print $object->getLibStatut(5); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); + } else { + // Show here line of result + $j = 0; + print ''; + 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 ''; - if (!$i) { - $totalarray['nbfield']++; + + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + + 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 ''; + 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 ''; if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['nbfield']++; } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); + 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; } - 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 ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - print ''."\n"; + print ''."\n"; + } $i++; } @@ -619,7 +819,7 @@ if ($num == 0) { $colspan++; } } - print ''; + print ''; } diff --git a/htdocs/recruitment/recruitmentcandidature_note.php b/htdocs/recruitment/recruitmentcandidature_note.php index ead2df3c973..d35edaa3b91 100644 --- a/htdocs/recruitment/recruitmentcandidature_note.php +++ b/htdocs/recruitment/recruitmentcandidature_note.php @@ -23,36 +23,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require_once '../main.inc.php'; dol_include_once('/recruitment/class/recruitmentcandidature.class.php'); dol_include_once('/recruitment/lib/recruitment_recruitmentcandidature.lib.php'); diff --git a/htdocs/recruitment/recruitmentjobposition_agenda.php b/htdocs/recruitment/recruitmentjobposition_agenda.php index 3f9e76d4dcf..45c84005743 100644 --- a/htdocs/recruitment/recruitmentjobposition_agenda.php +++ b/htdocs/recruitment/recruitmentjobposition_agenda.php @@ -23,36 +23,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require_once '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/recruitment/recruitmentjobposition_applications.php b/htdocs/recruitment/recruitmentjobposition_applications.php index 4295ce73284..c6e462161ed 100644 --- a/htdocs/recruitment/recruitmentjobposition_applications.php +++ b/htdocs/recruitment/recruitmentjobposition_applications.php @@ -195,92 +195,16 @@ if (empty($reshook)) { /* * View - * - * Put here all code to build page */ $form = new Form($db); $formfile = new FormFile($db); $formproject = new FormProjets($db); -$title = $langs->trans("PositionToBeFilled"); +$title = $langs->trans("JobPositionApplications"); $help_url = ''; llxHeader('', $title, $help_url); -// Part to create -if ($action == 'create') { - print load_fiche_titre($langs->trans("NewPositionToBeFilled"), '', 'object_'.$object->picto); - - print ''; - print ''; - print ''; - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - // Set some default values - if (!GETPOSTISSET('fk_user_recruiter')) { - $_POST['fk_user_recruiter'] = $user->id; - } - - print dol_get_fiche_head(array(), ''); - - print '
'; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { 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) { - print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth150', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { + } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { + print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); + } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + print '
'; + print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + } 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 ''; } print '
'; + print '
'; } - - 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 '
'; + print '
'; - 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; + // 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 ''; + 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 ''; + } + print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'."\n"; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; - - print '
'."\n"; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Create"); - - print ''; - - //dol_set_focus('input[name="ref"]'); -} - -// Part to edit record -if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans("PositionToBeFilled"), '', 'object_'.$object->picto); - - print '
'; - print ''; - print ''; - print ''; - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - print dol_get_fiche_head(); - - print ''."\n"; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; - - print '
'; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel(); - - print '
'; -} - // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals(); diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index ab065411ac0..27b58bad651 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -42,36 +42,7 @@ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require_once '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -220,8 +191,6 @@ if (empty($reshook)) { /* * View - * - * Put here all code to build page */ $form = new Form($db); diff --git a/htdocs/recruitment/recruitmentjobposition_document.php b/htdocs/recruitment/recruitmentjobposition_document.php index e9615777ade..e3e79a5482e 100644 --- a/htdocs/recruitment/recruitmentjobposition_document.php +++ b/htdocs/recruitment/recruitmentjobposition_document.php @@ -23,36 +23,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require_once '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index 3bf5fb94073..50eca44baf3 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- * * 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 @@ -42,42 +41,12 @@ //if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL', '1'); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require_once '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - -// load recruitment libraries -require_once __DIR__.'/class/recruitmentjobposition.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; // for other modules //dol_include_once('/othermodule/class/otherobject.class.php'); @@ -125,11 +94,10 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { - reset($object->fields); // Reset is required to avoid key() to return null. - $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. + $sortfield = "t.ref"; } if (!$sortorder) { - $sortorder = "ASC"; + $sortorder = "DESC"; } // Initialize array of search criterias @@ -171,6 +139,9 @@ foreach ($object->fields as $key => $val) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields['nbapplications'] = array('type'=>'integer', 'label'=>'Applications', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/recruitment/recruitmentjobposition_note.php b/htdocs/recruitment/recruitmentjobposition_note.php index 2645980f7bb..883f5612b97 100644 --- a/htdocs/recruitment/recruitmentjobposition_note.php +++ b/htdocs/recruitment/recruitmentjobposition_note.php @@ -23,36 +23,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require_once '../main.inc.php'; dol_include_once('/recruitment/class/recruitmentjobposition.class.php'); dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php'); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 3deab1e2ed8..3f077255a1c 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -554,7 +554,7 @@ if ($action == 'create') { print '
'; print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).''; print ' '; - print '
'; - $footerorder = '
'.$langs->trans("Label").''.$langs->trans("Qty").'
'.dol_print_date(dol_now(), 'dayhour').'
'; - $order_receipt_printer1 = ""; - $order_receipt_printer2 = ""; - $order_receipt_printer3 = ""; - $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); - $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); - $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3); - $linestoprint = 0; - foreach ($invoice->lines as $line) { - if ($line->special_code == "4") { - continue; + $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); + $price_min = $datapriceofproduct['price_min']; + $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); + + $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU'); + + // Check min price + if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) { + echo $langs->trans("CantBeLessThanMinPrice"); + } else { + if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { + dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + } else { + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $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); + } + } + } } - $c = new Categorie($db); - $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); - $result = array_intersect($catsprinter1, $existing); - $count = count($result); - if (!$line->fk_product) { - $count++; // Print Free-text item (Unassigned printer) to Printer 1 + + // Reload data + $invoice->fetch($placeid); + } elseif ($action == 'update_reduction_global') { + foreach ($invoice->lines as $line) { + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $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); } - if ($count > 0) { - $linestoprint++; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1 - $db->query($sql); - $order_receipt_printer1 .= ''; - if ($line->fk_product) { - $order_receipt_printer1 .= $line->product_label; + + $invoice->fetch($placeid); + } + + if ($action == "order" and $placeid != 0) { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { + require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; + $printer = new dolReceiptPrinter($db); + } + + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); + $resql = $db->query($sql); + $row = $db->fetch_object($resql); + $headerorder = '
'.$langs->trans('Place').' '.$row->label.'
'; + $footerorder = '
'.$langs->trans("Label").''.$langs->trans("Qty").'
'.dol_print_date(dol_now(), 'dayhour').'
'; + $order_receipt_printer1 = ""; + $order_receipt_printer2 = ""; + $order_receipt_printer3 = ""; + $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); + $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); + $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3); + $linestoprint = 0; + foreach ($invoice->lines as $line) { + if ($line->special_code == "4") { + continue; + } + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter1, $existing); + $count = count($result); + if (!$line->fk_product) { + $count++; // Print Free-text item (Unassigned printer) to Printer 1 + } + if ($count > 0) { + $linestoprint++; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1 + $db->query($sql); + $order_receipt_printer1 .= ''; + if ($line->fk_product) { + $order_receipt_printer1 .= $line->product_label; + } else { + $order_receipt_printer1 .= $line->description; + } + $order_receipt_printer1 .= ''.$line->qty; + if (!empty($line->array_options['options_order_notes'])) { + $order_receipt_printer1 .= "
(".$line->array_options['options_order_notes'].")"; + } + $order_receipt_printer1 .= ''; + } + } + if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { + $invoice->fetch($placeid); //Reload object before send to printer + $printer->orderprinter = 1; + echo ""; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed + $db->query($sql); + $invoice->fetch($placeid); //Reload object after set lines as printed + $linestoprint = 0; + + foreach ($invoice->lines as $line) { + if ($line->special_code == "4") { + continue; + } + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter2, $existing); + $count = count($result); + if ($count > 0) { + $linestoprint++; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2 + $db->query($sql); + $order_receipt_printer2 .= ''.$line->product_label.''.$line->qty; + if (!empty($line->array_options['options_order_notes'])) { + $order_receipt_printer2 .= "
(".$line->array_options['options_order_notes'].")"; + } + $order_receipt_printer2 .= ''; + } + } + if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { + $invoice->fetch($placeid); //Reload object before send to printer + $printer->orderprinter = 2; + echo ""; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed + $db->query($sql); + $invoice->fetch($placeid); //Reload object after set lines as printed + $linestoprint = 0; + + foreach ($invoice->lines as $line) { + if ($line->special_code == "4") { + continue; + } + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter3, $existing); + $count = count($result); + if ($count > 0) { + $linestoprint++; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3 + $db->query($sql); + $order_receipt_printer3 .= ''.$line->product_label.''.$line->qty; + if (!empty($line->array_options['options_order_notes'])) { + $order_receipt_printer3 .= "
(".$line->array_options['options_order_notes'].")"; + } + $order_receipt_printer3 .= ''; + } + } + if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { + $invoice->fetch($placeid); //Reload object before send to printer + $printer->orderprinter = 3; + echo ""; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed + $db->query($sql); + $invoice->fetch($placeid); //Reload object after set lines as printed + } + + $sectionwithinvoicelink = ''; + if ($action == "valid" || $action == "history" || $action == 'creditnote') { + $sectionwithinvoicelink .= ''."\n"; + $sectionwithinvoicelink .= ''; + $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; + $remaintopay = $invoice->getRemainToPay(); + if ($remaintopay > 0) { + $sectionwithinvoicelink .= $langs->trans('RemainToPay').': '.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).''; + } else { + if ($invoice->paye) { + $sectionwithinvoicelink .= ''.$langs->trans("Paid").''; } else { - $order_receipt_printer1 .= $line->description; + $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated'); } - $order_receipt_printer1 .= ''.$line->qty; - if (!empty($line->array_options['options_order_notes'])) { - $order_receipt_printer1 .= "
(".$line->array_options['options_order_notes'].")"; + } + $sectionwithinvoicelink .= '

'; + if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { + if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { + $sectionwithinvoicelink .= ' '; + } else { + $sectionwithinvoicelink .= ' '; } - $order_receipt_printer1 .= ''; - } - } - if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { - $invoice->fetch($placeid); //Reload object before send to printer - $printer->orderprinter = 1; - echo ""; - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed - $db->query($sql); - $invoice->fetch($placeid); //Reload object after set lines as printed - $linestoprint = 0; - - foreach ($invoice->lines as $line) { - if ($line->special_code == "4") { - continue; - } - $c = new Categorie($db); - $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); - $result = array_intersect($catsprinter2, $existing); - $count = count($result); - if ($count > 0) { - $linestoprint++; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2 - $db->query($sql); - $order_receipt_printer2 .= ''.$line->product_label.''.$line->qty; - if (!empty($line->array_options['options_order_notes'])) { - $order_receipt_printer2 .= "
(".$line->array_options['options_order_notes'].")"; - } - $order_receipt_printer2 .= ''; - } - } - if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { - $invoice->fetch($placeid); //Reload object before send to printer - $printer->orderprinter = 2; - echo ""; - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed - $db->query($sql); - $invoice->fetch($placeid); //Reload object after set lines as printed - $linestoprint = 0; - - foreach ($invoice->lines as $line) { - if ($line->special_code == "4") { - continue; - } - $c = new Categorie($db); - $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); - $result = array_intersect($catsprinter3, $existing); - $count = count($result); - if ($count > 0) { - $linestoprint++; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3 - $db->query($sql); - $order_receipt_printer3 .= ''.$line->product_label.''.$line->qty; - if (!empty($line->array_options['options_order_notes'])) { - $order_receipt_printer3 .= "
(".$line->array_options['options_order_notes'].")"; - } - $order_receipt_printer3 .= ''; - } - } - if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { - $invoice->fetch($placeid); //Reload object before send to printer - $printer->orderprinter = 3; - echo ""; - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed - $db->query($sql); - $invoice->fetch($placeid); //Reload object after set lines as printed -} - -$sectionwithinvoicelink = ''; -if ($action == "valid" || $action == "history" || $action == 'creditnote') { - $sectionwithinvoicelink .= ''."\n"; - $sectionwithinvoicelink .= ''; - $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; - $remaintopay = $invoice->getRemainToPay(); - if ($remaintopay > 0) { - $sectionwithinvoicelink .= $langs->trans('RemainToPay').': '.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).''; - } else { - if ($invoice->paye) { - $sectionwithinvoicelink .= ''.$langs->trans("Paid").''; + } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") { + $sectionwithinvoicelink .= ' '; } else { - $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated'); + $sectionwithinvoicelink .= ' '; + if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) { + $sectionwithinvoicelink .= ' '; + } + if (getDolGlobalString('TAKEPOS_GIFT_RECEIPT')) { + $sectionwithinvoicelink .= ' '; + } } - } - $sectionwithinvoicelink .= '
'; - if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { - if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { - $sectionwithinvoicelink .= ' '; - } else { - $sectionwithinvoicelink .= ' '; + if (getDolGlobalString('TAKEPOS_EMAIL_TEMPLATE_INVOICE') && $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) { + $sectionwithinvoicelink .= ' '; } - } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") { - $sectionwithinvoicelink .= ' '; - } else { - $sectionwithinvoicelink .= ' '; - if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) { - $sectionwithinvoicelink .= ' '; - } - if (getDolGlobalString('TAKEPOS_GIFT_RECEIPT')) { - $sectionwithinvoicelink .= ' '; - } - } - if (getDolGlobalString('TAKEPOS_EMAIL_TEMPLATE_INVOICE') && $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) { - $sectionwithinvoicelink .= ' '; - } - if ($remaintopay <= 0 && getDolGlobalString('TAKEPOS_AUTO_PRINT_TICKETS')) { - $sectionwithinvoicelink .= ''; + if ($remaintopay <= 0 && getDolGlobalString('TAKEPOS_AUTO_PRINT_TICKETS')) { + $sectionwithinvoicelink .= ''; + } } } - /* * View */ @@ -1287,6 +1302,13 @@ if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) { print $langs->trans("Products"); } print ''; + +// complete header by hook +$parameters=array(); +$reshook=$hookmanager->executeHooks('completeTakePosInvoiceHeader', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +print $hookmanager->resPrint; + if (empty($_SESSION["basiclayout"]) || $_SESSION["basiclayout"] != 1) { print ''.$langs->trans('ReductionShort').''; print ''.$langs->trans('Qty').''; @@ -1440,6 +1462,13 @@ if ($placeid > 0) { } } $htmlsupplements[$line->fk_parent_line] .= ''; + + // complete line by hook + $parameters=array('line' => $line); + $reshook=$hookmanager->executeHooks('completeTakePosInvoiceParentLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $htmlsupplements[$line->fk_parent_line] .= $hookmanager->resPrint; + if (empty($_SESSION["basiclayout"]) || $_SESSION["basiclayout"] != 1) { $htmlsupplements[$line->fk_parent_line] .= ''.vatrate($line->remise_percent, true).''; $htmlsupplements[$line->fk_parent_line] .= ''.$line->qty.''; @@ -1520,6 +1549,13 @@ if ($placeid > 0) { $htmlforlines .= '
'.get_date_range($line->date_start, $line->date_end).'
'; } $htmlforlines .= ''; + + // complete line by hook + $parameters=array('line' => $line); + $reshook=$hookmanager->executeHooks('completeTakePosInvoiceLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $htmlforlines .= $hookmanager->resPrint; + $htmlforlines .= ''.vatrate($line->remise_percent, true).''; $htmlforlines .= ''; if (!empty($conf->stock->enabled) && !empty($user->rights->stock->mouvement->lire)) { diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index 45ed3889a13..b29c55bd02d 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -147,9 +147,9 @@ span.butActionNewRefused>span.fa, span.butActionNewRefused>span.fa:hover } .butActionDelete, .butActionDelete:link, .butActionDelete:visited, .butActionDelete:hover, .butActionDelete:active, .buttonDelete { - background: var(--butactiondeletebg); + background: var(--butactiondeletebg) !important; /* border: 1px solid #633; */ - color: #633; + color: #633 !important; } .butActionDelete:hover { diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index 6bd8ede6331..338b4cf2759 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -121,8 +121,17 @@ button.dropdown-item.global-search-item { text-decoration: none !important; } + +/* CSS to hide the arrow to show open/close */ +div#topmenu-quickadd-dropdown, div#topmenu-bookmark-dropdown { + padding-right: 5px; +} +div#topmenu-quickadd-dropdown a::after, div#topmenu-bookmark-dropdown a::after { + display: none; +} + + .dropdown-toggle::after { - /* font part */ font-family: "Font Awesome 5 Free"; font-size: 0.7em; font-weight: 900; @@ -141,6 +150,7 @@ button.dropdown-item.global-search-item { transition: transform .2s ease-in-out; } + .open>.dropdown-toggle::after { transform: rotate(180deg); } @@ -197,7 +207,7 @@ button.dropdown-item.global-search-item { } div#topmenu-global-search-dropdown, div#topmenu-bookmark-dropdown, div#topmenu-quickadd-dropdown { - global->THEME_TOPMENU_DISABLE_IMAGE)) { ?> + line-height: 46px; } @@ -236,26 +246,28 @@ a.top-menu-dropdown-link { clear: both; } -.dropdown-menu > .bookmark-footer{ +.dropdown-menu > .bookmark-footer { border-top: 1px solid #f0f0f0; background-color: #f9f9f9; padding: 10px; + text-align: start; } -.dropdown-menu > .user-body, .dropdown-body{ +.dropdown-menu > .user-body, .dropdown-body { padding: 15px; border-bottom: 1px solid #f4f4f4; border-top: 1px solid #dddddd; white-space: normal; } -.dropdown-menu > .bookmark-body, .dropdown-body{ +.dropdown-menu > .bookmark-body, .dropdown-body { overflow-y: auto; max-height: 60vh ; /* fallback for browsers without support for calc() */ max-height: calc(90vh - 110px) ; white-space: normal; } +#topmenu-quickadd-dropdown .dropdown-menu > .bookmark-body, #topmenu-quickadd-dropdown .dropdown-body, #topmenu-bookmark-dropdown .dropdown-menu > .bookmark-body, #topmenu-bookmark-dropdown .dropdown-body{ max-height: 60vh ; /* fallback for browsers without support for calc() */ max-height: calc(90vh - 200px) ; @@ -287,7 +299,7 @@ a.top-menu-dropdown-link { #topmenuloginmoreinfo-btn, #topmenulogincompanyinfo-btn { display: block; - text-align: right; + text-align: start; color:#666; cursor: pointer; } @@ -298,6 +310,10 @@ a.top-menu-dropdown-link { font-size: 0.95em; } +a.dropdown-item { + text-align: start; +} + .button-top-menu-dropdown { display: inline-block; padding: 6px 12px; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 5fc9ea92c5b..55b716b0e0c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -240,7 +240,7 @@ input, select { } #mainbody input.button:not(.buttongen):not(.bordertransp), #mainbody a.button:not(.buttongen):not(.bordertransp) { background: var(--butactionbg); - color: var(--textbutaction)!important; + color: var(--textbutaction); border-radius: 3px; border-collapse: collapse; border: none; @@ -1956,6 +1956,7 @@ div.blockvmenulogo object-fit: contain; width: inherit; height: inherit; + image-rendering: -webkit-optimize-contrast; } #mainmenutd_companylogo::after, #mainmenutd_menu::after { content: unset !important; @@ -2470,12 +2471,13 @@ a.tmenudisabled:link, a.tmenudisabled:visited, a.tmenudisabled:hover, a.tmenudis a.tmenu:link, a.tmenu:visited, a.tmenu:hover, a.tmenu:active { padding: 0px 2px 0px 2px; + margin: 0px 0px 0px 0px; white-space: nowrap; color: var(--colortextbackhmenu); text-decoration: none; } a.tmenusel:link, a.tmenusel:visited, a.tmenusel:hover, a.tmenusel:active { - padding: 0px 4px 0px 4px; + padding: 0px 2px 0px 2px; margin: 0px 0px 0px 0px; white-space: nowrap; color: var(--colortextbackhmenu); @@ -2587,8 +2589,7 @@ button.ui-button.ui-corner-all.ui-widget:focus { /* For mainmenu, we always load the img */ div.mainmenu.menu { - background-image: url(); - + } #mainmenutd_menu a.tmenuimage { display: unset; @@ -2602,6 +2603,56 @@ a.tmenuimage:hover{ } +/* To show text of top menu on hover only (THEME_TOPMENU_DISABLE_IMAGE == 2) */ + + +.tmenulabel:not(.menuhider), .tmenulabel:not(.menuhider)::before { + display: none; + /* opacity: 0; To show text after transition */ +} +a.tmenuimage:not(.menuhider), a.tmenuimage:not(.menuhider)::before, +div.tmenuimage:not(.menuhider), div.tmenuimage:not(.menuhider)::before, +span.tmenuimage:not(.menuhider), span.tmenuimage:not(.menuhider)::before { + font-size: 1.3em; + margin-top: 8px !important; +} + + + +.tmenudiv:hover .tmenulabel:not(.menuhider), .tmenudiv:hover .tmenulabel:not(.menuhider)::before { + display: block; + position: relative; + overflow: hidden; + text-overflow: ellipsis; + /* For transition transition-delay: 1000ms; + transition-property: all; */ + opacity: 1; + display: initial !important; + line-height: 0.6em !important; + height: 1em !important; + overflow: hidden; + text-overflow: ellipsis; + color: var(--colortextbackhmenu); + top: 0px; +} + +.tmenudiv:hover .tmenuimage:not(.menuhider), .tmenudiv:hover .tmenuimage:not(.menuhider)::before { + /* For transition transition-delay: 1000ms; + transition-property: all; */ + margin-top: 0px !important; +} + + + +li.tmenu:hover .tmenulabel:not(.menuhider), li.tmenu:hover .tmenulabel:not(.menuhider)::before { + display: initial !important; +} +li.tmenu:hover .tmenuimage:not(.menuhider), li.tmenu:hover .tmenuimage:not(.menuhider):before { + font-size: 1.1em !important; + margin-top: 0px !important; +} + + /* Do not load menu img for other if hidden to save bandwidth */ @@ -2662,12 +2713,14 @@ a.tmenuimage:hover{ $url = dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.(min($generic, 4))."_over.png", 1); print "div.mainmenu.".$val." {\n"; print " background-image: url(".$url.");\n"; + print " background-position-y: 3px;\n"; print "}\n"; } $generic++; } else { print "div.mainmenu.".$val." {\n"; print " background-image: url(".$url.");\n"; + print " background-position-y: 3px;\n"; print "}\n"; } } @@ -3779,12 +3832,6 @@ div.pagination { div.pagination a { font-weight: normal; } -/*div.pagination a.butAction, div.fichehalfright a.butAction { - margin-right: 0px !important; -} -div.tabsAction a.butActionDelete:last-child, div.tabsAction a.butAction:last-child { - margin-right: 0px !important; -}*/ div.pagination ul { list-style: none; @@ -4673,6 +4720,9 @@ div.titre { padding-bottom: 5px; font-weight: 400; } +div.titre.small { + font-size: 1em; +} div.fiche > table.table-fiche-title:first-of-type div { color: var(--colortexttitlenotab); font-size: 1.1em; @@ -7295,11 +7345,18 @@ div.clipboardCPValue.hidewithsize { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + color: var(--colortextbackhmenu); + /* color: var(--colorbackhmenu1); */ } + .tmenuimage { + color: var(--colortextbackhmenu); + } + .mainmenuaspan { font-size: 0.9em; padding-right: 0; + padding-left: 0; } .topmenuimage { background-size: 22px auto; @@ -7354,6 +7411,15 @@ div.clipboardCPValue.hidewithsize { /* rule to reduce top menu - 3rd reduction: The menu for user is on left */ @media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3) ? round($nbtopmenuentries * 47, 0) + 130 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3; ?>px) /* reduction 3 */ { + + .tmenudiv .tmenulabel span.mainmenuaspan { + display: none !important; + } + .tmenudiv:hover .tmenuimage:not(.menuhider), .tmenudiv:hover .tmenuimage:not(.menuhider):before { + margin-top: 8px !important; + } + + .side-nav { z-index: 200; background: var(--colorbackvmenu1); diff --git a/htdocs/theme/eldy/main_menu_fa_icons.inc.php b/htdocs/theme/eldy/main_menu_fa_icons.inc.php index 60c3746fe66..ada1ae23a12 100644 --- a/htdocs/theme/eldy/main_menu_fa_icons.inc.php +++ b/htdocs/theme/eldy/main_menu_fa_icons.inc.php @@ -10,12 +10,12 @@ font-style: normal; font-variant: normal; text-rendering: auto; - line-height: 23px; - font-size: ; + line-height: 28px; -webkit-font-smoothing: antialiased; text-align:center; text-decoration:none; color: var(--colortextbackhmenu); + /* font-size: ; */ } .fa-15x { diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index dc94669d54f..40a03a0db5b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -276,7 +276,7 @@ $heightmenu = 50; /* height of top menu, part with image */ $heightmenu2 = 49; /* height of top menu, part with login */ $disableimages = 0; $maxwidthloginblock = 180; -if (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { +if (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1) { $disableimages = 1; $maxwidthloginblock = $maxwidthloginblock + 50; $minwidthtmenu = 0; } diff --git a/htdocs/theme/md/dropdown.inc.php b/htdocs/theme/md/dropdown.inc.php index 25cbbb28ea9..615951bbbd9 100644 --- a/htdocs/theme/md/dropdown.inc.php +++ b/htdocs/theme/md/dropdown.inc.php @@ -26,12 +26,12 @@ button.dropdown-item.global-search-item { } div#topmenu-quickadd-dropdown { position: fixed; - right: 65px; + : 55px; top: 0px; } div#topmenu-bookmark-dropdown { position: fixed; - right: 20px; + : 20px; top: 0px; } @@ -124,6 +124,15 @@ button.dropdown-item.global-search-item { } +/* CSS to hide the arrow to show open/close */ +div#topmenu-quickadd-dropdown, div#topmenu-bookmark-dropdown { + padding-right: 2px; +} +div#topmenu-quickadd-dropdown a::after, div#topmenu-bookmark-dropdown a::after { + display: none; +} + + .dropdown-toggle{ text-decoration: none !important; } @@ -201,7 +210,7 @@ button.dropdown-item.global-search-item { } div#topmenu-global-search-dropdown, div#topmenu-quickadd-dropdown, div#topmenu-bookmark-dropdown { - line-height: 46px; + line-height: px; } a.top-menu-dropdown-link { padding: 8px; @@ -221,7 +230,7 @@ a.top-menu-dropdown-link { } .dropdown-menu > .user-header{ - background: rgb(); + background: rgb(--colorbackhmenu1); } @@ -244,6 +253,7 @@ a.top-menu-dropdown-link { border-top: 1px solid #f0f0f0; background-color: #f9f9f9; padding: 10px; + text-align: start; } @@ -293,7 +303,7 @@ a.top-menu-dropdown-link { #topmenuloginmoreinfo-btn, #topmenulogincompanyinfo-btn { display: block; - text-align: right; + text-align: start; color:#666; cursor: pointer; } @@ -304,6 +314,10 @@ a.top-menu-dropdown-link { font-size: 0.95em; } +a.dropdown-item { + text-align: start; +} + .button-top-menu-dropdown { display: inline-block; padding: 6px 12px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index d5619f362fb..4532fa1d226 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2438,7 +2438,7 @@ $heightmenu = 48; /* height of top menu, part with image */ $heightmenu2 = 48; /* height of top menu, ârt with login */ $disableimages = 0; $maxwidthloginblock = 110; -if (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { +if (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1) { $heightmenu = 30; $disableimages = 1; $maxwidthloginblock = 180; $minwidthtmenu = 0; } ?> @@ -2623,98 +2623,21 @@ a.tmenuimage:focus, .mainmenu.topmenuimage:focus { outline: none; } -/* Do not load menu img if hidden to save bandwidth */ - - - - div.mainmenu.home{ - background-image: url(); background-position-x: center; } -div.mainmenu.billing { - background-image: url(); -} - -div.mainmenu.accountancy { - background-image: url(); -} - -div.mainmenu.agenda { - background-image: url(); -} - -div.mainmenu.bank { - background-image: url(); -} - -div.mainmenu.cashdesk { - background-image: url(); -} - -div.mainmenu.takepos { - background-image: url(); -} - -div.mainmenu.companies { - background-image: url(); -} - -div.mainmenu.commercial { - background-image: url(); -} - -div.mainmenu.ecm { - background-image: url(); -} - -div.mainmenu.externalsite { - background-image: url(); -} - -div.mainmenu.ftp { - background-image: url(); -} - -div.mainmenu.hrm { - background-image: url(); -} - -div.mainmenu.members { - background-image: url(); -} - div.mainmenu.menu { - background-image: url(); top: 10px; left: 1px; } -div.mainmenu.products { - background-image: url(); -} -div.mainmenu.mrp { - background-image: url(); -} -div.mainmenu.project { - background-image: url(); -} - -div.mainmenu.ticket { - background-image: url(); -} - -div.mainmenu.tools { - background-image: url(); -} - -div.mainmenu.website { - background-image: url(); -} +/* Do not load menu img if hidden to save bandwidth */ + + 'name of class for div') @@ -3162,6 +3085,7 @@ div.blockvmenulogo object-fit: contain; width: inherit; height: inherit; + image-rendering: -webkit-optimize-contrast; } #mainmenutd_companylogo::after { content: unset; @@ -4667,6 +4591,9 @@ div.titre { text-transform: uppercase; /* text-shadow: 1px 1px 2px #FFFFFF; */ } +div.titre.small { + font-size: 1em; +} div.titre { color: var(--colortexttitlenotab); } diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index b55c81f72fa..8e6e09f3fcf 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -55,8 +55,9 @@ $userid = $user->id; // Security check $result = restrictedArea($user, 'ticket', 0, '', '', '', ''); -$nowyear = strftime("%Y", dol_now()); -$year = GETPOST('year') > 0 ? GETPOST('year') : $nowyear; +$nowarray = dol_getdate(dol_now(), true); +$nowyear = $nowarray['year']; +$year = GETPOST('year', 'int') > 0 ? GETPOST('year', 'int') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; @@ -76,7 +77,6 @@ $object = new Ticket($db); $resultboxes = FormOther::getBoxesArea($user, "11"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) $form = new Form($db); -$tickesupstatic = new Ticket($db); llxHeader('', $langs->trans('TicketsIndex'), ''); @@ -108,7 +108,6 @@ if (empty($shownb) && empty($showtot)) { $shownb = 0; } -$nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) { $endyear = $nowarray['year']; } @@ -204,21 +203,21 @@ if ($result) { $dataseries = array(); $colorseries = array(); - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_NOT_READ]), 'data' => round($tick['unread'])); + $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_NOT_READ]), 'data' => round($tick['unread'])); $colorseries[Ticket::STATUS_NOT_READ] = '-'.$badgeStatus0; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_READ]), 'data' => round($tick['read'])); + $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_READ]), 'data' => round($tick['read'])); $colorseries[Ticket::STATUS_READ] = $badgeStatus1; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_ASSIGNED]), 'data' => round($tick['assigned'])); + $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_ASSIGNED]), 'data' => round($tick['assigned'])); $colorseries[Ticket::STATUS_ASSIGNED] = $badgeStatus3; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_IN_PROGRESS]), 'data' => round($tick['inprogress'])); + $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_IN_PROGRESS]), 'data' => round($tick['inprogress'])); $colorseries[Ticket::STATUS_IN_PROGRESS] = $badgeStatus4; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_WAITING]), 'data' => round($tick['waiting'])); + $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_WAITING]), 'data' => round($tick['waiting'])); $colorseries[Ticket::STATUS_WAITING] = '-'.$badgeStatus4; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_NEED_MORE_INFO]), 'data' => round($tick['needmoreinfo'])); + $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_NEED_MORE_INFO]), 'data' => round($tick['needmoreinfo'])); $colorseries[Ticket::STATUS_NEED_MORE_INFO] = '-'.$badgeStatus3; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_CANCELED]), 'data' => round($tick['canceled'])); + $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_CANCELED]), 'data' => round($tick['canceled'])); $colorseries[Ticket::STATUS_CANCELED] = $badgeStatus9; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_CLOSED]), 'data' => round($tick['closed'])); + $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_CLOSED]), 'data' => round($tick['closed'])); $colorseries[Ticket::STATUS_CLOSED] = $badgeStatus6; } else { dol_print_error($db); @@ -358,18 +357,18 @@ if ($result) { while ($i < $num) { $objp = $db->fetch_object($result); - $tickesupstatic->id = $objp->rowid; - $tickesupstatic->ref = $objp->ref; - $tickesupstatic->track_id = $objp->track_id; - $tickesupstatic->fk_statut = $objp->fk_statut; - $tickesupstatic->progress = $objp->progress; - $tickesupstatic->subject = $objp->subject; + $object->id = $objp->rowid; + $object->ref = $objp->ref; + $object->track_id = $objp->track_id; + $object->fk_statut = $objp->fk_statut; + $object->progress = $objp->progress; + $object->subject = $objp->subject; print ''; // Ref print ''; - print $tickesupstatic->getNomUrl(1); + print $object->getNomUrl(1); print "\n"; // Creation date @@ -405,7 +404,7 @@ if ($result) { print ""; print ''; - print $tickesupstatic->getLibStatut(5); + print $object->getLibStatut(5); print ""; print "\n"; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 9e50dd2c47d..33ca6d0ec9c 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -297,7 +297,7 @@ class User extends CommonObject public $all_permissions_are_loaded; /** - * @var int Number of rights granted to the user + * @var int Number of rights granted to the user. Value loaded after a getrights(). */ public $nb_rights; @@ -883,15 +883,18 @@ class User extends CommonObject $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($result); - $nid = $obj->id; - $sql = "DELETE FROM ".$this->db->prefix()."user_rights WHERE fk_user = ".((int) $this->id)." AND fk_id = ".((int) $nid)." AND entity = ".((int) $entity); - if (!$this->db->query($sql)) { - $error++; - } - $sql = "INSERT INTO ".$this->db->prefix()."user_rights (entity, fk_user, fk_id) VALUES (".((int) $entity).", ".((int) $this->id).", ".((int) $nid).")"; - if (!$this->db->query($sql)) { - $error++; + if ($obj) { + $nid = $obj->id; + + $sql = "DELETE FROM ".$this->db->prefix()."user_rights WHERE fk_user = ".((int) $this->id)." AND fk_id = ".((int) $nid)." AND entity = ".((int) $entity); + if (!$this->db->query($sql)) { + $error++; + } + $sql = "INSERT INTO ".$this->db->prefix()."user_rights (entity, fk_user, fk_id) VALUES (".((int) $entity).", ".((int) $this->id).", ".((int) $nid).")"; + if (!$this->db->query($sql)) { + $error++; + } } $i++; @@ -1096,6 +1099,14 @@ class User extends CommonObject } } + // For avoid error + if (!isset($this->rights) || !is_object($this->rights)) { + $this->rights = new stdClass(); // For avoid error + } + if (!isset($this->rights->user) || !is_object($this->rights->user)) { + $this->rights->user = new stdClass(); // For avoid error + } + // Get permission of users + Get permissions of groups // First user permissions @@ -1121,7 +1132,6 @@ class User extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -1131,9 +1141,6 @@ class User extends CommonObject $subperms = $obj->subperms; if (!empty($perms)) { - if (!isset($this->rights) || !is_object($this->rights)) { - $this->rights = new stdClass(); // For avoid error - } if (!empty($module)) { if (!isset($this->rights->$module) || !is_object($this->rights->$module)) { $this->rights->$module = new stdClass(); @@ -1200,9 +1207,6 @@ class User extends CommonObject $subperms = $obj->subperms; if (!empty($perms)) { - if (!isset($this->rights) || !is_object($this->rights)) { - $this->rights = new stdClass(); // For avoid error - } if (!empty($module)) { if (!isset($this->rights->$module) || !is_object($this->rights->$module)) { $this->rights->$module = new stdClass(); @@ -1232,6 +1236,63 @@ class User extends CommonObject $this->db->free($resql); } + // Force permission on user for admin + if (!empty($this->admin)) { + if (empty($this->rights->user->user)) { + $this->rights->user->user = new stdClass(); + } + $listofpermtotest = array('lire', 'creer', 'password', 'supprimer', 'export'); + foreach ($listofpermtotest as $permtotest) { + if (empty($this->rights->user->user->$permtotest)) { + $this->rights->user->user->$permtotest = 1; + $this->nb_rights++; + } + } + if (empty($this->rights->user->self)) { + $this->rights->user->self = new stdClass(); + } + $listofpermtotest = array('creer', 'password'); + foreach ($listofpermtotest as $permtotest) { + if (empty($this->rights->user->self->$permtotest)) { + $this->rights->user->self->$permtotest = 1; + $this->nb_rights++; + } + } + // Add test on advanced permissions + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { + if (empty($this->rights->user->user_advance)) { + $this->rights->user->user_advance = new stdClass(); + } + $listofpermtotest = array('readperms', 'write'); + foreach ($listofpermtotest as $permtotest) { + if (empty($this->rights->user->user_advance->$permtotest)) { + $this->rights->user->user_advance->$permtotest = 1; + $this->nb_rights++; + } + } + if (empty($this->rights->user->self_advance)) { + $this->rights->user->self_advance = new stdClass(); + } + $listofpermtotest = array('readperms', 'writeperms'); + foreach ($listofpermtotest as $permtotest) { + if (empty($this->rights->user->self_advance->$permtotest)) { + $this->rights->user->self_advance->$permtotest = 1; + $this->nb_rights++; + } + } + if (empty($this->rights->user->group_advance)) { + $this->rights->user->group_advance = new stdClass(); + } + $listofpermtotest = array('read', 'readperms', 'write', 'delete'); + foreach ($listofpermtotest as $permtotest) { + if (empty($this->rights->user) || empty($this->rights->user->group_advance->$permtotest)) { + $this->rights->user->group_advance->$permtotest = 1; + $this->nb_rights++; + } + } + } + } + // For backward compatibility if (isset($this->rights->propale) && !isset($this->rights->propal)) { $this->rights->propal = $this->rights->propale; diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index f698d1b5a07..b185ea4ce42 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -454,7 +454,7 @@ if ($action == 'create') { print ''.$useringroup->getLibStatut(5).''; print ''; if (!empty($user->admin)) { - print ''; + print ''; print img_picto($langs->trans("RemoveFromGroup"), 'unlink'); print ''; } else { @@ -483,7 +483,7 @@ if ($action == 'create') { $genallowed = $user->rights->user->user->creer; $delallowed = $user->rights->user->user->supprimer; - $somethingshown = $formfile->showdocuments('usergroup', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); + $somethingshown = $formfile->showdocuments('usergroup', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $mysoc->default_lang); // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, null); diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 478e345f2e3..34e181469cc 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -328,7 +328,7 @@ if ($object->id > 0) { //print img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName(); print ''; - if (is_array($permsgroupbyentity[$entity])) { + if (!empty($permsgroupbyentity[$entity]) && is_array($permsgroupbyentity[$entity])) { if (in_array($obj->id, $permsgroupbyentity[$entity])) { // Own permission by group if ($caneditperms) { diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 58ef5cd17e1..cf7536799a1 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -584,34 +584,6 @@ class SecurityTest extends PHPUnit\Framework\TestCase return $result; } - /** - * testCheckLoginPassEntity - * - * @return void - */ - public function testCheckLoginPassEntity() - { - $login=checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr')); - print __METHOD__." login=".$login."\n"; - $this->assertEquals($login, ''); - - $login=checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr')); - print __METHOD__." login=".$login."\n"; - $this->assertEquals($login, ''); - - $login=checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists - print __METHOD__." login=".$login."\n"; - $this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed'); - - $login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authentication method - print __METHOD__." login=".$login."\n"; - $this->assertEquals($login, 'admin'); - - $login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser')); - print __METHOD__." login=".$login."\n"; - $this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists - } - /** * testEncodeDecode * @@ -919,6 +891,10 @@ class SecurityTest extends PHPUnit\Framework\TestCase print "result = ".$result."\n"; $this->assertContains('Bad string syntax to evaluate', $result); + $result=dol_eval("90402.38+267678+0", 1, 1, 1); + print "result = ".$result."\n"; + $this->assertEquals('358080.38', $result); + global $leftmenu; // Used into strings to eval $leftmenu = 'AAA'; @@ -943,4 +919,33 @@ class SecurityTest extends PHPUnit\Framework\TestCase print "result = ".$result."\n"; $this->assertContains('Bad string syntax to evaluate', $result); } + + + /** + * testCheckLoginPassEntity + * + * @return void + */ + public function testCheckLoginPassEntity() + { + $login=checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr')); + print __METHOD__." login=".$login."\n"; + $this->assertEquals($login, ''); + + $login=checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr')); + print __METHOD__." login=".$login."\n"; + $this->assertEquals($login, ''); + + $login=checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists + print __METHOD__." login=".$login."\n"; + $this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed'); + + $login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authentication method + print __METHOD__." login=".$login."\n"; + $this->assertEquals($login, 'admin'); + + $login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser')); + print __METHOD__." login=".$login."\n"; + $this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists + } }