Fix: Add message if delete can(t be done because of joined files.
This commit is contained in:
parent
ac7b9da097
commit
5165e2e093
@ -83,12 +83,22 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes')
|
||||
{
|
||||
$propal = new Propal($db, 0, $_GET['propalid']);
|
||||
$propal->fetch($_GET['propalid']);
|
||||
$propal->delete($user);
|
||||
$result=$propal->delete($user);
|
||||
$propalid = 0;
|
||||
$brouillon = 1;
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
Header('Location: '.$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
if ($propal->error == 'ErrorFailToDeleteDir') $mesg='<div class="error">'.$langs->trans('ErrorFailedToDeleteJoinedFiles').'</div>';
|
||||
else $mesg='<div class="error">'.$propal->error.'</div>';
|
||||
}
|
||||
}
|
||||
Header('Location: '.$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -135,7 +145,7 @@ if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' &
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$fac->error.'</div>';
|
||||
$mesg='<div class="error">'.$propal->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -846,7 +856,7 @@ if ($_GET['propalid'] > 0)
|
||||
*
|
||||
*/
|
||||
|
||||
if ($mesg) print "$mesg<br>";
|
||||
if ($mesg) print $mesg."<br>";
|
||||
|
||||
$propal = new Propal($db);
|
||||
$propal->fetch($_GET['propalid']);
|
||||
|
||||
@ -6,6 +6,8 @@ ErrorFailToDeleteFile=Failed to remove file '<b>%s</b>'.
|
||||
ErrorFailToCreateFile=Failed to create file '<b>%s</b>'.
|
||||
ErrorFailToRenameDir=Failed to rename directory '<b>%s</b>' into '<b>%s</b>'.
|
||||
ErrorFailToCreateDir=Failed to create directory '<b>%s</b>'.
|
||||
ErrorFailToDeleteDir=Failed to delete directory '<b>%s</b>'.
|
||||
ErrorFailedToDeleteJoinedFiles=Can not delete entity because there is some joined files. Remove join files first.
|
||||
ErrorThisContactIsAlreadyDefinedAsThisType=This contact is already defined as contact for this type.
|
||||
ErrorCashAccountAcceptsOnlyCashMoney=This bank account is a cash account, so it accepts payments of type cash only.
|
||||
ErrorFromToAccountsMustDiffers=Source and targets bank accounts must be different.
|
||||
|
||||
@ -6,6 +6,8 @@ ErrorFailToCreateFile=Echec de la cr
|
||||
ErrorFailToDeleteFile=Echec de l'effacement du fichier '<b>%s</b>'.
|
||||
ErrorFailToRenameDir=Echec du renommage du répertoire '<b>%s</b>' en '<b>%s</b>'.
|
||||
ErrorFailToCreateDir=Echec de création du répertoire '<b>%s</b>'.
|
||||
ErrorFailToDeleteDir=Echec de la suppression du répertoire '<b>%s</b>'.
|
||||
ErrorFailedToDeleteJoinedFiles=Impossible de supprimer l'entité car il existe des pièces jointes. Supprimer d'abord les pièces jointes.
|
||||
ErrorThisContactIsAlreadyDefinedAsThisType=Ce contact est déjà défini comme contact pour ce type.
|
||||
ErrorCashAccountAcceptsOnlyCashMoney=Ce compte bancaire est de type caisse et n'accepte que les mode de réglement de type <b>espèce</b>.
|
||||
ErrorFromToAccountsMustDiffers=Le compte source et destination doivent etre différents.
|
||||
|
||||
@ -1999,8 +1999,10 @@ function dol_delete_file($file)
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Effacement d'un r<EFBFBD>pertoire
|
||||
\param file R<EFBFBD>pertoire a effacer
|
||||
* \brief Remove a directory
|
||||
* \param file Directory to delete
|
||||
* \return boolean True if success, false if error
|
||||
* \remarks If directory is not empty, return false
|
||||
*/
|
||||
function dol_delete_dir($dir)
|
||||
{
|
||||
@ -2008,10 +2010,10 @@ function dol_delete_dir($dir)
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Effacement d'un r<EFBFBD>pertoire $dir et de son arborescence
|
||||
\param file R<EFBFBD>pertoire a effacer
|
||||
\param count Compteur pour comptage nb elements supprim<EFBFBD>s
|
||||
\return int Nombre de fichier+rep<EFBFBD>rtoires supprim<EFBFBD>s
|
||||
* \brief Remove a directory $dir and its subdirectories
|
||||
* \param file Dir to delete
|
||||
* \param count Counter to count nb of deleted elements
|
||||
* \return int Number of files and directory removed
|
||||
*/
|
||||
function dol_delete_dir_recursive($dir,$count=0)
|
||||
{
|
||||
|
||||
@ -1408,16 +1408,17 @@ class Propal extends CommonObject
|
||||
*/
|
||||
function delete($user)
|
||||
{
|
||||
global $conf,$langs;
|
||||
global $conf;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id;
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
|
||||
// On efface le r<>pertoire du pdf
|
||||
// We remove directory
|
||||
$propalref = sanitizeFileName($this->ref);
|
||||
if ($conf->propal->dir_output)
|
||||
{
|
||||
@ -1429,30 +1430,36 @@ class Propal extends CommonObject
|
||||
|
||||
if (!dol_delete_file($file))
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
|
||||
$this->error='ErrorFailToDeleteFile';
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (file_exists($dir))
|
||||
{
|
||||
if (!dol_delete_dir($dir))
|
||||
$res=@dol_delete_dir($dir);
|
||||
if (! $res)
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
|
||||
$this->error='ErrorFailToDeleteDir';
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dolibarr_syslog("Suppression de la proposition $this->id par $user->id");
|
||||
dolibarr_syslog("Suppression de la proposition $this->id par $user->id", LOG_DEBUG);
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user