Skip to content
Snippets Groups Projects
Commit a6ef341a authored by Maxime Kohlhaas's avatar Maxime Kohlhaas
Browse files

Task # 1016 : can define a specific numbering for deposits

parent eccbf89e
No related branches found
No related tags found
No related merge requests found
......@@ -53,10 +53,13 @@ if ($action == 'updateMask')
{
$maskconstinvoice=GETPOST('maskconstinvoice','alpha');
$maskconstcredit=GETPOST('maskconstcredit','alpha');
$maskconstdeposit=GETPOST('maskconstdeposit','alpha');
$maskinvoice=GETPOST('maskinvoice','alpha');
$maskcredit=GETPOST('maskcredit','alpha');
$maskdeposit=GETPOST('maskdeposit','alpha');
if ($maskconstinvoice) $res = dolibarr_set_const($db,$maskconstinvoice,$maskinvoice,'chaine',0,'',$conf->entity);
if ($maskconstcredit) $res = dolibarr_set_const($db,$maskconstcredit,$maskcredit,'chaine',0,'',$conf->entity);
if ($maskconstdeposit) $res = dolibarr_set_const($db,$maskconstdeposit,$maskdeposit,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
......@@ -387,6 +390,21 @@ foreach ($dirmodels as $reldir)
{
$htmltooltip.=$langs->trans("NextValueForCreditNotes").': ';
if ($nextval)
{
$htmltooltip.=$nextval.'<br>';
}
else
{
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
// Example for deposit invoice
$facture->type=3;
$nextval=$module->getNextValue($mysoc,$facture);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=$langs->trans("NextValueForDeposit").': ';
if ($nextval)
{
$htmltooltip.=$nextval;
}
......
......@@ -56,6 +56,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
$texte.= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconstinvoice" value="FACTURE_MERCURE_MASK_INVOICE">';
$texte.= '<input type="hidden" name="maskconstcredit" value="FACTURE_MERCURE_MASK_CREDIT">';
$texte.= '<input type="hidden" name="maskconstdeposit" value="FACTURE_MERCURE_MASK_DEPOSIT">';
$texte.= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"));
......@@ -68,7 +69,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'):</td>';
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->FACTURE_MERCURE_MASK_INVOICE.'">',$tooltip,1,1).'</td>';
$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '<td align="left" rowspan="3">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr>';
......@@ -77,6 +78,11 @@ class mod_facture_mercure extends ModeleNumRefFactures
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->FACTURE_MERCURE_MASK_CREDIT.'">',$tooltip,1,1).'</td>';
$texte.= '</tr>';
// Parametrage du prefix des acomptes
$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->FACTURE_MERCURE_MASK_DEPOSIT.'">',$tooltip,1,1).'</td>';
$texte.= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
......@@ -124,6 +130,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
// Get Mask value
$mask = '';
if (is_object($facture) && $facture->type == 2) $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT;
else if (is_object($facture) && $facture->type == 3) $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT;
else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
if (! $mask)
{
......
......@@ -32,6 +32,7 @@ class mod_facture_terre extends ModeleNumRefFactures
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $prefixinvoice='FA';
var $prefixcreditnote='AV';
var $prefixdeposit='AC';
var $error='';
/**
......@@ -43,7 +44,7 @@ class mod_facture_terre extends ModeleNumRefFactures
{
global $langs;
$langs->load("bills");
return $langs->trans('TerreNumRefModelDesc1',$this->prefixinvoice,$this->prefixcreditnote);
return $langs->trans('TerreNumRefModelDesc1',$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit);
}
/**
......@@ -110,6 +111,27 @@ class mod_facture_terre extends ModeleNumRefFactures
$this->error=$langs->trans('ErrorNumRefModel',$max);
return false;
}
// Check deposit num
$fayymm='';
$posindice=8;
$sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$this->prefixdeposit."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; }
}
if ($fayymm && ! preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i',$fayymm))
{
$this->error=$langs->trans('ErrorNumRefModel',$max);
return false;
}
return true;
}
......@@ -127,6 +149,7 @@ class mod_facture_terre extends ModeleNumRefFactures
global $db,$conf;
if ($facture->type == 2) $prefix=$this->prefixcreditnote;
else if ($facture->type == 3) $prefix=$this->prefixdeposit;
else $prefix=$this->prefixinvoice;
// D'abord on recupere la valeur max
......
......@@ -72,6 +72,7 @@ Mask=Mask
NextValue=Next value
NextValueForInvoices=Next value (invoices)
NextValueForCreditNotes=Next value (credit notes)
NextValueForDeposit=Next value (deposit)
MustBeLowerThanPHPLimit=Note: your PHP limits each file upload's size to <b>%s</b> %s, whatever this parameter's value is
NoMaxSizeByPHPLimit=Note: No limit is set in your PHP configuration
MaxSizeForUploadedFiles=Maximum size for uploaded files (0 to disallow any upload)
......
......@@ -411,7 +411,7 @@ PDFCrabeDescription=Invoice PDF template Crabe. A complete invoice template (Tem
# oursin PDF Model
PDFOursinDescription=Invoice PDF template Oursin. A complete invoice template (Template alternative)
# NumRef Modules
TerreNumRefModelDesc1=Return numero with format %syymm-nnnn for standard invoices and %syymm-nnnn for credit notes where yy is year, mm is month and nnnn is a sequence with no break and no return to 0
TerreNumRefModelDesc1=Return numero with format %syymm-nnnn for standard invoices, %syymm-nnnn for credit notes and %syymm-nnnn for deposits where yy is year, mm is month and nnnn is a sequence with no break and no return to 0
MarsNumRefModelDesc1=Return numero with format %syymm-nnnn for standard invoices, %syymm-nnnn for replacement invoices, %syymm-nnnn for proforma invoices and %syymm-nnnn for credit notes where yy is year, mm is month and nnnn is a sequence with no break and no return to 0
TerreNumRefModelError=A bill starting with $syymm already exists and is not compatible with this model of sequence. Remove it or rename it to activate this module.
......@@ -72,6 +72,7 @@ Mask=Masque
NextValue=Prochaine valeur
NextValueForInvoices=Prochaine valeur (factures)
NextValueForCreditNotes=Prochaine valeur (avoirs)
NextValueForDeposit=Prochaine valeur (acomptes)
MustBeLowerThanPHPLimit=Remarque : Votre PHP limite la taille des envois à <b>%s</b> %s, quelle que soit la valeur de ce paramètre
NoMaxSizeByPHPLimit=Aucune limite configurée dans votre serveur PHP
MaxSizeForUploadedFiles=Taille maximum des fichiers envoyés (0 pour interdire l'envoi)
......
......@@ -411,7 +411,7 @@ PDFCrabeDescription=Modèle de facture PDF complet (modèle recommandé par déf
# oursin PDF Model
PDFOursinDescription=Modèle de facture PDF complet (modèle alternatif)
# NumRef Modules
TerreNumRefModelDesc1=Renvoie le numéro sous la forme %syymm-nnnn pour les factures et %syymm-nnnn pour les avoirs où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0
TerreNumRefModelDesc1=Renvoie le numéro sous la forme %syymm-nnnn pour les factures, %syymm-nnnn pour les avoirs et %syymm-nnnn pour les acomptes où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0
MarsNumRefModelDesc1=Renvoie le numéro sous la forme %syymm-nnnn pour les factures, %syymm-nnnn pour les factures de remplacement, %syymm-nnnn pour les factures proforma et %syymm-nnnn pour les avoirs où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0
TerreNumRefModelError=Une facture commençant par $syymm existe déjà et est incompatible avec cet modèle de numérotation. Supprimez-la ou renommez-la pour activer ce module.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment