2018-07-05 19:42:34 +00:00
< ? php
2024-11-10 22:47:14 +00:00
/* Copyright ( C ) 2014 Maxime Kohlhaas < support @ atm - consulting . fr >
* Copyright ( C ) 2014 Juanjo Menent < jmenent @ 2 byte . es >
2025-08-14 17:27:14 +00:00
* Copyright ( C ) 2021 - 2025 Frédéric France < frederic . france @ free . fr >
2025-03-15 15:34:35 +00:00
* Copyright ( C ) 2025 MDW < mdeweerd @ users . noreply . github . com >
2018-07-05 19:42:34 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2018-07-05 19:42:34 +00:00
*/
2025-03-18 14:21:20 +00:00
2024-11-10 22:47:14 +00:00
/**
2025-03-18 14:21:20 +00:00
* @ var CommonObject $object Object ( invoice , order , ... )
2024-11-10 22:47:14 +00:00
* @ var Conf $conf
* @ var DoliDB $db
2024-11-20 19:56:16 +00:00
* @ var ExtraFields $extrafields
2024-11-10 22:47:14 +00:00
* @ var Form $form
2025-08-14 17:27:14 +00:00
* @ var HookManager $hookmanager
2024-11-10 22:47:14 +00:00
* @ var Translate $langs
* @ var User $user
2025-03-18 14:21:20 +00:00
*
* @ var string $action
2025-03-19 13:42:04 +00:00
* @ var array < string , mixed > $parameters Array of parameters
2025-08-14 13:26:13 +00:00
* @ var int $cols @ deprecated Add this information into $parameters [ 'cols' ]
2025-04-26 00:31:19 +00:00
* @ var string $forcefieldid
* @ var string $forceobjectid
2024-11-10 22:47:14 +00:00
*/
2026-02-05 18:31:41 +00:00
'@phan-var-force array<string,mixed> $parameters' ;
2025-03-18 14:21:20 +00:00
2018-07-05 19:42:34 +00:00
// Protection to avoid direct call of template
2021-02-23 21:03:23 +00:00
if ( empty ( $object ) || ! is_object ( $object )) {
2018-07-05 19:42:34 +00:00
print " Error, template page can't be called as URL " ;
2024-03-16 22:08:15 +00:00
exit ( 1 );
2018-07-05 19:42:34 +00:00
}
2018-07-05 20:35:40 +00:00
2021-02-23 21:03:23 +00:00
if ( ! is_object ( $form )) {
$form = new Form ( $db );
}
2017-12-21 12:32:16 +00:00
2026-02-06 11:57:19 +00:00
// Ensure $objectoffield is available for dol_eval visibility formulas.
global $objectoffield ;
$objectoffield = $object ;
2018-07-05 19:42:34 +00:00
?>
2026-02-05 12:30:59 +00:00
<!-- BEGIN PHP TEMPLATE core / tpl / extrafields_view . tpl . php to show formObjectOptions + extrafields -->
2018-07-05 19:42:34 +00:00
< ? php
2022-04-11 00:01:32 +00:00
if ( ! isset ( $parameters ) || ! is_array ( $parameters )) {
2021-02-23 21:03:23 +00:00
$parameters = array ();
}
if ( ! empty ( $cols )) {
2025-08-14 13:26:13 +00:00
$parameters [ 'colspan' ] = ' colspan="' . $cols . '"' ; // deprecated, keptfor backward compatibility
2021-02-23 21:03:23 +00:00
}
2025-08-14 13:26:13 +00:00
if ( ! empty ( $cols ) && ! isset ( $parameters [ 'cols' ])) {
2021-02-23 21:03:23 +00:00
$parameters [ 'cols' ] = $cols ;
2025-08-14 13:26:13 +00:00
} elseif ( isset ( $parameters [ 'cols' ])) {
$cols = $parameters [ 'cols' ];
2021-02-23 21:03:23 +00:00
}
if ( ! empty ( $object -> fk_soc )) {
$parameters [ 'socid' ] = $object -> fk_soc ;
}
2018-07-05 19:42:34 +00:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action );
print $hookmanager -> resPrint ;
2021-02-23 21:03:23 +00:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2014-10-14 15:00:06 +00:00
2018-07-05 20:35:40 +00:00
2018-05-13 12:27:40 +00:00
//var_dump($extrafields->attributes[$object->table_element]);
2023-10-07 06:30:07 +00:00
if ( empty ( $reshook ) && ! empty ( $object -> table_element ) && isset ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2025-08-14 13:26:13 +00:00
//$lastseparatorkeyfound = '';
2020-10-31 13:32:18 +00:00
$extrafields_collapse_num = '' ;
2025-08-14 13:26:13 +00:00
//$extrafields_collapse_num_old = '';
2020-10-31 13:32:18 +00:00
$i = 0 ;
2023-02-05 21:17:09 +00:00
// Loop on each extrafield
2021-02-23 21:03:23 +00:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $tmpkeyextra => $tmplabelextra ) {
2020-05-13 11:29:50 +00:00
$i ++ ;
2018-07-05 19:42:34 +00:00
// Discard if extrafield is a hidden field on form
2018-04-12 21:16:23 +00:00
$enabled = 1 ;
2021-02-23 21:03:23 +00:00
if ( $enabled && isset ( $extrafields -> attributes [ $object -> table_element ][ 'enabled' ][ $tmpkeyextra ])) {
2024-11-20 19:56:16 +00:00
$enabled = ( int ) dol_eval (( string ) $extrafields -> attributes [ $object -> table_element ][ 'enabled' ][ $tmpkeyextra ], 1 , 1 , '2' );
2018-05-13 12:27:40 +00:00
}
2021-02-23 21:03:23 +00:00
if ( $enabled && isset ( $extrafields -> attributes [ $object -> table_element ][ 'list' ][ $tmpkeyextra ])) {
2025-11-06 12:15:03 +00:00
$enabled = ( int ) dol_eval (( string ) $extrafields -> attributes [ $object -> table_element ][ 'list' ][ $tmpkeyextra ], 1 , 1 , '2' );
2018-04-12 21:16:23 +00:00
}
2020-05-13 11:29:50 +00:00
2018-04-12 21:16:23 +00:00
$perms = 1 ;
2021-02-23 21:03:23 +00:00
if ( $perms && isset ( $extrafields -> attributes [ $object -> table_element ][ 'perms' ][ $tmpkeyextra ])) {
2025-11-06 12:15:03 +00:00
$perms = ( int ) dol_eval (( string ) $extrafields -> attributes [ $object -> table_element ][ 'perms' ][ $tmpkeyextra ], 1 , 1 , '1' );
2018-04-12 21:16:23 +00:00
}
2021-03-24 18:53:31 +00:00
//print $tmpkeyextra.'-'.$enabled.'-'.$perms.'<br>'."\n";
2018-04-12 21:16:23 +00:00
2021-02-23 21:03:23 +00:00
if ( empty ( $enabled )) {
continue ; // 0 = Never visible field
}
if ( abs ( $enabled ) != 1 && abs ( $enabled ) != 3 && abs ( $enabled ) != 5 && abs ( $enabled ) != 4 ) {
continue ; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list <> 4 = not visible at the creation
}
2025-03-18 14:21:20 +00:00
/* No perm means we can ' t edit , but we should be able to see according to visibility field .
2021-02-23 21:03:23 +00:00
if ( empty ( $perms )) {
continue ; // 0 = Not visible
}
2025-03-18 14:21:20 +00:00
*/
2017-10-28 14:00:07 +00:00
2018-07-05 19:42:34 +00:00
// Load language if required
2021-02-23 21:03:23 +00:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'langfile' ][ $tmpkeyextra ])) {
$langs -> load ( $extrafields -> attributes [ $object -> table_element ][ 'langfile' ][ $tmpkeyextra ]);
}
if ( $action == 'edit_extras' ) {
2022-12-08 17:57:58 +00:00
$value = ( GETPOSTISSET ( " options_ " . $tmpkeyextra ) ? GETPOST ( " options_ " . $tmpkeyextra ) : ( isset ( $object -> array_options [ " options_ " . $tmpkeyextra ]) ? $object -> array_options [ " options_ " . $tmpkeyextra ] : '' ));
2020-05-21 13:05:19 +00:00
} else {
2022-09-19 10:00:43 +00:00
$value = ( isset ( $object -> array_options [ " options_ " . $tmpkeyextra ]) ? $object -> array_options [ " options_ " . $tmpkeyextra ] : '' );
2020-07-27 12:04:41 +00:00
//var_dump($tmpkeyextra.' - '.$value);
2018-07-05 19:42:34 +00:00
}
2020-05-13 11:29:50 +00:00
// Print line tr of extra field
2021-02-23 21:03:23 +00:00
if ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $tmpkeyextra ] == 'separate' ) {
2022-03-01 03:02:06 +00:00
$extrafields_collapse_num = $tmpkeyextra ;
2019-05-03 14:14:44 +00:00
2020-07-27 12:04:41 +00:00
print $extrafields -> showSeparator ( $tmpkeyextra , $object );
2019-08-21 01:38:57 +00:00
2025-08-14 13:26:13 +00:00
//$lastseparatorkeyfound = $tmpkeyextra;
2020-05-21 13:05:19 +00:00
} else {
2022-02-24 11:54:33 +00:00
$collapse_group = $extrafields_collapse_num . ( ! empty ( $object -> id ) ? '_' . $object -> id : '' );
2023-02-05 21:17:09 +00:00
2022-02-24 11:54:33 +00:00
print '<tr class="trextrafields_collapse' . $collapse_group ;
2020-05-13 11:29:50 +00:00
/* if ( $extrafields_collapse_num && $extrafields_collapse_num_old && $extrafields_collapse_num != $extrafields_collapse_num_old ) {
print ' trextrafields_collapse_new' ;
} */
if ( $extrafields_collapse_num && $i == count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
print ' trextrafields_collapse_last' ;
}
2022-02-24 11:54:33 +00:00
print '"' ;
2022-03-16 14:40:17 +00:00
if ( isset ( $extrafields -> expand_display ) && empty ( $extrafields -> expand_display [ $collapse_group ])) {
2022-02-24 11:54:33 +00:00
print ' style="display: none;"' ;
}
print '>' ;
2025-08-14 13:26:13 +00:00
//$extrafields_collapse_num_old = $extrafields_collapse_num;
2024-09-11 12:01:31 +00:00
print '<td>' ;
2019-10-03 17:02:29 +00:00
print '<table class="nobordernopadding centpercent">' ;
2018-07-05 19:42:34 +00:00
print '<tr>' ;
2018-07-05 20:35:40 +00:00
2020-05-13 11:29:50 +00:00
print '<td class="' ;
2021-02-23 21:03:23 +00:00
if (( ! empty ( $action ) && ( $action == 'create' || $action == 'edit' )) && ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'required' ][ $tmpkeyextra ])) {
print ' fieldrequired' ;
}
2018-06-13 11:36:40 +00:00
print '">' ;
2020-12-09 18:26:41 +00:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'help' ][ $tmpkeyextra ])) {
// You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
$tmptooltip = explode ( ':' , $extrafields -> attributes [ $object -> table_element ][ 'help' ][ $tmpkeyextra ]);
print $form -> textwithpicto ( $langs -> trans ( $tmplabelextra ), $langs -> trans ( $tmptooltip [ 0 ]), 1 , 'help' , '' , 0 , 3 , ( empty ( $tmptooltip [ 1 ]) ? '' : 'extra_' . $tmpkeyextra . '_' . $tmptooltip [ 1 ]));
} else {
print $langs -> trans ( $tmplabelextra );
}
2018-06-13 11:36:40 +00:00
print '</td>' ;
2014-11-07 21:40:13 +00:00
2018-07-05 19:42:34 +00:00
//TODO Improve element and rights detection
//var_dump($user->rights);
2025-03-18 14:21:20 +00:00
$permwriteobject = false ;
2019-12-03 10:17:29 +00:00
$keyforperm = $object -> element ;
2022-03-29 13:02:29 +00:00
2021-02-23 21:03:23 +00:00
if ( $object -> element == 'fichinter' ) {
$keyforperm = 'ficheinter' ;
}
2023-07-07 09:28:37 +00:00
if ( $object -> element == 'product' ) {
$keyforperm = 'produit' ;
}
2025-01-29 18:44:50 +00:00
if ( $object -> element == 'project' ) {
$keyforperm = 'projet' ;
}
2021-02-23 21:03:23 +00:00
if ( isset ( $user -> rights -> $keyforperm )) {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( $keyforperm , 'creer' ) || $user -> hasRight ( $keyforperm , 'create' ) || $user -> hasRight ( $keyforperm , 'write' );
2021-02-23 21:03:23 +00:00
}
if ( $object -> element == 'order_supplier' ) {
2023-11-27 10:39:32 +00:00
if ( ! getDolGlobalString ( 'MAIN_USE_NEW_SUPPLIERMOD' )) {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( 'fournisseur' , 'commande' , 'creer' );
2021-04-12 05:37:34 +00:00
} else {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( 'supplier_order' , 'creer' );
2021-04-12 05:37:34 +00:00
}
2021-02-23 21:03:23 +00:00
}
if ( $object -> element == 'invoice_supplier' ) {
2023-11-27 10:39:32 +00:00
if ( ! getDolGlobalString ( 'MAIN_USE_NEW_SUPPLIERMOD' )) {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( 'fournisseur' , 'facture' , 'creer' );
2021-04-12 05:37:34 +00:00
} else {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( 'supplier_invoice' , 'creer' );
2021-04-12 05:37:34 +00:00
}
2021-02-23 21:03:23 +00:00
}
if ( $object -> element == 'shipping' ) {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( 'expedition' , 'creer' );
2021-02-23 21:03:23 +00:00
}
if ( $object -> element == 'delivery' ) {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( 'expedition' , 'delivery' , 'creer' );
2021-02-23 21:03:23 +00:00
}
if ( $object -> element == 'productlot' ) {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( 'stock' , 'creer' );
2021-02-23 21:03:23 +00:00
}
if ( $object -> element == 'facturerec' ) {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( 'facture' , 'creer' );
2021-02-23 21:03:23 +00:00
}
if ( $object -> element == 'mo' ) {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( 'mrp' , 'write' );
2021-02-23 21:03:23 +00:00
}
2021-04-07 15:28:13 +00:00
if ( $object -> element == 'contact' ) {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( 'societe' , 'contact' , 'creer' );
2021-04-07 15:28:13 +00:00
}
2021-09-06 12:58:06 +00:00
if ( $object -> element == 'salary' ) {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( 'salaries' , 'write' );
2021-09-06 10:30:39 +00:00
}
2025-01-11 09:34:01 +00:00
if ( $object -> element == 'member' ) {
2025-03-18 14:21:20 +00:00
$permwriteobject = $user -> hasRight ( 'adherent' , 'creer' );
}
// Set permission to edit/write extrafield.
//print "permwriteobject=".$permwriteobject." perms=".$perms;
$permtoeditextrafield = $perms ;
if ( ! isset ( $extrafields -> attributes [ $object -> table_element ][ 'perms' ][ $tmpkeyextra ])) {
$permtoeditextrafield = $permwriteobject ;
2025-01-11 09:34:01 +00:00
}
2020-07-04 14:14:53 +00:00
$isdraft = (( isset ( $object -> statut ) && $object -> statut == 0 ) || ( isset ( $object -> status ) && $object -> status == 0 ));
2020-07-27 12:04:41 +00:00
if (( $isdraft || ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'alwayseditable' ][ $tmpkeyextra ]))
2025-03-18 14:21:20 +00:00
&& $permtoeditextrafield && $enabled != 5 && ( $action != 'edit_extras' || GETPOST ( 'attribute' ) != $tmpkeyextra )
2021-02-23 21:03:23 +00:00
&& empty ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ][ $tmpkeyextra ])) {
2021-08-30 20:10:26 +00:00
$fieldid = empty ( $forcefieldid ) ? 'id' : $forcefieldid ;
$valueid = empty ( $forceobjectid ) ? $object -> id : $forceobjectid ;
2021-02-23 21:03:23 +00:00
if ( $object -> table_element == 'societe' ) {
$fieldid = 'socid' ;
}
2021-08-30 20:10:26 +00:00
2025-05-04 08:50:01 +00:00
print '<td class="right">' ;
2025-05-12 17:41:46 +00:00
if ( isModEnabled ( " ai " ) && ! empty ( $extrafields -> attributes [ $object -> table_element ][ " aiprompt " ][ $tmpkeyextra ])) {
$showlinktoai = " extrafieldfiller_ " . $tmpkeyextra ;
$showlinktoailabel = $langs -> trans ( " FillExtrafieldWithAi " );
$htmlname = ! empty ( $object -> id ) ? $object -> element . '_extras_' . $tmpkeyextra . '_' . $object -> id : " options_ " . $tmpkeyextra ;
$onlyenhancements = " textgenerationextrafield " ;
$morecss = " editfielda " ;
$aiprompt = $extrafields -> attributes [ $object -> table_element ][ " aiprompt " ][ $tmpkeyextra ];
$out = " " ;
// Fill $out
include DOL_DOCUMENT_ROOT . '/core/tpl/formlayoutai.tpl.php' ;
print $out ;
print ' < script >
$ ( document ) . ready ( function () {
$ ( " #'. $htmlname .' " ) . on ( " change " , function () {
value = $ ( this ) . html ();
$ . ajax ({
method : " POST " ,
dataType : " json " ,
url : " '. DOL_URL_ROOT.'/core/ajax/updateextrafield.php " ,
data : { " token " : " '.currentToken().' " , " objectType " : " '. $object->element .' " , " objectId " : " '. $object->id .' " , " field " : " '. $tmpkeyextra .' " , " value " : value },
success : function ( response ) {
console . log ( " Extrafield " + '.$tmpkeyextra.' + " successfully updated " );
},
});
});
});
</ script > ' ;
}
print '<a class="reposition editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?' . $fieldid . '=' . $valueid . '&action=edit_extras&token=' . newToken () . '&attribute=' . $tmpkeyextra . '&ignorecollapsesetup=1">' . img_edit () . '</a>' ;
print '</td>' ;
2025-04-25 23:59:36 +00:00
}
2018-07-05 19:42:34 +00:00
print '</tr></table>' ;
2018-06-13 11:00:08 +00:00
print '</td>' ;
2024-03-28 08:51:49 +00:00
$cssview = ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'cssview' ][ $tmpkeyextra ]) ? ( $extrafields -> attributes [ $object -> table_element ][ 'cssview' ][ $tmpkeyextra ] . ' ' ) : '' ;
2020-07-27 12:04:41 +00:00
$html_id = ! empty ( $object -> id ) ? $object -> element . '_extras_' . $tmpkeyextra . '_' . $object -> id : '' ;
2018-07-05 20:35:40 +00:00
2024-03-27 14:09:46 +00:00
print '<td id="' . $html_id . '" class="valuefield ' . $cssview . $object -> element . '_extras_' . $tmpkeyextra . ' wordbreakimp"' . ( ! empty ( $cols ) ? ' colspan="' . $cols . '"' : '' ) . '>' ;
2014-11-07 21:40:13 +00:00
2018-07-05 19:42:34 +00:00
// Convert date into timestamp format
2021-03-05 18:29:09 +00:00
if ( in_array ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $tmpkeyextra ], array ( 'date' ))) {
2021-10-28 18:34:05 +00:00
$datenotinstring = empty ( $object -> array_options [ 'options_' . $tmpkeyextra ]) ? '' : $object -> array_options [ 'options_' . $tmpkeyextra ];
2020-07-27 12:04:41 +00:00
// print 'X'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.'x';
2021-10-28 18:34:05 +00:00
if ( ! empty ( $object -> array_options [ 'options_' . $tmpkeyextra ]) && ! is_numeric ( $object -> array_options [ 'options_' . $tmpkeyextra ])) { // For backward compatibility
2018-07-05 19:42:34 +00:00
$datenotinstring = $db -> jdate ( $datenotinstring );
}
2020-07-27 12:04:41 +00:00
//print 'x'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour');
2026-06-24 14:51:23 +00:00
$value = ( $action == 'edit_extras' && GETPOSTISSET ( " options_ " . $tmpkeyextra )) ? dol_mktime ( 12 , 0 , 0 , GETPOSTINT ( " options_ " . $tmpkeyextra . " month " ), GETPOSTINT ( " options_ " . $tmpkeyextra . " day " ), GETPOSTINT ( " options_ " . $tmpkeyextra . " year " )) : $datenotinstring ;
2021-03-04 09:31:31 +00:00
}
2021-03-05 18:29:09 +00:00
if ( in_array ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $tmpkeyextra ], array ( 'datetime' ))) {
2021-10-28 18:34:05 +00:00
$datenotinstring = empty ( $object -> array_options [ 'options_' . $tmpkeyextra ]) ? '' : $object -> array_options [ 'options_' . $tmpkeyextra ];
2021-03-04 09:31:31 +00:00
// print 'X'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.'x';
2021-10-28 18:34:05 +00:00
if ( ! empty ( $object -> array_options [ 'options_' . $tmpkeyextra ]) && ! is_numeric ( $object -> array_options [ 'options_' . $tmpkeyextra ])) { // For backward compatibility
2021-03-04 09:31:31 +00:00
$datenotinstring = $db -> jdate ( $datenotinstring );
}
//print 'x'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour');
2026-06-24 14:51:23 +00:00
$value = ( $action == 'edit_extras' && GETPOSTISSET ( " options_ " . $tmpkeyextra )) ? dol_mktime ( GETPOSTINT ( " options_ " . $tmpkeyextra . " hour " ), GETPOSTINT ( " options_ " . $tmpkeyextra . " min " ), GETPOSTINT ( " options_ " . $tmpkeyextra . " sec " ), GETPOSTINT ( " options_ " . $tmpkeyextra . " month " ), GETPOSTINT ( " options_ " . $tmpkeyextra . " day " ), GETPOSTINT ( " options_ " . $tmpkeyextra . " year " ), 'tzuserrel' ) : $datenotinstring ;
2018-07-05 19:42:34 +00:00
}
2020-05-13 11:29:50 +00:00
2025-11-09 00:24:02 +00:00
// TODO Improve element and rights detection
2025-03-18 14:21:20 +00:00
if ( $action == 'edit_extras' && $permtoeditextrafield && GETPOST ( 'attribute' , 'restricthtml' ) == $tmpkeyextra ) {
2025-02-05 16:50:53 +00:00
// Show the extrafield in create or edit mode
2020-10-31 13:32:18 +00:00
$fieldid = 'id' ;
2021-02-23 21:03:23 +00:00
if ( $object -> table_element == 'societe' ) {
$fieldid = 'socid' ;
}
2021-11-18 09:43:52 +00:00
print '<form enctype="multipart/form-data" action="' . $_SERVER [ " PHP_SELF " ] . '?' . $fieldid . '=' . $object -> id . '" method="post" name="formextra">' ;
2018-07-05 19:42:34 +00:00
print '<input type="hidden" name="action" value="update_extras">' ;
2020-07-27 12:04:41 +00:00
print '<input type="hidden" name="attribute" value="' . $tmpkeyextra . '">' ;
2019-12-03 10:17:29 +00:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="' . $fieldid . '" value="' . $object -> id . '">' ;
2025-08-28 12:53:38 +00:00
print '<input type="hidden" name="page_y" value="">' ;
2026-08-15 01:04:31 +00:00
// Last parameter is 1 because the field is edited alone: a dependent list can't be filtered by javascript
// here (its parent list is not on this form), so it must be filtered on the saved value of its parent.
print $extrafields -> showInputField ( $tmpkeyextra , $value , '' , '' , '' , '' , $object , $object -> table_element , 0 , 1 );
2014-10-14 15:00:06 +00:00
2025-11-12 21:02:50 +00:00
print '<input type="submit" class="button reposition" value="' . dolPrintHTMLForAttribute ( $langs -> trans ( 'Modify' )) . '">' ;
2014-10-14 15:00:06 +00:00
2018-07-05 19:42:34 +00:00
print '</form>' ;
2025-04-25 23:59:36 +00:00
2025-08-14 17:27:14 +00:00
/** @var ?FormAI $formai */
2025-04-25 23:59:36 +00:00
if ( empty ( $formai ) || $formai instanceof FormAI ) {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formai.class.php' ;
$formai = new FormAI ( $db );
}
print $formai -> getAjaxAICallFunction ();
2020-05-21 13:05:19 +00:00
} else {
2025-02-05 16:50:53 +00:00
// Show the extrafield in view mode
2020-07-27 12:04:41 +00:00
//var_dump($tmpkeyextra.'-'.$value.'-'.$object->table_element);
2025-11-12 20:54:29 +00:00
2024-11-01 09:47:16 +00:00
print $extrafields -> showOutputField ( $tmpkeyextra , $value , '' , $object -> table_element , null , $object );
2025-11-09 00:24:02 +00:00
2025-11-12 20:54:29 +00:00
print '<input type="hidden" value="' . dolPrintHTMLForAttribute ( $value ) . '" name="options_' . dol_escape_htmltag ( $tmpkeyextra ) . '" id="options_' . dol_escape_htmltag ( $tmpkeyextra ) . '"/>' ; // it's needed when to get parent value when extra-field list depend on parent extra-field list
2018-07-05 19:42:34 +00:00
}
2018-07-05 20:35:40 +00:00
2018-06-13 11:00:08 +00:00
print '</td>' ;
2019-11-13 18:35:39 +00:00
print '</tr>' . " \n " ;
2018-06-13 11:00:08 +00:00
}
}
2017-06-07 14:44:04 +00:00
2018-06-13 11:00:08 +00:00
// Add code to manage list depending on others
// TODO Test/enhance this with a more generic solution
2021-02-23 21:03:23 +00:00
if ( ! empty ( $conf -> use_javascript_ajax )) {
2018-06-13 11:00:08 +00:00
print " \n " ;
print '
2020-08-16 20:03:11 +00:00
< script >
2018-07-05 19:42:34 +00:00
jQuery ( document ) . ready ( function () {
setListDependencies ();
});
</ script > ' . " \n " ;
}
}
?>
2025-08-14 13:26:13 +00:00
<!-- END PHP TEMPLATE core / tpl / extrafields_view . tpl . php -->