From f66750d5e782d5aa91edc6473793db178b665ae6 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 24 May 2013 11:23:56 +0200 Subject: [PATCH 1/3] Fix : Reset every month with @99 was not working properly (for 3.4 branch) --- htdocs/core/lib/functions2.lib.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index d8f86063e18..ab41e5aaec7 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -611,7 +611,10 @@ 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'); + if ($maskraz == 99) { + $maskraz = date('m'); + $resetEveryMonth = true; + } if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; // Define posy, posm and reg @@ -653,13 +656,13 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m else if ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1; } // For backward compatibility - else if (date("m",$date) < $maskraz) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year + else if (date("m",$date) < $maskraz && empty($resetEveryMonth)) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year $yearlen = dol_strlen($reg[$posy]); if ($yearlen == 4) $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset); elseif ($yearlen == 2) $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset); elseif ($yearlen == 1) $yearcomp=substr(date("y",$date),2,1)+$yearoffset; - if ($monthcomp > 1) // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) + if ($monthcomp > 1 && empty($resetEveryMonth)) // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) { if ($yearlen == 4) $yearcomp1=sprintf("%04d",date("Y",$date)+$yearoffset+1); elseif ($yearlen == 2) $yearcomp1=sprintf("%02d",date("y",$date)+$yearoffset+1); @@ -680,6 +683,17 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') "; $sqlwhere.=')'; } + else if($resetEveryMonth) { + $monthlen = dol_strlen($reg[$posm]); + $yearpos = (dol_strlen($reg[1])+1); + $monthpos = ($yearpos+$yearlen); + if ($posy == 3) { + $monthpos = (dol_strlen($reg[1])+1); + $yearpos = ($monthpos+$monthlen); + } + $sqlwhere.=" SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; + $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."' "; + } else // reset is done on january { $sqlwhere.='(SUBSTRING('.$field.', '.(dol_strlen($reg[1])+1).', '.dol_strlen($reg[2]).") = '".$yearcomp."')"; From 0a041a7705af93020738bbaf97609478220842f6 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Fri, 24 May 2013 22:39:28 +0200 Subject: [PATCH 2/3] Fix multilangue search product list --- htdocs/product/liste.php | 47 ++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 0495a318d42..ac1da0a399e 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -5,6 +5,7 @@ * Copyright (C) 2012 Marcos García * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2013 Raphaël Doursenaud + * Copyright (C) 2013 Jean Heimburger * * 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 @@ -131,19 +132,39 @@ else $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; +// multilang + if ($conf->global->MAIN_MULTILANGS) // si l'option est active + { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$langs->getDefaultLang() ."'"; + } $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; if ($sall) { // For natural search $scrit = explode(' ', $sall); - foreach ($scrit as $crit) { - $sql.= " AND (p.ref LIKE '%".$db->escape($crit)."%' OR p.label LIKE '%".$db->escape($crit)."%' OR p.description LIKE '%".$db->escape($crit)."%' OR p.note LIKE '%".$db->escape($crit)."%'"; - if (! empty($conf->barcode->enabled)) - { - $sql.= " OR p.barcode LIKE '%".$db->escape($crit)."%'"; - } - $sql.= ')'; - } + // multilang + if ($conf->global->MAIN_MULTILANGS) // si l'option est active + { + foreach ($scrit as $crit) { + $sql.= " AND (p.ref LIKE '%".$db->escape($crit)."%' OR p.label LIKE '%".$db->escape($crit)."%' OR p.description LIKE '%".$db->escape($crit)."%' OR p.note LIKE '%".$db->escape($crit)."%' OR pl.description LIKE '%".$db->escape($sall)."%' OR pl.note LIKE '%".$db->escape($sall)."%'"; + if (! empty($conf->barcode->enabled)) + { + $sql.= " OR p.barcode LIKE '%".$db->escape($crit)."%'"; + } + $sql.= ')'; + } + } + else + { + foreach ($scrit as $crit) { + $sql.= " AND (p.ref LIKE '%".$db->escape($crit)."%' OR p.label LIKE '%".$db->escape($crit)."%' OR p.description LIKE '%".$db->escape($crit)."%' OR p.note LIKE '%".$db->escape($crit)."%'"; + if (! empty($conf->barcode->enabled)) + { + $sql.= " OR p.barcode LIKE '%".$db->escape($crit)."%'"; + } + $sql.= ')'; + } + } } // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($type)) @@ -153,7 +174,15 @@ else } if ($sref) $sql.= " AND p.ref LIKE '%".$sref."%'"; if ($sbarcode) $sql.= " AND p.barcode LIKE '%".$sbarcode."%'"; - if ($snom) $sql.= " AND p.label LIKE '%".$db->escape($snom)."%'"; + if ($snom) + { + // multilang + if ($conf->global->MAIN_MULTILANGS) // si l'option est active + { + $sql.= " AND (p.label LIKE '%".$db->escape($snom)."%' OR (pl.label IS NOT null AND pl.label LIKE '%".$db->escape($snom)."%'))"; + } + else $sql.= " AND p.label LIKE '%".$db->escape($snom)."%'"; +} if (isset($tosell) && dol_strlen($tosell) > 0) $sql.= " AND p.tosell = ".$db->escape($tosell); if (isset($tobuy) && dol_strlen($tobuy) > 0) $sql.= " AND p.tobuy = ".$db->escape($tobuy); if (dol_strlen($canvas) > 0) $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; From 8656a9f41736212ee021d83920420e22a38d8300 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Sat, 25 May 2013 16:50:55 +0200 Subject: [PATCH 3/3] Fix [ bug #895 ] Description is lost when adding a new predefined product to a contract --- htdocs/contrat/fiche.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index ae5a1190c49..9c1f1ae2973 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -433,7 +433,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer) $desc = $prod->description; $desc.= $prod->description && GETPOST('desc') ? "\n" : ""; - $desc.= GETPOST('desc'); + $desc.= GETPOST('np_desc'); } else { @@ -871,10 +871,10 @@ if ($action == 'create') print ''.$langs->trans("NotePublic").''; - + $doleditor=new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, 70); print $doleditor->Create(1); - + if (! $user->societe_id) {