63 public function setBarcodeEncoder($selected, $barcodelist, $code_id, $idForm =
'formbarcode')
69 if (!empty($conf->use_javascript_ajax)) {
70 print
"\n".
'<script nonce="'.
getNonce().
'" type="text/javascript">';
71 print
'jQuery(document).ready(function () {
72 jQuery("#select'.$idForm.
'").change(function() {
73 var formName = document.getElementById("form'.$idForm.
'");
74 formName.action.value="setcoder";
78 print
'</script>'.
"\n";
83 if (((isModEnabled(
"product") || isModEnabled(
"service")) &&
getDolGlobalString(
'PRODUIT_DEFAULT_BARCODE_TYPE') == $code_id) ||
84 (isModEnabled(
"societe") &&
getDolGlobalString(
'GENBARCODE_BARCODETYPE_THIRDPARTY') == $code_id)) {
85 $disable =
'disabled';
88 if (!empty($conf->use_javascript_ajax)) {
89 $select_encoder =
'<form action="'.DOL_URL_ROOT.
'/admin/barcode.php" method="POST" id="form'.$idForm.
'">';
90 $select_encoder .=
'<input type="hidden" name="token" value="'.newToken().
'">';
91 $select_encoder .=
'<input type="hidden" name="action" value="update">';
92 $select_encoder .=
'<input type="hidden" name="code_id" value="'.$code_id.
'">';
95 $selectname = (!empty($conf->use_javascript_ajax) ?
'coder' :
'coder'.$code_id);
96 $select_encoder .=
'<select id="select'.$idForm.
'" class="flat" name="'.$selectname.
'">';
97 $select_encoder .=
'<option value="0"'.($selected == 0 ?
' selected' :
'').
' '.$disable.
'>'.$langs->trans(
'Disable').
'</option>';
98 $select_encoder .=
'<option value="-1" disabled>--------------------</option>';
99 foreach ($barcodelist as $key => $value) {
100 $select_encoder .=
'<option value="'.$key.
'"'.($selected == $key ?
' selected' :
'').
'>'.$value.
'</option>';
102 $select_encoder .=
'</select>';
104 if (!empty($conf->use_javascript_ajax)) {
105 $select_encoder .=
'</form>';
108 return $select_encoder;
137 global $langs, $conf;
141 $sql =
"SELECT rowid, code, libelle as label";
142 $sql .=
" FROM ".$this->db->prefix().
"c_barcode_type";
143 $sql .=
" WHERE coder <> '0'";
144 $sql .=
" AND entity = ".$conf->entity;
145 $sql .=
" ORDER BY code";
147 $result = $this->db->query($sql);
149 $num = $this->db->num_rows($result);
152 if ($useempty && $num > 0) {
153 $out .=
'<select class="flat minwidth75imp" name="'.$htmlname.
'" id="select_'.$htmlname.
'">';
154 $out .=
'<option value="0"> </option>';
156 $langs->load(
"errors");
157 $out .=
'<select disabled class="flat minwidth75imp" name="'.$htmlname.
'" id="select_'.$htmlname.
'">';
158 $out .=
'<option value="0" selected>'.$langs->trans(
'ErrorNoActivatedBarcode').
'</option>';
162 $obj = $this->db->fetch_object($result);
163 if ($selected == $obj->rowid) {
164 $out .=
'<option value="'.$obj->rowid.
'" selected>';
166 $out .=
'<option value="'.$obj->rowid.
'">';
206 global $langs, $conf;
208 if ($htmlname !=
"none") {
209 $out .=
'<form method="post" action="'.$page.
'">';
210 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
211 $out .=
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
212 $out .=
'<table class="nobordernopadding">';
216 $out .=
'<td class="left"><input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
217 $out .=
'</td></tr></table></form>';
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getNonce()
Return a random string to be used as a nonce value for js.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.