From f5637463105ecc51c0c7b4dbf1de1d1e80c0ed43 Mon Sep 17 00:00:00 2001 From: Quentin Vial-Gouteyron <quentin@mail.atm-consulting.fr> Date: Mon, 29 May 2017 15:38:40 +0200 Subject: [PATCH] NEW_extrafield_in_project_mask --- htdocs/core/lib/functions2.lib.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) mode change 100644 => 100755 htdocs/core/lib/functions2.lib.php diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php old mode 100644 new mode 100755 index 8934447fdfe..69ee228504d --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -711,7 +711,7 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti */ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true) { - global $conf; + global $conf,$user; if (! is_object($objsoc)) $valueforccc=$objsoc; else if($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur; @@ -790,7 +790,16 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $maskpersonew[$regKey[1]]=str_pad('', '_', $regKey[2], STR_PAD_RIGHT); $tmpmask=preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew, $tmpmask); }*/ - + + if(strstr($mask,'extra_')){ + + $start = "{extra_"; + $end = "\}"; + $extra= get_string_between($mask, "extra_", "}"); + if(!empty($user->array_options['options_'.$extra])){ + $mask = preg_replace('#('.($start).')(.*?)('.($end).')#si', $user->array_options['options_'.$extra], $mask); + } + } $maskwithonlyymcode=$mask; $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$maskcounter,$maskwithonlyymcode); $maskwithonlyymcode=preg_replace('/\{dd\}/i','dd',$maskwithonlyymcode); @@ -1110,7 +1119,14 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m dol_syslog("functions2::get_next_value return ".$numFinal,LOG_DEBUG); return $numFinal; } - +function get_string_between($string, $start, $end){ + $string = " ".$string; + $ini = strpos($string,$start); + if ($ini == 0) return ""; + $ini += strlen($start); + $len = strpos($string,$end,$ini) - $ini; + return substr($string,$ini,$len); +} /** * Check value * -- GitLab