forked from Wavyzz/dolibarr
modif pour permettre activ/desactiv de modele d'export pdf
This commit is contained in:
@@ -69,10 +69,42 @@ if ($_GET["action"] == 'setmod')
|
|||||||
$commande_addon_var = $_GET["value"];
|
$commande_addon_var = $_GET["value"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($_GET["action"] == 'set')
|
||||||
|
{
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_model_pdf (nom) VALUES ('".$_GET["value"]."')";
|
||||||
|
|
||||||
|
if ($db->query($sql))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$propale_addon_var_pdf = $conf->global->PROPALE_ADDON_PDF;
|
||||||
if ($_GET["action"] == 'setpdf')
|
if ($_GET["action"] == 'setpdf')
|
||||||
{
|
{
|
||||||
if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF",$_GET["value"])) $commande_addon_var_pdf = $_GET["value"];
|
|
||||||
|
if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF",$_GET["value"]))
|
||||||
|
$commande_addon_var_pdf = $_GET["value"];
|
||||||
|
|
||||||
|
// On active le modele
|
||||||
|
$sql_del = "delete from ".MAIN_DB_PREFIX."commande_model_pdf where nom = '".$_GET["value"]."';";
|
||||||
|
$db->query($sql_del);
|
||||||
|
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_model_pdf (nom) VALUES ('".$_GET["value"]."')";
|
||||||
|
if ($db->query($sql))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if ($_GET["action"] == 'del')
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_model_pdf WHERE nom='".$_GET["value"]."'";
|
||||||
|
|
||||||
|
if ($db->query($sql))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$propale_addon_var_pdf = $conf->global->PROPALE_ADDON_PDF;
|
||||||
|
|
||||||
$dir = "../includes/modules/commande/";
|
$dir = "../includes/modules/commande/";
|
||||||
|
|
||||||
@@ -141,52 +173,79 @@ print '</table>';
|
|||||||
print '<br>';
|
print '<br>';
|
||||||
print_titre("Mod<EFBFBD>les de commande pdf");
|
print_titre("Mod<EFBFBD>les de commande pdf");
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print "<table class=\"noborder\" width=\"100%\">\n";
|
||||||
print '<tr class="liste_titre">';
|
print "<tr class=\"liste_titre\">\n";
|
||||||
print '<td>'.$langs->trans("Name").'</td>';
|
print " <td width=\"140\">".$langs->trans("Name")."</td>\n";
|
||||||
print '<td>'.$langs->trans("Description").'</td>';
|
print " <td>".$langs->trans("Description")."</td>\n";
|
||||||
print '<td align="center" width="60">'.$langs->trans("Activated").'</td>';
|
print ' <td align="center" colspan="2">'.$langs->trans("Activated")."</td>\n";
|
||||||
print '<td align="center" width="60">'.$langs->trans("Default").'</td>';
|
print ' <td align="center">'.$langs->trans("Default")."</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
|
$def = array();
|
||||||
|
$sql = "SELECT nom FROM ".MAIN_DB_PREFIX."commande_model_pdf";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$i = 0;
|
||||||
|
$num_rows=$db->num_rows($resql);
|
||||||
|
while ($i < $num_rows)
|
||||||
|
{
|
||||||
|
$array = $db->fetch_array($resql);
|
||||||
|
array_push($def, $array[0]);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
}
|
||||||
$handle=opendir($dir);
|
$handle=opendir($dir);
|
||||||
|
|
||||||
$var=True;
|
$var=True;
|
||||||
while (($file = readdir($handle))!==false)
|
while (($file = readdir($handle))!==false)
|
||||||
{
|
{
|
||||||
if (eregi('\.modules\.php$',$file) && substr($file,0,4) == 'pdf_')
|
if (eregi('\.modules\.php$',$file) && substr($file,0,4) == 'pdf_')
|
||||||
{
|
{
|
||||||
$var = !$var;
|
$var = !$var;
|
||||||
$name = substr($file, 4, strlen($file) -16);
|
$name = substr($file, 4, strlen($file) -16);
|
||||||
$classname = substr($file, 0, strlen($file) -12);
|
$classname = substr($file, 0, strlen($file) -12);
|
||||||
|
|
||||||
print '<tr '.$bc[$var].'><td width="100">';
|
$var=!$var;
|
||||||
echo "$name";
|
print "<tr ".$bc[$var].">\n <td>";
|
||||||
print "</td><td>\n";
|
print "$name";
|
||||||
require_once($dir.$file);
|
print "</td>\n <td>\n";
|
||||||
$obj = new $classname($db);
|
require_once($dir.$file);
|
||||||
|
$obj = new $classname($db);
|
||||||
print $obj->description;
|
|
||||||
|
print $obj->description;
|
||||||
print '</td><td align="center">';
|
|
||||||
|
print "</td>\n <td align=\"center\">\n";
|
||||||
if ($commande_addon_var_pdf == "$name")
|
|
||||||
{
|
if (in_array($name, $def))
|
||||||
print ' ';
|
{
|
||||||
print '</td><td align="center">';
|
print img_tick();
|
||||||
print img_tick();
|
print "</td>\n <td>";
|
||||||
}
|
print '<a href="commande.php?action=del&value='.$name.'">'.$langs->trans("Disable").'</a>';
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
print ' ';
|
{
|
||||||
// print $commande_addon_var_pdf."iii";
|
print " ";
|
||||||
print '</td><td align="center">';
|
print "</td>\n <td>";
|
||||||
print '<a href="commande.php?action=setpdf&value='.$name.'">'.$langs->trans("Default").'</a>';
|
print '<a href="commande.php?action=set&value='.$name.'">'.$langs->trans("Activate").'</a>';
|
||||||
}
|
}
|
||||||
print "</td></tr>\n";
|
|
||||||
|
print "</td>\n <td align=\"center\">";
|
||||||
|
|
||||||
|
if ($commande_addon_var_pdf == "$name")
|
||||||
|
{
|
||||||
|
print img_tick();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a href="commande.php?action=setpdf&value='.$name.'">'.$langs->trans("Activate").'</a>';
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
|
|||||||
@@ -25,19 +25,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/includes/modules/commande/modules_commande.php
|
\file htdocs/includes/modules/commande/modules_commande.php
|
||||||
\ingroup commande
|
\ingroup commande
|
||||||
\brief Fichier contenant la classe m<>re de generation des commandes en PDF
|
\brief Fichier contenant la classe m<>re de generation des commandes en PDF
|
||||||
et la classe m<>re de num<75>rotation des commandes
|
et la classe m<>re de num<75>rotation des commandes
|
||||||
\version $Revision$
|
\version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(FPDF_PATH.'fpdf.php');
|
require_once(FPDF_PATH.'fpdf.php');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class ModelePDFCommandes
|
\class ModelePDFCommandes
|
||||||
\brief Classe m<>re des mod<6F>les de commandes
|
\brief Classe m<>re des mod<6F>les de commandes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ModelePDFCommandes extends FPDF
|
class ModelePDFCommandes extends FPDF
|
||||||
@@ -55,21 +55,29 @@ class ModelePDFCommandes extends FPDF
|
|||||||
/**
|
/**
|
||||||
* \brief Renvoi la liste des mod<6F>les actifs
|
* \brief Renvoi la liste des mod<6F>les actifs
|
||||||
*/
|
*/
|
||||||
function liste_modeles()
|
function liste_modeles($db)
|
||||||
{
|
{
|
||||||
$liste=array();
|
$liste=array();
|
||||||
$dir = "../includes/modules/commande/";
|
$sql ="SELECT nom as id, nom as lib";
|
||||||
$handle = opendir($dir);
|
$sql.=" FROM ".MAIN_DB_PREFIX."commande_model_pdf";
|
||||||
$var=True;
|
|
||||||
while (($file = readdir($handle))!==false)
|
$resql = $db->query($sql);
|
||||||
{
|
if ($resql)
|
||||||
if (eregi('\.modules\.php$',$file) && substr($file,0,4) == 'pdf_')
|
{
|
||||||
{
|
$num = $db->num_rows($resql);
|
||||||
$name = substr($file, 4, strlen($file) -16);
|
$i = 0;
|
||||||
$liste[$name] = $name;
|
while ($i < $num)
|
||||||
// $classname = substr($file, 0, strlen($file) -12);
|
{
|
||||||
}
|
$row = $db->fetch_row($resql);
|
||||||
}
|
$liste[$row[0]]=$row[1];
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return $liste;
|
return $liste;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +87,7 @@ class ModelePDFCommandes extends FPDF
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
\class ModeleNumRefCommandes
|
\class ModeleNumRefCommandes
|
||||||
\brief Classe m<>re des mod<6F>les de num<75>rotation des r<>f<EFBFBD>rences de commandes
|
\brief Classe m<>re des mod<6F>les de num<75>rotation des r<>f<EFBFBD>rences de commandes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ModeleNumRefCommandes
|
class ModeleNumRefCommandes
|
||||||
@@ -136,14 +144,14 @@ function commande_pdf_create($db, $comid, $modele='')
|
|||||||
if (! strlen($modele))
|
if (! strlen($modele))
|
||||||
{
|
{
|
||||||
if (defined("COMMANDE_ADDON_PDF") && COMMANDE_ADDON_PDF)
|
if (defined("COMMANDE_ADDON_PDF") && COMMANDE_ADDON_PDF)
|
||||||
{
|
{
|
||||||
$modele = COMMANDE_ADDON_PDF;
|
$modele = COMMANDE_ADDON_PDF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $langs->trans("Error")." ".$langs->trans("Error_PROPALE_ADDON_PDF_NotDefined");
|
print $langs->trans("Error")." ".$langs->trans("Error_PROPALE_ADDON_PDF_NotDefined");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Charge le modele
|
// Charge le modele
|
||||||
$file = "pdf_".$modele.".modules.php";
|
$file = "pdf_".$modele.".modules.php";
|
||||||
@@ -155,17 +163,17 @@ function commande_pdf_create($db, $comid, $modele='')
|
|||||||
$obj = new $classname($db);
|
$obj = new $classname($db);
|
||||||
|
|
||||||
if ( $obj->write_pdf_file($comid) > 0)
|
if ( $obj->write_pdf_file($comid) > 0)
|
||||||
{
|
{
|
||||||
// on supprime l'image correspondant au preview
|
// on supprime l'image correspondant au preview
|
||||||
commande_delete_preview($db, $comid);
|
commande_delete_preview($db, $comid);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Erreur dans commande_pdf_create");
|
dolibarr_syslog("Erreur dans commande_pdf_create");
|
||||||
dolibarr_print_error($db,$obj->pdferror());
|
dolibarr_print_error($db,$obj->pdferror());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -175,27 +183,27 @@ function commande_pdf_create($db, $comid, $modele='')
|
|||||||
}
|
}
|
||||||
function commande_delete_preview($db, $propalid)
|
function commande_delete_preview($db, $propalid)
|
||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf;
|
||||||
|
|
||||||
$com = new Commande($db,"",$propalid);
|
$com = new Commande($db,"",$propalid);
|
||||||
$com->fetch($propalid);
|
$com->fetch($propalid);
|
||||||
$client = new Societe($db);
|
$client = new Societe($db);
|
||||||
$client->fetch($com->soc_id);
|
$client->fetch($com->soc_id);
|
||||||
|
|
||||||
if ($conf->commande->dir_output)
|
if ($conf->commande->dir_output)
|
||||||
{
|
{
|
||||||
$comref = sanitize_string($com->ref);
|
$comref = sanitize_string($com->ref);
|
||||||
$dir = $conf->commande->dir_output . "/" . $comref ;
|
$dir = $conf->commande->dir_output . "/" . $comref ;
|
||||||
$file = $dir . "/" . $comref . ".pdf.png";
|
$file = $dir . "/" . $comref . ".pdf.png";
|
||||||
|
|
||||||
if ( file_exists( $file ) && is_writable( $file ) )
|
if ( file_exists( $file ) && is_writable( $file ) )
|
||||||
{
|
{
|
||||||
if ( ! unlink($file) )
|
if ( ! unlink($file) )
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
|
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -127,8 +127,10 @@ class modCommande extends DolibarrModules
|
|||||||
// Dir
|
// Dir
|
||||||
$this->dirs[0] = $conf->commande->dir_output;
|
$this->dirs[0] = $conf->commande->dir_output;
|
||||||
$this->dirs[1] = $conf->commande->dir_images;
|
$this->dirs[1] = $conf->commande->dir_images;
|
||||||
|
$sql = array(
|
||||||
$sql = array();
|
"DELETE FROM ".MAIN_DB_PREFIX."commande_model_pdf WHERE nom = '".$this->const[0][2]."'",
|
||||||
|
"INSERT INTO ".MAIN_DB_PREFIX."commande_model_pdf (nom) VALUES('".$this->const[0][2]."');",
|
||||||
|
);
|
||||||
|
|
||||||
return $this->_init($sql);
|
return $this->_init($sql);
|
||||||
}
|
}
|
||||||
@@ -141,7 +143,7 @@ class modCommande extends DolibarrModules
|
|||||||
function remove()
|
function remove()
|
||||||
{
|
{
|
||||||
$sql = array();
|
$sql = array();
|
||||||
|
|
||||||
return $this->_remove($sql);
|
return $this->_remove($sql);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user