diff --git a/.travis.yml b/.travis.yml index b9211e5b435..1cf17b17f95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -85,6 +85,9 @@ before_install: if [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then sudo apt install unzip apache2 php7.1 php7.1-cli php7.1-curl php7.1-mysql php7.1-pgsql php7.1-gd php7.1-imap php7.1-intl php7.1-ldap php7.1-xml php7.1-mbstring php7.1-xml php7.1-zip libapache2-mod-php7.1 fi + if [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then + sudo apt install unzip apache2 php7.1 php7.1-cli php7.1-curl php7.1-mysql php7.1-pgsql php7.1-gd php7.1-imap php7.1-intl php7.1-ldap php7.1-xml php7.1-mbstring php7.1-xml php7.1-zip libapache2-mod-php7.1 + fi if [ "$TRAVIS_PHP_VERSION" = '8.1' ]; then sudo apt install unzip apache2 php8.1 php8.1-cli php8.1-curl php8.1-mysql php8.1-pgsql php8.1-gd php8.1-imap php8.1-intl php8.1-ldap php8.1-xml php8.1-mbstring php8.1-xml php8.1-zip libapache2-mod-php8.1 fi @@ -125,6 +128,9 @@ before_install: install: - | + if [ "$TRAVIS_PHP_VERSION" = '7.0' ]; then + sudo update-alternatives --set php /usr/bin/php7.0 + fi if [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then sudo update-alternatives --set php /usr/bin/php7.1 fi diff --git a/ChangeLog b/ChangeLog index 8e55b6b3d25..40ee2daf181 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2274,7 +2274,7 @@ Following changes may create regressions for some external modules, but were nec ***** ChangeLog for 17.0.4 compared to 17.0.3 ***** -FIX: $this->newref already exists and could have been modified by trigger but we still use a local variable for the filesystem-based renaming +FIX: $this->newref already exists and could have been modified by a trigger but we still use a local variable for the filesystem-based renaming FIX: 16.0 only, backport fix for SQL error on global search product FIX: 17.0: deprecated field should only be a fallback FIX: 17.0 PHP8: supplier invoice class: diff --git a/dev/build/makepack-dolibarr.pl b/dev/build/makepack-dolibarr.pl index 2d11cb546b5..c7541455035 100755 --- a/dev/build/makepack-dolibarr.pl +++ b/dev/build/makepack-dolibarr.pl @@ -1051,7 +1051,7 @@ if ($nboftargetok) { $ret=`cp -fr "$SOURCE/dev/build/debian/apache" "$BUILDROOT/$PROJECT.tmp/debian/apache"`; $ret=`cp -f "$SOURCE/dev/build/debian/apache/.htaccess" "$BUILDROOT/$PROJECT.tmp/debian/apache"`; $ret=`cp -fr "$SOURCE/dev/build/debian/lighttpd" "$BUILDROOT/$PROJECT.tmp/debian/lighttpd"`; - # Add files also required to dev/build binary package + # Add files also required to build binary package $ret=`cp -f "$SOURCE/dev/build/debian/dolibarr.config" "$BUILDROOT/$PROJECT.tmp/debian"`; $ret=`cp -f "$SOURCE/dev/build/debian/dolibarr.postinst" "$BUILDROOT/$PROJECT.tmp/debian"`; $ret=`cp -f "$SOURCE/dev/build/debian/dolibarr.postrm" "$BUILDROOT/$PROJECT.tmp/debian"`; diff --git a/dev/build/makepack-howto.md b/dev/build/makepack-howto.md index 2e034397ca2..84d1ad344a9 100644 --- a/dev/build/makepack-howto.md +++ b/dev/build/makepack-howto.md @@ -60,7 +60,7 @@ Prerequisites to build autoexe DoliWamp package from Windows: ## Actions to do a BETA -This files describe steps made by Dolibarr packaging team to make a beta version of Dolibarr, step by step. +This section describes steps made by Dolibarr packaging team to make a beta version of Dolibarr, step by step. - Check all files are committed. - Update version/info in ChangeLog, for this you can: diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 1a334eff40c..9b84c3a3790 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -3178,7 +3178,7 @@ class BookKeeping extends CommonObject $error++; } $objtmp = $this->db->fetch_object($result); - $bookkeeping->subledger_label = $objtmp->subledger_label; // latest subledger label used + $bookkeeping->subledger_label = $objtmp->subledger_label ?? null; // latest subledger label used } else { $bookkeeping->subledger_account = null; $bookkeeping->subledger_label = null; diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 14da007e650..f1e9bcc1e49 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -641,6 +641,27 @@ class AdvanceTargetingMailing extends CommonObject if ($arrayquery['options_'.$key] > 0) { $sqlwhere[] = " (te.".$key." = ".((int) $arrayquery["options_".$key]).")"; } + } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'chkbxlst' + && is_array($arrayquery['options_'.$key])) { + if (count($arrayquery['options_'.$key])) { + $i2 = 0; + $field = "te.".$key; + $sqlwhereselllist=""; + foreach ($arrayquery['options_'.$key] as $data) { + $data = trim($data); + if ($data) { + $sqlwhereselllist .= ($i2 > 0 ? " OR (" : "(").$field." LIKE '".$this->db->escape($data).",%'"; + $sqlwhereselllist .= " OR ".$field." = '".$this->db->escape($data)."'"; + $sqlwhereselllist .= " OR ".$field." LIKE '%,".$this->db->escape($data)."'"; + $sqlwhereselllist .= " OR ".$field." LIKE '%,".$this->db->escape($data).",%'"; + $sqlwhereselllist .= ")"; + $i2++; // a criteria for 1 more field was added to string (we can add several criteria for the same field as it is a multiselect search criteria) + } + } + if (!empty($sqlwhereselllist)) { + $sqlwhere[] = "( ".$sqlwhereselllist." )"; + } + } } else { if (is_array($arrayquery['options_'.$key])) { $sqlwhere[] = " (te.".$key." IN (".$this->db->sanitize("'".implode("','", $arrayquery["options_".$key])."'", 1)."))"; @@ -784,6 +805,31 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere[] = " (te.".$key." = ".((int) $arrayquery["options_".$key."_cnct"]).")"; } } + } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { + if ($arrayquery['options_'.$key."_cnct"] > 0) { + $sqlwhere[]= " (te.".$key." = ".((int) $arrayquery["options_".$key."_cnct"]).")"; + } + } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'chkbxlst' + && is_array($arrayquery['options_'.$key.'_cnct'])) { + if (count($arrayquery['options_'.$key.'_cnct'])) { + $i2 = 0; + $field = "te.".$key; + $sqlwhereselllist=""; + foreach ($arrayquery['options_'.$key.'_cnct'] as $data) { + $data = trim($data); + if ($data) { + $sqlwhereselllist .= ($i2 > 0 ? " OR (" : "(").$field." LIKE '".$this->db->escape($data).",%'"; + $sqlwhereselllist .= " OR ".$field." = '".$this->db->escape($data)."'"; + $sqlwhereselllist .= " OR ".$field." LIKE '%,".$this->db->escape($data)."'"; + $sqlwhereselllist .= " OR ".$field." LIKE '%,".$this->db->escape($data).",%'"; + $sqlwhereselllist .= ")"; + $i2++; // a criteria for 1 more field was added to string (we can add several criteria for the same field as it is a multiselect search criteria) + } + } + if (!empty($sqlwhereselllist)) { + $sqlwhere[] = "( ".$sqlwhereselllist." )"; + } + } } else { if (is_array($arrayquery['options_'.$key.'_cnct'])) { $sqlwhere[] = " (te.".$key." IN (".$this->db->sanitize("'".implode("','", $arrayquery["options_".$key."_cnct"])."'", 1)."))"; @@ -888,6 +934,31 @@ class AdvanceTargetingMailing extends CommonObject if ($arrayquery['options_'.$key] != '') { $sqlwhere[] = " (tse.".$key." = ".((int) $arrayquery["options_".$key]).")"; } + } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { + if ($arrayquery['options_'.$key] > 0) { + $sqlwhere[]= " (te.".$key." = ".((int) $arrayquery["options_".$key]).")"; + } + } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'chkbxlst' + && is_array($arrayquery['options_'.$key])) { + if (count($arrayquery['options_'.$key])) { + $i2 = 0; + $field = "tse.".$key; + $sqlwhereselllist=""; + foreach ($arrayquery['options_'.$key] as $data) { + $data = trim($data); + if ($data) { + $sqlwhereselllist .= ($i2 > 0 ? " OR (" : "(").$field." LIKE '".$this->db->escape($data).",%'"; + $sqlwhereselllist .= " OR ".$field." = '".$this->db->escape($data)."'"; + $sqlwhereselllist .= " OR ".$field." LIKE '%,".$this->db->escape($data)."'"; + $sqlwhereselllist .= " OR ".$field." LIKE '%,".$this->db->escape($data).",%'"; + $sqlwhereselllist .= ")"; + $i2++; // a criteria for 1 more field was added to string (we can add several criteria for the same field as it is a multiselect search criteria) + } + } + if (!empty($sqlwhereselllist)) { + $sqlwhere[] = "( ".$sqlwhereselllist." )"; + } + } } else { if (is_array($arrayquery['options_'.$key])) { $sqlwhere[] = " (tse.".$key." IN (".$this->db->sanitize("'".implode("','", $arrayquery["options_".$key])."'", 1)."))"; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 8123044ea62..cd48f2643eb 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1616,10 +1616,10 @@ class Invoices extends DolibarrApi * Warning: Take care that all invoices are owned by the same customer. * Example of value for parameter arrayofamounts: {"1": {"amount": "99.99", "multicurrency_amount": ""}, "2": {"amount": "", "multicurrency_amount": "10"}} * - * @param array $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice + * @param array $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice * @phan-param array $arrayofamounts * @phpstan-param array $arrayofamounts - * @param string $datepaye {@from body} Payment date + * @param string $datepaye {@from body} Payment date * @param int $paymentid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} * @param int $accountid {@from body} Account Id {@min 1} @@ -1704,13 +1704,13 @@ class Invoices extends DolibarrApi $amount = price2num($amountarray["multicurrency_amount"], 'MT'); } - if ($amount > $remainstopay && !$accepthigherpayment) { + if (abs($amount) > abs($remainstopay) && !$accepthigherpayment) { $this->db->rollback(); throw new RestException(400, 'Payment amount on invoice ID '.$id.' ('.$amount.') is higher than remain to pay ('.$remainstopay.')'); } if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { - $amount = price2num(-1 * (float) $amount, 'MT'); + $amount = price2num(-1 * abs((float) $amount), 'MT'); } if ($is_multicurrency) { diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index c491243ed0e..1dde412f429 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -184,7 +184,7 @@ if ($action == 'fetch' && !empty($id)) { $sql .= " WHERE fk_product = ".((int) $id); $sql .= " AND entity IN (".getEntity('productprice').")"; $sql .= " AND price_level = ".((int) $price_level); - $sql .= " ORDER BY date_price"; + $sql .= " ORDER BY date_price DESC, rowid"; $sql .= " DESC LIMIT 1"; $result = $db->query($sql); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 5633f9a8ad2..a579de66f01 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -285,6 +285,9 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $error++; } + //If timespent date is not provided in POST (for eg, because in list the column date is hidden) we keep the actual date + $timespent_date = dol_mktime(12, 0, 0, GETPOSTINT("timelinemonth"), GETPOSTINT("timelineday"), GETPOSTINT("timelineyear")); + if (!$error) { if (GETPOSTINT('taskid') != $id) { // GETPOST('taskid') is id of new task $id_temp = GETPOSTINT('taskid'); // should not overwrite $id @@ -300,11 +303,11 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_old_duration = GETPOSTINT("old_duration"); $object->timespent_duration = GETPOSTINT("new_durationhour") * 60 * 60; // We store duration in seconds $object->timespent_duration += (GETPOSTINT("new_durationmin") ? GETPOSTINT('new_durationmin') : 0) * 60; // We store duration in seconds - if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered + if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0 && !empty($timespent_date)) { // If hour was entered $object->timespent_date = dol_mktime(GETPOSTINT("timelinehour"), GETPOSTINT("timelinemin"), 0, GETPOSTINT("timelinemonth"), GETPOSTINT("timelineday"), GETPOSTINT("timelineyear")); $object->timespent_withhour = 1; - } else { - $object->timespent_date = dol_mktime(12, 0, 0, GETPOSTINT("timelinemonth"), GETPOSTINT("timelineday"), GETPOSTINT("timelineyear")); + } elseif (!empty($timespent_date)) { + $object->timespent_date = $timespent_date; $object->timespent_withhour = 0; } $object->timespent_fk_user = GETPOSTINT("userid_line"); @@ -325,7 +328,8 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } else { $object->fetch($id, $ref); - $object->timespent_id = GETPOSTINT("lineid"); + $object->fetchTimeSpent(GETPOSTINT('lineid')); + $object->timespent_note = GETPOST("timespent_note_line", "alphanohtml"); $object->timespent_old_duration = GETPOSTINT("old_duration"); $object->timespent_duration = GETPOSTINT("new_durationhour") * 60 * 60; // We store duration in seconds @@ -333,8 +337,8 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered $object->timespent_date = dol_mktime(GETPOSTINT("timelinehour"), GETPOSTINT("timelinemin"), 0, GETPOSTINT("timelinemonth"), GETPOSTINT("timelineday"), GETPOSTINT("timelineyear")); $object->timespent_withhour = 1; - } else { - $object->timespent_date = dol_mktime(12, 0, 0, GETPOSTINT("timelinemonth"), GETPOSTINT("timelineday"), GETPOSTINT("timelineyear")); + } elseif (!empty($timespent_date)) { + $object->timespent_date = $timespent_date; $object->timespent_withhour = 0; } $object->timespent_fk_user = GETPOSTINT("userid_line");