From 21558dd0a623e3b3805a464e740a4eb2310669f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 9 Feb 2021 17:52:33 +0100 Subject: [PATCH] Debug and enhance the feature to assign tasks on project assignation --- htdocs/core/class/commonobject.class.php | 6 +- htdocs/core/class/html.form.class.php | 22 ++- htdocs/core/class/html.formcompany.class.php | 5 +- htdocs/projet/contact.php | 170 ++++++++++--------- 4 files changed, 117 insertions(+), 86 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4ada3c368d0..cc67030ccf6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -970,7 +970,7 @@ abstract class CommonObject * @param int|string $type_contact Type of contact (code or id). Must be id or code found into table llx_c_type_contact. For example: SALESREPFOLL * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) * @param int $notrigger Disable all triggers - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, 0 if already added, >0 if OK */ public function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) { @@ -1075,7 +1075,9 @@ abstract class CommonObject return -1; } } - } else return 0; + } else { + return 0; + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7fbff101859..4284b009019 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4308,7 +4308,7 @@ class Form * @param string $question Question * @param string $action Action * @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>)) - * type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'morecss', ... + * type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'morecss', 'other' or 'onecolumn'... * @param string $selectedchoice '' or 'no', or 'yes' or '1' or '0' * @param int|string $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx * @param int|string $height Force height of box (0 = auto) @@ -4422,6 +4422,8 @@ class Form $moreonecolumn .= '
'; $moreonecolumn .= $input['value']; $moreonecolumn .= '
'."\n"; + } else { + $more .= 'Error type '.$input['type'].' for the confirm box is not a supported type'; } } } @@ -4449,16 +4451,24 @@ class Form } $pageyes = $page.(preg_match('/\?/', $page) ? '&' : '?').'action='.$action.'&confirm=yes'; $pageno = ($useajax == 2 ? $page.(preg_match('/\?/', $page) ? '&' : '?').'confirm=no' : ''); + // Add input fields into list of fields to read during submit (inputok and inputko) - if (is_array($formquestion)) - { - foreach ($formquestion as $key => $input) - { + if (is_array($formquestion)) { + foreach ($formquestion as $key => $input) { //print "xx ".$key." rr ".is_array($input)."
\n"; - if (is_array($input) && isset($input['name'])) array_push($inputok, $input['name']); + // Add name of fields to propagate with the GET when submitting the form with button OK. + if (is_array($input) && isset($input['name'])) { + if (strpos($input['name'], ',') > 0) { + $inputok = array_merge($inputok, explode(',', $input['name'])); + } else { + array_push($inputok, $input['name']); + } + } + // Add name of fields to propagate with the GET when submitting the form with button KO. if (isset($input['inputko']) && $input['inputko'] == 1) array_push($inputko, $input['name']); } } + // Show JQuery confirm box. $formconfirm .= '