diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9d67c420e51..48577e33ef7 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -580,11 +580,11 @@ class CommandeFournisseur extends CommonOrder $soc->fetch($this->fourn_id); // Check if object has a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) { // empty should not happened, but when it occurs, the test save life - $num = $this->getNextNumRef($soc); - } else { - $num = $this->ref; - } + if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) { // empty should not happened, but when it occurs, the test save life + $num = $this->getNextNumRef($soc); + } else { + $num = $this->ref; + } $this->newref = dol_sanitizeFileName($num); $sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur"; @@ -596,75 +596,75 @@ class CommandeFournisseur extends CommonOrder $sql .= " AND fk_statut = ".self::STATUS_DRAFT; $resql = $this->db->query($sql); - if (!$resql) { - dol_print_error($this->db); + if (!$resql) { + dol_print_error($this->db); + $error++; + } + + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('ORDER_SUPPLIER_VALIDATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('ORDER_SUPPLIER_VALIDATE', $user); - if ($result < 0) { - $error++; + if (!$error) { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) { + // Now we rename also files into index + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'fournisseur/commande/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'fournisseur/commande/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->error = $this->db->lasterror(); } - // End call triggers - } - if (!$error) { - $this->oldref = $this->ref; + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->fournisseur->commande->dir_output.'/'.$oldref; + $dirdest = $conf->fournisseur->commande->dir_output.'/'.$newref; + if (!$error && file_exists($dirsource)) { + dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); - // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'fournisseur/commande/".$this->db->escape($this->newref)."'"; - $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'fournisseur/commande/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; $this->error = $this->db->lasterror(); - } - - // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments - $oldref = dol_sanitizeFileName($this->ref); - $newref = dol_sanitizeFileName($num); - $dirsource = $conf->fournisseur->commande->dir_output.'/'.$oldref; - $dirdest = $conf->fournisseur->commande->dir_output.'/'.$newref; - if (!$error && file_exists($dirsource)) { - dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); - - if (@rename($dirsource, $dirdest)) { - dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->fournisseur->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) { - $dirsource = $fileentry['name']; - $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource = $fileentry['path'].'/'.$dirsource; - $dirdest = $fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } + if (@rename($dirsource, $dirdest)) { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->fournisseur->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); } } } } + } - if (!$error) { - $result = 1; - $this->statut = self::STATUS_VALIDATED; - $this->ref = $num; - } + if (!$error) { + $result = 1; + $this->statut = self::STATUS_VALIDATED; + $this->ref = $num; + } - if (!$error) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } + if (!$error) { + $this->db->commit(); + return 1; } else { - $this->error = 'NotAuthorized'; - dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); + $this->db->rollback(); return -1; } + } else { + $this->error = 'NotAuthorized'; + dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); + return -1; + } } /** diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 7e0b857eb6d..87a9d6b1b47 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2285,7 +2285,7 @@ li.tmenu:hover { opacity: .50; /* show only a slight shadow */ } li.tmenusel a.tmenusel { - text-decoration: underline !important; + text-decoration: underline !important; } .tmenuend .tmenuleft { width: 0px; } .tmenuend { display: none; } diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php index f3d40c1c33e..740061f99ba 100644 --- a/htdocs/ticket/document.php +++ b/htdocs/ticket/document.php @@ -196,7 +196,7 @@ if ($object->id) { $permtoedit = $user->rights->ticket->write; $param = '&id='.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { accessforbidden('', 0, 1); }