30 if (empty($object) || !is_object($object)) {
31 print
"Error, template page can't be called as URL";
35 if (!is_object(
$form)) {
41 <!-- BEGIN PHP TEMPLATE extrafields_view.tpl.php -->
43 if (!isset($parameters) || !is_array($parameters)) {
44 $parameters = array();
47 $parameters[
'colspan'] =
' colspan="'.$cols.
'"';
50 $parameters[
'cols'] = $cols;
52 if (!empty($object->fk_soc)) {
53 $parameters[
'socid'] = $object->fk_soc;
55 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
56 print $hookmanager->resPrint;
63 if (empty($reshook) && isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label'])) {
64 $lastseparatorkeyfound =
'';
65 $extrafields_collapse_num =
'';
66 $extrafields_collapse_num_old =
'';
68 foreach ($extrafields->attributes[$object->table_element][
'label'] as $tmpkeyextra => $tmplabelextra) {
74 if ($enabled && isset($extrafields->attributes[$object->table_element][
'enabled'][$tmpkeyextra])) {
75 $enabled =
dol_eval($extrafields->attributes[$object->table_element][
'enabled'][$tmpkeyextra], 1);
77 if ($enabled && isset($extrafields->attributes[$object->table_element][
'list'][$tmpkeyextra])) {
78 $enabled =
dol_eval($extrafields->attributes[$object->table_element][
'list'][$tmpkeyextra], 1);
82 if ($perms && isset($extrafields->attributes[$object->table_element][
'perms'][$tmpkeyextra])) {
83 $perms =
dol_eval($extrafields->attributes[$object->table_element][
'perms'][$tmpkeyextra], 1);
87 if (empty($enabled)) {
90 if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4) {
98 if (!empty($extrafields->attributes[$object->table_element][
'langfile'][$tmpkeyextra])) {
99 $langs->load($extrafields->attributes[$object->table_element][
'langfile'][$tmpkeyextra]);
101 if ($action ==
'edit_extras') {
102 $value = (
GETPOSTISSET(
"options_".$tmpkeyextra) ?
GETPOST(
"options_".$tmpkeyextra) : (isset($object->array_options[
"options_".$tmpkeyextra]) ? $object->array_options[
"options_".$tmpkeyextra] :
''));
104 $value = (isset($object->array_options[
"options_".$tmpkeyextra]) ? $object->array_options[
"options_".$tmpkeyextra] :
'');
109 if ($extrafields->attributes[$object->table_element][
'type'][$tmpkeyextra] ==
'separate') {
110 $extrafields_collapse_num = $tmpkeyextra;
112 print $extrafields->showSeparator($tmpkeyextra, $object);
114 $lastseparatorkeyfound = $tmpkeyextra;
116 $collapse_group = $extrafields_collapse_num.(!empty($object->id) ?
'_'.$object->id :
'');
117 print
'<tr class="trextrafields_collapse'.$collapse_group;
121 if ($extrafields_collapse_num && $i == count($extrafields->attributes[$object->table_element][
'label'])) {
122 print
' trextrafields_collapse_last';
125 if (isset($extrafields->expand_display) && empty($extrafields->expand_display[$collapse_group])) {
126 print
' style="display: none;"';
129 $extrafields_collapse_num_old = $extrafields_collapse_num;
130 print
'<td class="titlefield">';
131 print
'<table class="nobordernopadding centpercent">';
135 if ((!empty($action) && ($action ==
'create' || $action ==
'edit')) && !empty($extrafields->attributes[$object->table_element][
'required'][$tmpkeyextra])) {
136 print
' fieldrequired';
139 if (!empty($extrafields->attributes[$object->table_element][
'help'][$tmpkeyextra])) {
141 $tmptooltip = explode(
':', $extrafields->attributes[$object->table_element][
'help'][$tmpkeyextra]);
142 print
$form->textwithpicto($langs->trans($tmplabelextra), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.$tmpkeyextra.
'_'.$tmptooltip[1]));
144 print $langs->trans($tmplabelextra);
151 $keyforperm = $object->element;
153 if ($object->element ==
'fichinter') {
154 $keyforperm =
'ficheinter';
156 if (isset($user->rights->$keyforperm)) {
157 $permok = !empty($user->rights->$keyforperm->creer) || !empty($user->rights->$keyforperm->create) || !empty($user->rights->$keyforperm->write);
159 if ($object->element ==
'order_supplier') {
160 if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
161 $permok = $user->rights->fournisseur->commande->creer;
163 $permok = $user->rights->supplier_order->creer;
166 if ($object->element ==
'invoice_supplier') {
167 if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
168 $permok = $user->rights->fournisseur->facture->creer;
170 $permok = $user->rights->supplier_invoice->creer;
173 if ($object->element ==
'shipping') {
174 $permok = $user->rights->expedition->creer;
176 if ($object->element ==
'delivery') {
177 $permok = $user->rights->expedition->delivery->creer;
179 if ($object->element ==
'productlot') {
180 $permok = $user->rights->stock->creer;
182 if ($object->element ==
'facturerec') {
183 $permok = $user->rights->facture->creer;
185 if ($object->element ==
'mo') {
186 $permok = $user->rights->mrp->write;
188 if ($object->element ==
'contact') {
189 $permok = $user->rights->societe->contact->creer;
191 if ($object->element ==
'salary') {
192 $permok = $user->rights->salaries->read;
195 $isdraft = ((isset($object->statut) && $object->statut == 0) || (isset($object->status) && $object->status == 0));
196 if (($isdraft || !empty($extrafields->attributes[$object->table_element][
'alwayseditable'][$tmpkeyextra]))
197 && $permok && $enabled != 5 && ($action !=
'edit_extras' ||
GETPOST(
'attribute') != $tmpkeyextra)
198 && empty($extrafields->attributes[$object->table_element][
'computed'][$tmpkeyextra])) {
199 $fieldid = empty($forcefieldid) ?
'id' : $forcefieldid;
200 $valueid = empty($forceobjectid) ? $object->id : $forceobjectid;
201 if ($object->table_element ==
'societe') {
205 print
'<td class="right"><a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?'.$fieldid.
'='.$valueid.
'&action=edit_extras&token='.
newToken().
'&attribute='.$tmpkeyextra.
'&ignorecollapsesetup=1">'.
img_edit().
'</a></td>';
207 print
'</tr></table>';
210 $html_id = !empty($object->id) ? $object->element.
'_extras_'.$tmpkeyextra.
'_'.$object->id :
'';
212 print
'<td id="'.$html_id.
'" class="valuefield '.$object->element.
'_extras_'.$tmpkeyextra.
' wordbreak"'.(!empty($cols) ?
' colspan="'.$cols.
'"' :
'').
'>';
215 if (in_array($extrafields->attributes[$object->table_element][
'type'][$tmpkeyextra], array(
'date'))) {
216 $datenotinstring = empty($object->array_options[
'options_'.$tmpkeyextra]) ?
'' : $object->array_options[
'options_'.$tmpkeyextra];
218 if (!empty($object->array_options[
'options_'.$tmpkeyextra]) && !is_numeric($object->array_options[
'options_'.$tmpkeyextra])) {
219 $datenotinstring = $db->jdate($datenotinstring);
222 $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;
224 if (in_array($extrafields->attributes[$object->table_element][
'type'][$tmpkeyextra], array(
'datetime'))) {
225 $datenotinstring = empty($object->array_options[
'options_'.$tmpkeyextra]) ?
'' : $object->array_options[
'options_'.$tmpkeyextra];
227 if (!empty($object->array_options[
'options_'.$tmpkeyextra]) && !is_numeric($object->array_options[
'options_'.$tmpkeyextra])) {
228 $datenotinstring = $db->jdate($datenotinstring);
231 $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;
235 if ($action ==
'edit_extras' && $permok &&
GETPOST(
'attribute',
'restricthtml') == $tmpkeyextra) {
237 if ($object->table_element ==
'societe') {
240 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"] .
'?' . $fieldid .
'=' . $object->id .
'" method="post" name="formextra">';
241 print
'<input type="hidden" name="action" value="update_extras">';
242 print
'<input type="hidden" name="attribute" value="'.$tmpkeyextra.
'">';
243 print
'<input type="hidden" name="token" value="'.newToken().
'">';
244 print
'<input type="hidden" name="'.$fieldid.
'" value="'.$object->id.
'">';
245 print $extrafields->showInputField($tmpkeyextra, $value,
'',
'',
'', 0, $object->id, $object->table_element);
247 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
'Modify')).
'">';
252 print $extrafields->showOutputField($tmpkeyextra, $value,
'', $object->table_element);
262 if (!empty($conf->use_javascript_ajax)) {
266 jQuery(document).ready(function() {
267 function showOptions(child_list, parent_list)
269 var val = $("select[name="+parent_list+"]").val();
270 var parentVal = parent_list + ":" + val;
272 $("select[name=\""+child_list+"\"] option[parent]").hide();
273 $("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").show();
275 $("select[name=\""+child_list+"\"] option").show();
278 function setListDependencies() {
279 jQuery("select option[parent]").parent().each(function() {
280 var child_list = $(this).attr("name");
281 var parent = $(this).find("option[parent]:first").attr("parent");
282 var infos = parent.split(":");
283 var parent_list = infos[0];
284 showOptions(child_list, parent_list);
286 /* Activate the handler to call showOptions on each future change */
287 $("select[name=\""+parent_list+"\"]").change(function() {
288 showOptions(child_list, parent_list);
292 setListDependencies();
298 <!-- END PHP TEMPLATE extrafields_view.tpl.php -->
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.