diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 8f7616e825e..a7511458a04 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -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 '
';
/*
- * Lignes de propale
- *
- */
+ * Lignes de propale
+ */
print '
';
$sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice,';
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 5984f9fc357..ab3b4549973 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -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;
diff --git a/htdocs/document.php b/htdocs/document.php
index 71152ac0d52..8d70485fa66 100644
--- a/htdocs/document.php
+++ b/htdocs/document.php
@@ -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);
-
?>
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index f00a3c7d753..3c3609479d7 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -2537,7 +2537,7 @@ class Form
if ($delallowed)
{
- print '| '.img_delete().' | ';
+ print ''.img_delete().' | ';
}
print '';
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index 46ff19e74a9..9fa753d4624 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -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