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

This commit is contained in:
Christophe Battarel 2019-09-05 15:45:23 +02:00
commit 9db9dd856e
959 changed files with 18382 additions and 7092 deletions

View File

@ -38,6 +38,7 @@ tools:
- doc/* - doc/*
- test/* - test/*
- htdocs/includes/* - htdocs/includes/*
- htdocs/core/class/lessc.class.php
paths: paths:
- htdocs/ - htdocs/
- scripts/ - scripts/

View File

@ -18,9 +18,7 @@ addons:
apt: apt:
sources: sources:
# To use the last version of pgloader, we add repo of postgresql # To use the last version of pgloader, we add repo of postgresql
- postgresql - pgdg-trusty
- sourceline: 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main'
- key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
packages: packages:
# We need a webserver to test the webservices # We need a webserver to test the webservices
# Let's install Apache with. # Let's install Apache with.
@ -112,32 +110,33 @@ install:
rm $TRAVIS_BUILD_DIR/composer.json rm $TRAVIS_BUILD_DIR/composer.json
rm $TRAVIS_BUILD_DIR/composer.lock rm $TRAVIS_BUILD_DIR/composer.lock
composer self-update composer self-update
# To have composer making parallel downloads
composer global require hirak/prestissimo
composer -n init composer -n init
composer -n config vendor-dir htdocs/includes composer -n config vendor-dir htdocs/includes
echo echo
- | - |
echo "Installing Parallel Lint" echo "Installing Composer dependencies (PHP Unit, Parallel Lint & PHP CodeSniffer"
composer -n require jakub-onderka/php-parallel-lint ^0
composer -n require jakub-onderka/php-console-highlighter ^0
echo
- |
echo "Installing PHP Unit"
if [ "$TRAVIS_PHP_VERSION" = '5.4' ] || [ "$TRAVIS_PHP_VERSION" = '5.5' ]; then 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 fi
if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \
composer -n require phpunit/phpunit ^5 [ "$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 fi
if [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
composer -n require phpunit/phpunit ^5 composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \
fi jakub-onderka/php-parallel-lint ^0 \
echo jakub-onderka/php-console-highlighter ^0 \
squizlabs/php_codesniffer ^3
- | fi
echo "Installing PHP CodeSniffer"
composer -n require squizlabs/php_codesniffer ^3
echo echo
- | - |
@ -246,8 +245,6 @@ before_script:
- echo "Setting up Apache + FPM" - echo "Setting up Apache + FPM"
- sudo apt-get update
- sudo apt-get install apache2 libapache2-mod-fastcgi
# enable php-fpm # enable php-fpm
- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- | - |

View File

@ -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() * The function show_theme() hase been renamed into showSkins()
* Rename 'module_part' parameter into 'modulepart' into document APIs, for consistency. * 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 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 ***** ***** ChangeLog for 10.0.1 compared to 10.0.0 *****

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

View File

Before

Width:  |  Height:  |  Size: 268 KiB

After

Width:  |  Height:  |  Size: 268 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 KiB

View File

@ -51,7 +51,12 @@ class AccountancySystem
public $pcg_type; public $pcg_type;
public $pcg_subtype; public $pcg_subtype;
/** /**
* @var string Accountancy System numero
*/
public $numero;
/**
* @var string Accountancy System label * @var string Accountancy System label
*/ */
public $label; public $label;

View File

@ -134,6 +134,13 @@ class BookKeeping extends CommonObject
public $journal_label; public $journal_label;
public $piece_num; 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 * Constructor
* *

View File

@ -533,7 +533,7 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->code_journal = $journal; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label; $bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $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 // No subledger_account value for the bank line but add a specific label_operation
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
@ -596,7 +596,7 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->code_journal = $journal; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label; $bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $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 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 $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->code_journal = $journal;
$bookkeeping->journal_label = $journal_label; $bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$bookkeeping->date_create = $now; $bookkeeping->date_creation = $now;
$bookkeeping->label_compte = ''; $bookkeeping->label_compte = '';
$bookkeeping->label_operation = $reflabel; $bookkeeping->label_operation = $reflabel;
$bookkeeping->entity = $conf->entity; $bookkeeping->entity = $conf->entity;

View File

@ -201,7 +201,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now; $bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'expense_report'; $bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->fk_docdet = $val["fk_expensereportdet"];
@ -254,7 +254,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now; $bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'expense_report'; $bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->fk_docdet = $val["fk_expensereportdet"];
@ -311,7 +311,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now; $bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'expense_report'; $bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->fk_docdet = $val["fk_expensereportdet"];

View File

@ -300,7 +300,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->date_lim_reglement = $val["datereg"];
$bookkeeping->doc_ref = $val["refsologest"]; $bookkeeping->doc_ref = $val["refsologest"];
$bookkeeping->date_create = $now; $bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->doc_type = 'supplier_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $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->doc_date = $val["date"];
$bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->date_lim_reglement = $val["datereg"];
$bookkeeping->doc_ref = $val["refsologest"]; $bookkeeping->doc_ref = $val["refsologest"];
$bookkeeping->date_create = $now; $bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->doc_type = 'supplier_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $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->doc_date = $val["date"];
$bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->date_lim_reglement = $val["datereg"];
$bookkeeping->doc_ref = $val["refsologest"]; $bookkeeping->doc_ref = $val["refsologest"];
$bookkeeping->date_create = $now; $bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->doc_type = 'supplier_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $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->doc_date = $val["date"];
$bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->date_lim_reglement = $val["datereg"];
$bookkeeping->doc_ref = $val["refsologest"]; $bookkeeping->doc_ref = $val["refsologest"];
$bookkeeping->date_create = $now; $bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->doc_type = 'supplier_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add

View File

