From 0cff48f9b30432005eaad93e55c03b8f16169085 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 21 Feb 2012 10:47:08 +0100 Subject: [PATCH] Fix: merge conflict --- htdocs/core/class/commonobject.class.php | 7 +- htdocs/core/class/conf.class.php | 4 +- htdocs/core/class/html.form.class.php | 1275 +++++++++------------- 3 files changed, 537 insertions(+), 749 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 439820a5ac5..44e6edc6d1a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1534,13 +1534,13 @@ abstract class CommonObject $sql.= "(fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')"; $sql.= " ".$clause." (fk_target = '".$targetid."' AND targettype = '".$targettype."')"; } - print $sql; + //print $sql; dol_syslog(get_class($this)."::fetchObjectLink sql=".$sql); $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); echo 'num='.$num.'
'; + $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { @@ -1549,14 +1549,13 @@ abstract class CommonObject { $this->linkedObjectsIds[$obj->targettype][]=$obj->fk_target; } - echo 'fk_target='.$obj->fk_target.' targetid='.$targetid.'
'; if ($obj->fk_target == $targetid) { $this->linkedObjectsIds[$obj->sourcetype][]=$obj->fk_source; } $i++; } -var_dump($this->linkedObjectsIds); + if (! empty($this->linkedObjectsIds)) { foreach($this->linkedObjectsIds as $objecttype => $objectids) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 8d5fb4ffabd..ddff62fc474 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -238,9 +238,9 @@ class Conf if (! empty($this->global->MAIN_MODULE_MULTICOMPANY) && ! empty($this->entity) && $this->entity > 1) { $rootfordata.='/'.$this->entity; - var_dump($mc->sharings); + //var_dump($mc->sharings); //var_dump($mc->referent); - var_dump($mc->entities); + //var_dump($mc->entities); } // For backward compatibility diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b9ef43a31ba..cd105ecc066 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -35,320 +35,322 @@ /** - * \class Form - * \brief Class to manage generation of HTML components - * \remarks Only common components must be here. + * Class to manage generation of HTML components + * Only common components must be here. */ class Form { - var $db; - var $error; + var $db; + var $error; - // Cache arrays - var $cache_types_paiements=array(); - var $cache_conditions_paiements=array(); - var $cache_availability=array(); - var $cache_demand_reason=array(); - var $cache_type_fees=array(); + // Cache arrays + var $cache_types_paiements=array(); + var $cache_conditions_paiements=array(); + var $cache_availability=array(); + var $cache_demand_reason=array(); + var $cache_type_fees=array(); - var $tva_taux_value; - var $tva_taux_libelle; + var $tva_taux_value; + var $tva_taux_libelle; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Output key field for an editable field - * - * @param string $text Text of label or key to translate - * @param string $htmlname Name of select field - * @param string $preselected Name of Value to show/edit (not used in this function) - * @param object $object Object - * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) - * @return string HTML edit field - */ - function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='string') - { - global $conf,$langs; + /** + * Output key field for an editable field + * + * @param string $text Text of label or key to translate + * @param string $htmlname Name of select field + * @param string $preselected Name of Value to show/edit (not used in this function) + * @param object $object Object + * @param boolean $perm Permission to allow button to edit parameter + * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) + * @return string HTML edit field + */ + function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='string') + { + global $conf,$langs; - $ret=''; + $ret=''; - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) - { - if ($perm) - { - $tmp=explode(':',$typeofdata); - $ret.= '
'; - $ret.= $langs->trans($text); - $ret.= '
'."\n"; - } - else - { - $ret.= $langs->trans($text); - } - } - else - { - $ret.=''; - if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; - $ret.='
'; - $ret.=$langs->trans($text); - $ret.='id.'">'.img_edit($langs->trans('Edit'),1).'
'; - } + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) + { + if ($perm) + { + $tmp=explode(':',$typeofdata); + $ret.= '
'; + $ret.= $langs->trans($text); + $ret.= '
'."\n"; + } + else + { + $ret.= $langs->trans($text); + } + } + else + { + $ret.=''; + if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; + $ret.='
'; + $ret.=$langs->trans($text); + $ret.='id.'">'.img_edit($langs->trans('Edit'),1).'
'; + } - return $ret; - } + return $ret; + } - /** - * Output val field for an editable field - * - * @param string $text Text of label (not used in this function) - * @param string $htmlname Name of select field - * @param string $value Value to show/edit - * @param object $object Object - * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) - * @param string $editvalue When in edit mode, use this value as $value instead of value - * @param object $extObject External object - * @return string HTML edit field - */ - function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='',$extObject=false) - { - global $conf,$langs,$db; + /** + * Output val field for an editable field + * + * @param string $text Text of label (not used in this function) + * @param string $htmlname Name of select field + * @param string $value Value to show/edit + * @param object $object Object + * @param boolean $perm Permission to allow button to edit parameter + * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) + * @param string $editvalue When in edit mode, use this value as $value instead of value + * @param object $extObject External object + * @param string $success Success message + * @return string HTML edit field + */ + function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='',$extObject=null,$success=null) + { + global $conf,$langs,$db; - $ret=''; + $ret=''; - // When option to edit inline is activated - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) - { - $ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $extObject); - } - else - { - if (GETPOST('action') == 'edit'.$htmlname) - { - $ret.="\n"; - $ret.='
'; - $ret.=''; - $ret.=''; - $ret.=''; - $ret.=''; - $ret.=''; - if ($typeofdata != 'day' && $typeofdata != 'datepicker') $ret.=''; - $ret.='
'; - if (preg_match('/^(string|email|numeric)/',$typeofdata)) - { - $tmp=explode(':',$typeofdata); - $ret.=''; - } - else if ($typeofdata == 'text' || $typeofdata == 'textarea' || $typeofdata == 'note') - { - $ret.=''; - } - else if ($typeofdata == 'day' || $typeofdata == 'datepicker') - { - $ret.=$this->form_date($_SERVER['PHP_SELF'].'?id='.$object->id,$value,$htmlname); - } - else if (preg_match('/^ckeditor/',$typeofdata)) - { - $tmp=explode(':',$typeofdata); - require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor($htmlname,($editvalue?$editvalue:$value),($tmp[2]?$tmp[2]:''),($tmp[3]?$tmp[3]:'100'),($tmp[1]?$tmp[1]:'dolibarr_notes'),'In',false,true,true); - $ret.=$doleditor->Create(1); - } - $ret.='
'."\n"; - $ret.='
'."\n"; - } - else - { - if ($typeofdata == 'email') $ret.=dol_print_email($value,0,0,0,0,1); - elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($value,'day'); - elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($value); - else if (preg_match('/^ckeditor/',$typeofdata)) - { - $tmpcontent=dol_htmlentitiesbr($value); - $firstline=preg_replace('/
.*/','',$tmpcontent); - $firstline=preg_replace('/[\n\r].*/','',$firstline); - $ret.=$firstline.((strlen($firstline) != strlen($tmpcontent))?'...':''); - } - else $ret.=$value; - } - } - return $ret; - } + // When option to edit inline is activated + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) + { + $ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $extObject, $success); + } + else + { + if (GETPOST('action') == 'edit'.$htmlname) + { + $ret.="\n"; + $ret.='
'; + $ret.=''; + $ret.=''; + $ret.=''; + $ret.=''; + $ret.=''; + if ($typeofdata != 'day' && $typeofdata != 'datepicker') $ret.=''; + $ret.='
'; + if (preg_match('/^(string|email|numeric)/',$typeofdata)) + { + $tmp=explode(':',$typeofdata); + $ret.=''; + } + else if ($typeofdata == 'text' || $typeofdata == 'textarea' || $typeofdata == 'note') + { + $ret.=''; + } + else if ($typeofdata == 'day' || $typeofdata == 'datepicker') + { + $ret.=$this->form_date($_SERVER['PHP_SELF'].'?id='.$object->id,$value,$htmlname); + } + else if (preg_match('/^ckeditor/',$typeofdata)) + { + $tmp=explode(':',$typeofdata); + require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); + $doleditor=new DolEditor($htmlname,($editvalue?$editvalue:$value),($tmp[2]?$tmp[2]:''),($tmp[3]?$tmp[3]:'100'),($tmp[1]?$tmp[1]:'dolibarr_notes'),'In',false,true,true); + $ret.=$doleditor->Create(1); + } + $ret.='
'."\n"; + $ret.='
'."\n"; + } + else + { + if ($typeofdata == 'email') $ret.=dol_print_email($value,0,0,0,0,1); + elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($value,'day'); + elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($value); + else if (preg_match('/^ckeditor/',$typeofdata)) + { + $tmpcontent=dol_htmlentitiesbr($value); + $firstline=preg_replace('/
.*/','',$tmpcontent); + $firstline=preg_replace('/[\n\r].*/','',$firstline); + $ret.=$firstline.((strlen($firstline) != strlen($tmpcontent))?'...':''); + } + else $ret.=$value; + } + } + return $ret; + } - /** - * Output edit in place form - * + /** + * Output edit in place form + * * @param object $object Object * @param string $value Value to show/edit * @param string $htmlname DIV ID (field name) * @param int $condition Condition to edit * @param string $inputType Type of input ('numeric', 'datepicker', 'textarea', 'ckeditor:dolibarr_zzz', 'select:xxx') * @param object $extObject External object + * @param string $success Success message * @return string HTML edit in place */ - private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $extObject=false) - { - global $conf; + private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $extObject=null, $success=null) + { + global $conf; - $out=''; + $out=''; - // Check parameters - if ($inputType == 'textarea') $value = dol_nl2br($value); - else if (preg_match('/^numeric/',$inputType)) $value = price($value); - else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day'); + // Check parameters + if ($inputType == 'textarea') $value = dol_nl2br($value); + else if (preg_match('/^numeric/',$inputType)) $value = price($value); + else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day'); - if ($condition) - { - $element = false; - $table_element = false; - $fk_element = false; - $loadmethod = false; - $savemethod = false; - $ext_element = false; - //$ext_table_element = false; - //$ext_fk_element = false; + if ($condition) + { + $element = false; + $table_element = false; + $fk_element = false; + $loadmethod = false; + $savemethod = false; + $ext_element = false; + //$ext_table_element = false; + //$ext_fk_element = false; - if (is_object($object)) - { - $element = $object->element; - $table_element = $object->table_element; - $fk_element = $object->id; - } + if (is_object($object)) + { + $element = $object->element; + $table_element = $object->table_element; + $fk_element = $object->id; + } - if (is_object($extObject)) - { - $ext_element = $extObject->element; - //$ext_table_element = $extObject->table_element; - //$ext_fk_element = $extObject->id; - } + if (is_object($extObject)) + { + $ext_element = $extObject->element; + //$ext_table_element = $extObject->table_element; + //$ext_fk_element = $extObject->id; + } - if (preg_match('/^(string|email|numeric)/',$inputType)) - { - $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $inputOption=$tmp[1]; - if (! empty($tmp[2])) $savemethod=$tmp[2]; - } - if (preg_match('/^datepicker/',$inputType)) - { - $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $inputOption=$tmp[1]; - if (! empty($tmp[2])) $savemethod=$tmp[2]; + if (preg_match('/^(string|email|numeric)/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $inputOption=$tmp[1]; + if (! empty($tmp[2])) $savemethod=$tmp[2]; + } + else if (preg_match('/^datepicker/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $inputOption=$tmp[1]; + if (! empty($tmp[2])) $savemethod=$tmp[2]; - $out.= ''."\n"; // Use for timestamp format - } - else if (preg_match('/^select/',$inputType)) - { - $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $loadmethod=$tmp[1]; - if (! empty($tmp[2])) $savemethod=$tmp[2]; - } - else if (preg_match('/^ckeditor/',$inputType)) - { - $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $toolbar=$tmp[1]; - if (! empty($tmp[2])) $width=$tmp[2]; - if (! empty($tmp[3])) $heigth=$tmp[3]; - if (! empty($tmp[4])) $savemethod=$tmp[4]; + $out.= ''."\n"; // Use for timestamp format + } + else if (preg_match('/^select/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $loadmethod=$tmp[1]; + if (! empty($tmp[2])) $savemethod=$tmp[2]; + } + else if (preg_match('/^ckeditor/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $toolbar=$tmp[1]; + if (! empty($tmp[2])) $width=$tmp[2]; + if (! empty($tmp[3])) $heigth=$tmp[3]; + if (! empty($tmp[4])) $savemethod=$tmp[4]; - if (! empty($conf->fckeditor->enabled)) - { - $out.= ''."\n"; - } - else - { - $inputType = 'textarea'; - } - } + if (! empty($conf->fckeditor->enabled)) + { + $out.= ''."\n"; + } + else + { + $inputType = 'textarea'; + } + } - $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - //$out.= ''."\n"; - //$out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + if (! empty($success)) $out.= ''."\n"; + //$out.= ''."\n"; + //$out.= ''."\n"; - $out.= '
'.$value.'
'."\n"; - } - else - { - $out = $value; - } + $out.= '
'.$value.'
'."\n"; + } + else + { + $out = $value; + } - return $out; - } + return $out; + } - /** - * Show a text and picto with tooltip on text or picto - * - * @param string $text Text to show - * @param string $htmltext Content html of tooltip. Must be HTML/UTF8 encoded. - * @param int $tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2 - * @param int $direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres - * @param string $img Code img du picto (use img_xxx() function to get it) - * @param string $extracss Add a CSS style to td tags - * @param int $notabs Do not include table and tr tags - * @param string $incbefore Include code before the text - * @param int $noencodehtmltext Do not encode into html entity the htmltext - * @return string Code html du tooltip (texte+picto) - * @see Use function textwithpicto if you can. - */ - function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$extracss='',$notabs=0,$incbefore='',$noencodehtmltext=0) - { - global $conf; + /** + * Show a text and picto with tooltip on text or picto + * + * @param string $text Text to show + * @param string $htmltext Content html of tooltip. Must be HTML/UTF8 encoded. + * @param int $tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2 + * @param int $direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres + * @param string $img Code img du picto (use img_xxx() function to get it) + * @param string $extracss Add a CSS style to td tags + * @param int $notabs Do not include table and tr tags + * @param string $incbefore Include code before the text + * @param int $noencodehtmltext Do not encode into html entity the htmltext + * @return string Code html du tooltip (texte+picto) + * @see Use function textwithpicto if you can. + */ + function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$extracss='',$notabs=0,$incbefore='',$noencodehtmltext=0) + { + global $conf; - if ($incbefore) $text = $incbefore.$text; - if (! $htmltext) return $text; + if ($incbefore) $text = $incbefore.$text; + if (! $htmltext) return $text; - // Sanitize tooltip - $htmltext=str_replace("\\","\\\\",$htmltext); - $htmltext=str_replace("\r","",$htmltext); - $htmltext=str_replace("\n","",$htmltext); + // Sanitize tooltip + $htmltext=str_replace("\\","\\\\",$htmltext); + $htmltext=str_replace("\r","",$htmltext); + $htmltext=str_replace("\n","",$htmltext); - $htmltext=str_replace('"',""",$htmltext); - if ($tooltipon == 2 || $tooltipon == 3) $paramfortooltipimg=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td img tag to store tooltip - else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag - if ($tooltipon == 1 || $tooltipon == 3) $paramfortooltiptd=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip - else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag + $htmltext=str_replace('"',""",$htmltext); + if ($tooltipon == 2 || $tooltipon == 3) $paramfortooltipimg=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td img tag to store tooltip + else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag + if ($tooltipon == 1 || $tooltipon == 3) $paramfortooltiptd=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip + else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag - $s=""; - if (empty($notabs)) $s.=''; - if ($direction > 0) - { - if ($text != '') - { - $s.=''.$text; - if ($direction) $s.=' '; - $s.=''; - } - if ($direction) $s.=''.$img.''; - } - else - { - if ($direction) $s.=''.$img.''; - if ($text != '') - { - $s.=''; - if ($direction) $s.=' '; - $s.=$text.''; - } - } - if (empty($notabs)) $s.='
'; + $s=""; + if (empty($notabs)) $s.=''; + if ($direction > 0) + { + if ($text != '') + { + $s.=''.$text; + if ($direction) $s.=' '; + $s.=''; + } + if ($direction) $s.=''.$img.''; + } + else + { + if ($direction) $s.=''.$img.''; + if ($text != '') + { + $s.=''; + if ($direction) $s.=' '; + $s.=$text.''; + } + } + if (empty($notabs)) $s.='
'; - return $s; - } + return $s; + } /** * Show a text with a picto and a tooltip on picto @@ -372,7 +374,8 @@ class Form if (empty($conf->use_javascript_ajax)) { if ($type == 'info' || $type == 'help') return $text; - else { $alt=$htmltext; $htmltext=''; } + else { $alt=$htmltext; $htmltext=''; + } } // If info or help with smartphone, show only text if (! empty($conf->browser->phone)) @@ -391,24 +394,25 @@ class Form } /** - * Return combo list of activated countries, into language of user + * Return combo list of activated countries, into language of user * - * @param selected Id or Code or Label of preselected country - * @param htmlname Name of html select object - * @param htmloption Options html on select object + * @param string $selected Id or Code or Label of preselected country + * @param string $htmlname Name of html select object + * @param string $htmloption Options html on select object + * @return void */ function select_pays($selected='',$htmlname='pays_id',$htmloption='') { - print $this->select_country($selected,$htmlname,$htmloption); + print $this->select_country($selected,$htmlname,$htmloption); } /** - * Return combo list of activated countries, into language of user + * Return combo list of activated countries, into language of user * - * @param selected Id or Code or Label of preselected country - * @param htmlname Name of html select object - * @param htmloption Options html on select object - * @return string HTML string with select + * @param string $selected Id or Code or Label of preselected country + * @param string $htmlname Name of html select object + * @param string $htmloption Options html on select object + * @return string HTML string with select */ function select_country($selected='',$htmlname='pays_id',$htmloption='') { @@ -436,13 +440,13 @@ class Form { $foundselected=false; - while ($i < $num) - { + while ($i < $num) + { $obj = $this->db->fetch_object($resql); $countryArray[$i]['rowid'] = $obj->rowid; $countryArray[$i]['code_iso'] = $obj->code_iso; $countryArray[$i]['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:'')); - $label[$i] = $countryArray[$i]['label']; + $label[$i] = $countryArray[$i]['label']; $i++; } @@ -450,10 +454,10 @@ class Form foreach ($countryArray as $row) { - //print 'rr'.$selected.'-'.$row['label'].'-'.$row['code_iso'].'
'; - if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['label']) ) - { - $foundselected=true; + //print 'rr'.$selected.'-'.$row['label'].'-'.$row['code_iso'].'
'; + if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['label']) ) + { + $foundselected=true; $out.= ''; + print ''; } print ''; @@ -711,29 +610,15 @@ class Form } /** - * Output html form to select a third party + * Output html form to select a third party * - * @param selected Preselected type - * @param htmlname Name of field in form - * @param filter Optionnal filters criteras - * @param showempty Add an empty field - * @param showtype Show third party type in combolist (customer, prospect or supplier) - * @param forcecombo Force to use combo box - */ - function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0) - { - print $this->select_company($selected,$htmlname,$filter,$showempty,$showtype,$forcecombo); - } - - /** - * Output html form to select a third party - * - * @param selected Preselected type - * @param htmlname Name of field in form - * @param filter Optionnal filters criteras - * @param showempty Add an empty field - * @param showtype Show third party type in combolist (customer, prospect or supplier) - * @param forcecombo Force to use combo box + * @param string $selected Preselected type + * @param string $htmlname Name of field in form + * @param string $filter Optionnal filters criteras + * @param int $showempty Add an empty field + * @param int $showtype Show third party type in combolist (customer, prospect or supplier) + * @param int $forcecombo Force to use combo box + * @return string HTML string with */ function select_company($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0) { @@ -750,7 +635,7 @@ class Form if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " ORDER BY nom ASC"; - dol_syslog("Form::select_societes sql=".$sql); + dol_syslog(get_class($this)."::select_company sql=".$sql); $resql=$this->db->query($sql); if ($resql) { @@ -758,7 +643,7 @@ class Form { //$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); - $out.= ajax_combobox($htmlname); + $out.= ajax_combobox($htmlname); } $out.= ''; - if ($show_empty) $out.= ''."\n"; + $out.= ''; - $out.= ''; + $out.= ''; } @@ -1115,13 +1000,13 @@ class Form if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) { - if ($selected && empty($selected_input_value)) - { - require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); - $product = new Product($this->db); - $product->fetch($selected); - $selected_input_value=$product->ref; - } + if ($selected && empty($selected_input_value)) + { + require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); + $product = new Product($this->db); + $product->fetch($selected); + $selected_input_value=$product->ref; + } // mode=1 means customers products print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajaxproducts.php', 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); if (! $hidelabel) print $langs->trans("RefOrLabel").' : '; @@ -1184,18 +1069,18 @@ class Form // Add criteria on ref/label if ($filterkey && $filterkey != '') { - if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) // Can use index - { - $sql.=" AND (p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%'"; - if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '".$filterkey."%'"; - $sql.=")"; - } - else - { - $sql.=" AND (p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%'"; - if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '%".$filterkey."%'"; - $sql.=")"; - } + if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) // Can use index + { + $sql.=" AND (p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%'"; + if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '".$filterkey."%'"; + $sql.=")"; + } + else + { + $sql.=" AND (p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%'"; + if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '%".$filterkey."%'"; + $sql.=")"; + } } $sql.= $db->order("p.ref"); $sql.= $db->plimit($limit); @@ -1211,7 +1096,7 @@ class Form $num = $this->db->num_rows($result); $outselect.=''; - print ''; - $num = $this->db->num_rows($resql); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - if ($selected == $obj->id) - { - print ''; - $i++; - } - } - print ''; - } - else - { - dol_print_error($this->db); - } - } - - /** * Return a HTML select list of bank accounts * @@ -2204,7 +2029,7 @@ class Form return $output; } - /** + /** * Show a confirmation HTML form or AJAX popup * * @param page Url of page to call if confirmation is OK @@ -2219,7 +2044,7 @@ class Form */ function form_confirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=170, $width=500) { - print $this->formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width); + print $this->formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width); } /** @@ -2245,65 +2070,65 @@ class Form if (is_array($formquestion) && count($formquestion) > 0) { - $more.=''."\n"; + $more.='
'."\n"; $more.=''."\n"; foreach ($formquestion as $key => $input) { - if (is_array($input)) - { - if ($input['type'] == 'text') - { - $more.=''."\n"; - } - else if ($input['type'] == 'password') - { - $more.=''."\n"; - } - else if ($input['type'] == 'select') - { - $more.=''."\n"; - } - else if ($input['type'] == 'checkbox') - { - $more.=''; - $more.=''; - if ($i==0) $more.=''; - else $more.=''; - $more.=''."\n"; - } - array_push($inputarray,$input['name']); - } + if (is_array($input)) + { + if ($input['type'] == 'text') + { + $more.=''."\n"; + } + else if ($input['type'] == 'password') + { + $more.=''."\n"; + } + else if ($input['type'] == 'select') + { + $more.=''."\n"; + } + else if ($input['type'] == 'checkbox') + { + $more.=''; + $more.=''; + if ($i==0) $more.=''; + else $more.=''; + $more.=''."\n"; + } + array_push($inputarray,$input['name']); + } } $more.='
'.$formquestion['text'].'
'.$input['label'].'
'.$input['label'].'
'; - if (! empty($input['label'])) $more.=$input['label'].''; - $more.=$this->selectarray($input['name'],$input['values'],$input['default'],1); - $more.='
'.$input['label'].' '; - $more.=' $selval) - { - $more.='
'.$input['label'].' '; - $more.=$input['value']; - $more.='
'.$input['label'].'
'.$input['label'].'
'; + if (! empty($input['label'])) $more.=$input['label'].''; + $more.=$this->selectarray($input['name'],$input['values'],$input['default'],1); + $more.='
'.$input['label'].' '; + $more.=' $selval) + { + $more.='
'.$input['label'].' '; + $more.=$input['value']; + $more.='
'."\n"; } @@ -2312,15 +2137,15 @@ class Form if ($useajax && $conf->use_javascript_ajax) { - $autoOpen=true; - $dialogconfirm='dialog-confirm'; - if (! is_int($useajax)) - { - $button=$useajax; - $useajax=1; - $autoOpen=false; - $dialogconfirm.='-'.$button; - } + $autoOpen=true; + $dialogconfirm='dialog-confirm'; + if (! is_int($useajax)) + { + $button=$useajax; + $useajax=1; + $autoOpen=false; + $dialogconfirm.='-'.$button; + } $pageyes=$page.'&action='.$action.'&confirm=yes'; $pageno=($useajax == 2?$page.'&confirm=no':''); @@ -2509,14 +2334,14 @@ class Form } } - /** - * Show a form to select a delivery delay + /** + * Show a form to select a delivery delay * - * @param page Page - * @param selected Id condition pre-selectionne - * @param htmlname Name of select html field - * @param addempty Ajoute entree vide - * @return void + * @param int $page Page + * @param string $selected Id condition pre-selectionne + * @param string $htmlname Name of select html field + * @param int $addempty Ajoute entree vide + * @return void */ function form_availability($page, $selected='', $htmlname='availability', $addempty=0) { @@ -2545,7 +2370,7 @@ class Form } } - /** + /** * Show a select form to select origin * * @param page Page @@ -2811,12 +2636,12 @@ class Form } } -/** - * Affiche formulaire de selection des tiers + /** + * Output html select to select thirdparty * - * @param page Page - * @param selected Id contact pre-selectionne - * @param htmlname Nom du formulaire select + * @param string $page Page + * @param string $selected Id preselected + * @param string $htmlname Name of HTML select * @return void */ function form_thirdparty($page, $selected='', $htmlname='socid') @@ -2830,7 +2655,7 @@ class Form print ''; print ''; print ''; print ''; print '
'; - $num=$this->select_societes($selected , $htmlname); + print $this->select_company($selected , $htmlname); print '
'; @@ -2843,48 +2668,6 @@ class Form $soc = new Societe($this->db); $soc->fetch($selected); print $soc->getNomUrl($langs); - } else { - print " "; - } - } - } - - /** - * Show form to select addresse - * - * @param page Page - * @param selected Id condition pre-selectionne - * @param htmlname Nom du formulaire select - * @param origin Origine de l'appel pour pouvoir creer un retour - * @param originid Id de l'origine - * @return void - * @deprecated - */ - function form_address($page, $selected='', $socid, $htmlname='address_id', $origin='', $originid='') - { - global $langs,$conf; - if ($htmlname != "none") - { - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'; - $this->select_address($selected, $socid, $htmlname, 1); - print ''; - $langs->load("companies"); - print '   '.$langs->trans("AddAddress").''; - print '
'; - } - else - { - if ($selected) - { - require_once(DOL_DOCUMENT_ROOT ."/societe/class/address.class.php"); - $address=new Address($this->db); - $result=$address->fetch_address($selected); - print ''.$address->label.''; } else { @@ -2902,7 +2685,7 @@ class Form */ function select_currency($selected='',$htmlname='currency_id') { - print $this->selectcurrency($selected,$htmlname); + print $this->selectcurrency($selected,$htmlname); } /** @@ -2942,14 +2725,14 @@ class Form $obj = $this->db->fetch_object($resql); $currencyArray[$i]['code_iso'] = $obj->code_iso; $currencyArray[$i]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:'')); - $label[$i] = $currencyArray[$i]['label']; + $label[$i] = $currencyArray[$i]['label']; $i++; } array_multisort($label, SORT_ASC, $currencyArray); foreach ($currencyArray as $row) { - if ($selected && $selected == $row['code_iso']) { + if ($selected && $selected == $row['code_iso']) { $foundselected=true; $out.= '\n"; @@ -3628,21 +3414,21 @@ class Form * Return a HTML area with the reference of object and a navigation bar for a business object * To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria. * - * @param object Object to show - * @param paramid Name of parameter to use to name the id into the URL link - * @param morehtml More html content to output just before the nav bar - * @param shownav Show Condition (navigation is shown if value is 1) - * @param fieldid Nom du champ en base a utiliser pour select next et previous - * @param fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous - * @param morehtmlref Code html supplementaire a afficher apres ref - * @param moreparam More param to add in nav link url. - * @return string Portion HTML avec ref + boutons nav + * @param Object $object Object to show + * @param int $paramid Name of parameter to use to name the id into the URL link + * @param string $morehtml More html content to output just before the nav bar + * @param int $shownav Show Condition (navigation is shown if value is 1) + * @param int $fieldid Nom du champ en base a utiliser pour select next et previous + * @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous + * @param string $morehtmlref Code html supplementaire a afficher apres ref + * @param string $moreparam More param to add in nav link url. + * @return tring Portion HTML avec ref + boutons nav */ function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='') { $ret=''; - //print "$paramid,$morehtml,$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; + //print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; $object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid); $previous_ref = $object->ref_previous?''.img_previous().'':''; $next_ref = $object->ref_next?''.img_next().'':''; @@ -3653,14 +3439,17 @@ class Form } $ret.=$object->$fieldref; - if ($morehtmlref) { + if ($morehtmlref) + { $ret.=' '.$morehtmlref; } - if ($morehtml) { + if ($morehtml) + { $ret.=''.$morehtml; } - if ($shownav && ($previous_ref || $next_ref)) { + if ($shownav && ($previous_ref || $next_ref)) + { $ret.=''.$previous_ref.''; $ret.=''.$next_ref; } @@ -3673,12 +3462,12 @@ class Form /** - * Return HTML code to output a barcode - * - * @param Object &$object Object containing data to retrieve file name - * @param int $width Width of photo - * @return string HTML code to output barcode - */ + * Return HTML code to output a barcode + * + * @param Object &$object Object containing data to retrieve file name + * @param int $width Width of photo + * @return string HTML code to output barcode + */ function showbarcode(&$object,$width=100) { global $conf; @@ -3767,27 +3556,27 @@ class Form else dol_print_error('','Call of showphoto with wrong parameters'); /* Disabled. lightbox seems to not work. I don't know why. - $ret.="\n\n"; + $ret.="\n\n"; $ret.="\n\n"; + jQuery(function() { + jQuery('.photologo').lightBox({ + overlayBgColor: '#FFF', + overlayOpacity: 0.6, + imageLoading: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-ico-loading.gif', + imageBtnClose: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-btn-close.gif', + imageBtnPrev: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-btn-prev.gif', + imageBtnNext: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-btn-next.gif', + containerResizeSpeed: 350, + txtImage: 'Imagem', + txtOf: 'de' + }); + }); + \n"; */ return $ret; @@ -3821,7 +3610,7 @@ class Form $sql = "SELECT ug.rowid, ug.nom "; if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity) { - $sql.= ", e.label"; + $sql.= ", e.label"; } $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as ug "; if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity) @@ -3832,11 +3621,11 @@ class Form } else { - $sql.= " WHERE ug.entity IN (0,".$conf->entity.")"; + $sql.= " WHERE ug.entity IN (0,".$conf->entity.")"; } if (is_array($exclude) && $excludeGroups) $sql.= " AND ug.rowid NOT IN ('".$excludeGroups."')"; if (is_array($include) && $includeGroups) $sql.= " AND ug.rowid IN ('".$includeGroups."')"; - $sql.= " ORDER BY ug.nom ASC"; + $sql.= " ORDER BY ug.nom ASC"; dol_syslog("Form::select_dolgroups sql=".$sql); $resql=$this->db->query($sql); @@ -3846,8 +3635,8 @@ class Form $i = 0; if ($num) { - $out.= ''; + if ($show_empty) $out.= ''."\n"; while ($i < $num) { @@ -3866,7 +3655,7 @@ class Form $out.= $obj->nom; if(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) { - $out.= " (".$obj->label.")"; + $out.= " (".$obj->label.")"; } $out.= ''; @@ -3875,8 +3664,8 @@ class Form } else { - $out.= ''; + $out.= ''; } $out.= ''; }