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

This commit is contained in:
Laurent Destailleur (aka Eldy) 2025-02-05 00:41:07 +01:00
commit 62b1fbc41d
7 changed files with 30 additions and 21 deletions

View File

@ -139,9 +139,9 @@ if ($action == 'add_currency') {
}
} elseif ($action == 'setapilayer') {
if (GETPOSTISSET('modify_apilayer')) {
dolibarr_set_const($db, 'MULTICURRENCY_APP_ID', GETPOST('MULTICURRENCY_APP_ID', 'alpha'));
dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha'));
//dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha'));
dolibarr_set_const($db, 'MULTICURRENCY_APP_ID', GETPOST('MULTICURRENCY_APP_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha'), 'chaine', 0, '', $conf->entity);
//dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha'), 'chaine', 0, '', $conf->entity);
} else {
$multiurrency = new MultiCurrency($db);
$result = $multiurrency->syncRates(getDolGlobalString('MULTICURRENCY_APP_ID'));

View File

@ -3942,7 +3942,7 @@ class Facture extends CommonInvoice
if (empty($fk_prev_id)) {
$fk_prev_id = 'null';
}
if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') {
if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '' || $situation_percent == null) {
$situation_percent = 100;
}
if (empty($ref_ext)) {
@ -4220,7 +4220,7 @@ class Facture extends CommonInvoice
if (empty($special_code) || $special_code == 3) {
$special_code = 0;
}
if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') {
if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '' || $situation_percent == null) {
$situation_percent = 100;
}
if (empty($ref_ext)) {

View File

@ -7020,7 +7020,7 @@ class Form
// Keep only the VAT qualified for $type_vat
$arrayofvatrates = array();
foreach ($this->cache_vatrates as $cachevalue) {
if (empty($cachevalue['type_vat']) || $cachevalue['type_vat'] != $type_vat) {
if (empty($cachevalue['type_vat']) || $cachevalue['type_vat'] == $type_vat) {
$arrayofvatrates[] = $cachevalue;
}
}

View File

@ -2938,7 +2938,7 @@ class EmailCollector extends CommonObject
$this->errors = $actioncomm->errors;
} else {
if ($fk_element_type == "ticket" && is_object($objectemail)) {
if ($objectemail->status == Ticket::STATUS_CLOSED || $objectemail->status == Ticket::STATUS_CANCELED) {
if ($objectemail->status == Ticket::STATUS_CLOSED || $objectemail->status == Ticket::STATUS_CANCELED || $objectemail->status == Ticket::STATUS_NEED_MORE_INFO || $objectemail->status == Ticket::STATUS_WAITING) {
if ($objectemail->fk_user_assign != null) {
$res = $objectemail->setStatut(Ticket::STATUS_ASSIGNED);
} else {
@ -3414,6 +3414,13 @@ class EmailCollector extends CommonObject
$tickettocreate->context['actionmsg'] = $langs->trans("ActionAC_EMAIL_IN").' - '.$langs->trans("TICKET_CREATEInDolibarr");
//$tickettocreate->email_fields_no_propagate_in_actioncomm = 0;
// Add sender to context array to make sure that confirmation e-mail can be sent by trigger script
$sender_contact = new Contact($this->db);
$sender_contact->fetch(0, null, '', $from);
if (!empty($sender_contact->id)) {
$tickettocreate->context['contactid'] = $sender_contact->id;
}
$result = $tickettocreate->create($user);
if ($result <= 0) {
$errorforactions++;
@ -3429,7 +3436,7 @@ class EmailCollector extends CommonObject
foreach ($attachments as $attachment) {
// $attachment->save($destdir.'/');
$typeattachment = (string) $attachment->getDisposition();
$filename = $attachment->getFilename();
$filename = $attachment->getName();
$content = $attachment->getContent();
$this->saveAttachment($destdir, $filename, $content);
}

View File

@ -66,7 +66,7 @@ class MultiCurrencies extends DolibarrApi
$sql = "SELECT t.rowid";
$sql .= " FROM ".$this->db->prefix()."multicurrency as t";
$sql .= ' WHERE 1 = 1';
$sql .= " WHERE t.entity IN (".getEntity('multicurrency').")";
// Add sql filters
if ($sqlfilters) {
$errormessage = '';

View File

@ -190,13 +190,11 @@ class MultiCurrency extends CommonObject
{
dol_syslog('MultiCurrency::fetch', LOG_DEBUG);
global $conf;
$sql = "SELECT";
$sql .= ' c.rowid, c.name, c.code, c.entity, c.date_create, c.fk_user';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' AS c';
$sql = "SELECT c.rowid, c.name, c.code, c.entity, c.date_create, c.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." AS c";
if (!empty($code)) {
$sql .= ' WHERE c.code = \''.$this->db->escape($code).'\' AND c.entity = '.$conf->entity;
$sql .= " WHERE c.code = '".$this->db->escape($code)."'";
$sql .= " AND c.entity IN (".getEntity($this->element).")";
} else {
$sql .= ' WHERE c.rowid = '.((int) $id);
}
@ -242,9 +240,10 @@ class MultiCurrency extends CommonObject
public function fetchAllCurrencyRate()
{
$sql = "SELECT cr.rowid";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as cr';
$sql .= ' WHERE cr.fk_multicurrency = '.((int) $this->id);
$sql .= ' ORDER BY cr.date_sync DESC';
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element_line." as cr";
$sql .= " WHERE cr.entity IN (".getEntity($this->element).")";
$sql .= " AND cr.fk_multicurrency = ".((int) $this->id);
$sql .= " ORDER BY cr.date_sync DESC";
$this->rates = array();
@ -480,8 +479,10 @@ class MultiCurrency extends CommonObject
{
$sql = "SELECT cr.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element_line." as cr";
$sql .= " WHERE cr.fk_multicurrency = ".((int) $this->id);
$sql .= " AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX.$this->table_element_line." AS cr2 WHERE cr2.fk_multicurrency = ".((int) $this->id).")";
$sql .= " WHERE cr.entity IN (".getEntity($this->element).")";
$sql .= " AND cr.fk_multicurrency = ".((int) $this->id);
$sql .= " AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX.$this->table_element_line." AS cr2";
$sql .= " WHERE cr2.entity IN (".getEntity($this->element).") AND cr2.fk_multicurrency = ".((int) $this->id).")";
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);

View File

@ -362,7 +362,8 @@ if ($search_rate) {
if ($search_code) {
$sql .= natural_search('m.code', $search_code);
}
$sql .= " WHERE m.code <> '".$db->escape($conf->currency)."'";
$sql .= " WHERE cr.entity IN (".getEntity('multicurrency').")";
$sql .= " AND m.code <> '".$db->escape($conf->currency)."'";
// Add where from hooks
$parameters = array();