64 public function setBarcodeEncoder($selected, $barcodelist, $code_id, $idForm =
'formbarcode')
70 if (!empty($conf->use_javascript_ajax)) {
71 print
"\n".
'<script nonce="'.
getNonce().
'" type="text/javascript">';
72 print
'jQuery(document).ready(function () {
73 jQuery("#select'.$idForm.
'").change(function() {
74 var formName = document.getElementById("form'.$idForm.
'");
75 formName.action.value="setcoder";
79 print
'</script>'.
"\n";
84 if (((isModEnabled(
"product") || isModEnabled(
"service")) &&
getDolGlobalString(
'PRODUIT_DEFAULT_BARCODE_TYPE') == $code_id) ||
85 (isModEnabled(
"societe") &&
getDolGlobalString(
'GENBARCODE_BARCODETYPE_THIRDPARTY') == $code_id)) {
86 $disable =
'disabled';
89 if (!empty($conf->use_javascript_ajax)) {
90 $select_encoder =
'<form action="'.DOL_URL_ROOT.
'/admin/barcode.php" method="POST" id="form'.$idForm.
'">';
91 $select_encoder .=
'<input type="hidden" name="token" value="'.newToken().
'">';
92 $select_encoder .=
'<input type="hidden" name="action" value="update">';
93 $select_encoder .=
'<input type="hidden" name="code_id" value="'.$code_id.
'">';
96 $selectname = (!empty($conf->use_javascript_ajax) ?
'coder' :
'coder'.$code_id);
97 $select_encoder .=
'<select id="select'.$idForm.
'" class="flat" name="'.$selectname.
'">';
98 $select_encoder .=
'<option value="0"'.($selected == 0 ?
' selected' :
'').
' '.$disable.
'>'.$langs->trans(
'Disable').
'</option>';
99 $select_encoder .=
'<option value="-1" disabled>--------------------</option>';
100 foreach ($barcodelist as $key => $value) {
101 $select_encoder .=
'<option value="'.$key.
'"'.($selected == $key ?
' selected' :
'').
'>'.$value.
'</option>';
103 $select_encoder .=
'</select>';
105 if (!empty($conf->use_javascript_ajax)) {
106 $select_encoder .=
'</form>';
109 return $select_encoder;
138 global $langs, $conf;
142 $sql =
"SELECT rowid, code, libelle as label";
143 $sql .=
" FROM ".$this->db->prefix().
"c_barcode_type";
144 $sql .=
" WHERE coder <> '0'";
145 $sql .=
" AND entity = ".$conf->entity;
146 $sql .=
" ORDER BY code";
148 $result = $this->db->query($sql);
150 $num = $this->db->num_rows($result);
153 if ($useempty && $num > 0) {
154 $out .=
'<select class="flat minwidth75imp" name="'.$htmlname.
'" id="select_'.$htmlname.
'">';
155 $out .=
'<option value="0"> </option>';
157 $langs->load(
"errors");
158 $out .=
'<select disabled class="flat minwidth75imp" name="'.$htmlname.
'" id="select_'.$htmlname.
'">';
159 $out .=
'<option value="0" selected>'.$langs->trans(
'ErrorNoActivatedBarcode').
'</option>';
163 $obj = $this->db->fetch_object($result);
164 if ($selected == $obj->rowid) {
165 $out .=
'<option value="'.$obj->rowid.
'" selected>';
167 $out .=
'<option value="'.$obj->rowid.
'">';
207 global $langs, $conf;
209 if ($htmlname !=
"none") {
210 $out .=
'<form method="post" action="'.$page.
'">';
211 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
212 $out .=
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
213 $out .=
'<table class="nobordernopadding">';
217 $out .=
'<td class="left"><input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
218 $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 a Dolibarr global constant string value.