diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index c44caecb710..1df42a44853 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -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')); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 5d22fb3f0fe..55416f01341 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -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)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 26971221bab..79822f7883d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -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; } } diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 344ac3e1ac4..8a91047c665 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -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); } diff --git a/htdocs/multicurrency/class/api_multicurrencies.class.php b/htdocs/multicurrency/class/api_multicurrencies.class.php index 50dff7401cc..ade16c56664 100644 --- a/htdocs/multicurrency/class/api_multicurrencies.class.php +++ b/htdocs/multicurrency/class/api_multicurrencies.class.php @@ -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 = ''; diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 8f4af567800..f5fe2aceea3 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -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); diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 01d197f0737..f69bb7ba07e 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -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();