New: La fonction supprimer le PDF gnr, depuis le cartouche des fichiers, est ok (Ncessite droit supprimer sur l'objet).

This commit is contained in:
Laurent Destailleur 2006-06-10 18:43:11 +00:00
parent f9b097dfde
commit 9e7499d522
5 changed files with 83 additions and 61 deletions

View File

@ -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
*/
@ -428,11 +421,15 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST
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->set_pdf_model($user, $_POST['model']);
propale_pdf_create($db, $_GET['propalid'], $_POST['model']);
$propal = new Propal($db);
$propal->fetch($_GET['propalid']);
if ($_POST['model']) $propal->set_pdf_model($user, $_POST['model']);
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
}
@ -830,9 +827,8 @@ if ($_GET['propalid'] > 0)
print '</table><br>';
/*
* Lignes de propale
*
*/
* Lignes de propale
*/
print '<table class="noborder" width="100%">';
$sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice,';

View File

@ -2047,8 +2047,7 @@ else
$filedir=$conf->facture->dir_output . '/' . sanitize_string($fac->ref);
$urlsource=$_SERVER['PHP_SELF'].'?facid='.$fac->id;
$genallowed=($fac->statut == 1 && $user->rights->facture->creer);
// $delallowed=$user->rights->facture->supprimer;
$delallowed=0;
$delallowed=$user->rights->facture->supprimer;
$var=true;

View File

@ -36,8 +36,10 @@ require_once("main.inc.php");
function llxHeader() { }
$action = $_GET["action"];
$original_file = urldecode($_GET["file"]);
$modulepart = urldecode($_GET["modulepart"]);
$urlsource = urldecode($_GET["urlsource"]);
// Défini type et attachment
$type = urldecode($_GET["type"]); $attachment = true;
if (eregi('\.html',$original_file)) { $type='text/html'; $attachment = false; }
@ -260,28 +262,53 @@ if (! $accessallowed)
}
// Ouvre et renvoi fichier
clearstatcache();
$filename = basename($original_file);
dolibarr_syslog("document.php download $original_file $filename content-type=$type");
if (! file_exists($original_file))
if ($action == 'remove_file')
{
dolibarr_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
exit;
/*
* 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();
$filename = basename($original_file);
dolibarr_syslog("document.php download $original_file $filename content-type=$type");
if (! file_exists($original_file))
{
dolibarr_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
exit;
}
// Les drois sont ok et fichier trouvé, on l'envoie
if ($type) header('Content-type: '.$type);
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
// Ajout directives pour résoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
readfile($original_file);
}
// Les drois sont ok et fichier trouvé, on l'envoie
if ($type) header('Content-type: '.$type);
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
// Ajout directives pour résoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
readfile($original_file);
?>

View File

@ -2537,7 +2537,7 @@ class Form
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>';

View File

@ -1141,31 +1141,31 @@ class Propal
}
}
/*
*
*
*
*/
function set_pdf_model($user, $modelpdf)
{
if ($user->rights->propale->creer)
/**
* \brief Positionne modele derniere generation
* \param user Objet use qui modifie
* \param modelpdf Nom du modele
*/
function set_pdf_model($user, $modelpdf)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET model_pdf = '$modelpdf'";
$sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;";
if ($this->db->query($sql) )
{
return 1;
}
else
{
dolibarr_print_error($this->db);
return 0;
}
if ($user->rights->propale->creer)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET model_pdf = '".$modelpdf."'";
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
if ($this->db->query($sql))
{
$this->modelpdf=$modelpdf;
return 1;
}
else
{
dolibarr_print_error($this->db);
return 0;
}
}
}
}
/**
* \brief Cloture de la proposition commerciale