Merge pull request #753 from grandoc/develop

try to fix : cannot display numbering models
This commit is contained in:
Laurent Destailleur 2013-03-17 05:05:28 -07:00
commit ca96bd6467
9 changed files with 165 additions and 128 deletions

View File

@ -6,7 +6,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -65,9 +65,9 @@ if ($action == 'updateMask')
if (isset($res)) if (isset($res))
{ {
if ($res < 0) if ($res < 0)
setEventMessage($langs->trans("Error"), 'errors');
else
setEventMessage($langs->trans("SetupSaved")); setEventMessage($langs->trans("SetupSaved"));
else
setEventMessage($langs->trans("Error"), 'errors');
} }
} }
@ -77,9 +77,9 @@ else if ($action == 'set_SHIPPING_FREE_TEXT')
$res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
if ($res < 0) if ($res < 0)
setEventMessage($langs->trans("Error"), 'errors');
else
setEventMessage($langs->trans("SetupSaved")); setEventMessage($langs->trans("SetupSaved"));
else
setEventMessage($langs->trans("Error"), 'errors');
} }
else if ($action == 'set_SHIPPING_DRAFT_WATERMARK') else if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
@ -88,9 +88,9 @@ else if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
$res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
if ($res < 0) if ($res < 0)
setEventMessage($langs->trans("Error"), 'errors');
else
setEventMessage($langs->trans("SetupSaved")); setEventMessage($langs->trans("SetupSaved"));
else
setEventMessage($langs->trans("Error"), 'errors');
} }
else if ($action == 'specimen') else if ($action == 'specimen')
@ -173,12 +173,7 @@ else if ($action == 'setdoc')
else if ($action == 'setmodel') else if ($action == 'setmodel')
{ {
$res = dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity); dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
if ($res < 0)
setEventMessage($langs->trans("Error"), 'errors');
else
setEventMessage($langs->trans("SetupSaved"));
} }
@ -225,9 +220,8 @@ if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON))
dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
/* /*
* Numbering module * Expedition numbering model
*/ */
//print "<br>";
print_titre($langs->trans("SendingsNumberingModules")); print_titre($langs->trans("SendingsNumberingModules"));
@ -259,16 +253,16 @@ foreach ($dirmodels as $reldir)
{ {
$file = substr($file, 0, dol_strlen($file)-4); $file = substr($file, 0, dol_strlen($file)-4);
require_once DOL_DOCUMENT_ROOT ."/core/modules/expedition/".$file.'.php'; require_once $dir.$file.'.php';
$module = new $file; $module = new $file;
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled()) if ($module->isEnabled())
{ {
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$module->nom."</td>\n"; print '<tr '.$bc[$var].'><td>'.$module->nom."</td>\n";
print '<td>'; print '<td>';
@ -278,7 +272,9 @@ foreach ($dirmodels as $reldir)
// Show example of numbering module // Show example of numbering module
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$tmp=$module->getExample(); $tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; } if (preg_match('/^Error/',$tmp)) {
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
}
elseif ($tmp=='NotConfigured') print $langs->trans($tmp); elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";
@ -333,7 +329,7 @@ print '</table><br>';
/* /*
* Modeles de documents * Documents models for Sendings Receipt
*/ */
print_titre($langs->trans("SendingsReceiptModel")); print_titre($langs->trans("SendingsReceiptModel"));
@ -495,4 +491,4 @@ print '</table>';
llxFooter(); llxFooter();
$db->close(); $db->close();
?> ?>

View File

@ -6,7 +6,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -164,7 +164,7 @@ if ($action == 'setmod')
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
dolibarr_set_const($db, "LIVRAISON_ADDON",$value,'chaine',0,'',$conf->entity); dolibarr_set_const($db, "LIVRAISON_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
} }
@ -209,8 +209,9 @@ $h++;
dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
/* /*
* Module numerotation * Livraison numbering model
*/ */
print_titre($langs->trans("DeliveryOrderNumberingModules")); print_titre($langs->trans("DeliveryOrderNumberingModules"));
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
@ -240,16 +241,16 @@ foreach ($dirmodels as $reldir)
{ {
$file = substr($file, 0, dol_strlen($file)-4); $file = substr($file, 0, dol_strlen($file)-4);
require_once DOL_DOCUMENT_ROOT ."/core/modules/livraison/".$file.'.php'; require_once $dir.$file.'.php';
$module = new $file; $module = new $file;
// Show modules according to features level if ($module->isEnabled())
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
{ {
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n"; print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
print $module->info(); print $module->info();
@ -258,13 +259,15 @@ foreach ($dirmodels as $reldir)
// Show example of numbering module // Show example of numbering module
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$tmp=$module->getExample(); $tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; } if (preg_match('/^Error/',$tmp)) {
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
}
elseif ($tmp=='NotConfigured') print $langs->trans($tmp); elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";
print '<td align="center">'; print '<td align="center">';
if ($conf->global->LIVRAISON_ADDON == "$file") if ($conf->global->LIVRAISON_ADDON_NUMBER == "$file")
{ {
print img_picto($langs->trans("Activated"),'switch_on'); print img_picto($langs->trans("Activated"),'switch_on');
} }
@ -311,12 +314,12 @@ print '</table>';
/* /*
* Modeles de documents * Documents Models for delivery
*/ */
print '<br>'; print '<br>';
print_titre($langs->trans("DeliveryOrderModel")); print_titre($langs->trans("DeliveryOrderModel"));
// Defini tableau def de modele invoice // Defini tableau def de modele
$type="delivery"; $type="delivery";
$def = array(); $def = array();
@ -397,7 +400,7 @@ foreach ($dirmodels as $reldir)
print "</td>"; print "</td>";
} }
// Defaut // Default
print "<td align=\"center\">"; print "<td align=\"center\">";
if ($conf->global->LIVRAISON_ADDON_PDF == "$name") if ($conf->global->LIVRAISON_ADDON_PDF == "$name")
{ {

View File

@ -54,9 +54,9 @@ $specimenthirdparty->initAsSpecimen();
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconstorder=GETPOST('maskconstorder','alpha'); $maskconstorder=GETPOST('maskconstorder','alpha');
$maskorder=GETPOST('maskorder','alpha'); $maskvalue=GETPOST('maskvalue','alpha');
if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity); if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskvalue,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;
@ -70,7 +70,7 @@ if ($action == 'updateMask')
} }
} }
if ($action == 'specimen') // For orders else if ($action == 'specimen') // For orders
{ {
$modele=GETPOST('module','alpha'); $modele=GETPOST('module','alpha');
@ -116,88 +116,54 @@ if ($action == 'specimen') // For orders
} }
} }
if ($action == 'set') // Activate a model
else if ($action == 'set')
{ {
$label = GETPOST('label','alpha'); $ret = addDocumentModel($value, $type, $label, $scandir);
$scandir = GETPOST('scandir','alpha');
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")";
$res=$db->query($sql);
if ($res)
{
}
// else dol_print_error($db);
} }
if ($action == 'del') else if ($action == 'del')
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $ret = delDocumentModel($value, $type);
$sql.= " WHERE nom = '".$value."'"; if ($ret > 0)
$sql.= " AND type = '".$type."'"; {
$sql.= " AND entity = ".$conf->entity; if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_SUPPLIER_ADDON_PDF',$conf->entity);
$db->query($sql); }
if ($res)
{
}
// else dol_print_error($db);
} }
if ($action == 'setdoc') // Set default model
else if ($action == 'setdoc')
{ {
$label = GETPOST('label','alpha'); if (dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
$scandir = GETPOST('scandir','alpha'); {
// La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent
$conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
}
$db->begin(); // On active le modele
$ret = delDocumentModel($value, $type);
if ($type == 'order_supplier' && dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) if ($ret > 0)
{ {
$conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value; $ret = addDocumentModel($value, $type, $label, $scandir);
} }
// On active le modele
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del.= " WHERE nom = '".$db->escape($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, libelle, description)";
$sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")";
$result2=$db->query($sql);
if ($result1 && $result2)
{
$db->commit();
}
else
{
$db->rollback();
}
} }
if ($action == 'setmod') else if ($action == 'setmod')
{ {
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON",$value,'chaine',0,'',$conf->entity); dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
} }
if ($action == 'addcat') else if ($action == 'addcat')
{ {
$fourn = new Fournisseur($db); $fourn = new Fournisseur($db);
$fourn->CreateCategory($user,$_POST["cat"]); $fourn->CreateCategory($user,$_POST["cat"]);
} }
if ($action == 'set_SUPPLIER_ORDER_FREE_TEXT') else if ($action == 'set_SUPPLIER_ORDER_FREE_TEXT')
{ {
$freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT'); // No alpha here, we want exact string $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT'); // No alpha here, we want exact string
@ -306,7 +272,7 @@ foreach ($dirmodels as $reldir)
print '</td>'."\n"; print '</td>'."\n";
print '<td align="center">'; print '<td align="center">';
if ($conf->global->COMMANDE_SUPPLIER_ADDON == "$file") if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER == "$file")
{ {
print img_picto($langs->trans("Activated"),'switch_on'); print img_picto($langs->trans("Activated"),'switch_on');
} }
@ -352,10 +318,8 @@ foreach ($dirmodels as $reldir)
print '</table><br>'; print '</table><br>';
/* /*
* Modeles documents for supplier orders * Documents models for supplier orders
*/ */
print_titre($langs->trans("OrdersModelModule")); print_titre($langs->trans("OrdersModelModule"));
@ -396,17 +360,14 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
$var=true;
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$dir = dol_buildpath($reldir."core/modules/supplier_order/pdf/"); $dir = dol_buildpath($reldir."core/modules/supplier_order/pdf/");
if (is_dir($dir)) if (is_dir($dir))
{ {
$var=true;
$handle=opendir($dir); $handle=opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
@ -448,7 +409,7 @@ foreach ($dirmodels as $reldir)
print "</td>"; print "</td>";
} }
// Defaut // Default
print '<td align="center">'; print '<td align="center">';
if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name")
{ {
@ -485,6 +446,12 @@ foreach ($dirmodels as $reldir)
} }
print '</table><br/>'; print '</table><br/>';
print '<br>';
/*
* Other options
*
*/
print_titre($langs->trans("OtherOptions")); print_titre($langs->trans("OtherOptions"));
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -101,7 +102,7 @@ class modExpedition extends DolibarrModules
$this->const[$r][4] = 0; $this->const[$r][4] = 0;
$r++; $r++;
$this->const[$r][0] = "LIVRAISON_ADDON"; $this->const[$r][0] = "LIVRAISON_ADDON_NUMBER";
$this->const[$r][1] = "chaine"; $this->const[$r][1] = "chaine";
$this->const[$r][2] = "mod_livraison_jade"; $this->const[$r][2] = "mod_livraison_jade";
$this->const[$r][3] = 'Nom du gestionnaire de numerotation des bons de reception'; $this->const[$r][3] = 'Nom du gestionnaire de numerotation des bons de reception';

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -81,21 +82,29 @@ class modFournisseur extends DolibarrModules
$this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_PDF"; $this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_PDF";
$this->const[$r][1] = "chaine"; $this->const[$r][1] = "chaine";
$this->const[$r][2] = "muscadet"; $this->const[$r][2] = "muscadet";
$this->const[$r][3] = 'Nom du gestionnaire de generation des bons de commande en PDF';
$this->const[$r][4] = 0;
$r++; $r++;
$this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON"; $this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_NUMBER";
$this->const[$r][1] = "chaine"; $this->const[$r][1] = "chaine";
$this->const[$r][2] = "mod_commande_fournisseur_muguet"; $this->const[$r][2] = "mod_commande_fournisseur_muguet";
$this->const[$r][3] = 'Nom du gestionnaire de numerotation des commandes fournisseur';
$this->const[$r][4] = 0;
$r++; $r++;
$this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_PDF"; $this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_PDF";
$this->const[$r][1] = "chaine"; $this->const[$r][1] = "chaine";
$this->const[$r][2] = "canelle"; $this->const[$r][2] = "canelle";
$this->const[$r][3] = 'Nom du gestionnaire de generation des factures fournisseur en PDF';
$this->const[$r][4] = 0;
$r++; $r++;
$this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_NUMBER"; $this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_NUMBER";
$this->const[$r][1] = "chaine"; $this->const[$r][1] = "chaine";
$this->const[$r][2] = "tulip"; $this->const[$r][2] = "mod_facture_fournisseur_tulip";
$this->const[$r][3] = 'Nom du gestionnaire de numerotation des factures fournisseur';
$this->const[$r][4] = 0;
$r++; $r++;
// Boxes // Boxes

View File

@ -20,11 +20,11 @@
/** /**
* \file htdocs/core/modules/supplier_order/mod_facture_fournisseur_cactus.php * \file htdocs/core/modules/supplier_order/mod_facture_fournisseur_cactus.php
* \ingroup commande * \ingroup supplier invoice
* \brief File containing the Cactus Class of numbering models of suppliers invoices references * \brief File containing the Cactus Class of numbering models of suppliers invoices references
*/ */
require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/modules_facturefournisseur.php'; require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/modules_facturefournisseur.php';
/** /**
@ -123,7 +123,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
//$date=time(); //$date=time();
$date=$object->datec; // Not always defined $date=$object->datec; // Not always defined
if (empty($date)) $date=$object->date; // Creation date is order date for suppliers orders if (empty($date)) $date=$object->date; // Creation date is invoice date for suppliers invoices
$yymm = strftime("%y%m",$date); $yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1); $num = sprintf("%04s",$max+1);

View File

@ -123,7 +123,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices
return 0; return 0;
} }
$numFinal=get_next_value($db,$mask,'facture_fournisseur','ref','',$objsoc->code_fournisseur,$object->date_commande); $numFinal=get_next_value($db,$mask,'facture_fournisseur','ref','',$objsoc->code_fournisseur,$object->datec);
return $numFinal; return $numFinal;
} }

View File

@ -22,6 +22,7 @@
* \file htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php * \file htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
* \ingroup facture fournisseur * \ingroup facture fournisseur
* \brief File that contains parent class for supplier invoices models * \brief File that contains parent class for supplier invoices models
* and parent class for supplier invoices numbering models
*/ */
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requis car utilise par les classes qui heritent require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requis car utilise par les classes qui heritent
@ -36,7 +37,7 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator
/** /**
* Return list of active generation modules * Return list of active generation models
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show * @param string $maxfilenamelength Max length of value to show
@ -131,7 +132,7 @@ abstract class ModeleNumRefSuppliersInvoices
} }
/** /**
* Create a document onto disk according to template module. * Create a document onto disk according to template model.
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param Object $object Object supplier invoice * @param Object $object Object supplier invoice
@ -158,7 +159,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided
$srctemplatepath=''; $srctemplatepath='';
// Positionne le modele sur le nom du modele a utiliser // Set the model on the model name to use
if (! dol_strlen($modele)) if (! dol_strlen($modele))
{ {
if (! empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) if (! empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF))
@ -189,7 +190,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided
{ {
$file = $prefix."_".$modele.".modules.php"; $file = $prefix."_".$modele.".modules.php";
// On verifie l'emplacement du modele // We checked the location of the model
$file=dol_buildpath($reldir."core/modules/supplier_invoice/pdf/".$file,0); $file=dol_buildpath($reldir."core/modules/supplier_invoice/pdf/".$file,0);
if (file_exists($file)) if (file_exists($file))
{ {
@ -201,7 +202,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided
if ($filefound) break; if ($filefound) break;
} }
// Charge le modele // Load the model
if ($filefound) if ($filefound)
{ {
require_once $file; require_once $file;
@ -219,12 +220,12 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_delete_preview($object); dol_delete_preview($object);
// Appel des triggers // Calls triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($db); $interface=new Interfaces($db);
$result=$interface->run_triggers('BILL_INVOICE_BUILDDOC',$object,$user,$langs,$conf); $result=$interface->run_triggers('BILL_INVOICE_BUILDDOC',$object,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers // End calls triggers
return 1; return 1;
} }
@ -238,7 +239,14 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided
} }
else else
{ {
print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file); if (! $conf->global->INVOICE_SUPPLIER_ADDON_PDF)
{
print $langs->trans("Error")." ".$langs->trans("Error_INVOICE_SUPPLIER_ADDON_PDF_NotDefined");
}
else
{
print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file);
}
return 0; return 0;
} }
} }

View File

@ -1305,6 +1305,59 @@ class FactureFournisseur extends CommonInvoice
$result.=$lien.($max?dol_trunc($this->ref,$max):$this->ref).$lienfin; $result.=$lien.($max?dol_trunc($this->ref,$max):$this->ref).$lienfin;
return $result; return $result;
} }
/**
* Renvoie la reference de facture suivante non utilisee en fonction du modele
* de numerotation actif defini dans INVOICE_SUPPLIER_ADDON_NUMBER
*
* @param Societe $soc objet societe
* @return string reference libre pour la facture
*/
function getNextNumRef($soc)
{
global $db, $langs, $conf;
$langs->load("orders");
$dir = DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/';
if (! empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER))
{
$file = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER.'.php';
if (is_readable($dir.'/'.$file))
{
// Definition du nom de modele de numerotation de commande fournisseur
$modName=$conf->global->INVOICE_SUPPLIER_ADDON_NUMBER;
require_once $dir.'/'.$file;
// Recuperation de la nouvelle reference
$objMod = new $modName($this->db);
$numref = "";
$numref = $objMod->invoice_get_num($soc,$this);
if ( $numref != "")
{
return $numref;
}
else
{
dol_print_error($db, get_class($this)."::getNextNumRef ".$obj->error);
return -1;
}
}
else
{
print $langs->trans("Error")." ".$langs->trans("Error_FailedToLoad_INVOICE_SUPPLIER_ADDON_NUMBER_File",$conf->global->INVOICE_SUPPLIER_ADDON_NUMBER);
return -2;
}
}
else
{
print $langs->trans("Error")." ".$langs->trans("Error_INVOICE_SUPPLIER_ADDON_NUMBER_NotDefined");
return -3;
}
}
/** /**