@ -311,7 +311,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->date_lim_reglement = $val["datereg"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now; $bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $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->doc_date = $val["date"];
$bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->date_lim_reglement = $val["datereg"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now; $bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $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->doc_date = $val["date"];
$bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->date_lim_reglement = $val["datereg"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now; $bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add

View File

@ -289,7 +289,7 @@ if (empty($reshook))
$object->login = trim(GETPOST("login", 'alpha')); $object->login = trim(GETPOST("login", 'alpha'));
$object->pass = trim(GETPOST("pass", '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->company = trim(GETPOST("societe", 'alpha'));
$object->address = trim(GETPOST("address", 'alpha')); $object->address = trim(GETPOST("address", 'alpha'));
@ -468,7 +468,8 @@ if (empty($reshook))
$object->firstname = $firstname; $object->firstname = $firstname;
$object->lastname = $lastname; $object->lastname = $lastname;
$object->gender = $gender; $object->gender = $gender;
$object->societe = $societe; $object->societe = $societe; // deprecated
$object->company = $societe;
$object->address = $address; $object->address = $address;
$object->zip = $zip; $object->zip = $zip;
$object->town = $town; $object->town = $town;
@ -946,7 +947,7 @@ else
print "</td>\n"; print "</td>\n";
// Company // Company
print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(GETPOST('societe', 'alpha')?GETPOST('societe', 'alpha'):$object->societe).'"></td></tr>'; print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(GETPOST('societe', 'alpha')?GETPOST('societe', 'alpha'):$object->company).'"></td></tr>';
// Civility // Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td>'; print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
@ -1066,7 +1067,7 @@ else
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
} }
print '<tbody>'; print '<tbody>';
print "</table>\n"; print "</table>\n";
dol_fiche_end(); dol_fiche_end();
@ -1206,7 +1207,7 @@ else
print "</td></tr>"; print "</td></tr>";
// Company // Company
print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(isset($_POST["societe"])?GETPOST("societe", '', 2):$object->societe).'"></td></tr>'; print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(isset($_POST["societe"])?GETPOST("societe", '', 2):$object->company).'"></td></tr>';
// Civility // Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td>'; print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
@ -1370,7 +1371,7 @@ else
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
} }
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
@ -1447,13 +1448,13 @@ else
if ($object->morphy == 'mor') if ($object->morphy == 'mor')
{ {
$companyname=$object->societe; $companyname=$object->company;
if (! empty($fullname)) $companyalias=$fullname; if (! empty($fullname)) $companyalias=$fullname;
} }
else else
{ {
$companyname=$fullname; $companyname=$fullname;
if (! empty($object->societe)) $companyalias=$object->societe; if (! empty($object->company)) $companyalias=$object->company;
} }
// Create a form array // Create a form array
@ -1635,7 +1636,7 @@ else
print '</td></tr>'; print '</td></tr>';
// Company // Company
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'</td></tr>'; print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
// Civility // Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>'; print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';

View File

@ -324,7 +324,7 @@ class Adherent extends CommonObject
$infos.= $langs->transnoentities("id").": ".$this->id."\n"; $infos.= $langs->transnoentities("id").": ".$this->id."\n";
$infos.= $langs->transnoentities("Lastname").": ".$this->lastname."\n"; $infos.= $langs->transnoentities("Lastname").": ".$this->lastname."\n";
$infos.= $langs->transnoentities("Firstname").": ".$this->firstname."\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("Address").": ".$this->address."\n";
$infos.= $langs->transnoentities("Zip").": ".$this->zip."\n"; $infos.= $langs->transnoentities("Zip").": ".$this->zip."\n";
$infos.= $langs->transnoentities("Town").": ".$this->town."\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:''), '__FIRSTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->firstname):($this->firstname?$this->firstname:''),
'__LASTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->lastname):($this->lastname?$this->lastname:''), '__LASTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->lastname):($this->lastname?$this->lastname:''),
'__FULLNAME__'=>$msgishtml?dol_htmlentitiesbr($this->getFullName($langs)):$this->getFullName($langs), '__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:''), '__ADDRESS__'=>$msgishtml?dol_htmlentitiesbr($this->address):($this->address?$this->address:''),
'__ZIP__'=>$msgishtml?dol_htmlentitiesbr($this->zip):($this->zip?$this->zip:''), '__ZIP__'=>$msgishtml?dol_htmlentitiesbr($this->zip):($this->zip?$this->zip:''),
'__TOWN__'=>$msgishtml?dol_htmlentitiesbr($this->town):($this->town?$this->town:''), '__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.= ", lastname = ".($this->lastname?"'".$this->db->escape($this->lastname)."'":"null");
$sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' $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.= ", 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.= ", fk_soc = ".($this->socid > 0?$this->db->escape($this->socid):"null");
$sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null"); $sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null");
$sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null"); $sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null");
@ -682,7 +682,7 @@ class Adherent extends CommonObject
$luser->lastname=$this->lastname; $luser->lastname=$this->lastname;
$luser->gender=$this->gender; $luser->gender=$this->gender;
$luser->pass=$this->pass; $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; $luser->birth=$this->birth;
@ -1608,13 +1608,13 @@ class Adherent extends CommonObject
if ($this->morphy == 'mor') if ($this->morphy == 'mor')
{ {
$companyname=$this->societe; $companyname=$this->company;
if (! empty($fullname)) $companyalias=$fullname; if (! empty($fullname)) $companyalias=$fullname;
} }
else else
{ {
$companyname=$fullname; $companyname=$fullname;
if (! empty($this->societe)) $companyalias=$this->societe; if (! empty($this->company)) $companyalias=$this->company;
} }
$result=$customer->create_from_member($this, $companyname, $companyalias); $result=$customer->create_from_member($this, $companyname, $companyalias);
@ -2297,7 +2297,7 @@ class Adherent extends CommonObject
// phpcs:enable // phpcs:enable
global $conf, $langs; 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(); $now=dol_now();
@ -2398,7 +2398,7 @@ class Adherent extends CommonObject
$this->gender='man'; $this->gender='man';
$this->login='dolibspec'; $this->login='dolibspec';
$this->pass='dolibspec'; $this->pass='dolibspec';
$this->societe = 'Societe ABC'; $this->company = 'Societe ABC';
$this->address = '61 jump street'; $this->address = '61 jump street';
$this->zip = '75000'; $this->zip = '75000';
$this->town = 'Paris'; $this->town = 'Paris';
@ -2483,9 +2483,9 @@ class Adherent extends CommonObject
$this->fullname=$this->getFullName($langs); $this->fullname=$this->getFullName($langs);
// For avoid ldap error when firstname and lastname are empty // For avoid ldap error when firstname and lastname are empty
if ($this->morphy == 'mor' && (empty($this->fullname) || $this->fullname == $this->societe)) { if ($this->morphy == 'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
$this->fullname = $this->societe; $this->fullname = $this->company;
$this->lastname = $this->societe; $this->lastname = $this->company;
} }
// Possible LDAP KEY (constname => varname) // 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->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->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->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->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; 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->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
$actioncomm->code = 'AC_'.$actioncode; $actioncomm->code = 'AC_'.$actioncode;
$actioncomm->label = $actionmsg2; $actioncomm->label = $actionmsg2;
$actioncomm->note = $actionmsg; $actioncomm->note_private= $actionmsg;
$actioncomm->fk_project = 0; $actioncomm->fk_project = 0;
$actioncomm->datep = $now; $actioncomm->datep = $now;
$actioncomm->datef = $now; $actioncomm->datef = $now;

View File

@ -37,6 +37,7 @@ class AdherentStats extends Stats
*/ */
public $table_element; public $table_element;
public $memberid;
public $socid; public $socid;
public $userid; public $userid;

View File

@ -235,7 +235,7 @@ class MembersTypes extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); 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'); throw new RestException(401, 'error when deleting member type');
} }

View File

@ -134,7 +134,7 @@ if ($id > 0)
print '</tr>'; print '</tr>';
// Company // Company
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'</td></tr>'; print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
// Civility // Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>'; print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';

View File

@ -83,10 +83,10 @@ if ($action == 'dolibarr2ldap')
* View * View
*/ */
llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
$form = new Form($db); $form = new Form($db);
llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
$head = member_prepare_head($object); $head = member_prepare_head($object);
dol_fiche_head($head, 'ldap', $langs->trans("Member"), 0, 'user'); dol_fiche_head($head, 'ldap', $langs->trans("Member"), 0, 'user');
@ -98,12 +98,12 @@ dol_banner_tab($object, 'rowid', $linkback);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent tableforfield">';
// Login // Login
print '<tr><td class="titlefield">'.$langs->trans("Login").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
// 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)) if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD))
{ {
print '<tr><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td>'; print '<tr><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td>';
@ -111,18 +111,11 @@ if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD))
print "</tr>\n"; print "</tr>\n";
} }
// Password crypted $adht = new AdherentType($db);
if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $adht->fetch($object->typeid);
{
print '<tr><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td>';
print '<td class="valeur">'.$object->pass_crypted.'</td>';
print "</tr>\n";
}
// Type // Type
print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$object->type."</td></tr>\n"; print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
$langs->load("admin");
// LDAP DN // LDAP DN
print '<tr><td>LDAP '.$langs->trans("LDAPMemberDn").'</td><td class="valeur">'.$conf->global->LDAP_MEMBER_DN."</td></tr>\n"; print '<tr><td>LDAP '.$langs->trans("LDAPMemberDn").'</td><td class="valeur">'.$conf->global->LDAP_MEMBER_DN."</td></tr>\n";
@ -182,7 +175,7 @@ if ($result > 0)
if (empty($dn)) if (empty($dn))
{ {
$langs->load("errors"); $langs->load("errors");
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).'</font></td></tr>'; print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).'</font></td></tr>';
} }
else else
{ {
@ -190,12 +183,12 @@ if ($result > 0)
//print_r($records); //print_r($records);
// Affichage arbre // Show tree
if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
{ {
if (! is_array($records)) if (! is_array($records))
{ {
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
} }
else else
{ {
@ -204,7 +197,7 @@ if ($result > 0)
} }
else else
{ {
print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>'; print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
} }
} }

View File

@ -135,11 +135,12 @@ $arrayfields=array(
'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000) 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000)
); );
// Extra fields // 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.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.= " 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.= " 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 // 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 // Add fields from hooks
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $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"; $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 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_country as country on (country.rowid = d.country)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)"; $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 { } else {
$companyname=$obj->company; $companyname=$obj->company;
} }
$memberstatic->societe = $companyname; $memberstatic->company = $companyname;
print '<tr class="oddeven">'; print '<tr class="oddeven">';

View File

@ -80,7 +80,7 @@ if ($id)
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent tableforfield">';
// Login // Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
@ -99,7 +99,7 @@ if ($id)
print '</tr>'; print '</tr>';
// Company // Company
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'</td></tr>'; print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
// Civility // Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>'; print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';

View File

@ -478,7 +478,7 @@ if ($rowid > 0)
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border centpercent tableforfield">';
// Login // Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
@ -494,7 +494,7 @@ if ($rowid > 0)
print '</tr>'; print '</tr>';
// Company // Company
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'</td></tr>'; print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
// Civility // Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>'; print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
@ -862,13 +862,13 @@ if ($rowid > 0)
if ($object->morphy == 'mor') if ($object->morphy == 'mor')
{ {
$companyname=$object->societe; $companyname=$object->company;
if (! empty($fullname)) $companyalias=$fullname; if (! empty($fullname)) $companyalias=$fullname;
} }
else else
{ {
$companyname=$fullname; $companyname=$fullname;
if (! empty($object->societe)) $companyalias=$object->societe; if (! empty($object->company)) $companyalias=$object->company;
} }
// Create a form array // Create a form array
@ -903,7 +903,7 @@ if ($rowid > 0)
print '<input type="hidden" name="action" value="subscription">'; print '<input type="hidden" name="action" value="subscription">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">'; print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).'">'; print '<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).'">';
print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->societe).'">'; print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->company).'">';
dol_fiche_head(''); dol_fiche_head('');

View File

