From 3705c352c88665ed8acfd84a13907be187da65fb Mon Sep 17 00:00:00 2001 From: sparkyx Date: Mon, 24 Nov 2025 13:16:44 +0100 Subject: [PATCH] Card : quick code by default based on accounting + name --- include/class/fiche.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index f9a031cda..0858e6b8d 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -482,7 +482,7 @@ class Fiche * \brief insert a new record thanks an array , either as parameter or $_POST * * \param $p_fiche_def fiche_def.fd_id - * \param $p_array is the array containing the data key = av_textX where X is AD_ID + * \param $p_array (double array) array containing arrays of key (av_textX where X is AD_ID ), value of the property *\param $transation DEPRECATED : if we are in a transaction, we don't commit here , else if not, the * then a transaction is started and committed * @@ -527,10 +527,14 @@ class Fiche // by default the quick_code is the base account of the class + first letters of the name if ( $p_array["av_text".ATTR_DEF_QUICKCODE] =="") { - $base_acc=$this->cn->get_value("select fd_class_base from fiche_def where fd_id = $1", + if ( ! empty( $p_array['av_text'. ATTR_DEF_ACCOUNT])) { + $base_acc=substr($p_array['av_text'. ATTR_DEF_ACCOUNT]??"",0, 3); + }else { + $base_acc=$this->cn->get_value("select substr(fd_class_base,1,2) from fiche_def where fd_id = $1", [$p_fiche_def]); + } $p_array["av_text".ATTR_DEF_QUICKCODE]=sprintf("%s%s" - , substr($base_acc,0, 3) + , $base_acc , substr($p_array["av_text".ATTR_DEF_NAME], 0, 4) ); }