New: La fonction supprimer le PDF généré, depuis le cartouche des fichiers, est ok (Nécessite droit supprimer sur l'objet).
This commit is contained in:
parent
f9b097dfde
commit
9e7499d522
@ -219,13 +219,6 @@ if ($_POST['action'] == 'add')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_GET['action'] == 'builddoc')
|
|
||||||
{
|
|
||||||
$propal = new Propal($db);
|
|
||||||
$propal->fetch($_GET['propalid']);
|
|
||||||
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cloture de la propale
|
* Cloture de la propale
|
||||||
*/
|
*/
|
||||||
@ -428,11 +421,15 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST
|
|||||||
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
|
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['action'] == 'builddoc' && $user->rights->propale->creer)
|
/*
|
||||||
|
* Generation doc (depuis lien ou depuis cartouche doc)
|
||||||
|
*/
|
||||||
|
if ($_REQUEST['action'] == 'builddoc' && $user->rights->propale->creer)
|
||||||
{
|
{
|
||||||
$propal = new Propal($db, 0, $_GET['propalid']);
|
$propal = new Propal($db);
|
||||||
$propal->set_pdf_model($user, $_POST['model']);
|
$propal->fetch($_GET['propalid']);
|
||||||
propale_pdf_create($db, $_GET['propalid'], $_POST['model']);
|
if ($_POST['model']) $propal->set_pdf_model($user, $_POST['model']);
|
||||||
|
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -831,7 +828,6 @@ if ($_GET['propalid'] > 0)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Lignes de propale
|
* Lignes de propale
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
|
|
||||||
|
|||||||
@ -2047,8 +2047,7 @@ else
|
|||||||
$filedir=$conf->facture->dir_output . '/' . sanitize_string($fac->ref);
|
$filedir=$conf->facture->dir_output . '/' . sanitize_string($fac->ref);
|
||||||
$urlsource=$_SERVER['PHP_SELF'].'?facid='.$fac->id;
|
$urlsource=$_SERVER['PHP_SELF'].'?facid='.$fac->id;
|
||||||
$genallowed=($fac->statut == 1 && $user->rights->facture->creer);
|
$genallowed=($fac->statut == 1 && $user->rights->facture->creer);
|
||||||
// $delallowed=$user->rights->facture->supprimer;
|
$delallowed=$user->rights->facture->supprimer;
|
||||||
$delallowed=0;
|
|
||||||
|
|
||||||
$var=true;
|
$var=true;
|
||||||
|
|
||||||
|
|||||||
@ -36,8 +36,10 @@ require_once("main.inc.php");
|
|||||||
function llxHeader() { }
|
function llxHeader() { }
|
||||||
|
|
||||||
|
|
||||||
|
$action = $_GET["action"];
|
||||||
$original_file = urldecode($_GET["file"]);
|
$original_file = urldecode($_GET["file"]);
|
||||||
$modulepart = urldecode($_GET["modulepart"]);
|
$modulepart = urldecode($_GET["modulepart"]);
|
||||||
|
$urlsource = urldecode($_GET["urlsource"]);
|
||||||
// Défini type et attachment
|
// Défini type et attachment
|
||||||
$type = urldecode($_GET["type"]); $attachment = true;
|
$type = urldecode($_GET["type"]); $attachment = true;
|
||||||
if (eregi('\.html',$original_file)) { $type='text/html'; $attachment = false; }
|
if (eregi('\.html',$original_file)) { $type='text/html'; $attachment = false; }
|
||||||
@ -260,7 +262,31 @@ if (! $accessallowed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Ouvre et renvoi fichier
|
if ($action == 'remove_file')
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Suppression fichier
|
||||||
|
*/
|
||||||
|
clearstatcache();
|
||||||
|
$filename = basename($original_file);
|
||||||
|
|
||||||
|
dolibarr_syslog("document.php remove $original_file $filename $urlsource");
|
||||||
|
|
||||||
|
if (! file_exists($original_file))
|
||||||
|
{
|
||||||
|
dolibarr_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
unlink($original_file);
|
||||||
|
|
||||||
|
Header("Location: ".urldecode($urlsource));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Ouvre et renvoi fichier
|
||||||
|
*/
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
$filename = basename($original_file);
|
$filename = basename($original_file);
|
||||||
|
|
||||||
@ -283,5 +309,6 @@ header('Cache-Control: Public, must-revalidate');
|
|||||||
header('Pragma: public');
|
header('Pragma: public');
|
||||||
|
|
||||||
readfile($original_file);
|
readfile($original_file);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -2537,7 +2537,7 @@ class Form
|
|||||||
|
|
||||||
if ($delallowed)
|
if ($delallowed)
|
||||||
{
|
{
|
||||||
print '<td><a href="'.$urlsource.'&action=remove_file&modulepart='.$modulepart.'&file='.urlencode($relativepath).'">'.img_delete().'</a></td>';
|
print '<td><a href="'.DOL_URL_ROOT.'/document.php?action=remove_file&modulepart='.$modulepart.'&file='.urlencode($relativepath).'&urlsource='.urlencode($urlsource).'">'.img_delete().'</a></td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|||||||
@ -1141,22 +1141,22 @@ class Propal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
*
|
* \brief Positionne modele derniere generation
|
||||||
*
|
* \param user Objet use qui modifie
|
||||||
*
|
* \param modelpdf Nom du modele
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function set_pdf_model($user, $modelpdf)
|
function set_pdf_model($user, $modelpdf)
|
||||||
{
|
{
|
||||||
if ($user->rights->propale->creer)
|
if ($user->rights->propale->creer)
|
||||||
{
|
{
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET model_pdf = '$modelpdf'";
|
$sql.= " SET model_pdf = '".$modelpdf."'";
|
||||||
$sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;";
|
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
$this->modelpdf=$modelpdf;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user