diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php index 4c5f7941248..bfe4c4d1f43 100644 --- a/htdocs/admin/fournisseur.php +++ b/htdocs/admin/fournisseur.php @@ -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='
'.$obj->error.'
'; + dol_syslog($obj->error, LOG_ERR); + } + } + else + { + $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + 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 "\n"; } } + +closedir($handle); + +print '
'; + +/* + * 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 "\n"; +print "\n"; +print ' \n"; +print " \n"; +print '\n"; +print '\n"; +print ''; +print "\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 "\n \n \n"; + + // Active + if (in_array($name, $def)) + { + print ""; + } + else + { + print ""; + } + + // Defaut + print "'; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); + $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); + print ''; + print ''; + + print "\n"; + } +} closedir($handle); print '
'.$langs->trans("Name")."".$langs->trans("Description")."'.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("Info").'
$name"; + print "\n"; + require_once($dir.$file); + $module = new $classname($db); + print $module->description; + print "\n"; + if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") + { + print ''; + print img_picto($langs->trans("Enabled"),'on'); + print ''; + } + else + { + print img_picto($langs->trans("Enabled"),'on'); + } + print "\n"; + print ''.img_picto($langs->trans("Disabled"),'off').''; + print ""; + if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print ''.img_picto($langs->trans("Disabled"),'on').''; + } + print ''; + print $html->textwithpicto('',$htmltooltip,1,0); + print ''; + print ''.img_object($langs->trans("Preview"),'order').''; + print '

'; diff --git a/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 84819f19cd9..c84b53a6cd7 100755 --- a/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -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 { diff --git a/htdocs/langs/ca_ES/admin.lang b/htdocs/langs/ca_ES/admin.lang index ec9979b723a..72513d6c170 100644 --- a/htdocs/langs/ca_ES/admin.lang +++ b/htdocs/langs/ca_ES/admin.lang @@ -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.
Exemple: /usr/local/share/GeoIP/GeoIP.dat diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5c8dcbe4344..504d74f4bcf 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -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.
Example: /usr/local/share/GeoIP/GeoIP.dat diff --git a/htdocs/langs/es_AR/admin.lang b/htdocs/langs/es_AR/admin.lang index f9de2b6e6e7..8d2b9073e19 100755 --- a/htdocs/langs/es_AR/admin.lang +++ b/htdocs/langs/es_AR/admin.lang @@ -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.
Ejemplo: /usr/local/share/GeoIP/GeoIP.dat diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang index e8ef53c25d9..b0cc08474cd 100644 --- a/htdocs/langs/es_ES/admin.lang +++ b/htdocs/langs/es_ES/admin.lang @@ -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.
Ejemplo: /usr/local/share/GeoIP/GeoIP.dat diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 1e08230873b..8c23247e3c9 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -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.
Exemple: /usr/local/share/GeoIP/GeoIP.dat