From 77eaa635fe3275fbda1bf49699163ce4e5e6d86e Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 10 Nov 2016 06:29:11 +0100 Subject: [PATCH 1/4] Align actions buttons --- htdocs/fourn/facture/card.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 923d226a57c..47198891a5a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2623,7 +2623,7 @@ else // Modify a validated invoice with no payments if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer) { - print ''.$langs->trans('Modify').''; + print '
'.$langs->trans('Modify').'
'; } // Reopen a standard paid invoice @@ -2631,11 +2631,11 @@ else { if (! $facidnext && $object->close_code != 'replaced') // Not replaced by another invoice { - print ''.$langs->trans('ReOpen').''; + print '
'.$langs->trans('ReOpen').'
'; } else { - print ''.$langs->trans('ReOpen').''; + print '
'.$langs->trans('ReOpen').'
'; } } @@ -2644,22 +2644,22 @@ else { if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send) { - print ''.$langs->trans('SendByMail').''; + print '
'.$langs->trans('SendByMail').'
'; } - else print ''.$langs->trans('SendByMail').''; + else print '
'.$langs->trans('SendByMail').'
'; } // Make payments if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) { - print ''.$langs->trans('DoPayment').''; // must use facid because id is for payment id not invoice + print '
'.$langs->trans('DoPayment').'
'; // must use facid because id is for payment id not invoice } // Classify paid if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) { - print ''.$langs->trans('ClassifyPaid').''; + print '
'.$langs->trans('ClassifyPaid').'
'; //print ''.$langs->trans('ClassifyPaid').''; } @@ -2672,13 +2672,13 @@ else if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate))) { - print ''.$langs->trans('Validate').''; + print '
'.$langs->trans('Validate').'
'; } else { - print ''.$langs->trans('Validate').''; + print '
'.$langs->trans('Validate').'
'; } } } @@ -2692,7 +2692,7 @@ else // Clone if ($action != 'edit' && $user->rights->fournisseur->facture->creer) { - print 'socid.'">'.$langs->trans('ToClone').''; + print '
socid.'">'.$langs->trans('ToClone').'
'; } // Create a credit note @@ -2710,7 +2710,7 @@ else if ($object->getSommePaiement()) { print '
' . $langs->trans('Delete') . '
'; } else { - print ''.$langs->trans('Delete').''; + print '
'.$langs->trans('Delete').'
'; } } print ''; From f3da39c0a76184affa2312ec6b5e1708842c43a4 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 10 Nov 2016 06:51:15 +0100 Subject: [PATCH 2/4] Add buttons to convert to reduction or money back --- htdocs/fourn/facture/card.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 47198891a5a..ecad08da51a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2650,7 +2650,7 @@ else } // Make payments - if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) + if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) { print ''; // must use facid because id is for payment id not invoice } @@ -2664,6 +2664,32 @@ else //print ''.$langs->trans('ClassifyPaid').''; } + // Reverse back money or convert to reduction + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) { + // For credit note only + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0) + { + if ($resteapayer == 0) + { + print '
'.$langs->trans('DoPaymentBack').'
'; + } + else + { + print ''; + } + } + + // For credit note + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() == 0) { + print ''; + } + // For deposit invoice + if ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->paye == 1 && $resteapayer == 0 && $user->rights->fournisseur->facture->creer && empty($discount->id)) + { + print ''; + } + } + // Validate if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_DRAFT) { From 60219fa84d97349250cd18f7213b487ea13f3faf Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 11 Nov 2016 07:06:45 +0100 Subject: [PATCH 3/4] Update tulip model --- .../mod_facture_fournisseur_tulip.php | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index ba31d979864..b7a3801a9cd 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -3,7 +3,8 @@ * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Philippe Grand - * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2016 Alexandre Spangaro * * 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 @@ -59,6 +60,9 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $texte.= ''; $texte.= ''; $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; $texte.= ''; $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")); @@ -68,13 +72,28 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $tooltip.=$langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; + // Parametrage du prefix des replacement + $texte.= ''; + $texte.= ''; + $texte.= ''; + + // Parametrage du prefix des avoirs + $texte.= ''; + $texte.= ''; + $texte.= ''; + + // Parametrage du prefix des acomptes + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= '
'.$langs->trans("Mask").':
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'):'.$form->textwithpicto('',$tooltip,1,1).' 
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):'.$form->textwithpicto('',$tooltip,1,1).'
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):'.$form->textwithpicto('',$tooltip,1,1).'
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):'.$form->textwithpicto('',$tooltip,1,1).'
'; $texte.= ''; @@ -106,7 +125,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices * Return next value * * @param Societe $objsoc Object third party - * @param Object $object Object + * @param Object $object Object invoice * @param string $mode 'next' for next value or 'last' for last value * @return string Value if OK, 0 if KO */ @@ -116,16 +135,26 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; - // On defini critere recherche compteur - $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; - + // Get Mask value + $mask = ''; + if (is_object($object) && $object->type == 1) + { + $mask=$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK; + if (! $mask) + { + $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; + } + } + else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK; + else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK; + else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; if (! $mask) { $this->error='NotConfigured'; return 0; } - //Supplier invoices take invoice date instead of creation date for the mask + // Supplier invoices take invoice date instead of creation date for the mask $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date); return $numFinal; From c65678d00a718bfa6779eb742a5be0475df444ce Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 11 Nov 2016 07:36:26 +0100 Subject: [PATCH 4/4] Update cactus numbering model --- .../mod_facture_fournisseur_cactus.php | 109 +++++++++++++----- htdocs/langs/en_US/bills.lang | 1 + 2 files changed, 81 insertions(+), 29 deletions(-) diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index ea0456bc3ff..0a4f5d98c46 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2016 Alexandre Spangaro * * 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 @@ -21,14 +22,15 @@ /** * \file htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php * \ingroup supplier invoice - * \brief File containing the Cactus Class of numbering models of suppliers invoices references + * \brief File containing class for the numbering module Cactus */ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/modules_facturefournisseur.php'; /** - * Cactus Class of numbering models of suppliers invoices references + * \class mod_facture_fournisseur_cactus + * \brief Cactus Class of numbering models of suppliers invoices references */ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices { @@ -36,6 +38,8 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices var $error = ''; var $nom = 'Cactus'; var $prefixinvoice='SI'; + var $prefixcreditnote='SA'; + var $prefixdeposit='SD'; /** @@ -46,7 +50,8 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices function info() { global $langs; - return $langs->trans("SimpleNumRefModelDesc",$this->prefixinvoice); + $langs->load("bills"); + return $langs->trans("CactusNumRefModelDesc1",$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit); } @@ -61,45 +66,90 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices } - /** - * Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering. - * - * @return boolean false if conflict, true if ok - */ - function canBeActivated() - { - global $conf,$langs,$db; + /** + * Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering. + * + * @return boolean false if conflict, true if ok + */ + function canBeActivated() + { + global $conf,$langs,$db; - $siyymm=''; $max=''; + $langs->load("bills"); + + // Check invoice num + $siyymm=''; $max=''; $posindice=8; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; $sql.= " WHERE ref LIKE '".$this->prefixinvoice."____-%'"; - $sql.= " AND entity = ".$conf->entity; - $resql=$db->query($sql); - if ($resql) - { - $row = $db->fetch_row($resql); - if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } - } - if (! $siyymm || preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$siyymm)) - { - return true; - } - else - { + $sql.= " AND entity = ".$conf->entity; + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } + } + if (! $siyymm || preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$siyymm)) + { + return true; + } + else + { $langs->load("errors"); $this->error=$langs->trans('ErrorNumRefModel',$max); - return false; - } + return false; + } + + // Check credit note num + $siyymm=''; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; + $sql.= " WHERE ref LIKE '".$this->prefixcreditnote."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } + } + if ($siyymm && ! preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i',$siyymm)) + { + $this->error=$langs->trans('ErrorNumRefModel',$max); + return false; + } + + // Check deposit num + $siyymm=''; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; + $sql.= " WHERE ref LIKE '".$this->prefixdeposit."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } + } + if ($siyymm && ! preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i',$siyymm)) + { + $this->error=$langs->trans('ErrorNumRefModel',$max); + return false; + } } /** * Return next value * * @param Societe $objsoc Object third party - * @param Object $object Object + * @param Object $object Object invoice * @param string $mode 'next' for next value or 'last' for last value * @return string Value if OK, 0 if KO */ @@ -108,6 +158,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices global $db,$conf; if ($object->type == 2) $prefix=$this->prefixcreditnote; + else if ($facture->type == 3) $prefix=$this->prefixdeposit; else $prefix=$this->prefixinvoice; // D'abord on recupere la valeur max diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 3f4898630ba..825c31744e0 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -446,6 +446,7 @@ PDFCrevetteDescription=Invoice PDF template Crevette. A complete invoice templat TerreNumRefModelDesc1=Return number 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 MarsNumRefModelDesc1=Return number with format %syymm-nnnn for standard invoices, %syymm-nnnn for replacement invoices, %syymm-nnnn for deposit 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. +CactusNumRefModelDesc1=Return number with format %syymm-nnnn for standard invoices, %syymm-nnnn for credit notes and %syymm-nnnn for deposit invoices where yy is year, mm is month and nnnn is a sequence with no break and no return to 0 ##### Types de contacts ##### TypeContact_facture_internal_SALESREPFOLL=Representative following-up customer invoice TypeContact_facture_external_BILLING=Customer invoice contact