@ -106,11 +106,11 @@ if ($cancel) {
if ($action == 'add' && $user->rights->adherent->configurer) { if ($action == 'add' && $user->rights->adherent->configurer) {
$object->label = trim($label); $object->label = trim($label);
$object->morphy = trim($morphy); $object->morphy = trim($morphy);
$object->statut = (int) $statut; $object->statut = (int) $statut;
$object->subscription = (int) $subscription; $object->subscription = (int) $subscription;
$object->note = trim($comment); $object->note = trim($comment);
$object->mail_valid = trim($mail_valid); $object->mail_valid = trim($mail_valid);
$object->vote = (boolean) trim($vote); $object->vote = (int) $vote;
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object); $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
@ -489,7 +489,7 @@ if ($rowid > 0)
$now=dol_now(); $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.datefin,";
$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
$sql.= " t.libelle as type, t.subscription"; $sql.= " t.libelle as type, t.subscription";
@ -649,7 +649,7 @@ if ($rowid > 0)
// Lastname // Lastname
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if ($objp->societe != '') if ($objp->company != '')
{ {
print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).'</a></td>'."\n"; print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).'</a></td>'."\n";
} }
@ -812,21 +812,25 @@ if ($rowid > 0)
if (empty($reshook)) if (empty($reshook))
{ {
print '<br><br><table class="border" width="100%">'; print '<br><br><table class="border" width="100%">';
foreach($extrafields->attribute_label as $key=>$label) if (is_array($extrafields->attributes['adherent_type']['label']))
{ {
if (isset($_POST["options_" . $key])) { foreach($extrafields->attributes['adherent_type']['label'] as $key=>$label)
if (is_array($_POST["options_" . $key])) { {
// $_POST["options"] is an array but following code expects a comma separated string if (isset($_POST["options_" . $key])) {
$value = implode(",", $_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 { } else {
$value = $_POST["options_" . $key]; $value = $object->array_options["options_" . $key];
} }
} else {
$value = $adht->array_options["options_" . $key]; print '<tr><td width="30%">'.$label.'</td><td>';
print $extrafields->showInputField($key, $value);
print "</td></tr>\n";
} }
print '<tr><td width="30%">'.$label.'</td><td>';
print $extrafields->showInputField($key, $value);
print "</td></tr>\n";
} }
print '</table><br><br>'; print '</table><br><br>';
} }

View File

@ -155,16 +155,17 @@ if ($result > 0)
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info, 1); $dn=$object->_load_ldap_dn($info, 1);
$search = "(".$object->_load_ldap_dn($info, 2).")"; $search = "(".$object->_load_ldap_dn($info, 2).")";
$records = $ldap->getAttribute($dn, $search); $records = $ldap->getAttribute($dn, $search);
//print_r($records); //print_r($records);
// Affichage arbre // Show tree
if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
{ {
if (! is_array($records)) if (! is_array($records))
{ {
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
} }
else else
{ {
@ -173,7 +174,7 @@ if ($result > 0)
} }
else else
{ {
print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>'; print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
} }
$ldap->unbind(); $ldap->unbind();

View File

@ -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/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.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 // Load translation files required by the page
$langs->loadLangs(array("errors","admin","main","companies","resource","holiday","accountancy","hrm","orders","contracts","projects","propal","bills","interventions")); $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); $formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
$withentity=''; $withentity='';
@ -1890,6 +1890,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
elseif (in_array($fieldlist[$field], array('libelle_facture'))) { elseif (in_array($fieldlist[$field], array('libelle_facture'))) {
print '<td>'; print '<td>';
$transfound=0; $transfound=0;
$transkey='';
// Special case for labels // Special case for labels
if ($tabname == MAIN_DB_PREFIX.'c_payment_term') if ($tabname == MAIN_DB_PREFIX.'c_payment_term')
{ {

View File

@ -254,6 +254,7 @@ class PrestaShopWebservice
public function add($options) public function add($options)
{ {
$xml = ''; $xml = '';
$url = '';
if (isset($options['resource'], $options['postXml']) || isset($options['url'], $options['postXml'])) 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']; $url .= '&id_group_shop='.$options['id_group_shop'];
} }
else else
{
throw new PrestaShopWebserviceException('Bad parameters given'); throw new PrestaShopWebserviceException('Bad parameters given');
}
$request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $xml)); $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $xml));
self::checkStatusCode($request['status_code']); self::checkStatusCode($request['status_code']);

View File

@ -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']); if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']);
} }
// Extra fields // 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');

View File

