Task #8618: works in setup module

This commit is contained in:
Juanjo Menent 2010-10-08 16:11:28 +00:00
parent beccea90f7
commit 7e4d04dca8
7 changed files with 216 additions and 3 deletions

View File

@ -88,6 +88,41 @@ if ($_GET["action"] == 'specimen')
}
}
if ($_GET["action"] == 'specimenfacture')
{
$modele=$_GET["module"];
$facture = new FactureFournisseur($db);
$facture->initAsSpecimen();
// Charge le modele
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/supplier_invoice/pdf/";
$file = "pdf_".$modele.".modules.php";
if (file_exists($dir.$file))
{
$classname = "pdf_".$modele;
require_once($dir.$file);
$obj = new $classname($db);
if ($obj->write_file($facture,$langs) > 0)
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
return;
}
else
{
$mesg='<div class="error">'.$obj->error.'</div>';
dol_syslog($obj->error, LOG_ERR);
}
}
else
{
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>';
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
}
}
if ($_GET["action"] == 'set')
{
$type='supplier_order';
@ -98,6 +133,16 @@ if ($_GET["action"] == 'set')
}
}
if ($_GET["action"] == 'setfacture')
{
$type='supplier_invoice';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES ('".$_GET["value"]."','".$type."',".$conf->entity.")";
if ($db->query($sql))
{
}
}
if ($_GET["action"] == 'del')
{
$type='supplier_order';
@ -111,6 +156,19 @@ if ($_GET["action"] == 'del')
}
}
if ($_GET["action"] == 'delfacture')
{
$type='supplier_invoice';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom = '".$_GET["value"]."'";
$sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
if ($db->query($sql))
{
}
}
if ($_GET["action"] == 'setdoc')
{
$db->begin();
@ -139,6 +197,35 @@ if ($_GET["action"] == 'setdoc')
}
}
if ($_GET["action"] == 'setdocfacture')
{
$db->begin();
if (dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity))
{
$conf->global->INVOICE_SUPPLIER_ADDON_PDF = $_GET["value"];
}
// On active le modele
$type='supplier_invoice';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del.= " WHERE nom = '".$_GET["value"]."'";
$sql_del.= " AND type = '".$type."'";
$sql_del.= " AND entity = ".$conf->entity;
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type,entity) VALUES ('".$_GET["value"]."','".$type."',".$conf->entity.")";
$result2=$db->query($sql);
if ($result1 && $result2)
{
$db->commit();
}
else
{
$db->rollback();
}
}
if ($_GET["action"] == 'setmod')
{
// \todo Verifier si module numerotation choisi peut etre active
@ -375,6 +462,127 @@ while (($file = readdir($handle))!==false)
print "</tr>\n";
}
}
closedir($handle);
print '</table><br/>';
/*
* Modeles documents for supplier invoices
*/
$dir = DOL_DOCUMENT_ROOT.'/includes/modules/supplier_invoice/pdf/';
print_titre($langs->trans("InvoicesModelModule"));
// Defini tableau def de modele
$type='supplier_invoice';
$def = array();
$sql = "SELECT nom";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
$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
{
dol_print_error($db);
}
print "<table class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n";
print ' <td width="100">'.$langs->trans("Name")."</td>\n";
print " <td>".$langs->trans("Description")."</td>\n";
print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
print '<td align="center" width="32" colspan="2">'.$langs->trans("Info").'</td>';
print "</tr>\n";
clearstatcache();
$handle=opendir($dir);
$var=true;
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
$var=!$var;
print "<tr ".$bc[$var].">\n <td>$name";
print "</td>\n <td>\n";
require_once($dir.$file);
$module = new $classname($db);
print $module->description;
print "</td>\n";
// Active
if (in_array($name, $def))
{
print "<td align=\"center\">\n";
if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name")
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=delfacture&amp;value='.$name.'">';
print img_picto($langs->trans("Enabled"),'on');
print '</a>';
}
else
{
print img_picto($langs->trans("Enabled"),'on');
}
print "</td>";
}
else
{
print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setfacture&amp;value='.$name.'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
print "</td>";
}
// Defaut
print "<td align=\"center\">";
if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name")
{
print img_picto($langs->trans("Default"),'on');
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdocfacture&amp;value='.$name.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'on').'</a>';
}
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
print '<td align="center">';
print $html->textwithpicto('',$htmltooltip,1,0);
print '</td>';
print '<td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimenfacture&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>';
print '</td>';
print "</tr>\n";
}
}
closedir($handle);
print '</table><br/>';

