490 |
|
|
491 |
|
|
492 |
/** |
/** |
493 |
* \brief Charge dans cache la liste des conditions de paiements possibles |
* \brief Charge dans cache la liste des conditions de paiements possibles |
494 |
|
* \return int Nb lignes chargées, 0 si déjà chargées, <0 si ko |
495 |
*/ |
*/ |
496 |
function load_cache_conditions_paiements() |
function load_cache_conditions_paiements() |
497 |
{ |
{ |
498 |
global $langs; |
global $langs; |
499 |
|
|
500 |
|
if (sizeof($this->cache_conditions_paiements_code)) return 0; // Cache déja chargé |
501 |
|
|
502 |
dolibarr_syslog('html.form.class.php::load_cache_conditions_paiements'); |
dolibarr_syslog('html.form.class.php::load_cache_conditions_paiements'); |
503 |
$sql = "SELECT rowid, libelle"; |
$sql = "SELECT rowid, libelle"; |
504 |
$sql.= " FROM ".MAIN_DB_PREFIX."cond_reglement"; |
$sql.= " FROM ".MAIN_DB_PREFIX."cond_reglement"; |
528 |
} |
} |
529 |
|
|
530 |
/** |
/** |
531 |
* \brief Charge dans cache la liste des types de paiements possibles |
* \brief Charge dans cache la liste des types de paiements possibles |
532 |
|
* \return int Nb lignes chargées, 0 si déjà chargées, <0 si ko |
533 |
*/ |
*/ |
534 |
function load_cache_types_paiements() |
function load_cache_types_paiements() |
535 |
{ |
{ |
536 |
global $langs; |
global $langs; |
537 |
|
|
538 |
|
if (sizeof($this->cache_types_paiements_code)) return 0; // Cache déja chargé |
539 |
|
|
540 |
dolibarr_syslog('html.form.class.php::load_cache_types_paiements'); |
dolibarr_syslog('html.form.class.php::load_cache_types_paiements'); |
541 |
$sql = "SELECT id, code, libelle, type"; |
$sql = "SELECT id, code, libelle, type"; |
542 |
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement"; |
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement"; |
558 |
$this->cache_types_paiements_type[$obj->id]=$obj->type; |
$this->cache_types_paiements_type[$obj->id]=$obj->type; |
559 |
$i++; |
$i++; |
560 |
} |
} |
561 |
return 1; |
return $num; |
562 |
} |
} |
563 |
else { |
else { |
564 |
dolibarr_print_error($this->db); |
dolibarr_print_error($this->db); |
569 |
|
|
570 |
|
|
571 |
/** |
/** |
572 |
* \brief Retourne la liste des types de paiements possibles |
* \brief Retourne la liste des types de paiements possibles |
573 |
* \param selected Type de praiement présélectionné |
* \param selected Id du type de paiement présélectionné |
574 |
* \param htmlname Nom de la zone select |
* \param htmlname Nom de la zone select |
575 |
* \param filtertype Pour filtre |
* \param filtertype Pour filtre |
576 |
*/ |
*/ |
577 |
function select_conditions_paiements($selected='',$htmlname='condid',$filtertype=-1) |
function select_conditions_paiements($selected='',$htmlname='condid',$filtertype=-1) |
578 |
{ |
{ |
579 |
global $langs; |
global $langs; |
580 |
|
|
581 |
// Charge le cache si premier appel |
$this->load_cache_conditions_paiements(); |
|
if (! sizeof($this->cache_conditions_paiements_code)) |
|
|
{ |
|
|
$this->load_cache_conditions_paiements(); |
|
|
} |
|
582 |
|
|
583 |
print '<select class="flat" name="'.$htmlname.'">'; |
print '<select class="flat" name="'.$htmlname.'">'; |
584 |
foreach($this->cache_conditions_paiements_code as $id => $code) |
foreach($this->cache_conditions_paiements_code as $id => $code) |
585 |
{ |
{ |
586 |
if ($selected == $code) |
if ($selected == $id) |
587 |
{ |
{ |
588 |
print '<option value="'.$id.'" selected="true">'; |
print '<option value="'.$id.'" selected="true">'; |
589 |
} |
} |
601 |
|
|
602 |
|
|
603 |
/** |
/** |
604 |
* \brief Retourne la liste des types de paiements possibles |
* \brief Retourne la liste des modes de paiements possibles |
605 |
* \param selected Type de praiement présélectionné |
* \param selected Id du mode de paiement présélectionné |
606 |
* \param htmlname Nom de la zone select |
* \param htmlname Nom de la zone select |
607 |
* \param filtertype Pour filtre |
* \param filtertype Pour filtre |
608 |
* \param format 0=id+libelle, 1=code+code |
* \param format 0=id+libelle, 1=code+code |
614 |
$filterarray=array(); |
$filterarray=array(); |
615 |
if ($filtertype && $filtertype != '-1') $filterarray=split(',',$filtertype); |
if ($filtertype && $filtertype != '-1') $filterarray=split(',',$filtertype); |
616 |
|
|
617 |
// Charge le cache si premier appel |
$this->load_cache_types_paiements(); |
|
if (! sizeof($this->cache_types_paiements_code)) |
|
|
{ |
|
|
$this->load_cache_types_paiements(); |
|
|
} |
|
618 |
|
|
|
//dolibarr_syslog('html.form.class.php::select_types_paiements use cache'); |
|
619 |
print '<select class="flat" name="'.$htmlname.'">'; |
print '<select class="flat" name="'.$htmlname.'">'; |
620 |
foreach($this->cache_types_paiements_code as $id => $code) |
foreach($this->cache_types_paiements_code as $id => $code) |
621 |
{ |
{ |
624 |
|
|
625 |
if ($format == 0) print '<option value="'.$id.'"'; |
if ($format == 0) print '<option value="'.$id.'"'; |
626 |
if ($format == 1) print '<option value="'.$code.'"'; |
if ($format == 1) print '<option value="'.$code.'"'; |
627 |
if ($selected == $code) |
// Si selected est text, on compare avec code, sinon avec id |
628 |
{ |
if (eregi('[a-z]', $selected) && $selected == $code) print ' selected="true"'; |
629 |
print ' selected="true"'; |
elseif ($selected == $id) print ' selected="true"'; |
|
} |
|
630 |
print '>'; |
print '>'; |
631 |
if ($format == 0) print $this->cache_types_paiements_libelle[$id]; |
if ($format == 0) print $this->cache_types_paiements_libelle[$id]; |
632 |
if ($format == 1) print $code; |
if ($format == 1) print $code; |
927 |
} |
} |
928 |
|
|
929 |
|
|
930 |
/** |
/** |
931 |
* \brief Affiche formulaire de selection de projet |
* \brief Affiche formulaire de selection de projet |
932 |
* \param page Page |
* \param page Page |
933 |
* \param socid Id societe |
* \param socid Id societe |
934 |
* \param selected Id projet présélectionné |
* \param selected Id projet présélectionné |
935 |
* \param htmlname Nom du formulaire select |
* \param htmlname Nom du formulaire select |
936 |
*/ |
*/ |
937 |
function form_project($page, $socid, $selected='', $htmlname='projectid') |
function form_project($page, $socid, $selected='', $htmlname='projectid') |
938 |
{ |
{ |
939 |
global $langs; |
global $langs; |
961 |
} |
} |
962 |
} |
} |
963 |
|
|
964 |
/** |
/** |
965 |
* \brief Retourne la liste des devies, dans la langue de l'utilisateur |
* \brief Affiche formulaire de selection de conditions de paiement |
966 |
* \param selected code devise pré-sélectionnée |
* \param page Page |
967 |
* \param htmlname nom de la liste deroulante |
* \param selected Id condition présélectionnée |
968 |
* \todo trier liste sur noms après traduction plutot que avant |
* \param htmlname Nom du formulaire select |
969 |
*/ |
*/ |
970 |
|
function form_conditions_reglement($page, $selected='', $htmlname='cond_reglement_id') |
971 |
|
{ |
972 |
|
global $langs; |
973 |
|
if ($htmlname != "none") |
974 |
|
{ |
975 |
|
print '<form method="post" action="'.$page.'">'; |
976 |
|
print '<input type="hidden" name="action" value="setconditions">'; |
977 |
|
print '<table class="noborder" cellpadding="0" cellspacing="0">'; |
978 |
|
print '<tr><td>'; |
979 |
|
$this->select_conditions_paiements($selected,$htmlname); |
980 |
|
print '</td>'; |
981 |
|
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; |
982 |
|
print '</tr></table></form>'; |
983 |
|
} |
984 |
|
else |
985 |
|
{ |
986 |
|
if ($selected) |
987 |
|
{ |
988 |
|
$this->load_cache_conditions_paiements(); |
989 |
|
print $this->cache_conditions_paiements_libelle[$selected]; |
990 |
|
} else { |
991 |
|
print " "; |
992 |
|
} |
993 |
|
} |
994 |
|
} |
995 |
|
|
996 |
|
|
997 |
|
/** |
998 |
|
* \brief Affiche formulaire de selection des modes de reglement |
999 |
|
* \param page Page |
1000 |
|
* \param selected Id mode présélectionné |
1001 |
|
* \param htmlname Nom du formulaire select |
1002 |
|
*/ |
1003 |
|
function form_modes_reglement($page, $selected='', $htmlname='mode_reglement_id') |
1004 |
|
{ |
1005 |
|
global $langs; |
1006 |
|
if ($htmlname != "none") |
1007 |
|
{ |
1008 |
|
print '<form method="post" action="'.$page.'">'; |
1009 |
|
print '<input type="hidden" name="action" value="setmode">'; |
1010 |
|
print '<table class="noborder" cellpadding="0" cellspacing="0">'; |
1011 |
|
print '<tr><td>'; |
1012 |
|
$this->select_types_paiements($selected,$htmlname); |
1013 |
|
print '</td>'; |
1014 |
|
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; |
1015 |
|
print '</tr></table></form>'; |
1016 |
|
} |
1017 |
|
else |
1018 |
|
{ |
1019 |
|
if ($selected) |
1020 |
|
{ |
1021 |
|
$this->load_cache_types_paiements(); |
1022 |
|
print $this->cache_types_paiements_libelle[$selected]; |
1023 |
|
} else { |
1024 |
|
print " "; |
1025 |
|
} |
1026 |
|
} |
1027 |
|
} |
1028 |
|
|
1029 |
|
|
1030 |
|
/** |
1031 |
|
* \brief Retourne la liste des devises, dans la langue de l'utilisateur |
1032 |
|
* \param selected code devise pré-sélectionnée |
1033 |
|
* \param htmlname nom de la liste deroulante |
1034 |
|
* \todo trier liste sur noms après traduction plutot que avant |
1035 |
|
*/ |
1036 |
function select_currency($selected='',$htmlname='currency_id') |
function select_currency($selected='',$htmlname='currency_id') |
1037 |
{ |
{ |
1038 |
global $conf,$langs; |
global $conf,$langs; |