diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php index 41af6721d52..5a57bef27b7 100644 --- a/htdocs/compta/bank/fiche.php +++ b/htdocs/compta/bank/fiche.php @@ -28,6 +28,7 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/bank.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formbank.class.php"); $langs->load("banks"); $langs->load("companies"); @@ -187,18 +188,16 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user- * View */ +$form = new Form($db); +$formbank = new FormBank($db); +$formcompany = new FormCompany($db); + $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; llxHeader(); -$form = new Form($db); -$formcompany = new FormCompany($db); -/* ************************************************************************** */ -/* */ -/* Affichage page en mode creation */ -/* */ -/* ************************************************************************** */ +// Creation if ($action == 'create') { @@ -238,7 +237,7 @@ if ($action == 'create') // Type print ''.$langs->trans("AccountType").''; print ''; - print $form->select_type_comptes_financiers(isset($_POST["type"])?$_POST["type"]:1,"type"); + print $formbank->select_type_comptes_financiers(isset($_POST["type"])?$_POST["type"]:1,"type"); print ''; // Currency diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b704fa954e7..8962f7add5d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -40,154 +40,154 @@ */ 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 + * @return string HTML edit field + */ + function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='',$extObject=false) + { + 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); + } + 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) @@ -196,158 +196,158 @@ class Form * @param object $extObject External object * @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=false) + { + 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]; + } + 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"; + //$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 @@ -371,7 +371,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)) @@ -390,25 +391,25 @@ class Form } /** - * Return combo list of activated countries, into language of user + * Return combo list of activated countries, into language of user * - * @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 + * @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 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 + * @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 +437,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 +451,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 ''; @@ -654,7 +619,7 @@ class Form */ function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0) { - print $this->select_company($selected,$htmlname,$filter,$showempty,$showtype,$forcecombo); + print $this->select_company($selected,$htmlname,$filter,$showempty,$showtype,$forcecombo); } /** @@ -690,7 +655,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.= ''; } @@ -1047,13 +1012,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").' : '; @@ -1116,18 +1081,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); @@ -1143,7 +1108,7 @@ class Form $num = $this->db->num_rows($result); $outselect.=''."\n"; - } - else if ($input['type'] == 'password') - { - $more.=''.$input['label'].''."\n"; - } - else if ($input['type'] == 'select') - { - $more.=''; - if (! empty($input['label'])) $more.=$input['label'].''; - $more.=$this->selectarray($input['name'],$input['values'],$input['default'],1); - $more.=''."\n"; - } - else if ($input['type'] == 'checkbox') - { - $more.=''; - $more.=''.$input['label'].' '; - $more.=' $selval) - { - $more.=''; - if ($i==0) $more.=''.$input['label'].''; - else $more.=' '; - $more.=''; - $more.=$input['value']; - $more.=''."\n"; - } - array_push($inputarray,$input['name']); - } + if (is_array($input)) + { + if ($input['type'] == 'text') + { + $more.=''.$input['label'].''."\n"; + } + else if ($input['type'] == 'password') + { + $more.=''.$input['label'].''."\n"; + } + else if ($input['type'] == 'select') + { + $more.=''; + if (! empty($input['label'])) $more.=$input['label'].''; + $more.=$this->selectarray($input['name'],$input['values'],$input['default'],1); + $more.=''."\n"; + } + else if ($input['type'] == 'checkbox') + { + $more.=''; + $more.=''.$input['label'].' '; + $more.=' $selval) + { + $more.=''; + if ($i==0) $more.=''.$input['label'].''; + else $more.=' '; + $more.=''; + $more.=$input['value']; + $more.=''."\n"; + } + array_push($inputarray,$input['name']); + } } $more.=''."\n"; } @@ -2184,15 +2149,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':''); @@ -2381,14 +2346,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) { @@ -2417,7 +2382,7 @@ class Form } } - /** + /** * Show a select form to select origin * * @param page Page @@ -2683,7 +2648,7 @@ class Form } } -/** + /** * Affiche formulaire de selection des tiers * * @param page Page @@ -2730,7 +2695,7 @@ class Form */ function select_currency($selected='',$htmlname='currency_id') { - print $this->selectcurrency($selected,$htmlname); + print $this->selectcurrency($selected,$htmlname); } /** @@ -2770,14 +2735,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"; @@ -3505,12 +3472,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; @@ -3599,27 +3566,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; @@ -3653,7 +3620,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) @@ -3664,11 +3631,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); @@ -3678,8 +3645,8 @@ class Form $i = 0; if ($num) { - $out.= ''; + if ($show_empty) $out.= ''."\n"; while ($i < $num) { @@ -3698,7 +3665,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.= ''; @@ -3707,8 +3674,8 @@ class Form } else { - $out.= ''; + $out.= ''; } $out.= ''; } diff --git a/htdocs/core/class/html.formbank.class.php b/htdocs/core/class/html.formbank.class.php new file mode 100644 index 00000000000..b41d700dc51 --- /dev/null +++ b/htdocs/core/class/html.formbank.class.php @@ -0,0 +1,81 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/class/html.formbank.class.php + * \ingroup core + * \brief File of class with all html predefined components + */ + + +/** + * Class to manage generation of HTML components for bank module + */ +class FormBank +{ + var $db; + var $error; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + + /** + * Retourne la liste des types de comptes financiers + * + * @param string $selected Type pre-selectionne + * @param string $htmlname Nom champ formulaire + * @return void + */ + function select_type_comptes_financiers($selected=1,$htmlname='type') + { + global $langs; + $langs->load("banks"); + + $type_available=array(0,1,2); + + print ''; + } + +} + +?>