diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 85809bcc058..7c43ab24aef 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -38,6 +38,7 @@ tools: - doc/* - test/* - htdocs/includes/* + - htdocs/core/class/lessc.class.php paths: - htdocs/ - scripts/ diff --git a/.travis.yml b/.travis.yml index 7c1552bb2a8..cccc1efe1c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,9 +18,7 @@ addons: apt: sources: # To use the last version of pgloader, we add repo of postgresql - - postgresql - - sourceline: 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' - - key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' + - pgdg-trusty packages: # We need a webserver to test the webservices # Let's install Apache with. @@ -112,32 +110,33 @@ install: rm $TRAVIS_BUILD_DIR/composer.json rm $TRAVIS_BUILD_DIR/composer.lock composer self-update + # To have composer making parallel downloads + composer global require hirak/prestissimo composer -n init composer -n config vendor-dir htdocs/includes echo - | - echo "Installing Parallel Lint" - composer -n require jakub-onderka/php-parallel-lint ^0 - composer -n require jakub-onderka/php-console-highlighter ^0 - echo - -- | - echo "Installing PHP Unit" + echo "Installing Composer dependencies (PHP Unit, Parallel Lint & PHP CodeSniffer" if [ "$TRAVIS_PHP_VERSION" = '5.4' ] || [ "$TRAVIS_PHP_VERSION" = '5.5' ]; then - composer -n require phpunit/phpunit ^4 + composer -n require phpunit/phpunit ^4 \ + jakub-onderka/php-parallel-lint ^0 \ + jakub-onderka/php-console-highlighter ^0 \ + squizlabs/php_codesniffer ^3 fi - if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then - composer -n require phpunit/phpunit ^5 + if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \ + [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ]; then + composer -n require phpunit/phpunit ^5 \ + jakub-onderka/php-parallel-lint ^0 \ + jakub-onderka/php-console-highlighter ^0 \ + squizlabs/php_codesniffer ^3 fi - if [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then - composer -n require phpunit/phpunit ^5 - fi - echo - -- | - echo "Installing PHP CodeSniffer" - composer -n require squizlabs/php_codesniffer ^3 + if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \ + jakub-onderka/php-parallel-lint ^0 \ + jakub-onderka/php-console-highlighter ^0 \ + squizlabs/php_codesniffer ^3 + fi echo - | @@ -246,8 +245,6 @@ before_script: - echo "Setting up Apache + FPM" - - sudo apt-get update - - sudo apt-get install apache2 libapache2-mod-fastcgi # enable php-fpm - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf - | diff --git a/ChangeLog b/ChangeLog index 54b40dc0f04..2e0bbf78352 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,8 +18,8 @@ Following changes may create regressions for some external modules, but were nec * The function show_theme() hase been renamed into showSkins() * Rename 'module_part' parameter into 'modulepart' into document APIs, for consistency. * The deprecated method get_OutstandingBill has been removed. You can use getOutstandingBills() instead. - - +* The hook "moreFamily" must return payment into var "totalpayment" and no more "paiement" (english replace french). +* Removed deprecated method actioncomm->add(), use create() instead ***** ChangeLog for 10.0.1 compared to 10.0.0 ***** diff --git a/doc/images/dolibarr_screenshot5_1280x800.png b/doc/images/dolibarr_screenshot5_1280x800.png deleted file mode 100644 index 92f6dfa521d..00000000000 Binary files a/doc/images/dolibarr_screenshot5_1280x800.png and /dev/null differ diff --git a/doc/images/dolibarr_screenshot5_1920x1080_b.jpg b/doc/images/dolibarr_screenshot5_1920x1080.jpg similarity index 100% rename from doc/images/dolibarr_screenshot5_1920x1080_b.jpg rename to doc/images/dolibarr_screenshot5_1920x1080.jpg diff --git a/doc/images/dolibarr_screenshot5_1920x1080_a.jpg b/doc/images/dolibarr_screenshot5_1920x1080_a.jpg deleted file mode 100644 index 1c6e2cbdbdf..00000000000 Binary files a/doc/images/dolibarr_screenshot5_1920x1080_a.jpg and /dev/null differ diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 580ecda0b50..3093c8fb0c1 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -51,7 +51,12 @@ class AccountancySystem public $pcg_type; public $pcg_subtype; - /** + /** + * @var string Accountancy System numero + */ + public $numero; + + /** * @var string Accountancy System label */ public $label; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 8e1f36bbf41..9e59093b885 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -134,6 +134,13 @@ class BookKeeping extends CommonObject public $journal_label; public $piece_num; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'generic'; + + + /** * Constructor * diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 1bf1d8617db..ced89cbe515 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -533,7 +533,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; // No subledger_account value for the bank line but add a specific label_operation $bookkeeping->subledger_account = ''; @@ -596,7 +596,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp @@ -730,7 +730,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; $bookkeeping->label_compte = ''; $bookkeeping->label_operation = $reflabel; $bookkeeping->entity = $conf->entity; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index c06506c0895..fd22446554c 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -201,7 +201,7 @@ if ($action == 'writebookkeeping') { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; @@ -254,7 +254,7 @@ if ($action == 'writebookkeeping') { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; @@ -311,7 +311,7 @@ if ($action == 'writebookkeeping') { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 8ff70219c68..6f6f37125ab 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -300,7 +300,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_date = $val["date"]; $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["refsologest"]; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add @@ -357,7 +357,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_date = $val["date"]; $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["refsologest"]; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add @@ -418,7 +418,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_date = $val["date"]; $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["refsologest"]; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add @@ -475,7 +475,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_date = $val["date"]; $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["refsologest"]; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index b69f485a558..4595557de13 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -311,7 +311,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_date = $val["date"]; $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add @@ -368,7 +368,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_date = $val["date"]; $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add @@ -428,7 +428,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_date = $val["date"]; $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; + $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index a6fd91a4210..5836bf48332 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -289,7 +289,7 @@ if (empty($reshook)) $object->login = trim(GETPOST("login", 'alpha')); $object->pass = trim(GETPOST("pass", 'alpha')); - $object->societe = trim(GETPOST("societe", 'alpha')); + $object->societe = trim(GETPOST("societe", 'alpha')); // deprecated $object->company = trim(GETPOST("societe", 'alpha')); $object->address = trim(GETPOST("address", 'alpha')); @@ -468,7 +468,8 @@ if (empty($reshook)) $object->firstname = $firstname; $object->lastname = $lastname; $object->gender = $gender; - $object->societe = $societe; + $object->societe = $societe; // deprecated + $object->company = $societe; $object->address = $address; $object->zip = $zip; $object->town = $town; @@ -946,7 +947,7 @@ else print "\n"; // Company - print ''.$langs->trans("Company").''; + print ''.$langs->trans("Company").''; // Civility print ''.$langs->trans("UserTitle").''; @@ -1066,7 +1067,7 @@ else { print $object->showOptionals($extrafields, 'edit'); } - + print ''; print "\n"; dol_fiche_end(); @@ -1206,7 +1207,7 @@ else print ""; // Company - print ''.$langs->trans("Company").'societe).'">'; + print ''.$langs->trans("Company").'company).'">'; // Civility print ''.$langs->trans("UserTitle").''; @@ -1370,7 +1371,7 @@ else { print $object->showOptionals($extrafields, 'edit'); } - + print ''; dol_fiche_end(); @@ -1447,13 +1448,13 @@ else if ($object->morphy == 'mor') { - $companyname=$object->societe; + $companyname=$object->company; if (! empty($fullname)) $companyalias=$fullname; } else { $companyname=$fullname; - if (! empty($object->societe)) $companyalias=$object->societe; + if (! empty($object->company)) $companyalias=$object->company; } // Create a form array @@ -1635,7 +1636,7 @@ else print ''; // Company - print ''.$langs->trans("Company").''.$object->societe.''; + print ''.$langs->trans("Company").''.$object->company.''; // Civility print ''.$langs->trans("UserTitle").''.$object->getCivilityLabel().' '; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 12825d9a780..c5128942830 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -324,7 +324,7 @@ class Adherent extends CommonObject $infos.= $langs->transnoentities("id").": ".$this->id."\n"; $infos.= $langs->transnoentities("Lastname").": ".$this->lastname."\n"; $infos.= $langs->transnoentities("Firstname").": ".$this->firstname."\n"; - $infos.= $langs->transnoentities("Company").": ".$this->societe."\n"; + $infos.= $langs->transnoentities("Company").": ".$this->company."\n"; $infos.= $langs->transnoentities("Address").": ".$this->address."\n"; $infos.= $langs->transnoentities("Zip").": ".$this->zip."\n"; $infos.= $langs->transnoentities("Town").": ".$this->town."\n"; @@ -350,7 +350,7 @@ class Adherent extends CommonObject '__FIRSTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->firstname):($this->firstname?$this->firstname:''), '__LASTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->lastname):($this->lastname?$this->lastname:''), '__FULLNAME__'=>$msgishtml?dol_htmlentitiesbr($this->getFullName($langs)):$this->getFullName($langs), - '__COMPANY__'=>$msgishtml?dol_htmlentitiesbr($this->societe):($this->societe?$this->societe:''), + '__COMPANY__'=>$msgishtml?dol_htmlentitiesbr($this->company):($this->company?$this->company:''), '__ADDRESS__'=>$msgishtml?dol_htmlentitiesbr($this->address):($this->address?$this->address:''), '__ZIP__'=>$msgishtml?dol_htmlentitiesbr($this->zip):($this->zip?$this->zip:''), '__TOWN__'=>$msgishtml?dol_htmlentitiesbr($this->town):($this->town?$this->town:''), @@ -558,7 +558,7 @@ class Adherent extends CommonObject $sql.= ", lastname = ".($this->lastname?"'".$this->db->escape($this->lastname)."'":"null"); $sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' $sql.= ", login = ".($this->login?"'".$this->db->escape($this->login)."'":"null"); - $sql.= ", societe = ".($this->societe?"'".$this->db->escape($this->societe)."'":"null"); + $sql.= ", societe = ".($this->company?"'".$this->db->escape($this->company)."'":($this->societe?"'".$this->db->escape($this->societe)."'":"null")); $sql.= ", fk_soc = ".($this->socid > 0?$this->db->escape($this->socid):"null"); $sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null"); $sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null"); @@ -682,7 +682,7 @@ class Adherent extends CommonObject $luser->lastname=$this->lastname; $luser->gender=$this->gender; $luser->pass=$this->pass; - $luser->societe_id=$this->societe; + //$luser->socid=$this->fk_soc; // We do not enable this. This may transform a user into an external user. $luser->birth=$this->birth; @@ -1608,13 +1608,13 @@ class Adherent extends CommonObject if ($this->morphy == 'mor') { - $companyname=$this->societe; + $companyname=$this->company; if (! empty($fullname)) $companyalias=$fullname; } else { $companyname=$fullname; - if (! empty($this->societe)) $companyalias=$this->societe; + if (! empty($this->company)) $companyalias=$this->company; } $result=$customer->create_from_member($this, $companyname, $companyalias); @@ -2297,7 +2297,7 @@ class Adherent extends CommonObject // phpcs:enable global $conf, $langs; - if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe $now=dol_now(); @@ -2398,7 +2398,7 @@ class Adherent extends CommonObject $this->gender='man'; $this->login='dolibspec'; $this->pass='dolibspec'; - $this->societe = 'Societe ABC'; + $this->company = 'Societe ABC'; $this->address = '61 jump street'; $this->zip = '75000'; $this->town = 'Paris'; @@ -2483,9 +2483,9 @@ class Adherent extends CommonObject $this->fullname=$this->getFullName($langs); // For avoid ldap error when firstname and lastname are empty - if ($this->morphy == 'mor' && (empty($this->fullname) || $this->fullname == $this->societe)) { - $this->fullname = $this->societe; - $this->lastname = $this->societe; + if ($this->morphy == 'mor' && (empty($this->fullname) || $this->fullname == $this->company)) { + $this->fullname = $this->company; + $this->lastname = $this->company; } // Possible LDAP KEY (constname => varname) @@ -2513,7 +2513,7 @@ class Adherent extends CommonObject } if ($this->firstname && ! empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname; if ($this->poste && ! empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste; - if ($this->societe && ! empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->societe; + if ($this->company && ! empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->company; if ($this->address && ! empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address; if ($this->zip && ! empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip; if ($this->town && ! empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; @@ -2885,7 +2885,7 @@ class Adherent extends CommonObject $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $actioncomm->code = 'AC_'.$actioncode; $actioncomm->label = $actionmsg2; - $actioncomm->note = $actionmsg; + $actioncomm->note_private= $actionmsg; $actioncomm->fk_project = 0; $actioncomm->datep = $now; $actioncomm->datef = $now; diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index b9085b1f6b4..fcccc0ddafc 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -37,6 +37,7 @@ class AdherentStats extends Stats */ public $table_element; + public $memberid; public $socid; public $userid; diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 80b7d738ad7..c703ca1ba6a 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -235,7 +235,7 @@ class MembersTypes extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (! $membertype->delete($membertype->id)) { + if (! $membertype->delete()) { throw new RestException(401, 'error when deleting member type'); } diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 72a1bd0d569..7d9b3405d1e 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -134,7 +134,7 @@ if ($id > 0) print ''; // Company - print ''.$langs->trans("Company").''.$object->societe.''; + print ''.$langs->trans("Company").''.$object->company.''; // Civility print ''.$langs->trans("UserTitle").''.$object->getCivilityLabel().' '; diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 1d890ab580f..db5cd04de22 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -83,10 +83,10 @@ if ($action == 'dolibarr2ldap') * View */ -llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); - $form = new Form($db); +llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); + $head = member_prepare_head($object); dol_fiche_head($head, 'ldap', $langs->trans("Member"), 0, 'user'); @@ -98,12 +98,12 @@ dol_banner_tab($object, 'rowid', $linkback); print '
'; print '
'; -print ''; +print '
'; // Login -print ''; +print ''; -// Password not crypted +// If there is a link to password not crypted, we show value in database here so we can compare because it is shown nowhere else if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) { print ''; @@ -111,18 +111,11 @@ if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) print "\n"; } -// Password crypted -if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) -{ - print ''; - print ''; - print "\n"; -} +$adht = new AdherentType($db); +$adht->fetch($object->typeid); // Type -print '\n"; - -$langs->load("admin"); +print '\n"; // LDAP DN print '\n"; @@ -182,7 +175,7 @@ if ($result > 0) if (empty($dn)) { $langs->load("errors"); - print ''; + print ''; } else { @@ -190,12 +183,12 @@ if ($result > 0) //print_r($records); - // Affichage arbre - if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) + // Show tree + if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) { if (! is_array($records)) { - print ''; + print ''; } else { @@ -204,7 +197,7 @@ if ($result > 0) } else { - print ''; + print ''; } } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 02f3d319aa3..3ddf739c813 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -135,11 +135,12 @@ $arrayfields=array( 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000) ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + 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])); } } @@ -252,15 +253,17 @@ $sql.= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country, $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,"; $sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; $sql.= " t.libelle as type, t.subscription,"; -$sql.= " state.code_departement as state_code, state.nom as state_name"; +$sql.= " state.code_departement as state_code, state.nom as state_name,"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +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.', ' : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$sql.=preg_replace('/^,/', '', $hookmanager->resPrint); +$sql =preg_replace('/, $/', '', $sql); $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)"; if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)"; @@ -683,7 +686,7 @@ while ($i < min($num, $limit)) } else { $companyname=$obj->company; } - $memberstatic->societe = $companyname; + $memberstatic->company = $companyname; print ''; diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index ce2918cb86a..083c056a518 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -80,7 +80,7 @@ if ($id) print '
'; print '
'; - print '
'.$langs->trans("Login").''.$object->login.' 
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("LDAPFieldPasswordNotCrypted").'
'.$langs->trans("LDAPFieldPasswordCrypted").''.$object->pass_crypted.'
'.$langs->trans("Type").''.$object->type."
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
LDAP '.$langs->trans("LDAPMemberDn").''.$conf->global->LDAP_MEMBER_DN."
'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).'
'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).'
'.$langs->trans("ErrorFailedToReadLDAP").'
'.$langs->trans("ErrorFailedToReadLDAP").'
'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')
'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')
'; + print '
'; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) @@ -99,7 +99,7 @@ if ($id) print ''; // Company - print ''; + print ''; // Civility print ''; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index ab8206c66b8..0922ca4f572 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -478,7 +478,7 @@ if ($rowid > 0) print '
'; print '
'; - print '
'.$langs->trans("Company").''.$object->societe.'
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'; + print '
'; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) @@ -494,7 +494,7 @@ if ($rowid > 0) print ''; // Company - print ''; + print ''; // Civility print ''; @@ -862,13 +862,13 @@ if ($rowid > 0) if ($object->morphy == 'mor') { - $companyname=$object->societe; + $companyname=$object->company; if (! empty($fullname)) $companyalias=$fullname; } else { $companyname=$fullname; - if (! empty($object->societe)) $companyalias=$object->societe; + if (! empty($object->company)) $companyalias=$object->company; } // Create a form array @@ -903,7 +903,7 @@ if ($rowid > 0) print ''; print ''; print ''; - print ''; + print ''; dol_fiche_head(''); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 96b043fcf7b..233d2601871 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -106,11 +106,11 @@ if ($cancel) { if ($action == 'add' && $user->rights->adherent->configurer) { $object->label = trim($label); $object->morphy = trim($morphy); - $object->statut = (int) $statut; - $object->subscription = (int) $subscription; + $object->statut = (int) $statut; + $object->subscription = (int) $subscription; $object->note = trim($comment); $object->mail_valid = trim($mail_valid); - $object->vote = (boolean) trim($vote); + $object->vote = (int) $vote; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); @@ -489,7 +489,7 @@ if ($rowid > 0) $now=dol_now(); - $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, "; + $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe as company,"; $sql.= " d.datefin,"; $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; $sql.= " t.libelle as type, t.subscription"; @@ -649,7 +649,7 @@ if ($rowid > 0) // Lastname print ''; - if ($objp->societe != '') + if ($objp->company != '') { print ''."\n"; } @@ -812,21 +812,25 @@ if ($rowid > 0) if (empty($reshook)) { print '

