29 if (empty($object) || !is_object($object))
31 print "Error, template page can't be called as URL";
35 if (!is_object($form)) $form =
new Form($db);
39 <!-- BEGIN PHP TEMPLATE extrafields_view.tpl.php -->
41 if (!is_array($parameters)) $parameters = array();
42 if (!empty($cols)) $parameters[
'colspan'] =
' colspan="'.$cols.
'"';
43 if (!empty($cols)) $parameters[
'cols'] = $cols;
44 if (!empty($object->fk_soc)) $parameters[
'socid'] = $object->fk_soc;
45 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
46 print $hookmanager->resPrint;
47 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
51 if (empty($reshook) && is_array($extrafields->attributes[$object->table_element][
'label']))
53 $lastseparatorkeyfound =
'';
54 $extrafields_collapse_num =
'';
55 $extrafields_collapse_num_old =
'';
57 foreach ($extrafields->attributes[$object->table_element][
'label'] as $tmpkeyextra => $tmplabelextra)
64 if ($enabled && isset($extrafields->attributes[$object->table_element][
'enabled'][$tmpkeyextra]))
66 $enabled =
dol_eval($extrafields->attributes[$object->table_element][
'enabled'][$tmpkeyextra], 1);
68 if ($enabled && isset($extrafields->attributes[$object->table_element][
'list'][$tmpkeyextra]))
70 $enabled =
dol_eval($extrafields->attributes[$object->table_element][
'list'][$tmpkeyextra], 1);
74 if ($perms && isset($extrafields->attributes[$object->table_element][
'perms'][$tmpkeyextra]))
76 $perms =
dol_eval($extrafields->attributes[$object->table_element][
'perms'][$tmpkeyextra], 1);
80 if (empty($enabled))
continue;
81 if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4)
continue;
82 if (empty($perms))
continue;
85 if (!empty($extrafields->attributes[$object->table_element][
'langfile'][$tmpkeyextra])) $langs->load($extrafields->attributes[$object->table_element][
'langfile'][$tmpkeyextra]);
86 if ($action ==
'edit_extras')
88 $value = (
GETPOSTISSET(
"options_".$tmpkeyextra) ?
GETPOST(
"options_".$tmpkeyextra) : $object->array_options[
"options_".$tmpkeyextra]);
90 $value = $object->array_options[
"options_".$tmpkeyextra];
95 if ($extrafields->attributes[$object->table_element][
'type'][$tmpkeyextra] ==
'separate')
97 $extrafields_collapse_num =
'';
98 $extrafield_param = $extrafields->attributes[$object->table_element][
'param'][$tmpkeyextra];
99 if (!empty($extrafield_param) && is_array($extrafield_param)) {
100 $extrafield_param_list = array_keys($extrafield_param[
'options']);
102 if (count($extrafield_param_list) > 0) {
103 $extrafield_collapse_display_value = intval($extrafield_param_list[0]);
105 if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) {
106 $extrafields_collapse_num = $extrafields->attributes[$object->table_element][
'pos'][$tmpkeyextra];
111 print $extrafields->showSeparator($tmpkeyextra, $object);
113 $lastseparatorkeyfound = $tmpkeyextra;
115 print '<tr class="trextrafields_collapse'.$extrafields_collapse_num;
119 if ($extrafields_collapse_num && $i == count($extrafields->attributes[$object->table_element][
'label'])) {
120 print ' trextrafields_collapse_last';
123 $extrafields_collapse_num_old = $extrafields_collapse_num;
124 print '<td class="titlefield">';
125 print '<table class="nobordernopadding centpercent">';
129 if ((!empty($action) && ($action ==
'create' || $action ==
'edit')) && !empty($extrafields->attributes[$object->table_element][
'required'][$tmpkeyextra]))
print ' fieldrequired';
131 if (!empty($extrafields->attributes[$object->table_element][
'help'][$tmpkeyextra])) {
133 $tmptooltip = explode(
':', $extrafields->attributes[$object->table_element][
'help'][$tmpkeyextra]);
134 print $form->textwithpicto($langs->trans($tmplabelextra), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.$tmpkeyextra.
'_'.$tmptooltip[1]));
136 print $langs->trans($tmplabelextra);
143 $keyforperm = $object->element;
144 if ($object->element ==
'fichinter') $keyforperm =
'ficheinter';
145 if (isset($user->rights->$keyforperm)) $permok = $user->rights->$keyforperm->creer || $user->rights->$keyforperm->create || $user->rights->$keyforperm->write;
146 if ($object->element ==
'order_supplier') $permok = $user->rights->fournisseur->commande->creer;
147 if ($object->element ==
'invoice_supplier') $permok = $user->rights->fournisseur->facture->creer;
148 if ($object->element ==
'shipping') $permok = $user->rights->expedition->creer;
149 if ($object->element ==
'delivery') $permok = $user->rights->expedition->delivery->creer;
150 if ($object->element ==
'productlot') $permok = $user->rights->stock->creer;
151 if ($object->element ==
'facturerec') $permok = $user->rights->facture->creer;
152 if ($object->element ==
'mo') $permok = $user->rights->mrp->write;
154 $isdraft = ((isset($object->statut) && $object->statut == 0) || (isset($object->status) && $object->status == 0));
155 if (($isdraft || !empty($extrafields->attributes[$object->table_element][
'alwayseditable'][$tmpkeyextra]))
156 && $permok && $enabled != 5 && ($action !=
'edit_extras' ||
GETPOST(
'attribute') != $tmpkeyextra)
157 && empty($extrafields->attributes[$object->table_element][
'computed'][$tmpkeyextra]))
160 if ($object->table_element ==
'societe') $fieldid =
'socid';
161 print '<td class="right"><a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?'.$fieldid.
'='.$object->id.
'&action=edit_extras&attribute='.$tmpkeyextra.
'&ignorecollapsesetup=1">'.
img_edit().
'</a></td>';
163 print '</tr></table>';
166 $html_id = !empty($object->id) ? $object->element.
'_extras_'.$tmpkeyextra.
'_'.$object->id :
'';
168 print '<td id="'.$html_id.
'" class="'.$object->element.
'_extras_'.$tmpkeyextra.
' wordbreak"'.($cols ?
' colspan="'.$cols.
'"' :
'').
'>';
171 if (in_array($extrafields->attributes[$object->table_element][
'type'][$tmpkeyextra], array(
'date')))
173 $datenotinstring = $object->array_options[
'options_'.$tmpkeyextra];
175 if (!is_numeric($object->array_options[
'options_'.$tmpkeyextra]))
177 $datenotinstring = $db->jdate($datenotinstring);
180 $value =
GETPOSTISSET(
"options_".$tmpkeyextra) ?
dol_mktime(12, 0, 0,
GETPOST(
"options_".$tmpkeyextra.
"month",
'int'),
GETPOST(
"options_".$tmpkeyextra.
"day",
'int'),
GETPOST(
"options_".$tmpkeyextra.
"year",
'int')) : $datenotinstring;
182 if (in_array($extrafields->attributes[$object->table_element][
'type'][$tmpkeyextra], array(
'datetime')))
184 $datenotinstring = $object->array_options[
'options_'.$tmpkeyextra];
186 if (!is_numeric($object->array_options[
'options_'.$tmpkeyextra]))
188 $datenotinstring = $db->jdate($datenotinstring);
191 $value =
GETPOSTISSET(
"options_".$tmpkeyextra) ?
dol_mktime(
GETPOST(
"options_".$tmpkeyextra.
"hour",
'int'),
GETPOST(
"options_".$tmpkeyextra.
"min",
'int'),
GETPOST(
"options_".$tmpkeyextra.
"sec",
'int'),
GETPOST(
"options_".$tmpkeyextra.
"month",
'int'),
GETPOST(
"options_".$tmpkeyextra.
"day",
'int'),
GETPOST(
"options_".$tmpkeyextra.
"year",
'int'),
'tzuserrel') : $datenotinstring;
195 if ($action ==
'edit_extras' && $permok &&
GETPOST(
'attribute',
'restricthtml') == $tmpkeyextra)
198 if ($object->table_element ==
'societe') $fieldid =
'socid';
199 print '<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formextra">';
200 print '<input type="hidden" name="action" value="update_extras">';
201 print '<input type="hidden" name="attribute" value="'.$tmpkeyextra.
'">';
202 print '<input type="hidden" name="token" value="'.newToken().
'">';
203 print '<input type="hidden" name="'.$fieldid.
'" value="'.$object->id.
'">';
204 print $extrafields->showInputField($tmpkeyextra, $value,
'',
'',
'', 0, $object->id, $object->table_element);
206 print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
'Modify')).
'">';
211 print $extrafields->showOutputField($tmpkeyextra, $value,
'', $object->table_element);
222 if (!empty($conf->use_javascript_ajax))
227 jQuery(document).ready(function() {
228 function showOptions(child_list, parent_list)
230 var val = $("select[name="+parent_list+"]").val();
231 var parentVal = parent_list + ":" + val;
233 $("select[name=\""+child_list+"\"] option[parent]").hide();
234 $("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").show();
236 $("select[name=\""+child_list+"\"] option").show();
239 function setListDependencies() {
240 jQuery("select option[parent]").parent().each(function() {
241 var child_list = $(this).attr("name");
242 var parent = $(this).find("option[parent]:first").attr("parent");
243 var infos = parent.split(":");
244 var parent_list = infos[0];
245 showOptions(child_list, parent_list);
247 /* Activate the handler to call showOptions on each future change */
248 $("select[name=\""+parent_list+"\"]").change(function() {
249 showOptions(child_list, parent_list);
253 setListDependencies();
259 <!-- END PHP TEMPLATE extrafields_view.tpl.php -->
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
dol_eval($s, $returnvalue=0, $hideerrors=1)
Replace eval function to add more security.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print
Draft customers invoices.