diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e18e8d78afd..192c1a1c0f6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3943,7 +3943,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)) { @@ -4207,7 +4207,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/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 87aebb5c6eb..70d746be584 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -10472,7 +10472,7 @@ abstract class CommonObject } // Create lines - if (!empty($this->table_element_line) && !empty($this->fk_element)) { + if (!empty($this->table_element_line) && !empty($this->fk_element) && !empty($this->lines)) { foreach ($this->lines as $line) { $keyforparent = $this->fk_element; $line->$keyforparent = $this->id; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fefa4a3fa83..c7df20a40cb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7000,7 +7000,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/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index a6012f37864..17c461f6025 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1588,7 +1588,9 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, } } } else { - $ok = false; // to avoid false positive + if (empty($nophperrors)) { + $ok = false; // to avoid false positive + } dol_syslog("No files to delete found", LOG_DEBUG); } } else { diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 0cbbbb0dd8b..171abd78213 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -604,15 +604,10 @@ class modAgenda extends DolibarrModules */ public function init($options = '') { - global $conf; - // Permissions $this->remove($options); - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type='action' AND entity = ".((int) $conf->entity), - // "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','action',".((int) $conf->entity).")" - ); + $sql = array(); return $this->_init($sql, $options); } diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 344c25a7baf..dcab6c1f349 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/holiday/document.php b/htdocs/holiday/document.php index f671fe90cd9..db579e5ab5f 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -104,7 +104,7 @@ if (($id > 0) || $ref) { } -$upload_dir = $conf->holiday->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, ''); +$upload_dir = $conf->holiday->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, ''); $modulepart = 'holiday'; // Protection if external user @@ -303,7 +303,7 @@ if ($object->id) { $permissiontoadd = $user->hasRight('holiday', 'write'); $permtoedit = $user->hasRight('holiday', 'write'); $param = '&id='.$object->id; - $relativepathwithnofile = dol_sanitizeFileName($object->ref).'/'; + $relativepathwithnofile = get_exdir(0, 0, 0, 1, $object, '').'/'; $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__'; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 6a69f9575b2..67c2d00fc78 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4157,7 +4157,7 @@ function migrate_delete_old_files($db, $langs, $conf) //print ''DOL_DOCUMENT_ROOT.$filetodelete."
\n"; if (preg_match('/\*/', $filetodelete) || file_exists(DOL_DOCUMENT_ROOT.$filetodelete)) { //print "Process file ".$filetodelete."\n"; - $result = dol_delete_file(DOL_DOCUMENT_ROOT.$filetodelete, 0, 0, 0, null, true, 0); + $result = dol_delete_file(DOL_DOCUMENT_ROOT.$filetodelete, 0, (preg_match('/\*/', $filetodelete) ? 1 : 0), 0, null, true, 0); if (!$result) { $langs->load("errors"); print '
'.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteFile", DOL_DOCUMENT_ROOT.$filetodelete);