@ -115,7 +115,7 @@ llxHeader('', $langs->trans("PrintingSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup'); 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'); dol_fiche_head($head, 'tokengeneration', '', -1, 'technic');

View File

@ -219,7 +219,7 @@ if (! $error && $xml)
$scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude);
// Fill file_list with files in signature, new files, modified files // 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 // Complete with list of new files
foreach ($scanfiles as $keyfile => $valfile) foreach ($scanfiles as $keyfile => $valfile)
{ {

View File

@ -586,7 +586,7 @@ print "\n";
?> ?>
<br> <br>
<div class="center"><input type="submit" class="button" <div class="center"><input type="submit" class="button reposition"
value="<?php echo $langs->trans("GenerateBackup") ?>" id="buttonGo" /><br> value="<?php echo $langs->trans("GenerateBackup") ?>" id="buttonGo" /><br>
<br> <br>
</div> </div>

View File

@ -112,21 +112,27 @@ $utils = new Utils($db);
if ($compression == 'zip') 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) if ($ret < 0)
{ {
$errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputfile); $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputdir);
} }
} }
elseif (in_array($compression, array('gz', 'bz'))) 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'; $file .= '.tar';
$cmd = 'tar -cf '.$outputdir."/".$file." --exclude=documents/admin/documents -C ".DOL_DATA_ROOT." ".DOL_DATA_ROOT."/../documents/"; // We also exclude '/temp/' dir and 'documents/admin/documents'
exec($cmd, $out, $retval); $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);
//var_dump($cmd, DOL_DATA_ROOT);exit;
$result = $utils->executeCLI($cmd, $outputfile);
if ($retval != 0)
$retval = $result['error'];
if ($result['result'] || ! empty($retval))
{ {
$langs->load("errors"); $langs->load("errors");
dol_syslog("Documents tar retval after exec=".$retval, LOG_ERR); dol_syslog("Documents tar retval after exec=".$retval, LOG_ERR);
@ -136,15 +142,17 @@ elseif (in_array($compression, array('gz', 'bz')))
{ {
if ($compression == 'gz') if ($compression == 'gz')
{ {
$cmd = "gzip " . $outputdir."/".$file; $cmd = "gzip -f " . $outputdir."/".$file;
} }
if ($compression == 'bz') if ($compression == 'bz')
{ {
$cmd = "bzip2 " . $outputdir."/".$file; $cmd = "bzip2 -f " . $outputdir."/".$file;
} }
exec($cmd, $out, $retval); $result = $utils->executeCLI($cmd, $outputfile);
if ($retval != 0)
$retval = $result['error'];
if ($result['result'] || ! empty($retval))
{ {
$errormsg = 'Error '.$compression.' generation return '.$retval; $errormsg = 'Error '.$compression.' generation return '.$retval;
unlink($outputdir."/".$file); unlink($outputdir."/".$file);

View File

@ -169,9 +169,6 @@ class DolibarrApiAccess implements iAuthenticate
// phpcs:disable PEAR.NamingConventions.ValidFunctionName // phpcs:disable PEAR.NamingConventions.ValidFunctionName
/** /**
* @return string string to be used with WWW-Authenticate header * @return string string to be used with WWW-Authenticate header
* @example Basic
* @example Digest
* @example OAuth
*/ */
public function __getWWWAuthenticateString() public function __getWWWAuthenticateString()
{ {

View File

@ -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 $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 $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 $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) * @param int $overwriteifexists Overwrite file if exists (1 by default)
* @return string * @return string
* *

View File

@ -178,7 +178,7 @@ class Setup extends DolibarrApi
} }
} }
} else { } 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; return $list;
@ -331,7 +331,7 @@ class Setup extends DolibarrApi
* @param string $module To filter on module events * @param string $module To filter on module events
* @param int $active Payment term is active or not {@min 0} {@max 1} * @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)" * @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 * @url GET dictionary/event_types
* *
@ -394,7 +394,7 @@ class Setup extends DolibarrApi
* @param string $module To filter on module events * @param string $module To filter on module events
* @param int $active Payment term is active or not {@min 0} {@max 1} * @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)" * @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 * @url GET dictionary/civilities
* *
@ -456,7 +456,7 @@ class Setup extends DolibarrApi
* @param int $page Page number (starting from zero) * @param int $page Page number (starting from zero)
* @param int $active Payment term is active or not {@min 0} {@max 1} * @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)" * @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 * @url GET dictionary/currencies
* *
@ -477,7 +477,7 @@ class Setup extends DolibarrApi
$sql.= " AND m.entity IN (".getEntity('multicurrency').")"; $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)"; 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 // Add sql filters
if ($sqlfilters) if ($sqlfilters)
{ {
@ -523,7 +523,7 @@ class Setup extends DolibarrApi
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...) * @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-%')" * @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 * @url GET extrafields
* *
@ -602,7 +602,7 @@ class Setup extends DolibarrApi
* @param string $town To filter on city name * @param string $town To filter on city name
* @param int $active Payment term is active or not {@min 0} {@max 1} * @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)" * @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 * @url GET dictionary/towns
* *
@ -717,7 +717,7 @@ class Setup extends DolibarrApi
return $list; return $list;
} }
/** /**
* Get the list of shipping methods. * Get the list of shipping methods.
* *
@ -788,7 +788,7 @@ class Setup extends DolibarrApi
* @param int $page Page number (starting from zero) * @param int $page Page number (starting from zero)
* @param int $active Payment term is active or not {@min 0} {@max 1} * @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)" * @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 * @url GET dictionary/units
* *
@ -848,7 +848,7 @@ class Setup extends DolibarrApi
* @param int $page Page number (starting from zero) * @param int $page Page number (starting from zero)
* @param int $active Payment term is active or not {@min 0} {@max 1} * @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)" * @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 * @url GET dictionary/ticket_categories
* *
@ -908,7 +908,7 @@ class Setup extends DolibarrApi
* @param int $page Page number (starting from zero) * @param int $page Page number (starting from zero)
* @param int $active Payment term is active or not {@min 0} {@max 1} * @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)" * @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 * @url GET dictionary/ticket_severities
* *
@ -968,7 +968,7 @@ class Setup extends DolibarrApi
* @param int $page Page number (starting from zero) * @param int $page Page number (starting from zero)
* @param int $active Payment term is active or not {@min 0} {@max 1} * @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)" * @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 * @url GET dictionary/ticket_types
* *
@ -1026,7 +1026,7 @@ class Setup extends DolibarrApi
* Do a test of integrity for files and setup. * 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. * @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 * @url GET checkintegrity
* *
@ -1158,7 +1158,7 @@ class Setup extends DolibarrApi
$scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude);
// Fill file_list with files in signature, new files, modified files // 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 // Complete with list of new files
foreach ($scanfiles as $keyfile => $valfile) foreach ($scanfiles as $keyfile => $valfile)
{ {

View File

@ -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']); 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 // 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'); $object->fields = dol_sort_array($object->fields, 'position');

View File

@ -55,7 +55,7 @@ function bomAdminPrepareHead()
//$this->tabs = array( //$this->tabs = array(
// 'entity:-tabname:Title:@bom:/bom/mypage.php?id=__ID__' // 'entity:-tabname:Title:@bom:/bom/mypage.php?id=__ID__'
//); // to remove a tab //); // 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; return $head;
} }

View File

@ -188,10 +188,12 @@ class Categorie extends CommonObject
* @var string Color * @var string Color
*/ */
public $color; public $color;
/** /**
* @var ??? * @var int Id of thirdparty when CATEGORY_ASSIGNED_TO_A_CUSTOMER is set
*/ */
public $socid; public $socid;
/** /**
* @var string Category type * @var string Category type
* *

View File

@ -251,9 +251,6 @@ class ActionComm extends CommonObject
public function __construct(DoliDB $db) public function __construct(DoliDB $db)
{ {
$this->db = $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); $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; $userownerid=$this->userownerid;
$userdoneid=$this->userdoneid; $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 * 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->contactid = $obj->fk_contact; // To have fetch_contact method working
$this->fk_project = $obj->fk_project; // To have fetch_project 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->contact->id = $obj->fk_contact; // deprecated
$this->fk_element = $obj->elementid; $this->fk_element = $obj->elementid;
@ -889,8 +870,8 @@ class ActionComm extends CommonObject
return -1; return -1;
} }
$socid=($this->socid?$this->socid:((isset($this->societe->id) && $this->societe->id > 0) ? $this->societe->id : 0)); $socid=(($this->socid > 0)?$this->socid:0);
$contactid=($this->contactid?$this->contactid:0); $contactid=(($this->contactid > 0)?$this->contactid:0);
$userownerid=($this->userownerid?$this->userownerid:0); $userownerid=($this->userownerid?$this->userownerid:0);
$userdoneid=($this->userdoneid?$this->userdoneid:0); $userdoneid=($this->userdoneid?$this->userdoneid:0);

View File

@ -452,6 +452,7 @@ if ($resql)
if (! empty($arrayfields['owner']['checked'])) print '<td class="liste_titre"></td>'; if (! empty($arrayfields['owner']['checked'])) print '<td class="liste_titre"></td>';
if (! empty($arrayfields['c.libelle']['checked'])) print '<td class="liste_titre"></td>'; if (! empty($arrayfields['c.libelle']['checked'])) print '<td class="liste_titre"></td>';
if (! empty($arrayfields['a.label']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>'; if (! empty($arrayfields['a.label']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
if (! empty($arrayfields['a.note']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>';
if (! empty($arrayfields['a.datep']['checked'])) { if (! empty($arrayfields['a.datep']['checked'])) {
print '<td class="liste_titre nowraponall" align="center">'; print '<td class="liste_titre nowraponall" align="center">';
print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0); print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0);

View File

@ -2500,7 +2500,7 @@ $formquestion = array_merge($formquestion, array(
if ($usercansend) { if ($usercansend) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>';
} else } else
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans('SendMail') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">' . $langs->trans('SendMail') . '</a></div>';
} }
// Create an order // Create an order
@ -2538,7 +2538,14 @@ $formquestion = array_merge($formquestion, array(
$arrayofinvoiceforpropal = $object->getInvoiceArrayList(); $arrayofinvoiceforpropal = $object->getInvoiceArrayList();
if ((is_array($arrayofinvoiceforpropal) && count($arrayofinvoiceforpropal) > 0) || empty($conf->global->WORKFLOW_PROPAL_NEED_INVOICE_TO_BE_CLASSIFIED_BILLED)) if ((is_array($arrayofinvoiceforpropal) && count($arrayofinvoiceforpropal) > 0) || empty($conf->global->WORKFLOW_PROPAL_NEED_INVOICE_TO_BE_CLASSIFIED_BILLED))
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifybilled&amp;socid=' . $object->socid . '">' . $langs->trans("ClassifyBilled") . '</a></div>'; if ($usercanclose)
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifybilled&amp;socid=' . $object->socid . '">' . $langs->trans("ClassifyBilled") . '</a></div>';
}
else
{
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">' . $langs->trans("ClassifyBilled") . '</a></div>';
}
} }
} }

View File

@ -92,7 +92,7 @@ class Proposals extends DolibarrApi
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @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')" * @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 * @return array Array of order objects
*/ */

View File

@ -168,18 +168,20 @@ $arrayfields=array(
'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1),
'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>"DateModificationShort", '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), 'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
); );
// Extra fields // 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 * Actions
*/ */
@ -276,19 +278,20 @@ $sql.= ' u.login';
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; 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"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
// Add fields from extrafields // 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 // Add fields from hooks
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint; $sql.=$hookmanager->resPrint;
$sql=preg_replace('/, $/', '', $sql);
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $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_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_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)"; $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 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'; $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 ($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'; 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'; $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(); $now = dol_now();
$i=0; $i=0;
$totalarray=array(); $totalarray=array();
$typenArray=null;
while ($i < min($num, $limit)) while ($i < min($num, $limit))
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
@ -880,8 +885,9 @@ if ($resql)
// Type ent // Type ent
if (! empty($arrayfields['typent.code']['checked'])) if (! empty($arrayfields['typent.code']['checked']))
{ {
if (! is_array($typenArray) || empty($typenArray)) $typenArray = $formcompany->typent_array(1);
print '<td align="center">'; print '<td align="center">';
if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
print $typenArray[$obj->typent_code]; print $typenArray[$obj->typent_code];
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;

View File

@ -94,7 +94,7 @@ class Orders extends DolibarrApi
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @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')" * @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 * @return array Array of order objects
* *

View File

@ -143,18 +143,21 @@ $arrayfields=array(
'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'c.tms'=>array('label'=>"DateModificationShort", '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.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))) 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
); );
// Extra fields // 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');

View File

