From 57f8f30494a8cecb5e68faa1f6ecbd9a2bc8ffa3 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Tue, 21 Jan 2014 12:57:32 +0100 Subject: [PATCH 1/4] Correction Reset Mask (before do not work with FA{yy}{mm}-{0000@99} with date 2014-01-01) --- htdocs/core/lib/functions2.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 145049c999c..d8ff3b3eafe 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -612,13 +612,13 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m if ($maskraz > 0) // A reset is required { if ($maskraz == 99) { - $maskraz = date('m'); + $maskraz = date('m',$date); $resetEveryMonth = true; } if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; // Define posy, posm and reg - if ($maskraz > 1) + if ($maskraz >= 1) { if (! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode) && ! preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; From 79c2e314390192370cff2bcefa79d9909bf1df38 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Tue, 21 Jan 2014 13:47:48 +0100 Subject: [PATCH 2/4] Fix mask --- htdocs/core/lib/functions2.lib.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index d8ff3b3eafe..7d642eaf6dd 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -534,10 +534,10 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m // but we should use local year and month of user // For debugging - //include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); - //$mask='{yyyy}-{0000}'; + include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); + $mask='FA{yy}{mm}-{0000@99}'; //$date=dol_mktime(12, 0, 0, 1, 1, 1900); - //$date=dol_stringtotime('20121001'); + $date=dol_stringtotime('20130101'); // Extract value for mask counter, mask raz and mask offset if (! preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$mask,$reg)) return 'ErrorBadMask'; @@ -618,7 +618,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; // Define posy, posm and reg - if ($maskraz >= 1) + if ($maskraz >= 1 && $resetEveryMonth) { if (! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode) && ! preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; @@ -626,10 +626,17 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit'; } - else + elseif ($maskraz > 1) { - if (! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode)) return 'ErrorCantUseRazIfNoYearInMask'; - if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; } + if (! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode) + && ! preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; + if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } + elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } + if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit'; + + } else { + if (! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode)) return 'ErrorCantUseRazIfNoYearInMask'; + if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; } } //print "x".$maskwithonlyymcode." ".$maskraz." ".$posy." ".$posm; //var_dump($reg); From cd84a5fd17c72496cf26d06e7ddbba9908415e4d Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Tue, 21 Jan 2014 13:48:47 +0100 Subject: [PATCH 3/4] remove debug --- htdocs/core/lib/functions2.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 7d642eaf6dd..40b872520a5 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -534,10 +534,10 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m // but we should use local year and month of user // For debugging - include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); - $mask='FA{yy}{mm}-{0000@99}'; + //include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); + //$mask='FA{yy}{mm}-{0000@99}'; //$date=dol_mktime(12, 0, 0, 1, 1, 1900); - $date=dol_stringtotime('20130101'); + //$date=dol_stringtotime('20130101'); // Extract value for mask counter, mask raz and mask offset if (! preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$mask,$reg)) return 'ErrorBadMask'; From 98805ace4aa32317b8e173a2ad3c8440e7244146 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Jan 2014 00:25:42 +0100 Subject: [PATCH 4/4] Fix: Error management when deleting a payment on supplier invoice. --- htdocs/fourn/class/paiementfourn.class.php | 7 +++++-- htdocs/fourn/facture/fiche.php | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index a1324f774ae..582d9158a3c 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -305,8 +305,11 @@ class PaiementFourn extends Paiement if ($bank_line_id) { $accline = new AccountLine($this->db); - $accline->fetch($bank_line_id); - $result=$accline->delete(); + $result=$accline->fetch($bank_line_id); + if ($result > 0) // If result = 0, record not found, we don't try to delete + { + $result=$accline->delete(); + } if ($result < 0) { $this->error=$accline->error; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index c2dc17f798f..6acd960270f 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -234,14 +234,14 @@ elseif ($action == 'setnote_private' && $user->rights->fournisseur->facture->cre } // Delete payment -elseif ($action == 'deletepaiement') +elseif ($action == 'deletepaiement' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); - if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) + if ($object->statut == 1 && $object->paye == 0) { - $paiementfourn = new PaiementFourn($db); - $paiementfourn->fetch(GETPOST('paiement_id')); - $result=$paiementfourn->delete(); + $paiementfourn = new PaiementFourn($db); + $result=$paiementfourn->fetch(GETPOST('paiement_id')); + if ($result > 0) $result=$paiementfourn->delete(); // If fetch ok and found if ($result < 0) $mesg='
'.$paiementfourn->error.'
'; } } @@ -1527,7 +1527,7 @@ else $bankaccountstatic->ref=$objp->ref; $bankaccountstatic->label=$objp->ref; print ''; - print $bankaccountstatic->getNomUrl(1,'transactions'); + if ($objp->baid > 0) print $bankaccountstatic->getNomUrl(1,'transactions'); print ''; } print ''.price($objp->amount).'';