Fix phpcs
This commit is contained in:
parent
161baa672a
commit
1c8a2ce15a
@ -580,11 +580,11 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
$soc->fetch($this->fourn_id);
|
$soc->fetch($this->fourn_id);
|
||||||
|
|
||||||
// Check if object has a temporary ref
|
// 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
|
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);
|
$num = $this->getNextNumRef($soc);
|
||||||
} else {
|
} else {
|
||||||
$num = $this->ref;
|
$num = $this->ref;
|
||||||
}
|
}
|
||||||
$this->newref = dol_sanitizeFileName($num);
|
$this->newref = dol_sanitizeFileName($num);
|
||||||
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur";
|
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur";
|
||||||
@ -596,75 +596,75 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
$sql .= " AND fk_statut = ".self::STATUS_DRAFT;
|
$sql .= " AND fk_statut = ".self::STATUS_DRAFT;
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error && !$notrigger) {
|
||||||
|
// Call trigger
|
||||||
|
$result = $this->call_trigger('ORDER_SUPPLIER_VALIDATE', $user);
|
||||||
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
// End call triggers
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error && !$notrigger) {
|
if (!$error) {
|
||||||
// Call trigger
|
$this->oldref = $this->ref;
|
||||||
$result = $this->call_trigger('ORDER_SUPPLIER_VALIDATE', $user);
|
|
||||||
if ($result < 0) {
|
// Rename directory if dir was a temporary ref
|
||||||
$error++;
|
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) {
|
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
|
||||||
$this->oldref = $this->ref;
|
$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 (@rename($dirsource, $dirdest)) {
|
||||||
if (preg_match('/^[\(]?PROV/i', $this->ref)) {
|
dol_syslog("Rename ok");
|
||||||
// Now we rename also files into index
|
// Rename docs starting with $oldref with $newref
|
||||||
$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)."'";
|
$listoffiles = dol_dir_list($conf->fournisseur->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
|
||||||
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'fournisseur/commande/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
|
foreach ($listoffiles as $fileentry) {
|
||||||
$resql = $this->db->query($sql);
|
$dirsource = $fileentry['name'];
|
||||||
if (!$resql) {
|
$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
|
||||||
$error++; $this->error = $this->db->lasterror();
|
$dirsource = $fileentry['path'].'/'.$dirsource;
|
||||||
}
|
$dirdest = $fileentry['path'].'/'.$dirdest;
|
||||||
|
@rename($dirsource, $dirdest);
|
||||||
// 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 (!$error) {
|
if (!$error) {
|
||||||
$result = 1;
|
$result = 1;
|
||||||
$this->statut = self::STATUS_VALIDATED;
|
$this->statut = self::STATUS_VALIDATED;
|
||||||
$this->ref = $num;
|
$this->ref = $num;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
|
||||||
$this->db->rollback();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$this->error = 'NotAuthorized';
|
$this->db->rollback();
|
||||||
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$this->error = 'NotAuthorized';
|
||||||
|
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2285,7 +2285,7 @@ li.tmenu:hover {
|
|||||||
opacity: .50; /* show only a slight shadow */
|
opacity: .50; /* show only a slight shadow */
|
||||||
}
|
}
|
||||||
li.tmenusel a.tmenusel {
|
li.tmenusel a.tmenusel {
|
||||||
text-decoration: underline !important;
|
text-decoration: underline !important;
|
||||||
}
|
}
|
||||||
.tmenuend .tmenuleft { width: 0px; }
|
.tmenuend .tmenuleft { width: 0px; }
|
||||||
.tmenuend { display: none; }
|
.tmenuend { display: none; }
|
||||||
|
|||||||
@ -196,7 +196,7 @@ if ($object->id) {
|
|||||||
$permtoedit = $user->rights->ticket->write;
|
$permtoedit = $user->rights->ticket->write;
|
||||||
$param = '&id='.$object->id;
|
$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 {
|
} else {
|
||||||
accessforbidden('', 0, 1);
|
accessforbidden('', 0, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user