@ -213,9 +213,9 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$paiement = '';
$ref = ''; $ref = '';
$refcomp = ''; $refcomp = '';
$totalpayment = '';
$obj = array_shift($tab_sqlobj); $obj = array_shift($tab_sqlobj);
@ -236,7 +236,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$societestatic->name = $obj->name; $societestatic->name = $obj->name;
$refcomp=$societestatic->getNomUrl(1, '', 24); $refcomp=$societestatic->getNomUrl(1, '', 24);
$paiement = -1*$facturefournstatic->getSommePaiement(); // Payment already done $totalpayment = -1*$facturefournstatic->getSommePaiement(); // Payment already done
} }
} }
if ($obj->family == 'invoice') if ($obj->family == 'invoice')
@ -250,9 +250,9 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$societestatic->name = $obj->name; $societestatic->name = $obj->name;
$refcomp=$societestatic->getNomUrl(1, '', 24); $refcomp=$societestatic->getNomUrl(1, '', 24);
$paiement = $facturestatic->getSommePaiement(); // Payment already done $totalpayment = $facturestatic->getSommePaiement(); // Payment already done
$paiement+= $facturestatic->getSumDepositsUsed(); $totalpayment+= $facturestatic->getSumDepositsUsed();
$paiement+= $facturestatic->getSumCreditNotesUsed(); $totalpayment+= $facturestatic->getSumCreditNotesUsed();
} }
if ($obj->family == 'social_contribution') if ($obj->family == 'social_contribution')
{ {
@ -261,19 +261,19 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$socialcontribstatic->lib=$obj->type; $socialcontribstatic->lib=$obj->type;
$ref = $socialcontribstatic->getNomUrl(1, 24); $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 $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if(empty($reshook)){ if(empty($reshook)){
$ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : $ref; $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : $ref;
$refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : $refcomp; $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; $total_ttc = $obj->total_ttc;
if ($paiement) $total_ttc = $obj->total_ttc - $paiement; if ($totalpayment) $total_ttc = $obj->total_ttc - $totalpayment;
$solde += $total_ttc; $solde += $total_ttc;
// We discard lines with a remainder to pay to 0 // We discard lines with a remainder to pay to 0

View File

@ -98,7 +98,7 @@ class Invoices extends DolibarrApi
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @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 $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')" * @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 * @return array Array of invoice objects

View File

@ -210,12 +210,12 @@ class Facture extends CommonInvoice
* @var double percentage of retainage * @var double percentage of retainage
*/ */
public $retained_warranty; public $retained_warranty;
/** /**
* @var int timestamp of date limit of retainage * @var int timestamp of date limit of retainage
*/ */
public $retained_warranty_date_limit; public $retained_warranty_date_limit;
/** /**
* @var int Code in llx_c_paiement * @var int Code in llx_c_paiement
*/ */
@ -459,7 +459,16 @@ class Facture extends CommonInvoice
} }
// Define due date if not already defined // 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 // Insert into database
$socid = $this->socid; $socid = $this->socid;
@ -514,7 +523,7 @@ class Facture extends CommonInvoice
$sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".($this->fk_project?$this->fk_project:"null");
$sql.= ", ".$this->cond_reglement_id; $sql.= ", ".$this->cond_reglement_id;
$sql.= ", ".$this->mode_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_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null");
$sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null"); $sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null");
$sql.= ", ".($this->situation_final?$this->situation_final:0); $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)?"0":$this->db->escape($this->retained_warranty));
$sql.= ", ".(!empty($this->retained_warranty_date_limit)?"'".$this->db->idate($this->retained_warranty_date_limit)."'":'NULL'); $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.= ", ".(int) $this->retained_warranty_fk_cond_reglement;
$sql.=")"; $sql.=")";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -1430,7 +1439,7 @@ class Facture extends CommonInvoice
$this->retained_warranty = $obj->retained_warranty; $this->retained_warranty = $obj->retained_warranty;
$this->retained_warranty_date_limit = $this->db->jdate($obj->retained_warranty_date_limit); $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->retained_warranty_fk_cond_reglement = $obj->retained_warranty_fk_cond_reglement;
$this->extraparams = (array) json_decode($obj->extraparams, true); $this->extraparams = (array) json_decode($obj->extraparams, true);
//Incoterms //Incoterms
@ -1679,7 +1688,7 @@ class Facture extends CommonInvoice
if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf);
if (isset($this->import_key)) $this->import_key=trim($this->import_key); if (isset($this->import_key)) $this->import_key=trim($this->import_key);
if (isset($this->retained_warranty)) $this->retained_warranty = floatval($this->retained_warranty); if (isset($this->retained_warranty)) $this->retained_warranty = floatval($this->retained_warranty);
// Check parameters // Check parameters
// Put here code to add control on parameters values // 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.= " 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_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.= " 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_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.= " 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").","; $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) ){ if(empty($this->retained_warranty) ){
return -1; return -1;
} }
$retainedWarrantyAmount = 0; $retainedWarrantyAmount = 0;
// Billed - retained warranty // Billed - retained warranty
if($this->type == Facture::TYPE_SITUATION) if($this->type == Facture::TYPE_SITUATION)
{ {
@ -4438,18 +4447,18 @@ class Facture extends CommonInvoice
} }
} }
} }
if($displayWarranty && !empty($this->situation_final)) if($displayWarranty && !empty($this->situation_final))
{ {
$this->fetchPreviousNextSituationInvoice(); $this->fetchPreviousNextSituationInvoice();
$TPreviousIncoice = $this->tab_previous_situation_invoice; $TPreviousIncoice = $this->tab_previous_situation_invoice;
$total2BillWT = 0; $total2BillWT = 0;
foreach ($TPreviousIncoice as &$fac){ foreach ($TPreviousIncoice as &$fac){
$total2BillWT += $fac->total_ttc; $total2BillWT += $fac->total_ttc;
} }
$total2BillWT += $this->total_ttc; $total2BillWT += $this->total_ttc;
$retainedWarrantyAmount = $total2BillWT * $this->retained_warranty / 100; $retainedWarrantyAmount = $total2BillWT * $this->retained_warranty / 100;
} }
else{ else{
@ -4461,10 +4470,10 @@ class Facture extends CommonInvoice
// Because one day retained warranty could be used on standard invoices // Because one day retained warranty could be used on standard invoices
$retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100; $retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100;
} }
return $retainedWarrantyAmount; return $retainedWarrantyAmount;
} }
/** /**
* Change the retained warranty * Change the retained warranty
* *
@ -4480,7 +4489,7 @@ class Facture extends CommonInvoice
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.floatval($value); $sql .= ' SET '.$fieldname.' = '.floatval($value);
$sql .= ' WHERE rowid='.$this->id; $sql .= ' WHERE rowid='.$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->retained_warranty = floatval($value); $this->retained_warranty = floatval($value);
@ -4500,8 +4509,8 @@ class Facture extends CommonInvoice
return -2; return -2;
} }
} }
/** /**
* Change the retained_warranty_date_limit * Change the retained_warranty_date_limit
* *
@ -4514,8 +4523,8 @@ class Facture extends CommonInvoice
if(!$timestamp && $dateYmd){ if(!$timestamp && $dateYmd){
$timestamp = $this->db->jdate($dateYmd); $timestamp = $this->db->jdate($dateYmd);
} }
dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit('.$timestamp.')'); dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit('.$timestamp.')');
if ($this->statut >= 0) if ($this->statut >= 0)
{ {
@ -4523,7 +4532,7 @@ class Facture extends CommonInvoice
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.(strval($timestamp)!='' ? '\'' .$this->db->idate($timestamp).'\'' : 'null' ); $sql .= ' SET '.$fieldname.' = '.(strval($timestamp)!='' ? '\'' .$this->db->idate($timestamp).'\'' : 'null' );
$sql .= ' WHERE rowid='.$this->id; $sql .= ' WHERE rowid='.$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->retained_warranty_date_limit = $timestamp; $this->retained_warranty_date_limit = $timestamp;
@ -5168,13 +5177,16 @@ class FactureLigne extends CommonInvoiceLine
public function get_prev_progress($invoiceid, $include_credit_note = true) public function get_prev_progress($invoiceid, $include_credit_note = true)
{ {
// phpcs:enable // phpcs:enable
global $invoicecache;
if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") {
return 0; return 0;
} else { } else {
// If invoice is not a situation invoice, this->fk_prev_id is used for something else // If invoice is not a situation invoice, this->fk_prev_id is used for something else
$tmpinvoice=new Facture($this->db); if (!isset($invoicecache[$invoiceid])) {
$tmpinvoice->fetch($invoiceid); $invoicecache[$invoiceid]=new Facture($this->db);
if ($tmpinvoice->type != Facture::TYPE_SITUATION) return 0; $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; $sql = 'SELECT situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE rowid=' . $this->fk_prev_id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -133,13 +133,16 @@ $arrayfields=array(
'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
); );
// Extra fields // 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');
/* /*

View File

@ -189,13 +189,16 @@ if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_
} }
// Extra fields // 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 '<input class="flat" type="text" size="4" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">'; print '<input class="flat" type="text" size="4" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
print '</td>'; print '</td>';
} }
if(! empty($arrayfields['f.retained_warranty']['checked'])) if(! empty($arrayfields['f.retained_warranty']['checked']))
{ {
print '<td class="liste_titre" align="right">'; print '<td class="liste_titre" align="right">';
print '</td>'; print '</td>';
} }
if (! empty($arrayfields['dynamount_payed']['checked'])) if (! empty($arrayfields['dynamount_payed']['checked']))
{ {
print '<td class="liste_titre right">'; print '<td class="liste_titre right">';

View File

@ -72,9 +72,8 @@ class Paiement extends CommonObject
public $amounts=array(); // Array of amounts public $amounts=array(); // Array of amounts
public $multicurrency_amounts=array(); // Array of amounts public $multicurrency_amounts=array(); // Array of amounts
public $author; public $author;
public $paiementid; // Type de paiement. Stocke dans fk_paiement public $paiementid; // Type of payment. Id saved into fields fk_paiement on llx_paiement
// de llx_paiement qui est lie aux types de public $paiementcode; // Code of payment.
//paiement de llx_c_paiement
/** /**
* @var string type libelle * @var string type libelle
@ -89,14 +88,14 @@ class Paiement extends CommonObject
/** /**
* @var string Numero du CHQ, VIR, etc... * @var string Numero du CHQ, VIR, etc...
* @deprecated * @deprecated
* @see num_payment * @see $num_payment
*/ */
public $numero; public $numero;
/** /**
* @var string Numero du CHQ, VIR, etc... * @var string Numero du CHQ, VIR, etc...
* @deprecated * @deprecated
* @see num_payment * @see $num_payment
*/ */
public $num_paiement; public $num_paiement;

View File

