30if (empty($object) || !is_object($object)) {
 
   31  print 
"Error, template page can't be called as URL";
 
   35if (!is_object($form)) {
 
   36  $form = 
new Form($db);
 
   41<!-- BEGIN PHP TEMPLATE extrafields_view.tpl.php -->
 
   43if (!isset($parameters) || !is_array($parameters)) {
 
   44  $parameters = array();
 
   47  $parameters[
'colspan'] = 
' colspan="'.$cols.
'"';
 
   50  $parameters[
'cols'] = $cols;
 
   52if (!empty($object->fk_soc)) {
 
   53  $parameters[
'socid'] = $object->fk_soc;
 
   55$reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
 
   56print $hookmanager->resPrint;
 
   63if (empty($reshook) && !empty($object->table_element) && 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 = 
'';
 
   70  foreach ($extrafields->attributes[$object->table_element][
'label'] as $tmpkeyextra => $tmplabelextra) {
 
   76    if ($enabled && isset($extrafields->attributes[$object->table_element][
'enabled'][$tmpkeyextra])) {
 
   77      $enabled = 
dol_eval($extrafields->attributes[$object->table_element][
'enabled'][$tmpkeyextra], 1, 1, 
'2');
 
   79    if ($enabled && isset($extrafields->attributes[$object->table_element][
'list'][$tmpkeyextra])) {
 
   80      $enabled = 
dol_eval($extrafields->attributes[$object->table_element][
'list'][$tmpkeyextra], 1, 1, 
'2');
 
   84    if ($perms && isset($extrafields->attributes[$object->table_element][
'perms'][$tmpkeyextra])) {
 
   85      $perms = 
dol_eval($extrafields->attributes[$object->table_element][
'perms'][$tmpkeyextra], 1, 1, 
'2');
 
   89    if (empty($enabled)) {
 
   92    if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4) {
 
  100    if (!empty($extrafields->attributes[$object->table_element][
'langfile'][$tmpkeyextra])) {
 
  101      $langs->load($extrafields->attributes[$object->table_element][
'langfile'][$tmpkeyextra]);
 
  103    if ($action == 
'edit_extras') {
 
  104      $value = (GETPOSTISSET(
"options_".$tmpkeyextra) ? 
GETPOST(
"options_".$tmpkeyextra) : (isset($object->array_options[
"options_".$tmpkeyextra]) ? $object->array_options[
"options_".$tmpkeyextra] : 
''));
 
  106      $value = (isset($object->array_options[
"options_".$tmpkeyextra]) ? $object->array_options[
"options_".$tmpkeyextra] : 
'');
 
  111    if ($extrafields->attributes[$object->table_element][
'type'][$tmpkeyextra] == 
'separate') {
 
  112      $extrafields_collapse_num = $tmpkeyextra;
 
  114      print $extrafields->showSeparator($tmpkeyextra, $object);
 
  116      $lastseparatorkeyfound = $tmpkeyextra;
 
  118      $collapse_group = $extrafields_collapse_num.(!empty($object->id) ? 
'_'.$object->id : 
'');
 
  120      print 
'<tr class="trextrafields_collapse'.$collapse_group;
 
  124      if ($extrafields_collapse_num && $i == count($extrafields->attributes[$object->table_element][
'label'])) {
 
  125        print 
' trextrafields_collapse_last';
 
  128      if (isset($extrafields->expand_display) && empty($extrafields->expand_display[$collapse_group])) {
 
  129        print 
' style="display: none;"';
 
  132      $extrafields_collapse_num_old = $extrafields_collapse_num;
 
  133      print 
'<td class="titlefield">';
 
  134      print 
'<table class="nobordernopadding centpercent">';
 
  138      if ((!empty($action) && ($action == 
'create' || $action == 
'edit')) && !empty($extrafields->attributes[$object->table_element][
'required'][$tmpkeyextra])) {
 
  139        print 
' fieldrequired';
 
  142      if (!empty($extrafields->attributes[$object->table_element][
'help'][$tmpkeyextra])) {
 
  144        $tmptooltip = explode(
':', $extrafields->attributes[$object->table_element][
'help'][$tmpkeyextra]);
 
  145        print $form->textwithpicto($langs->trans($tmplabelextra), $langs->trans($tmptooltip[0]), 1, 
'help', 
'', 0, 3, (empty($tmptooltip[1]) ? 
'' : 
'extra_'.$tmpkeyextra.
'_'.$tmptooltip[1]));
 
  147        print $langs->trans($tmplabelextra);
 
  154      $keyforperm = $object->element;
 
  156      if ($object->element == 
'fichinter') {
 
  157        $keyforperm = 
'ficheinter';
 
  159      if ($object->element == 
'product') {
 
  160        $keyforperm = 
'produit';
 
  162      if ($object->element == 
'project') {
 
  163        $keyforperm = 
'projet';
 
  165      if (isset($user->rights->$keyforperm)) {
 
  166        $permok = $user->hasRight($keyforperm, 
'creer') || $user->hasRight($keyforperm, 
'create') || $user->hasRight($keyforperm, 
'write');
 
  168      if ($object->element == 
'order_supplier') {
 
  169        if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
 
  170          $permok = $user->hasRight(
'fournisseur', 
'commande', 
'creer');
 
  172          $permok = $user->hasRight(
'supplier_order', 
'creer');
 
  175      if ($object->element == 
'invoice_supplier') {
 
  176        if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
 
  177          $permok = $user->hasRight(
'fournisseur', 
'facture', 
'creer');
 
  179          $permok = $user->hasRight(
'supplier_invoice', 
'creer');
 
  182      if ($object->element == 
'shipping') {
 
  183        $permok = $user->hasRight(
'expedition', 
'creer');
 
  185      if ($object->element == 
'delivery') {
 
  186        $permok = $user->hasRight(
'expedition', 
'delivery', 
'creer');
 
  188      if ($object->element == 
'productlot') {
 
  189        $permok = $user->hasRight(
'stock', 
'creer');
 
  191      if ($object->element == 
'facturerec') {
 
  192        $permok = $user->hasRight(
'facture', 
'creer');
 
  194      if ($object->element == 
'mo') {
 
  195        $permok = $user->hasRight(
'mrp', 
'write');
 
  197      if ($object->element == 
'contact') {
 
  198        $permok = $user->hasRight(
'societe', 
'contact', 
'creer');
 
  200      if ($object->element == 
'salary') {
 
  201        $permok = $user->hasRight(
'salaries', 
'read');
 
  204      $isdraft = ((isset($object->statut) && $object->statut == 0) || (isset($object->status) && $object->status == 0));
 
  205      if (($isdraft || !empty($extrafields->attributes[$object->table_element][
'alwayseditable'][$tmpkeyextra]))
 
  206        && $permok && $enabled != 5 && ($action != 
'edit_extras' || 
GETPOST(
'attribute') != $tmpkeyextra)
 
  207        && empty($extrafields->attributes[$object->table_element][
'computed'][$tmpkeyextra])) {
 
  208        $fieldid = empty($forcefieldid) ? 
'id' : $forcefieldid;
 
  209        $valueid = empty($forceobjectid) ? $object->id : $forceobjectid;
 
  210        if ($object->table_element == 
'societe') {
 
  214        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>';
 
  216      print 
'</tr></table>';
 
  219      $html_id = !empty($object->id) ? $object->element.
'_extras_'.$tmpkeyextra.
'_'.$object->id : 
'';
 
  221      print 
'<td id="' . $html_id . 
'" class="valuefield ' . $object->element . 
'_extras_' . $tmpkeyextra . 
' wordbreakimp"' . (!empty($cols) ? 
' colspan="' . $cols . 
'"' : 
'') . 
'>';
 
  224      if (in_array($extrafields->attributes[$object->table_element][
'type'][$tmpkeyextra], array(
'date'))) {
 
  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(12, 0, 0, 
GETPOST(
"options_".$tmpkeyextra.
"month", 
'int'), 
GETPOST(
"options_".$tmpkeyextra.
"day", 
'int'), 
GETPOST(
"options_".$tmpkeyextra.
"year", 
'int')) : $datenotinstring;
 
  233      if (in_array($extrafields->attributes[$object->table_element][
'type'][$tmpkeyextra], array(
'datetime'))) {
 
  234        $datenotinstring = empty($object->array_options[
'options_'.$tmpkeyextra]) ? 
'' : $object->array_options[
'options_'.$tmpkeyextra];
 
  236        if (!empty($object->array_options[
'options_'.$tmpkeyextra]) && !is_numeric($object->array_options[
'options_'.$tmpkeyextra])) {  
 
  237          $datenotinstring = $db->jdate($datenotinstring);
 
  240        $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;
 
  244      if ($action == 
'edit_extras' && $permok && 
GETPOST(
'attribute', 
'restricthtml') == $tmpkeyextra) {
 
  246        if ($object->table_element == 
'societe') {
 
  249        print 
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"] . 
'?' . $fieldid . 
'=' . $object->id . 
'" method="post" name="formextra">';
 
  250        print 
'<input type="hidden" name="action" value="update_extras">';
 
  251        print 
'<input type="hidden" name="attribute" value="'.$tmpkeyextra.
'">';
 
  252        print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  253        print 
'<input type="hidden" name="'.$fieldid.
'" value="'.$object->id.
'">';
 
  254        print $extrafields->showInputField($tmpkeyextra, $value, 
'', 
'', 
'', 0, $object->id, $object->table_element);
 
  256        print 
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
'Modify')).
'">';
 
  261        print $extrafields->showOutputField($tmpkeyextra, $value, 
'', $object->table_element);
 
  271  if (!empty($conf->use_javascript_ajax)) {
 
  275            jQuery(document).ready(function() { 
  276              function showOptions(child_list, parent_list) 
  278                var val = $("select[name="+parent_list+"]").val(); 
  279                var parentVal = parent_list + ":" + val; 
  281                  $("select[name=\""+child_list+"\"] option[parent]").hide(); 
  282                  $("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").show(); 
  284                $("select[name=\""+child_list+"\"] option").show(); 
  287            function setListDependencies() { 
  288                jQuery("select option[parent]").parent().each(function() { 
  289                  var child_list = $(this).attr("name"); 
  290                var parent = $(this).find("option[parent]:first").attr("parent"); 
  291                var infos = parent.split(":"); 
  292                var parent_list = infos[0]; 
  293                showOptions(child_list, parent_list); 
  295                /* Activate the handler to call showOptions on each future change */ 
  296                $("select[name=\""+parent_list+"\"]").change(function() { 
  297                  showOptions(child_list, parent_list); 
  301            setListDependencies(); 
  307<!-- END PHP TEMPLATE extrafields_view.tpl.php -->
 
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...
 
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.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
 
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.