'.$langs->trans("Company").''.$object->societe.'
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).'
'; - foreach($extrafields->attribute_label as $key=>$label) + if (is_array($extrafields->attributes['adherent_type']['label'])) { - if (isset($_POST["options_" . $key])) { - if (is_array($_POST["options_" . $key])) { - // $_POST["options"] is an array but following code expects a comma separated string - $value = implode(",", $_POST["options_" . $key]); + foreach($extrafields->attributes['adherent_type']['label'] as $key=>$label) + { + if (isset($_POST["options_" . $key])) { + if (is_array($_POST["options_" . $key])) { + // $_POST["options"] is an array but following code expects a comma separated string + $value = implode(",", $_POST["options_" . $key]); + } else { + $value = $_POST["options_" . $key]; + } } else { - $value = $_POST["options_" . $key]; + $value = $object->array_options["options_" . $key]; } - } else { - $value = $adht->array_options["options_" . $key]; + + print '\n"; } - print '\n"; } print '
'.$label.''; + print $extrafields->showInputField($key, $value); + print "
'.$label.''; - print $extrafields->showInputField($key, $value); - print "


'; } diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index 6fe29379b58..86672386502 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -155,16 +155,17 @@ if ($result > 0) $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; + $records = $ldap->getAttribute($dn, $search); //print_r($records); - // Affichage arbre - if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) + // Show tree + if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) { if (! is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; + print ''.$langs->trans("ErrorFailedToReadLDAP").''; } else { @@ -173,7 +174,7 @@ if ($result > 0) } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; } $ldap->unbind(); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index f68864fcc3d..ee90a0638fb 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page $langs->loadLangs(array("errors","admin","main","companies","resource","holiday","accountancy","hrm","orders","contracts","projects","propal","bills","interventions")); @@ -1782,7 +1782,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); - if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); + $formaccounting = new FormAccounting($db); $withentity=''; @@ -1890,6 +1890,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') elseif (in_array($fieldlist[$field], array('libelle_facture'))) { print ''; $transfound=0; + $transkey=''; // Special case for labels if ($tabname == MAIN_DB_PREFIX.'c_payment_term') { diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index a12d1cc3ed4..c6262e84a79 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -254,6 +254,7 @@ class PrestaShopWebservice public function add($options) { $xml = ''; + $url = ''; if (isset($options['resource'], $options['postXml']) || isset($options['url'], $options['postXml'])) { @@ -265,7 +266,9 @@ class PrestaShopWebservice $url .= '&id_group_shop='.$options['id_group_shop']; } else + { throw new PrestaShopWebserviceException('Bad parameters given'); + } $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $xml)); self::checkStatusCode($request['status_code']); diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 931d1168238..7abf8247a71 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -98,14 +98,16 @@ foreach($object->fields as $key => $val) if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); } // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + 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])); } } - +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index e284d4b4834..0be3330bec4 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -115,7 +115,7 @@ llxHeader('', $langs->trans("PrintingSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup'); -$head=oauthadmin_prepare_head($mode); +$head = oauthadmin_prepare_head(); dol_fiche_head($head, 'tokengeneration', '', -1, 'technic'); diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 9d7d10b932a..2a3bb1d752d 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -219,7 +219,7 @@ if (! $error && $xml) $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); // Fill file_list with files in signature, new files, modified files - $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat, $scanfiles); // Fill array $file_list + $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list // Complete with list of new files foreach ($scanfiles as $keyfile => $valfile) { diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index e07e7999414..3c6bc1d48ec 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -586,7 +586,7 @@ print "\n"; ?>
-
" id="buttonGo" />

diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php index c1ddedfea53..4f9e8b933d2 100644 --- a/htdocs/admin/tools/export_files.php +++ b/htdocs/admin/tools/export_files.php @@ -112,21 +112,27 @@ $utils = new Utils($db); if ($compression == 'zip') { - $ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression); + $ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, '/(\.log|\/temp\/|documents\/admin\/documents\/)/'); if ($ret < 0) { - $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputfile); + $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputdir); } } elseif (in_array($compression, array('gz', 'bz'))) { - $file = substr($file, 0, strrpos($file, '.')); + $userlogin = ($user->login ? $user->login : 'unknown'); + + $outputfile = $conf->admin->dir_temp.'/export_files.'.$userlogin.'.out'; // File used with popen method + + $file = substr($file, 0, strrpos($file, '.')); $file .= '.tar'; - $cmd = 'tar -cf '.$outputdir."/".$file." --exclude=documents/admin/documents -C ".DOL_DATA_ROOT." ".DOL_DATA_ROOT."/../documents/"; - exec($cmd, $out, $retval); - //var_dump($cmd, DOL_DATA_ROOT);exit; - - if ($retval != 0) + // We also exclude '/temp/' dir and 'documents/admin/documents' + $cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude='documents/admin/documents' -C ".dirname(DOL_DATA_ROOT)." ".basename(DOL_DATA_ROOT); + + $result = $utils->executeCLI($cmd, $outputfile); + + $retval = $result['error']; + if ($result['result'] || ! empty($retval)) { $langs->load("errors"); dol_syslog("Documents tar retval after exec=".$retval, LOG_ERR); @@ -136,15 +142,17 @@ elseif (in_array($compression, array('gz', 'bz'))) { if ($compression == 'gz') { - $cmd = "gzip " . $outputdir."/".$file; + $cmd = "gzip -f " . $outputdir."/".$file; } if ($compression == 'bz') { - $cmd = "bzip2 " . $outputdir."/".$file; + $cmd = "bzip2 -f " . $outputdir."/".$file; } - - exec($cmd, $out, $retval); - if ($retval != 0) + + $result = $utils->executeCLI($cmd, $outputfile); + + $retval = $result['error']; + if ($result['result'] || ! empty($retval)) { $errormsg = 'Error '.$compression.' generation return '.$retval; unlink($outputdir."/".$file); diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 010bb854f25..983d9d3dca5 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -169,9 +169,6 @@ class DolibarrApiAccess implements iAuthenticate // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * @return string string to be used with WWW-Authenticate header - * @example Basic - * @example Digest - * @example OAuth */ public function __getWWWAuthenticateString() { diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 1b98ad5f2ec..d1d51798e4a 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -426,7 +426,7 @@ class Documents extends DolibarrApi * @param string $ref Reference of object (This will define subdir automatically and store submited file into it) * @param string $subdir Subdirectory (Only if ref not provided) * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) - * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) {@example '' or 'base64'} + * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) * @param int $overwriteifexists Overwrite file if exists (1 by default) * @return string * diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 35ea7d79f5a..dfc14d31889 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -178,7 +178,7 @@ class Setup extends DolibarrApi } } } else { - throw new RestException(503, 'Error when retrieving list of countries : '.$country->error); + throw new RestException(503, 'Error when retrieving list of countries'); } return $list; @@ -331,7 +331,7 @@ class Setup extends DolibarrApi * @param string $module To filter on module events * @param int $active Payment term is active or not {@min 0} {@max 1} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of events types + * @return array List of events types * * @url GET dictionary/event_types * @@ -394,7 +394,7 @@ class Setup extends DolibarrApi * @param string $module To filter on module events * @param int $active Payment term is active or not {@min 0} {@max 1} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of events types + * @return array List of civility types * * @url GET dictionary/civilities * @@ -456,7 +456,7 @@ class Setup extends DolibarrApi * @param int $page Page number (starting from zero) * @param int $active Payment term is active or not {@min 0} {@max 1} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of events types + * @return array List of currencies * * @url GET dictionary/currencies * @@ -477,7 +477,7 @@ class Setup extends DolibarrApi $sql.= " AND m.entity IN (".getEntity('multicurrency').")"; if (!empty($multicurrency) && $multicurrency != 2) $sql.= " AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX."multicurrency_rate AS cr2 WHERE cr2.fk_multicurrency = m.rowid)"; } - + // Add sql filters if ($sqlfilters) { @@ -523,7 +523,7 @@ class Setup extends DolibarrApi * @param string $sortorder Sort order * @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...) * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')" - * @return List of extra fields + * @return array List of extra fields * * @url GET extrafields * @@ -602,7 +602,7 @@ class Setup extends DolibarrApi * @param string $town To filter on city name * @param int $active Payment term is active or not {@min 0} {@max 1} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of towns + * @return array List of towns * * @url GET dictionary/towns * @@ -717,7 +717,7 @@ class Setup extends DolibarrApi return $list; } - + /** * Get the list of shipping methods. * @@ -788,7 +788,7 @@ class Setup extends DolibarrApi * @param int $page Page number (starting from zero) * @param int $active Payment term is active or not {@min 0} {@max 1} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of events types + * @return array List of measuring unit * * @url GET dictionary/units * @@ -848,7 +848,7 @@ class Setup extends DolibarrApi * @param int $page Page number (starting from zero) * @param int $active Payment term is active or not {@min 0} {@max 1} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of events types + * @return array List of ticket categories * * @url GET dictionary/ticket_categories * @@ -908,7 +908,7 @@ class Setup extends DolibarrApi * @param int $page Page number (starting from zero) * @param int $active Payment term is active or not {@min 0} {@max 1} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of events types + * @return array List of ticket severities * * @url GET dictionary/ticket_severities * @@ -968,7 +968,7 @@ class Setup extends DolibarrApi * @param int $page Page number (starting from zero) * @param int $active Payment term is active or not {@min 0} {@max 1} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of events types + * @return array List of ticket types * * @url GET dictionary/ticket_types * @@ -1026,7 +1026,7 @@ class Setup extends DolibarrApi * Do a test of integrity for files and setup. * * @param string $target Can be 'local' or 'default' or Url of the signatures file to use for the test. Must be reachable by the tested Dolibarr. - * @return Result of file and setup integrity check + * @return array Result of file and setup integrity check * * @url GET checkintegrity * @@ -1158,7 +1158,7 @@ class Setup extends DolibarrApi $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); // Fill file_list with files in signature, new files, modified files - $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat, $scanfiles); // Fill array $file_list + $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list // Complete with list of new files foreach ($scanfiles as $keyfile => $valfile) { diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index 7ca92570aa4..26fcb76795f 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -100,11 +100,12 @@ foreach($object->fields as $key => $val) if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + 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])); } } $object->fields = dol_sort_array($object->fields, 'position'); diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php index b54a2e21b57..290e29c3f2b 100644 --- a/htdocs/bom/lib/bom.lib.php +++ b/htdocs/bom/lib/bom.lib.php @@ -55,7 +55,7 @@ function bomAdminPrepareHead() //$this->tabs = array( // 'entity:-tabname:Title:@bom:/bom/mypage.php?id=__ID__' //); // to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'bom'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'bom'); return $head; } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index eb263bdffae..b9a92f85d5e 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -188,10 +188,12 @@ class Categorie extends CommonObject * @var string Color */ public $color; + /** - * @var ??? + * @var int Id of thirdparty when CATEGORY_ASSIGNED_TO_A_CUSTOMER is set */ public $socid; + /** * @var string Category type * diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 07db3b5a5d8..12926f9b360 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -251,9 +251,6 @@ class ActionComm extends CommonObject public function __construct(DoliDB $db) { $this->db = $db; - - $this->societe = new stdClass(); // deprecated - $this->contact = new stdClass(); // deprecated } /** @@ -307,8 +304,6 @@ class ActionComm extends CommonObject $this->userassigned[$tmpid]=array('id'=>$tmpid, 'transparency'=>$this->transparency); } - //if (is_object($this->contact) && isset($this->contact->id) && $this->contact->id > 0 && ! ($this->contactid > 0)) $this->contactid = $this->contact->id; // For backward compatibility. Using this->contact->xx is deprecated - $userownerid=$this->userownerid; $userdoneid=$this->userdoneid; @@ -502,20 +497,6 @@ class ActionComm extends CommonObject } } - /** - * Add an action/event into database. - * $this->type_id OR $this->type_code must be set. - * - * @param User $user Object user making action - * @param int $notrigger 1 = disable triggers, 0 = enable triggers - * @return int Id of created event, < 0 if KO - * @deprecated Use create instead - */ - public function add(User $user, $notrigger = 0) - { - return $this->create($user, $notrigger); - } - /** * Load an object from its id and create a new one in database * @@ -678,7 +659,7 @@ class ActionComm extends CommonObject $this->contactid = $obj->fk_contact; // To have fetch_contact method working $this->fk_project = $obj->fk_project; // To have fetch_project method working - $this->societe->id = $obj->fk_soc; // deprecated + //$this->societe->id = $obj->fk_soc; // deprecated //$this->contact->id = $obj->fk_contact; // deprecated $this->fk_element = $obj->elementid; @@ -889,8 +870,8 @@ class ActionComm extends CommonObject return -1; } - $socid=($this->socid?$this->socid:((isset($this->societe->id) && $this->societe->id > 0) ? $this->societe->id : 0)); - $contactid=($this->contactid?$this->contactid:0); + $socid=(($this->socid > 0)?$this->socid:0); + $contactid=(($this->contactid > 0)?$this->contactid:0); $userownerid=($this->userownerid?$this->userownerid:0); $userdoneid=($this->userdoneid?$this->userdoneid:0); diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index bd57005b7bf..2ef4c74f765 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -452,6 +452,7 @@ if ($resql) if (! empty($arrayfields['owner']['checked'])) print ''; if (! empty($arrayfields['c.libelle']['checked'])) print ''; if (! empty($arrayfields['a.label']['checked'])) print ''; + if (! empty($arrayfields['a.note']['checked'])) print ''; if (! empty($arrayfields['a.datep']['checked'])) { print ''; print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 9adc0bff336..5b9bf0f9eab 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2500,7 +2500,7 @@ $formquestion = array_merge($formquestion, array( if ($usercansend) { print '
' . $langs->trans('SendMail') . '
'; } else - print '
' . $langs->trans('SendMail') . '
'; + print '
' . $langs->trans('SendMail') . '
'; } // Create an order @@ -2538,7 +2538,14 @@ $formquestion = array_merge($formquestion, array( $arrayofinvoiceforpropal = $object->getInvoiceArrayList(); if ((is_array($arrayofinvoiceforpropal) && count($arrayofinvoiceforpropal) > 0) || empty($conf->global->WORKFLOW_PROPAL_NEED_INVOICE_TO_BE_CLASSIFIED_BILLED)) { - print '
socid . '">' . $langs->trans("ClassifyBilled") . '
'; + if ($usercanclose) + { + print '
socid . '">' . $langs->trans("ClassifyBilled") . '
'; + } + else + { + print '
' . $langs->trans("ClassifyBilled") . '
'; + } } } diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index d9fe5ccaf1a..9cc8bd32d26 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -92,7 +92,7 @@ class Proposals extends DolibarrApi * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter commercial proposals. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} + * @param string $thirdparty_ids Thirdparty ids to filter commercial proposals (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" * @return array Array of order objects */ diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 2964ff98690..768ea188174 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -168,18 +168,20 @@ $arrayfields=array( 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1), 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), - 'p.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), + 'p.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), 'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + 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])); } } + /* * Actions */ @@ -276,19 +278,20 @@ $sql.= ' u.login'; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +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 : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/', '', $sql); $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ - $sql.= ', '.MAIN_DB_PREFIX.'propal as p'; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal_extrafields as ef on (p.rowid = ef.fk_object)"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; @@ -750,6 +753,8 @@ if ($resql) $now = dol_now(); $i=0; $totalarray=array(); + $typenArray=null; + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -880,8 +885,9 @@ if ($resql) // Type ent if (! empty($arrayfields['typent.code']['checked'])) { + if (! is_array($typenArray) || empty($typenArray)) $typenArray = $formcompany->typent_array(1); + print ''; - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print ''; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 36df0c0eacb..440ea9e6984 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -94,7 +94,7 @@ class Orders extends DolibarrApi * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter orders of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} + * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of order objects * diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 66a3862bd2c..59922a02c01 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -143,18 +143,21 @@ $arrayfields=array( 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), - 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), + 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + 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])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index d89eecfed1a..ac4c9c767e8 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -213,9 +213,9 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $i = 0; while ($i < $num) { - $paiement = ''; $ref = ''; $refcomp = ''; + $totalpayment = ''; $obj = array_shift($tab_sqlobj); @@ -236,7 +236,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $societestatic->name = $obj->name; $refcomp=$societestatic->getNomUrl(1, '', 24); - $paiement = -1*$facturefournstatic->getSommePaiement(); // Payment already done + $totalpayment = -1*$facturefournstatic->getSommePaiement(); // Payment already done } } if ($obj->family == 'invoice') @@ -250,9 +250,9 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $societestatic->name = $obj->name; $refcomp=$societestatic->getNomUrl(1, '', 24); - $paiement = $facturestatic->getSommePaiement(); // Payment already done - $paiement+= $facturestatic->getSumDepositsUsed(); - $paiement+= $facturestatic->getSumCreditNotesUsed(); + $totalpayment = $facturestatic->getSommePaiement(); // Payment already done + $totalpayment+= $facturestatic->getSumDepositsUsed(); + $totalpayment+= $facturestatic->getSumCreditNotesUsed(); } if ($obj->family == 'social_contribution') { @@ -261,19 +261,19 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $socialcontribstatic->lib=$obj->type; $ref = $socialcontribstatic->getNomUrl(1, 24); - $paiement = -1*$socialcontribstatic->getSommePaiement(); // Payment already done + $totalpayment = -1*$socialcontribstatic->getSommePaiement(); // Payment already done } - $parameters = array('obj' => $obj); + $parameters = array('obj' => $obj, 'ref' => $ref, 'refcomp' => $refcomp, 'totalpayment' => $totalpayment); $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if(empty($reshook)){ $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : $ref; $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : $refcomp; - $paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : $paiement; + $totalpayment = isset($hookmanager->resArray['totalpayment']) ? $hookmanager->resArray['totalpayment'] : $totalpayment; } $total_ttc = $obj->total_ttc; - if ($paiement) $total_ttc = $obj->total_ttc - $paiement; + if ($totalpayment) $total_ttc = $obj->total_ttc - $totalpayment; $solde += $total_ttc; // We discard lines with a remainder to pay to 0 diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 9036b513961..d6b33acbda6 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -98,7 +98,7 @@ class Invoices extends DolibarrApi * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter orders of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} + * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of invoice objects diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 33de9d47e18..131f0ee90fd 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -210,12 +210,12 @@ class Facture extends CommonInvoice * @var double percentage of retainage */ public $retained_warranty; - + /** * @var int timestamp of date limit of retainage */ public $retained_warranty_date_limit; - + /** * @var int Code in llx_c_paiement */ @@ -459,7 +459,16 @@ class Facture extends CommonInvoice } // Define due date if not already defined - $datelim=(empty($forceduedate)?$this->calculate_date_lim_reglement():$forceduedate); + if (empty($forceduedate)) { + $duedate = $this->calculate_date_lim_reglement(); + /*if ($duedate < 0) { Regression, a date can be negative if before 1970. + dol_syslog(__METHOD__ . ' Error in calculate_date_lim_reglement. We got ' . $duedate, LOG_ERR); + return -1; + }*/ + $this->date_lim_reglement = $duedate; + } else { + $this->date_lim_reglement = $forceduedate; + } // Insert into database $socid = $this->socid; @@ -514,7 +523,7 @@ class Facture extends CommonInvoice $sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".$this->cond_reglement_id; $sql.= ", ".$this->mode_reglement_id; - $sql.= ", '".$this->db->idate($datelim)."', '".$this->db->escape($this->modelpdf)."'"; + $sql.= ", '".$this->db->idate($this->date_lim_reglement)."', '".$this->db->escape($this->modelpdf)."'"; $sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null"); $sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null"); $sql.= ", ".($this->situation_final?$this->situation_final:0); @@ -526,7 +535,7 @@ class Facture extends CommonInvoice $sql.= ", ".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty)); $sql.= ", ".(!empty($this->retained_warranty_date_limit)?"'".$this->db->idate($this->retained_warranty_date_limit)."'":'NULL'); $sql.= ", ".(int) $this->retained_warranty_fk_cond_reglement; - + $sql.=")"; $resql=$this->db->query($sql); @@ -1430,7 +1439,7 @@ class Facture extends CommonInvoice $this->retained_warranty = $obj->retained_warranty; $this->retained_warranty_date_limit = $this->db->jdate($obj->retained_warranty_date_limit); $this->retained_warranty_fk_cond_reglement = $obj->retained_warranty_fk_cond_reglement; - + $this->extraparams = (array) json_decode($obj->extraparams, true); //Incoterms @@ -1679,7 +1688,7 @@ class Facture extends CommonInvoice if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); if (isset($this->import_key)) $this->import_key=trim($this->import_key); if (isset($this->retained_warranty)) $this->retained_warranty = floatval($this->retained_warranty); - + // Check parameters // Put here code to add control on parameters values @@ -1695,7 +1704,7 @@ class Facture extends CommonInvoice $sql.= " datef=".(strval($this->date)!='' ? "'".$this->db->idate($this->date)."'" : 'null').","; $sql.= " date_pointoftax=".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null').","; $sql.= " date_valid=".(strval($this->date_validation)!='' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; - $sql.= " paye=".(isset($this->paye)?$this->db->escape($this->paye):"null").","; + $sql.= " paye=".(isset($this->paye)?$this->db->escape($this->paye):0).","; $sql.= " remise_percent=".(isset($this->remise_percent)?$this->db->escape($this->remise_percent):"null").","; $sql.= " remise_absolue=".(isset($this->remise_absolue)?$this->db->escape($this->remise_absolue):"null").","; $sql.= " close_code=".(isset($this->close_code)?"'".$this->db->escape($this->close_code)."'":"null").","; @@ -4422,9 +4431,9 @@ class Facture extends CommonInvoice if(empty($this->retained_warranty) ){ return -1; } - + $retainedWarrantyAmount = 0; - + // Billed - retained warranty if($this->type == Facture::TYPE_SITUATION) { @@ -4438,18 +4447,18 @@ class Facture extends CommonInvoice } } } - + if($displayWarranty && !empty($this->situation_final)) { $this->fetchPreviousNextSituationInvoice(); $TPreviousIncoice = $this->tab_previous_situation_invoice; - + $total2BillWT = 0; foreach ($TPreviousIncoice as &$fac){ $total2BillWT += $fac->total_ttc; } $total2BillWT += $this->total_ttc; - + $retainedWarrantyAmount = $total2BillWT * $this->retained_warranty / 100; } else{ @@ -4461,10 +4470,10 @@ class Facture extends CommonInvoice // Because one day retained warranty could be used on standard invoices $retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100; } - + return $retainedWarrantyAmount; } - + /** * Change the retained warranty * @@ -4480,7 +4489,7 @@ class Facture extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= ' SET '.$fieldname.' = '.floatval($value); $sql .= ' WHERE rowid='.$this->id; - + if ($this->db->query($sql)) { $this->retained_warranty = floatval($value); @@ -4500,8 +4509,8 @@ class Facture extends CommonInvoice return -2; } } - - + + /** * Change the retained_warranty_date_limit * @@ -4514,8 +4523,8 @@ class Facture extends CommonInvoice if(!$timestamp && $dateYmd){ $timestamp = $this->db->jdate($dateYmd); } - - + + dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit('.$timestamp.')'); if ($this->statut >= 0) { @@ -4523,7 +4532,7 @@ class Facture extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= ' SET '.$fieldname.' = '.(strval($timestamp)!='' ? '\'' .$this->db->idate($timestamp).'\'' : 'null' ); $sql .= ' WHERE rowid='.$this->id; - + if ($this->db->query($sql)) { $this->retained_warranty_date_limit = $timestamp; @@ -5168,13 +5177,16 @@ class FactureLigne extends CommonInvoiceLine public function get_prev_progress($invoiceid, $include_credit_note = true) { // phpcs:enable + global $invoicecache; if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { return 0; } else { // If invoice is not a situation invoice, this->fk_prev_id is used for something else - $tmpinvoice=new Facture($this->db); - $tmpinvoice->fetch($invoiceid); - if ($tmpinvoice->type != Facture::TYPE_SITUATION) return 0; + if (!isset($invoicecache[$invoiceid])) { + $invoicecache[$invoiceid]=new Facture($this->db); + $invoicecache[$invoiceid]->fetch($invoiceid); + } + if ($invoicecache[$invoiceid]->type != Facture::TYPE_SITUATION) return 0; $sql = 'SELECT situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE rowid=' . $this->fk_prev_id; $resql = $this->db->query($sql); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 1226f7c8a79..bb072291cb8 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -133,13 +133,16 @@ $arrayfields=array( 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + 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])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index dd3f2add4ba..ad9e2295d6d 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -189,13 +189,16 @@ if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_ } // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + 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])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* @@ -844,13 +847,13 @@ if ($resql) print ''; print ''; } - + if(! empty($arrayfields['f.retained_warranty']['checked'])) { print ''; print ''; } - + if (! empty($arrayfields['dynamount_payed']['checked'])) { print ''; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 614782c519b..a96a3d12f26 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -72,9 +72,8 @@ class Paiement extends CommonObject public $amounts=array(); // Array of amounts public $multicurrency_amounts=array(); // Array of amounts public $author; - public $paiementid; // Type de paiement. Stocke dans fk_paiement - // de llx_paiement qui est lie aux types de - //paiement de llx_c_paiement + public $paiementid; // Type of payment. Id saved into fields fk_paiement on llx_paiement + public $paiementcode; // Code of payment. /** * @var string type libelle @@ -89,14 +88,14 @@ class Paiement extends CommonObject /** * @var string Numero du CHQ, VIR, etc... * @deprecated - * @see num_payment + * @see $num_payment */ public $numero; /** * @var string Numero du CHQ, VIR, etc... * @deprecated - * @see num_payment + * @see $num_payment */ public $num_paiement; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index e064b93504d..ebfafa698b7 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -82,26 +82,11 @@ class Contact extends CommonObject public $civility_id; // In fact we store civility_code public $civility_code; - public $civility; + public $civility; public $address; public $zip; public $town; - /** - * @deprecated - * @see $state_id - */ - public $fk_departement; - /** - * @deprecated - * @see $state_code - */ - public $departement_code; - /** - * @deprecated - * @see $state - */ - public $departement; public $state_id; // Id of department public $state_code; // Code of department public $state; // Label of department @@ -1023,7 +1008,7 @@ class Contact extends CommonObject // Removed extrafields if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) { // For avoid conflicts if trigger used - $result=$this->deleteExtraFields($this); + $result=$this->deleteExtraFields(); if ($result < 0) $error++; } diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index 1514a2188ff..b00976938ab 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -80,12 +80,12 @@ if ($action == 'dolibarr2ldap') * View */ +$form = new Form($db); + $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); llxHeader('', $title, 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); -$form = new Form($db); - $head = contact_prepare_head($object); dol_fiche_head($head, 'ldap', $title, -1, 'contact'); @@ -172,16 +172,17 @@ if ($result > 0) $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; + $records = $ldap->getAttribute($dn, $search); //var_dump($records); - // Affichage arbre - if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) + // Show tree + if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) { if (! is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; + print ''.$langs->trans("ErrorFailedToReadLDAP").''; } else { @@ -190,7 +191,7 @@ if ($result > 0) } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; } $ldap->unbind(); diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 00d168a0db4..4735f840582 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -95,7 +95,7 @@ class Contracts extends DolibarrApi * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter contracts of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} + * @param string $thirdparty_ids Thirdparty ids to filter contracts of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of contract objects * diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 01cc12dd34a..79745113f88 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -130,13 +130,16 @@ $arrayfields=array( 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + 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])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 07b5cceee1a..9371a9ea835 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -132,13 +132,16 @@ $arrayfields=array( 'cd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + 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])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); @@ -702,7 +705,7 @@ while ($i < min($num, $limit)) print ''; if ($obj->cstatut == 0) // If contract is draft, we say line is also draft { - print $contractstatic->LibStatut(0, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now)); + print $contractstatic->LibStatut(0, 5); } else { diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 995ba93fb64..416a0b46144 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -57,12 +57,12 @@ class box_activity extends ModeleBoxes { global $conf, $user; - $this->db=$db; + $this->db = $db; // FIXME: Pb into some status - $this->enabled=($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments) + $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments) - $this->hidden= ! ((! empty($conf->facture->enabled) && $user->rights->facture->lire) + $this->hidden = ! ((! empty($conf->facture->enabled) && $user->rights->facture->lire) || (! empty($conf->commande->enabled) && $user->rights->commande->lire) || (! empty($conf->propal->enabled) && $user->rights->propale->lire) ); diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 0e37d830ef8..f15c5c8d1cb 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -56,7 +56,7 @@ class box_birthdays extends ModeleBoxes */ public function __construct($db, $param = '') { - global $conf, $user; + global $user; $this->db = $db; @@ -71,7 +71,7 @@ class box_birthdays extends ModeleBoxes */ public function loadBox($max = 20) { - global $user, $langs, $db, $conf; + global $user, $langs, $db; $langs->load("boxes"); $this->max=$max; diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index 6a36bc01ae4..446b74a184c 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -56,7 +56,7 @@ class box_birthdays_members extends ModeleBoxes */ public function __construct($db, $param = '') { - global $conf, $user; + global $user; $this->db = $db; @@ -71,7 +71,7 @@ class box_birthdays_members extends ModeleBoxes */ public function loadBox($max = 20) { - global $user, $langs, $db, $conf; + global $user, $langs, $db; $langs->load("boxes"); $this->max=$max; diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index 52f8c0f4a77..bb35c311f00 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -54,9 +54,9 @@ class box_bookmarks extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->bookmark->lire); + $this->hidden = ! ($user->rights->bookmark->lire); } /** diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 956e73b4acf..e0d7d1fee4d 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -58,9 +58,9 @@ class box_commandes extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->commande->lire); + $this->hidden = ! ($user->rights->commande->lire); } /** diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 45886e00be7..667f892bc0a 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -60,9 +60,9 @@ class box_contacts extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->societe->lire && $user->rights->societe->contact->lire); + $this->hidden = ! ($user->rights->societe->lire && $user->rights->societe->contact->lire); } /** diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 6447b63b120..43ade84ad20 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -57,9 +57,9 @@ class box_contracts extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->contrat->lire); + $this->hidden = ! ($user->rights->contrat->lire); } /** diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 3465182ff02..5aa7d0575c6 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -56,9 +56,9 @@ class box_factures extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->facture->lire); + $this->hidden = ! ($user->rights->facture->lire); } /** diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index fd55478932c..9d2e8e995e3 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -57,9 +57,9 @@ class box_factures_fourn extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->fournisseur->facture->lire); + $this->hidden = ! ($user->rights->fournisseur->facture->lire); } /** diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index 74f8cbc6b64..a28f275dc96 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -56,9 +56,9 @@ class box_factures_fourn_imp extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->fournisseur->facture->lire); + $this->hidden = ! ($user->rights->fournisseur->facture->lire); } /** diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index a0692c791b2..5dfa6c8c492 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -59,9 +59,9 @@ class box_factures_imp extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->facture->lire); + $this->hidden = ! ($user->rights->facture->lire); } /** diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index 0debc76c507..8311ae7226c 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -57,9 +57,9 @@ class box_ficheinter extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->ficheinter->lire); + $this->hidden = ! ($user->rights->ficheinter->lire); } /** diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 01f62bc38c9..8d231cc472b 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -57,9 +57,9 @@ class box_fournisseurs extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->societe->lire && empty($user->socid)); + $this->hidden = ! ($user->rights->societe->lire && empty($user->socid)); } /** diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 75673ee3fce..36a35c3bbc2 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -52,9 +52,9 @@ class box_graph_propales_permonth extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->propale->lire); + $this->hidden = ! ($user->rights->propale->lire); } /** diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index c0c82677d4e..b0f1200dec7 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -65,7 +65,7 @@ class box_members extends ModeleBoxes $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); if (! in_array('adherent', $listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users - $this->hidden=! ($user->rights->adherent->lire); + $this->hidden = ! ($user->rights->adherent->lire); } /** diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 38f9a73f57f..68c1b4c790b 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -64,7 +64,7 @@ class box_produits extends ModeleBoxes $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); $tmpentry=array('enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)), 'module'=>'product|service'); $showmode=isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); - $this->hidden=($showmode != 1); + $this->hidden = ($showmode != 1); } /** diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index d1381870338..bdecbde39de 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -66,7 +66,7 @@ class box_produits_alerte_stock extends ModeleBoxes $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); $tmpentry=array('enabled'=>((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && ! empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); $showmode=isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); - $this->hidden=($showmode != 1); + $this->hidden = ($showmode != 1); } /** diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index e7281708802..3cd36c470fe 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -59,9 +59,9 @@ class box_project extends ModeleBoxes $langs->loadLangs(array('boxes', 'projects')); $this->db = $db; - $this->boxlabel="OpenedProjects"; + $this->boxlabel = "OpenedProjects"; - $this->hidden=! ($user->rights->projet->lire); + $this->hidden = ! ($user->rights->projet->lire); } /** diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 6bf6a2c2166..f486463a32a 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -58,9 +58,9 @@ class box_propales extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->propale->lire); + $this->hidden = ! ($user->rights->propale->lire); } /** diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 7f5cc566f42..947ebc18b52 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -65,7 +65,7 @@ class box_prospect extends ModeleBoxes // disable box for such cases if (! empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled=0; // disabled by this option - $this->hidden=! ($user->rights->societe->lire && empty($user->socid)); + $this->hidden = ! ($user->rights->societe->lire && empty($user->socid)); } /** diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 3fcd8001227..eaca6dc1548 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -58,9 +58,9 @@ class box_services_contracts extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->service->lire && $user->rights->contrat->lire); + $this->hidden = ! ($user->rights->service->lire && $user->rights->contrat->lire); } /** diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 738d6af078f..58262a16dec 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -56,9 +56,9 @@ class box_services_expired extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->contrat->lire); + $this->hidden = ! ($user->rights->contrat->lire); } /** diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 34316cd1ad1..59a3a8afec6 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -56,9 +56,9 @@ class box_supplier_orders extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->fournisseur->commande->lire); + $this->hidden = ! ($user->rights->fournisseur->commande->lire); } /** diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 34070520aa5..00559bcde32 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -54,7 +54,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box public $enabled=1; /** - * @var int Condition to have widget visible (in most cases, permissions) + * @var boolean Condition to have widget visible (in most cases, permissions) */ public $hidden=0; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index fadd0c02fde..1df572c8a35 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -497,8 +497,16 @@ abstract class CommonDocGenerator $resarray['object_total_up'] = $totalUp; $resarray['object_total_up_locale'] = price($resarray['object_total_up'], 0, $outputlangs); if (method_exists($object, 'getTotalDiscount')) { - $resarray['object_total_discount'] = round(100 / $totalUp * $object->getTotalDiscount(), 2); + $totalDiscount=$object->getTotalDiscount(); + } else { + $totalDiscount=0; + } + if (!empty($totalUp) && !empty($totalDiscount)) { + $resarray['object_total_discount'] = round(100 / $totalUp * $totalDiscount, 2); $resarray['object_total_discount_locale'] = price($resarray['object_total_discount'], 0, $outputlangs); + } else { + $resarray['object_total_discount']=''; + $resarray['object_total_discount_locale']=''; } } @@ -766,10 +774,20 @@ abstract class CommonDocGenerator //Add value to store price with currency $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); } - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') + elseif($extrafields->attribute_type[$key] == 'select') { $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; } + elseif($extrafields->attribute_type[$key] == 'checkbox') { + $valArray=explode(',', $object->array_options['options_'.$key]); + $output=array(); + foreach($extrafields->attribute_param[$key]['options'] as $keyopt=>$valopt) { + if (in_array($keyopt, $valArray)) { + $output[]=$valopt; + } + } + $object->array_options['options_'.$key] = implode(', ', $output); + } elseif($extrafields->attribute_type[$key] == 'date') { if (strlen($object->array_options['options_'.$key])>0) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index f94c95ff246..3c03f9ea14c 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -177,6 +177,7 @@ class Conf if ($value && preg_match('/^MAIN_MODULE_/', $key)) { + $reg=array(); // If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs']. if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key)) { @@ -674,6 +675,9 @@ class Conf if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com'; if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567'; + // If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined. + if (! isset($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $conf->global->MAIN_FEATURES_LEVEL >= 2) $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1; + // For backward compatibility if (isset($this->product)) $this->produit=$this->product; if (isset($this->facture)) $this->invoice=$this->facture; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5ee969a73a0..5e2c754fce6 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1903,6 +1903,15 @@ class Form $price_level = (! empty($price_level) ? $price_level : 0); if (is_null($ajaxoptions)) $ajaxoptions=array(); + if(strval($filtertype) === '' && (!empty($conf->product->enabled) || !empty($conf->service->enabled))){ + if(!empty($conf->product->enabled) && empty($conf->service->enabled)){ + $filtertype = '0'; + } + elseif(empty($conf->product->enabled) && !empty($conf->service->enabled)){ + $filtertype = '1'; + } + } + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { $placeholder=''; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 1622ee88c2f..b7138d90f10 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1381,7 +1381,7 @@ class FormFile if (! empty($conf->dol_use_jmobile)) $useajax=0; if (empty($conf->use_javascript_ajax)) $useajax=0; if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; - print ''.img_delete().''; + print ''.img_delete().''; } print ""; diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 42c3b36025b..1a38bfff0ee 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -162,13 +162,13 @@ class FormWebsite /** - * Return a HTML select list of a dictionary + * Return a HTML select list of type of containers * * @param string $htmlname Name of select zone * @param string $selected Selected value * @param int $useempty 1=Add an empty value in list * @param string $moreattrib More attributes on HTML select tag - * @return void + * @return string HTML select component with list of type of containers */ public function selectSampleOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') { diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index c00f4003d5d..1d1a6122288 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -944,7 +944,7 @@ class Ldap // Only one entry should ever be returned $entry = ldap_first_entry($this->connection, $search); - if (!$entry) + if (! $entry) { $this->ldapErrorCode = -1; $this->ldapErrorText = "Couldn't find entry"; @@ -952,7 +952,7 @@ class Ldap } // Get values - if (! $values = ldap_get_attributes($this->connection, $entry)) + if (! ($values = ldap_get_attributes($this->connection, $entry))) { $this->ldapErrorCode = ldap_errno($this->connection); $this->ldapErrorText = ldap_error($this->connection); diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index 6a67c8cb2b5..f6a9208cadf 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -1033,6 +1033,7 @@ class Lessc { return $this->lib_e($items[0]); } $this->throwError("unrecognised input"); + return null; case "string": $arg[1] = ""; return $arg; @@ -1050,6 +1051,7 @@ class Lessc { $template = $this->compileValue($this->lib_e($string)); $i = 0; + $m = array(); if (preg_match_all('/%[dsa]/', $template, $m)) { foreach ($m[0] as $match) { $val = isset($values[$i]) ? diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index 283b296b3e3..a5242c597c4 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -355,22 +355,27 @@ class Link extends CommonObject /** * Delete a link from database * - * @return int <0 if KO, 0 if nothing done, >0 if OK + * @param User $user Object suer + * @return int <0 if KO, 0 if nothing done, >0 if OK */ - public function delete() + public function delete($user) { - global $user, $langs, $conf; + global $langs, $conf; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $error = 0; + $this->db->begin(); + // Call trigger $result=$this->call_trigger('LINK_DELETE', $user); - if ($result < 0) return -1; + if ($result < 0) + { + $this->db->rollback(); + return -1; + } // End call triggers - $this->db->begin(); - // Remove link $sql = "DELETE FROM " . MAIN_DB_PREFIX . "links"; $sql.= " WHERE rowid = " . $this->id; diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index 2612aa5057b..5c0b09a7368 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -299,7 +299,7 @@ class SimpleOpenID * @param string $url URL * @param string $method Method * @param string $params Params - * @return boolean|unknown + * @return boolean|void True if success, False if error */ public function FSOCK_Request($url, $method = "GET", $params = "") { diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index be220c90487..13596bc26c3 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -316,27 +316,29 @@ class Utils // TODO Replace with executeCLI function if ($execmethod == 1) { - exec($fullcommandclear, $readt, $retval); - $result = $retval; + $output_arr = array(); $retval = null; + exec($fullcommandclear, $output_arr, $retval); if ($retval != 0) { $langs->load("errors"); dol_syslog("Datadump retval after exec=".$retval, LOG_ERR); - $error = 'Error '.$retval; + $errormsg = 'Error '.$retval; $ok=0; } else { $i=0; - if (!empty($readt)) - foreach($readt as $key=>$read) + if (!empty($output_arr)) { - $i++; // output line number - if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue; - fwrite($handle, $read.($execmethod == 2 ? '' : "\n")); - if (preg_match('/'.preg_quote('-- Dump completed').'/i', $read)) $ok=1; - elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i', $read)) $ok=1; + foreach($output_arr as $key => $read) + { + $i++; // output line number + if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue; + fwrite($handle, $read.($execmethod == 2 ? '' : "\n")); + if (preg_match('/'.preg_quote('-- Dump completed').'/i', $read)) $ok=1; + elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i', $read)) $ok=1; + } } } } @@ -534,6 +536,7 @@ class Utils if ($execmethod == 1) { + $retval = null; exec($command, $output_arr, $retval); $result = $retval; if ($retval != 0) @@ -545,7 +548,6 @@ class Utils } if ($execmethod == 2) // With this method, there is no way to get the return code, only output { - $ok=0; $handle = fopen($outputfile, 'w+b'); if ($handle) { diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index 55e7fe27b0b..26824095e1c 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -223,7 +223,7 @@ interface Database * @param string $name name of database (not used for mysql, used for pgsql) * @param int $port Port of database server * @return resource Database access handler - * @see close + * @see close() */ public function connect($host, $login, $passwd, $name, $port = 0); @@ -265,7 +265,7 @@ interface Database * * @param resource $resultset Resulset of requests * @return int Nb of lines - * @see affected_rows + * @see affected_rows() */ public function num_rows($resultset); // phpcs:enable @@ -461,7 +461,7 @@ interface Database * Close database connexion * * @return boolean True if disconnect successfull, false otherwise - * @see connect + * @see connect() */ public function close(); diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index a52e052b531..68533ce8d35 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -607,7 +607,7 @@ class DoliDBPgsql extends DoliDB /** * Return number of lines for result of a SELECT * - * @param resourse $resultset Resulset of requests + * @param resource $resultset Resulset of requests * @return int Nb of lines, -1 on error * @see affected_rows() */ diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index c6bc31956d6..9316dcbfeb6 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -549,15 +549,13 @@ function calendars_prepare_head($param) $h++; - $object=new stdClass(); - // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'agenda'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda'); - complete_head_from_modules($conf, $langs, $object, $head, $h, 'agenda', 'remove'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda', 'remove'); return $head; } diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php index b9890533a00..8e8b561ac8e 100644 --- a/htdocs/core/lib/asset.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -48,7 +48,7 @@ function asset_admin_prepare_head() //$this->tabs = array( // 'entity:-tabname:Title:@assets:/asset/mypage.php?id=__ID__' //); // to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'assets_admin'); $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); @@ -60,7 +60,7 @@ function asset_admin_prepare_head() $head[$h][2] = 'attributes_type'; $h++; - complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin', 'remove'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'assets_admin', 'remove'); return $head; } @@ -68,11 +68,12 @@ function asset_admin_prepare_head() /** * Prepare admin pages header * + * @param Contrat $object Object related to tabs * @return array head array with tabs */ -function asset_prepare_head() +function asset_prepare_head(Asset $object) { - global $langs, $conf; + global $db, $langs, $conf; $langs->load("assets"); @@ -96,7 +97,7 @@ function asset_prepare_head() require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->assets->dir_output . '/' . get_exdir($filename, 2, 0, 1, $object, 'assets'). '/'. dol_sanitizeFileName($object->ref); + $upload_dir = $conf->assets->dir_output . '/' . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks=Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id; diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index f117bc24daf..54d1c491878 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -163,7 +163,6 @@ function bank_admin_prepare_head($object) */ function various_payment_prepare_head($object) { - global $db, $langs, $conf; $h = 0; diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index d1a4a07689e..80609f524d4 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -101,7 +101,7 @@ function contract_prepare_head(Contrat $object) */ function contract_admin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf; $h = 0; $head = array(); @@ -127,9 +127,7 @@ function contract_admin_prepare_head() $head[$h][2] = 'attributeslines'; $h++; - - complete_head_from_modules($conf, $langs, null, $head, $h, 'contract_admin', 'remove'); - return $head; + return $head; } diff --git a/htdocs/core/lib/donation.lib.php b/htdocs/core/lib/donation.lib.php index 91c41ffcced..7b78ac96b91 100644 --- a/htdocs/core/lib/donation.lib.php +++ b/htdocs/core/lib/donation.lib.php @@ -80,7 +80,7 @@ function donation_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->don->dir_output . '/' . get_exdir($filename, 2, 0, 1, $object, 'donation'). '/'. dol_sanitizeFileName($object->ref); + $upload_dir = $conf->don->dir_output . '/' . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks=Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 5861ad07a72..0c72fe35fab 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1222,9 +1222,12 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, } } } - else dol_syslog("Failed to remove file ".$filename, LOG_WARNING); - // TODO Failure to remove can be because file was already removed or because of permission - // If error because it does not exists, we should return true, and we should return false if this is a permission problem + else + { + dol_syslog("Failed to remove file ".$filename, LOG_WARNING); + // TODO Failure to remove can be because file was already removed or because of permission + // If error because it does not exists, we should return true, and we should return false if this is a permission problem + } } } else dol_syslog("No files to delete found", LOG_DEBUG); @@ -1881,14 +1884,16 @@ function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '', $page = '' /** - * Compress a file + * Compress a file. + * An error string may be returned into parameters. * * @param string $inputfile Source file name * @param string $outputfile Target file name * @param string $mode 'gz' or 'bz' or 'zip' + * @param string $errorstring Error string * @return int <0 if KO, >0 if OK */ -function dol_compress_file($inputfile, $outputfile, $mode = "gz") +function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring = null) { global $conf; @@ -1913,8 +1918,12 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz") $zip = new ZipArchive; if ($zip->open($outputfile, ZipArchive::CREATE) !== true) { - $errormsg="Failed to open file ".$outputfile."\n"; - dol_syslog("dol_compress_file failure - ".$errormsg, LOG_ERR); + $errorstring="dol_compress_file failure - Failed to open file ".$outputfile."\n"; + dol_syslog($errorstring, LOG_ERR); + + global $errormsg; + $errormsg = $errorstring; + return -6; } @@ -1958,12 +1967,16 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz") { global $errormsg; $errormsg=$archive->errorInfo(true); - dol_syslog("dol_compress_file failure - ".$errormsg, LOG_ERR); + if ($archive->errorCode() == PCLZIP_ERR_WRITE_OPEN_FAIL) { - dol_syslog("dol_compress_file error PCLZIP_ERR_WRITE_OPEN_FAIL", LOG_ERR); + $errorstring = "PCLZIP_ERR_WRITE_OPEN_FAIL"; + dol_syslog("dol_compress_file error - archive->errorCode() = PCLZIP_ERR_WRITE_OPEN_FAIL", LOG_ERR); return -4; } + + $errorstring = "dol_compress_file error archive->errorCode = ".$archive->errorCode()." errormsg=".$errormsg; + dol_syslog("dol_compress_file failure - ".$errormsg, LOG_ERR); return -3; } else @@ -1983,7 +1996,11 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz") } else { - dol_syslog("Try to zip with format ".$mode." with no handler for this format", LOG_ERR); + $errorstring = "Try to zip with format ".$mode." with no handler for this format"; + dol_syslog($errorstring, LOG_ERR); + + global $errormsg; + $errormsg = $errorstring; return -2; } } @@ -1991,8 +2008,10 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz") { global $langs, $errormsg; $langs->load("errors"); - dol_syslog("Failed to open file ".$outputfile, LOG_ERR); $errormsg=$langs->trans("ErrorFailedToWriteInDir"); + + $errorstring = "Failed to open file ".$outputfile; + dol_syslog($errorstring, LOG_ERR); return -1; } } @@ -2063,13 +2082,14 @@ function dol_uncompress($inputfile, $outputdir) * @param string $inputdir Source dir name * @param string $outputfile Target file name (output directory must exists and be writable) * @param string $mode 'zip' + * @param string $excludefiles A regex pattern. For example: '/\.log$|\/temp\//' * @return int <0 if KO, >0 if OK */ -function dol_compress_dir($inputdir, $outputfile, $mode = "zip") +function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = '') { $foundhandler=0; - dol_syslog("Try to zip dir ".$inputdir." into ".$outputdir." mode=".$mode); + dol_syslog("Try to zip dir ".$inputdir." into ".$outputfile." mode=".$mode); if (! dol_is_dir(dirname($outputfile)) || ! is_writable(dirname($outputfile))) { @@ -2096,6 +2116,7 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip") return 1; } else*/ + //if (class_exists('ZipArchive') && ! empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_COMPRESS)) if (class_exists('ZipArchive')) { $foundhandler=1; @@ -2103,6 +2124,13 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip") // Initialize archive object $zip = new ZipArchive(); $result = $zip->open($outputfile, ZipArchive::CREATE | ZipArchive::OVERWRITE); + if (! $result) + { + global $langs, $errormsg; + $langs->load("errors"); + $errormsg=$langs->trans("ErrorFailedToWriteInFile", $outputfile); + return -4; + } // Create recursive directory iterator /** @var SplFileInfo[] $files */ @@ -2119,9 +2147,11 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip") // Get real and relative path for current file $filePath = $file->getRealPath(); $relativePath = substr($filePath, strlen($inputdir) + 1); - - // Add current file to archive - $zip->addFile($filePath, $relativePath); + if (empty($excludefiles) || ! preg_match($excludefiles, $filePath)) + { + // Add current file to archive + $zip->addFile($filePath, $relativePath); + } } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 994426412ba..ca45ad1514b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -816,8 +816,10 @@ function dol_size($size, $type = '') */ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1) { - // List of special chars for filenames are defined on page https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file - $filesystem_forbidden_chars = array('<', '>', '/', '\\', '?', '*', '|', '"', ':', '°'); + // List of special chars for filenames in windows are defined on page https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file + // Char '>' '<' '|' '$' and ';' are special chars for shells. + // Char '/' and '\' are file delimiters. + $filesystem_forbidden_chars = array('<', '>', '/', '\\', '?', '*', '|', '"', ':', '°', '$', ';'); return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars); } @@ -942,11 +944,15 @@ function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0) * @param string $stringtoescape String to escape * @param int $keepb 1=Preserve b tags (otherwise, remove them) * @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value). Set to 1 when escaping for a '; + $texte.= '
'; + $texte.= ''; + $texte.= '
'; + + // Scan directories + $nbofiles=count($listoffiles); + if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)) + { + $texte.=$langs->trans("NumberOfModelFilesFound").': '; + //$texte.=$nbofiles?'':''; + $texte.=count($listoffiles); + //$texte.=$nbofiles?'':''; + $texte.=''; + } + + if ($nbofiles) + { + $texte.='