@ -82,26 +82,11 @@ class Contact extends CommonObject
public $civility_id; // In fact we store civility_code public $civility_id; // In fact we store civility_code
public $civility_code; public $civility_code;
public $civility; public $civility;
public $address; public $address;
public $zip; public $zip;
public $town; 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_id; // Id of department
public $state_code; // Code of department public $state_code; // Code of department
public $state; // Label of department public $state; // Label of department
@ -1023,7 +1008,7 @@ class Contact extends CommonObject
// Removed extrafields // Removed extrafields
if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) { if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) {
// For avoid conflicts if trigger used // For avoid conflicts if trigger used
$result=$this->deleteExtraFields($this); $result=$this->deleteExtraFields();
if ($result < 0) $error++; if ($result < 0) $error++;
} }

View File

@ -80,12 +80,12 @@ if ($action == 'dolibarr2ldap')
* View * View
*/ */
$form = new Form($db);
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
llxHeader('', $title, 'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas'); llxHeader('', $title, 'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas');
$form = new Form($db);
$head = contact_prepare_head($object); $head = contact_prepare_head($object);
dol_fiche_head($head, 'ldap', $title, -1, 'contact'); dol_fiche_head($head, 'ldap', $title, -1, 'contact');
@ -172,16 +172,17 @@ if ($result > 0)
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info, 1); $dn=$object->_load_ldap_dn($info, 1);
$search = "(".$object->_load_ldap_dn($info, 2).")"; $search = "(".$object->_load_ldap_dn($info, 2).")";
$records = $ldap->getAttribute($dn, $search); $records = $ldap->getAttribute($dn, $search);
//var_dump($records); //var_dump($records);
// Affichage arbre // Show tree
if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
{ {
if (! is_array($records)) if (! is_array($records))
{ {
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
} }
else else
{ {
@ -190,7 +191,7 @@ if ($result > 0)
} }
else else
{ {
print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>'; print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
} }
$ldap->unbind(); $ldap->unbind();

View File

@ -95,7 +95,7 @@ class Contracts extends DolibarrApi
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @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')" * @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 * @return array Array of contract objects
* *

View File

@ -130,13 +130,16 @@ $arrayfields=array(
'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
); );
// Extra fields // 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');
/* /*

View File

@ -132,13 +132,16 @@ $arrayfields=array(
'cd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) 'cd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500)
); );
// Extra fields // 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 '<td class="right">'; print '<td class="right">';
if ($obj->cstatut == 0) // If contract is draft, we say line is also draft 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 else
{ {

View File

@ -57,12 +57,12 @@ class box_activity extends ModeleBoxes
{ {
global $conf, $user; global $conf, $user;
$this->db=$db; $this->db = $db;
// FIXME: Pb into some status // 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->commande->enabled) && $user->rights->commande->lire)
|| (! empty($conf->propal->enabled) && $user->rights->propale->lire) || (! empty($conf->propal->enabled) && $user->rights->propale->lire)
); );

View File

@ -56,7 +56,7 @@ class box_birthdays extends ModeleBoxes
*/ */
public function __construct($db, $param = '') public function __construct($db, $param = '')
{ {
global $conf, $user; global $user;
$this->db = $db; $this->db = $db;
@ -71,7 +71,7 @@ class box_birthdays extends ModeleBoxes
*/ */
public function loadBox($max = 20) public function loadBox($max = 20)
{ {
global $user, $langs, $db, $conf; global $user, $langs, $db;
$langs->load("boxes"); $langs->load("boxes");
$this->max=$max; $this->max=$max;

View File

@ -56,7 +56,7 @@ class box_birthdays_members extends ModeleBoxes
*/ */
public function __construct($db, $param = '') public function __construct($db, $param = '')
{ {
global $conf, $user; global $user;
$this->db = $db; $this->db = $db;
@ -71,7 +71,7 @@ class box_birthdays_members extends ModeleBoxes
*/ */
public function loadBox($max = 20) public function loadBox($max = 20)
{ {
global $user, $langs, $db, $conf; global $user, $langs, $db;
$langs->load("boxes"); $langs->load("boxes");
$this->max=$max; $this->max=$max;

View File

@ -54,9 +54,9 @@ class box_bookmarks extends ModeleBoxes
{ {
global $user; global $user;
$this->db=$db; $this->db = $db;
$this->hidden=! ($user->rights->bookmark->lire); $this->hidden = ! ($user->rights->bookmark->lire);
} }
/** /**

View File

@ -58,9 +58,9 @@ class box_commandes extends ModeleBoxes
{ {
global $user; global $user;
$this->db=$db; $this->db = $db;
$this->hidden=! ($user->rights->commande->lire); $this->hidden = ! ($user->rights->commande->lire);
} }
/** /**

View File

@ -60,9 +60,9 @@ class box_contacts extends ModeleBoxes
{ {
global $user; 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);
} }
/** /**

View File

@ -57,9 +57,9 @@ class box_contracts extends ModeleBoxes
{ {
global $user; global $user;
$this->db=$db; $this->db = $db;
$this->hidden=! ($user->rights->contrat->lire); $this->hidden = ! ($user->rights->contrat->lire);
} }
/** /**

View File

@ -56,9 +56,9 @@ class box_factures extends ModeleBoxes
{ {
global $user; global $user;
$this->db=$db; $this->db = $db;
$this->hidden=! ($user->rights->facture->lire); $this->hidden = ! ($user->rights->facture->lire);
} }
/** /**

View File

@ -57,9 +57,9 @@ class box_factures_fourn extends ModeleBoxes
{ {
global $user; global $user;
$this->db=$db; $this->db = $db;
$this->hidden=! ($user->rights->fournisseur->facture->lire); $this->hidden = ! ($user->rights->fournisseur->facture->lire);
} }
/** /**

View File

@ -56,9 +56,9 @@ class box_factures_fourn_imp extends ModeleBoxes
{ {
global $user; global $user;
$this->db=$db; $this->db = $db;
$this->hidden=! ($user->rights->fournisseur->facture->lire); $this->hidden = ! ($user->rights->fournisseur->facture->lire);
} }
/** /**

View File

@ -59,9 +59,9 @@ class box_factures_imp extends ModeleBoxes
{ {
global $user; global $user;
$this->db=$db; $this->db = $db;
$this->hidden=! ($user->rights->facture->lire); $this->hidden = ! ($user->rights->facture->lire);
} }
/** /**

View File

@ -57,9 +57,9 @@ class box_ficheinter extends ModeleBoxes
{ {
global $user; global $user;
$this->db=$db; $this->db = $db;
$this->hidden=! ($user->rights->ficheinter->lire); $this->hidden = ! ($user->rights->ficheinter->lire);
} }
/** /**

View File

@ -57,9 +57,9 @@ class box_fournisseurs extends ModeleBoxes
{ {
global $user; 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));
} }
/** /**

View File

@ -52,9 +52,9 @@ class box_graph_propales_permonth extends ModeleBoxes
{ {
global $user; global $user;
$this->db=$db; $this->db = $db;
$this->hidden=! ($user->rights->propale->lire); $this->hidden = ! ($user->rights->propale->lire);
} }
/** /**

View File

@ -65,7 +65,7 @@ class box_members extends ModeleBoxes
$listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
if (! in_array('adherent', $listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users 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);
} }
/** /**

View File

@ -64,7 +64,7 @@ class box_produits extends ModeleBoxes
$listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); $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'); $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); $showmode=isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
$this->hidden=($showmode != 1); $this->hidden = ($showmode != 1);
} }
/** /**

View File

@ -66,7 +66,7 @@ class box_produits_alerte_stock extends ModeleBoxes
$listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); $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'); $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); $showmode=isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
$this->hidden=($showmode != 1); $this->hidden = ($showmode != 1);
} }
/** /**

View File

@ -59,9 +59,9 @@ class box_project extends ModeleBoxes
$langs->loadLangs(array('boxes', 'projects')); $langs->loadLangs(array('boxes', 'projects'));
$this->db = $db; $this->db = $db;
$this->boxlabel="OpenedProjects"; $this->boxlabel = "OpenedProjects";
$this->hidden=! ($user->rights->projet->lire); $this->hidden = ! ($user->rights->projet->lire);
} }
/** /**

View File

@ -58,9 +58,9 @@ class box_propales extends ModeleBoxes
{ {
global $user; global $user;
$this->db=$db; $this->db = $db;
$this->hidden=! ($user->rights->propale->lire); $this->hidden = ! ($user->rights->propale->lire);
} }
/** /**

View File

@ -65,7 +65,7 @@ class box_prospect extends ModeleBoxes
// disable box for such cases // disable box for such cases
if (! empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled=0; // disabled by this option 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));
} }
/** /**

View File

@ -58,9 +58,9 @@ class box_services_contracts extends ModeleBoxes
{ {
global $user; 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);
} }
/** /**

View File

@ -56,9 +56,9 @@ class box_services_expired extends ModeleBoxes
{ {
global $user; global $user;
$this->db=$db; $this->db = $db;
$this->hidden=! ($user->rights->contrat->lire); $this->hidden = ! ($user->rights->contrat->lire);
} }
/** /**

View File

@ -56,9 +56,9 @@ class box_supplier_orders extends ModeleBoxes
{ {
global $user; global $user;
$this->db=$db; $this->db = $db;
$this->hidden=! ($user->rights->fournisseur->commande->lire); $this->hidden = ! ($user->rights->fournisseur->commande->lire);
} }
/** /**

View File

@ -54,7 +54,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
public $enabled=1; 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; public $hidden=0;

View File

@ -497,8 +497,16 @@ abstract class CommonDocGenerator
$resarray['object_total_up'] = $totalUp; $resarray['object_total_up'] = $totalUp;
$resarray['object_total_up_locale'] = price($resarray['object_total_up'], 0, $outputlangs); $resarray['object_total_up_locale'] = price($resarray['object_total_up'], 0, $outputlangs);
if (method_exists($object, 'getTotalDiscount')) { 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); $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 //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'])); $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]]; $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') elseif($extrafields->attribute_type[$key] == 'date')
{ {
if (strlen($object->array_options['options_'.$key])>0) if (strlen($object->array_options['options_'.$key])>0)

View File

@ -177,6 +177,7 @@ class Conf
if ($value && preg_match('/^MAIN_MODULE_/', $key)) 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 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)) 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_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 (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 // For backward compatibility
if (isset($this->product)) $this->produit=$this->product; if (isset($this->product)) $this->produit=$this->product;
if (isset($this->facture)) $this->invoice=$this->facture; if (isset($this->facture)) $this->invoice=$this->facture;

View File

@ -1903,6 +1903,15 @@ class Form
$price_level = (! empty($price_level) ? $price_level : 0); $price_level = (! empty($price_level) ? $price_level : 0);
if (is_null($ajaxoptions)) $ajaxoptions=array(); 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)) if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT))
{ {
$placeholder=''; $placeholder='';

View File

@ -1381,7 +1381,7 @@ class FormFile
if (! empty($conf->dol_use_jmobile)) $useajax=0; if (! empty($conf->dol_use_jmobile)) $useajax=0;
if (empty($conf->use_javascript_ajax)) $useajax=0; if (empty($conf->use_javascript_ajax)) $useajax=0;
if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0;
print '<a href="'.((($useinecm && $useinecm != 6) && $useajax)?'#':($url.'?action=delete&urlfile='.urlencode($filepath).$param)).'" class="deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>'; print '<a href="'.((($useinecm && $useinecm != 6) && $useajax)?'#':($url.'?action=delete&urlfile='.urlencode($filepath).$param)).'" class="reposition deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>';
} }
print "</td>"; print "</td>";

View File

@ -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 $htmlname Name of select zone
* @param string $selected Selected value * @param string $selected Selected value
* @param int $useempty 1=Add an empty value in list * @param int $useempty 1=Add an empty value in list
* @param string $moreattrib More attributes on HTML select tag * @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 = '') public function selectSampleOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '')
{ {

View File

@ -944,7 +944,7 @@ class Ldap
// Only one entry should ever be returned // Only one entry should ever be returned
$entry = ldap_first_entry($this->connection, $search); $entry = ldap_first_entry($this->connection, $search);
if (!$entry) if (! $entry)
{ {
$this->ldapErrorCode = -1; $this->ldapErrorCode = -1;
$this->ldapErrorText = "Couldn't find entry"; $this->ldapErrorText = "Couldn't find entry";
@ -952,7 +952,7 @@ class Ldap
} }
// Get values // 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->ldapErrorCode = ldap_errno($this->connection);
$this->ldapErrorText = ldap_error($this->connection); $this->ldapErrorText = ldap_error($this->connection);

View File

@ -1033,6 +1033,7 @@ class Lessc {
return $this->lib_e($items[0]); return $this->lib_e($items[0]);
} }
$this->throwError("unrecognised input"); $this->throwError("unrecognised input");
return null;
case "string": case "string":
$arg[1] = ""; $arg[1] = "";
return $arg; return $arg;
@ -1050,6 +1051,7 @@ class Lessc {
$template = $this->compileValue($this->lib_e($string)); $template = $this->compileValue($this->lib_e($string));
$i = 0; $i = 0;
$m = array();
if (preg_match_all('/%[dsa]/', $template, $m)) { if (preg_match_all('/%[dsa]/', $template, $m)) {
foreach ($m[0] as $match) { foreach ($m[0] as $match) {
$val = isset($values[$i]) ? $val = isset($values[$i]) ?

View File

@ -355,22 +355,27 @@ class Link extends CommonObject
/** /**
* Delete a link from database * 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); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$error = 0; $error = 0;
$this->db->begin();
// Call trigger // Call trigger
$result=$this->call_trigger('LINK_DELETE', $user); $result=$this->call_trigger('LINK_DELETE', $user);
if ($result < 0) return -1; if ($result < 0)
{
$this->db->rollback();
return -1;
}
// End call triggers // End call triggers
$this->db->begin();
// Remove link // Remove link
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "links"; $sql = "DELETE FROM " . MAIN_DB_PREFIX . "links";
$sql.= " WHERE rowid = " . $this->id; $sql.= " WHERE rowid = " . $this->id;

View File

@ -299,7 +299,7 @@ class SimpleOpenID
* @param string $url URL * @param string $url URL
* @param string $method Method * @param string $method Method
* @param string $params Params * @param string $params Params
* @return boolean|unknown * @return boolean|void True if success, False if error
*/ */
public function FSOCK_Request($url, $method = "GET", $params = "") public function FSOCK_Request($url, $method = "GET", $params = "")
{ {

View File

@ -316,27 +316,29 @@ class Utils
// TODO Replace with executeCLI function // TODO Replace with executeCLI function
if ($execmethod == 1) if ($execmethod == 1)
{ {
exec($fullcommandclear, $readt, $retval); $output_arr = array(); $retval = null;
$result = $retval; exec($fullcommandclear, $output_arr, $retval);
if ($retval != 0) if ($retval != 0)
{ {
$langs->load("errors"); $langs->load("errors");
dol_syslog("Datadump retval after exec=".$retval, LOG_ERR); dol_syslog("Datadump retval after exec=".$retval, LOG_ERR);
$error = 'Error '.$retval; $errormsg = 'Error '.$retval;
$ok=0; $ok=0;
} }
else else
{ {
$i=0; $i=0;
if (!empty($readt)) if (!empty($output_arr))
foreach($readt as $key=>$read)
{ {
$i++; // output line number foreach($output_arr as $key => $read)
if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue; {
fwrite($handle, $read.($execmethod == 2 ? '' : "\n")); $i++; // output line number
if (preg_match('/'.preg_quote('-- Dump completed').'/i', $read)) $ok=1; if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue;
elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i', $read)) $ok=1; 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) if ($execmethod == 1)
{ {
$retval = null;
exec($command, $output_arr, $retval); exec($command, $output_arr, $retval);
$result = $retval; $result = $retval;
if ($retval != 0) 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 if ($execmethod == 2) // With this method, there is no way to get the return code, only output
{ {
$ok=0;
$handle = fopen($outputfile, 'w+b'); $handle = fopen($outputfile, 'w+b');
if ($handle) if ($handle)
{ {

View File

@ -223,7 +223,7 @@ interface Database
* @param string $name name of database (not used for mysql, used for pgsql) * @param string $name name of database (not used for mysql, used for pgsql)
* @param int $port Port of database server * @param int $port Port of database server
* @return resource Database access handler * @return resource Database access handler
* @see close * @see close()
*/ */
public function connect($host, $login, $passwd, $name, $port = 0); public function connect($host, $login, $passwd, $name, $port = 0);
@ -265,7 +265,7 @@ interface Database
* *
* @param resource $resultset Resulset of requests * @param resource $resultset Resulset of requests
* @return int Nb of lines * @return int Nb of lines
* @see affected_rows * @see affected_rows()
*/ */
public function num_rows($resultset); public function num_rows($resultset);
// phpcs:enable // phpcs:enable
@ -461,7 +461,7 @@ interface Database
* Close database connexion * Close database connexion
* *
* @return boolean True if disconnect successfull, false otherwise * @return boolean True if disconnect successfull, false otherwise
* @see connect * @see connect()
*/ */
public function close(); public function close();

View File

@ -607,7 +607,7 @@ class DoliDBPgsql extends DoliDB
/** /**
* Return number of lines for result of a SELECT * 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 * @return int Nb of lines, -1 on error
* @see affected_rows() * @see affected_rows()
*/ */

View File

@ -549,15 +549,13 @@ function calendars_prepare_head($param)
$h++; $h++;
$object=new stdClass();
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // 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:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a 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; return $head;
} }

View File

@ -48,7 +48,7 @@ function asset_admin_prepare_head()
//$this->tabs = array( //$this->tabs = array(
// 'entity:-tabname:Title:@assets:/asset/mypage.php?id=__ID__' // 'entity:-tabname:Title:@assets:/asset/mypage.php?id=__ID__'
//); // to remove a tab //); // 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][0] = DOL_URL_ROOT . '/asset/admin/assets_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields"); $head[$h][1] = $langs->trans("ExtraFields");
@ -60,7 +60,7 @@ function asset_admin_prepare_head()
$head[$h][2] = 'attributes_type'; $head[$h][2] = 'attributes_type';
$h++; $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; return $head;
} }
@ -68,11 +68,12 @@ function asset_admin_prepare_head()
/** /**
* Prepare admin pages header * Prepare admin pages header
* *
* @param Contrat $object Object related to tabs
* @return array head array with 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"); $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/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.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)$')); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks=Link::count($db, $object->element, $object->id); $nbLinks=Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id;

View File

@ -163,7 +163,6 @@ function bank_admin_prepare_head($object)
*/ */
function various_payment_prepare_head($object) function various_payment_prepare_head($object)
{ {
global $db, $langs, $conf; global $db, $langs, $conf;
$h = 0; $h = 0;

View File

@ -101,7 +101,7 @@ function contract_prepare_head(Contrat $object)
*/ */
function contract_admin_prepare_head() function contract_admin_prepare_head()
{ {
global $langs, $conf, $user; global $langs, $conf;
$h = 0; $h = 0;
$head = array(); $head = array();
@ -127,9 +127,7 @@ function contract_admin_prepare_head()
$head[$h][2] = 'attributeslines'; $head[$h][2] = 'attributeslines';
$h++; $h++;
complete_head_from_modules($conf, $langs, null, $head, $h, 'contract_admin', 'remove'); complete_head_from_modules($conf, $langs, null, $head, $h, 'contract_admin', 'remove');
return $head; return $head;
} }

View File

@ -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/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.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)$')); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks=Link::count($db, $object->element, $object->id); $nbLinks=Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id;

View File

@ -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); else
// 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 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); 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 $inputfile Source file name
* @param string $outputfile Target file name * @param string $outputfile Target file name
* @param string $mode 'gz' or 'bz' or 'zip' * @param string $mode 'gz' or 'bz' or 'zip'
* @param string $errorstring Error string
* @return int <0 if KO, >0 if OK * @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; global $conf;
@ -1913,8 +1918,12 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz")
$zip = new ZipArchive; $zip = new ZipArchive;
if ($zip->open($outputfile, ZipArchive::CREATE) !== true) { if ($zip->open($outputfile, ZipArchive::CREATE) !== true) {
$errormsg="Failed to open file ".$outputfile."\n"; $errorstring="dol_compress_file failure - Failed to open file ".$outputfile."\n";
dol_syslog("dol_compress_file failure - ".$errormsg, LOG_ERR); dol_syslog($errorstring, LOG_ERR);
global $errormsg;
$errormsg = $errorstring;
return -6; return -6;
} }
@ -1958,12 +1967,16 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz")
{ {
global $errormsg; global $errormsg;
$errormsg=$archive->errorInfo(true); $errormsg=$archive->errorInfo(true);
dol_syslog("dol_compress_file failure - ".$errormsg, LOG_ERR);
if ($archive->errorCode() == PCLZIP_ERR_WRITE_OPEN_FAIL) 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; return -4;
} }
$errorstring = "dol_compress_file error archive->errorCode = ".$archive->errorCode()." errormsg=".$errormsg;
dol_syslog("dol_compress_file failure - ".$errormsg, LOG_ERR);
return -3; return -3;
} }
else else
@ -1983,7 +1996,11 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz")
} }
else 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; return -2;
} }
} }
@ -1991,8 +2008,10 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz")
{ {
global $langs, $errormsg; global $langs, $errormsg;
$langs->load("errors"); $langs->load("errors");
dol_syslog("Failed to open file ".$outputfile, LOG_ERR);
$errormsg=$langs->trans("ErrorFailedToWriteInDir"); $errormsg=$langs->trans("ErrorFailedToWriteInDir");
$errorstring = "Failed to open file ".$outputfile;
dol_syslog($errorstring, LOG_ERR);
return -1; return -1;
} }
} }
@ -2063,13 +2082,14 @@ function dol_uncompress($inputfile, $outputdir)
* @param string $inputdir Source dir name * @param string $inputdir Source dir name
* @param string $outputfile Target file name (output directory must exists and be writable) * @param string $outputfile Target file name (output directory must exists and be writable)
* @param string $mode 'zip' * @param string $mode 'zip'
* @param string $excludefiles A regex pattern. For example: '/\.log$|\/temp\//'
* @return int <0 if KO, >0 if OK * @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; $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))) if (! dol_is_dir(dirname($outputfile)) || ! is_writable(dirname($outputfile)))
{ {
@ -2096,6 +2116,7 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip")
return 1; return 1;
} }
else*/ else*/
//if (class_exists('ZipArchive') && ! empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_COMPRESS))
if (class_exists('ZipArchive')) if (class_exists('ZipArchive'))
{ {
$foundhandler=1; $foundhandler=1;
@ -2103,6 +2124,13 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip")
// Initialize archive object // Initialize archive object
$zip = new ZipArchive(); $zip = new ZipArchive();
$result = $zip->open($outputfile, ZipArchive::CREATE | ZipArchive::OVERWRITE); $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 // Create recursive directory iterator
/** @var SplFileInfo[] $files */ /** @var SplFileInfo[] $files */
@ -2119,9 +2147,11 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip")
// Get real and relative path for current file // Get real and relative path for current file
$filePath = $file->getRealPath(); $filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($inputdir) + 1); $relativePath = substr($filePath, strlen($inputdir) + 1);
if (empty($excludefiles) || ! preg_match($excludefiles, $filePath))
// Add current file to archive {
$zip->addFile($filePath, $relativePath); // Add current file to archive
$zip->addFile($filePath, $relativePath);
}
} }
} }

View File

@ -816,8 +816,10 @@ function dol_size($size, $type = '')
*/ */
function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1) 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 // List of special chars for filenames in windows are defined on page https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
$filesystem_forbidden_chars = array('<', '>', '/', '\\', '?', '*', '|', '"', ':', '°'); // 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); 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 string $stringtoescape String to escape
* @param int $keepb 1=Preserve b tags (otherwise, remove them) * @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 <textarea>. * @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value). Set to 1 when escaping for a <textarea>.
* @param string $keepmoretags '' or 'common' or list of tags
* @return string Escaped string * @return string Escaped string
* @see dol_string_nohtmltag(), dol_string_nospecial(), dol_string_unaccent() * @see dol_string_nohtmltag(), dol_string_nospecial(), dol_string_unaccent()
*/ */
function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0) function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $keepmoretags = '')
{ {
if ($keepmoretags == 'common') $keepmoretags = 'html,body,a,em,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody';
// TODO Implement $keepmoretags
// escape quotes and backslashes, newlines, etc. // escape quotes and backslashes, newlines, etc.
$tmp=html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags $tmp=html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags
if (! $keepb) $tmp=strtr($tmp, array("<b>"=>'','</b>'=>'')); if (! $keepb) $tmp=strtr($tmp, array("<b>"=>'','</b>'=>''));
@ -3861,6 +3867,8 @@ function dol_print_error($db = '', $error = '', $errors = null)
if (empty($dolibarr_main_prod)) print $out; if (empty($dolibarr_main_prod)) print $out;
else else
{ {
print 'This website is currently temporarly offline. This may be due to a maintenance operation. Current status of operation are on next line...<br><br>'."\n";
$langs->load("errors");
print $langs->trans("DolibarrHasDetectedError").'. '; print $langs->trans("DolibarrHasDetectedError").'. ';
print $langs->trans("YouCanSetOptionDolibarrMainProdToZero"); print $langs->trans("YouCanSetOptionDolibarrMainProdToZero");
define("MAIN_CORE_ERROR", 1); define("MAIN_CORE_ERROR", 1);
@ -5564,7 +5572,7 @@ function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml = false)
/** /**
* This function is called to encode a string into a HTML string but differs from htmlentities because * This function is called to encode a string into a HTML string but differs from htmlentities because
* a detection is done before to see if text is already HTML or not. Also, all entities but &,<,> are converted. * a detection is done before to see if text is already HTML or not. Also, all entities but &,<,>," are converted.
* This permits to encode special chars to entities with no double encoding for already encoded HTML strings. * This permits to encode special chars to entities with no double encoding for already encoded HTML strings.
* This function also remove last EOL or BR if $removelasteolbr=1 (default). * This function also remove last EOL or BR if $removelasteolbr=1 (default).
* For PDF usage, you can show text by 2 ways: * For PDF usage, you can show text by 2 ways:

View File

@ -124,7 +124,7 @@ function show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass)
} }
else else
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action='.$testlabel.'">'.$butlabel.'</a>'; print '<a class="butAction reposition" href="'.$_SERVER["PHP_SELF"].'?action='.$testlabel.'">'.$butlabel.'</a>';
} }
print '<br><br>'; print '<br><br>';
} }

View File

@ -40,7 +40,7 @@ function multicurrencyAdminPrepareHead()
$head[$h][2] = 'settings'; $head[$h][2] = 'settings';
$h++; $h++;
complete_head_from_modules($conf, $langs, $object, $head, $h, 'multicurrency'); complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency');
return $head; return $head;
} }

View File

@ -271,7 +271,7 @@ $list = array (
*/ */
function oauthadmin_prepare_head() function oauthadmin_prepare_head()
{ {
global $langs, $conf, $user; global $langs, $conf;
$h = 0; $h = 0;
$head = array(); $head = array();

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