View File

@ -24,15 +24,15 @@
* \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT."/includes/modules/supplier_invoice/modules_invoicefournisseur.php");
require_once(DOL_DOCUMENT_ROOT."/includes/modules/supplier_invoice/modules_facturefournisseur.php");
require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
/**
* \class pdf_muscadet
* \brief Classe permettant de generer les factures fournisseurs au modele Muscadet
* \class pdf_canelle
* \brief Classe permettant de generer les factures fournisseurs au modele Canelle
*/
class pdf_canelle extends ModelePDFSuppliersInvoices
{

View File

@ -1199,6 +1199,7 @@ MultiCompanySetup=Configuració del mòdul Multi-empresa
##### Suppliers #####
SuppliersSetup=Configuració del mòdul Proveïdors
SuppliersCommandModel=Model de comandes a proveïdors complet (logo...)
SuppliersInvoiceModel=Model de factures de proveïdors complet (logo...)
##### GeoIPMaxmind #####
GeoIPMaxmindSetup=Configuració del mòdul GeoIP Maxmind
PathToGeoIPMaxmindCountryDataFile=Ruta de l'arxiu Maxmind que conté les conversions IP-> País.<br>Exemple: /usr/local/share/GeoIP/GeoIP.dat

View File

@ -1189,6 +1189,7 @@ MultiCompanySetup=Multi-company module setup
##### Suppliers #####
SuppliersSetup=Supplier module setup
SuppliersCommandModel=Complete template of supplier order (logo...)
SuppliersInvoiceModel=Complete template of supplier invoice (logo...)
##### GeoIPMaxmind #####
GeoIPMaxmindSetup=GeoIP Maxmind module setup
PathToGeoIPMaxmindCountryDataFile=Path to file containing Maxmind ip to country translation.<br>Example: /usr/local/share/GeoIP/GeoIP.dat

View File

@ -1198,6 +1198,7 @@ MultiCompanySetup=Configuración del módulo Multi-empresa
##### Suppliers #####
SuppliersSetup=Configuración del módulo Proveedores
SuppliersCommandModel=Modelo de pedidos a proveedores completo (logo...)
SuppliersInvoiceModel=Modelo de facturas de proveedores completo (logo...)
##### GeoIPMaxmind #####
GeoIPMaxmindSetup=Configuración del módulo GeoIP Maxmind
PathToGeoIPMaxmindCountryDataFile=Ruta del archivo Maxmind que contiene las conversiones IP->País.<br>Ejemplo: /usr/local/share/GeoIP/GeoIP.dat

View File

@ -1198,6 +1198,7 @@ MultiCompanySetup=Configuración del módulo Multi-empresa
##### Suppliers #####
SuppliersSetup=Configuración del módulo Proveedores
SuppliersCommandModel=Modelo de pedidos a proveedores completo (logo...)
SuppliersInvoiceModel=Modelo de facturas de proveedores completo (logo...)
##### GeoIPMaxmind #####
GeoIPMaxmindSetup=Configuración del módulo GeoIP Maxmind
PathToGeoIPMaxmindCountryDataFile=Ruta del archivo Maxmind que contiene las conversiones IP->País.<br>Ejemplo: /usr/local/share/GeoIP/GeoIP.dat

View File

@ -1201,6 +1201,7 @@ MultiCompanySetup=Configuration du module Multi-société
##### Suppliers #####
SuppliersSetup=Configuration du module Fournisseurs
SuppliersCommandModel=Modèle de commandes fournisseur complet (logo...)
SuppliersInvoiceModel=Modèle de factures fournisseur complet (logo...)
##### GeoIPMaxmind #####
GeoIPMaxmindSetup=Configuration du module GeoIP Maxmind
PathToGeoIPMaxmindCountryDataFile=Chemin du fichier Maxmind contenant les conversions IP->Pays.<br>Exemple: /usr/local/share/GeoIP/GeoIP.dat