26require
'../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT .
'/core/lib/asset.lib.php';
28require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetmodel.class.php';
29require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formcompany.class.php';
30require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formfile.class.php';
33$langs->loadLangs(array(
"assets",
"other"));
38$action =
GETPOST(
'action',
'aZ09');
39$confirm =
GETPOST(
'confirm',
'alpha');
40$cancel =
GETPOST(
'cancel',
'aZ09');
41$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'assetmodelcard';
42$backtopage =
GETPOST(
'backtopage',
'alpha');
43$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
48$diroutputmassaction = $conf->asset->dir_output .
'/temp/massgeneration/' . $user->id;
49$hookmanager->initHooks(array(
'assetmodelcard',
'globalcard'));
52$extrafields->fetch_name_optionals_label($object->table_element);
54$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
57$search_all =
GETPOST(
"search_all",
'alpha');
59foreach ($object->fields as $key => $val) {
60 if (
GETPOST(
'search_' . $key,
'alpha')) {
61 $search[$key] =
GETPOST(
'search_' . $key,
'alpha');
65if (empty($action) && empty($id) && empty($ref)) {
70include DOL_DOCUMENT_ROOT .
'/core/actions_fetchobject.inc.php';
72$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
'asset',
'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
'asset',
'model_advance',
'read')));
73$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
'asset',
'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
'asset',
'model_advance',
'write')));
74$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
'asset',
'delete')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
'asset',
'model_advance',
'delete'))) || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
75$permissionnote = $permissiontoadd;
76$permissiondellink = $permissiontoadd;
77$upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1];
81if ($user->socid > 0) $socid = $user->socid;
82$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
83restrictedArea($user,
'asset', $object->id, $object->table_element,
'',
'fk_soc',
'rowid', $isdraft);
93$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
101 $backurlforlist = DOL_URL_ROOT .
'/asset/model/list.php';
103 if (empty($backtopage) || ($cancel && empty($id))) {
104 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
105 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
106 $backtopage = $backurlforlist;
108 $backtopage = DOL_URL_ROOT .
'/asset/model/card.php?id=' . ((!empty($id) && $id > 0) ? $id :
'__ID__');
113 $triggermodname =
'ASSETMODEL_MODIFY';
115 if (($action ==
'edit' && !($permissiontoadd && $object->status == $object::STATUS_DRAFT)) ||
116 ($action ==
'confirm_setdraft' && !($permissiontoadd && $object->status != $object::STATUS_DRAFT)) ||
117 ($action ==
'confirm_validate' && !($permissiontoadd && $object->status != $object::STATUS_VALIDATED)) ||
118 ($action ==
'confirm_close' && !($permissiontoadd && $object->status != $object::STATUS_CANCELED))
124 include DOL_DOCUMENT_ROOT .
'/core/actions_addupdatedelete.inc.php';
134$form =
new Form($db);
137$title = $langs->trans(
"AssetModel") .
' - ' . $langs->trans(
"Card");
142if ($action ==
'create') {
143 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"AssetModel")),
'',
'object_' . $object->picto);
145 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
146 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
147 print
'<input type="hidden" name="action" value="add">';
149 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
151 if ($backtopageforcancel) {
152 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
160 print
'<table class="border centpercent tableforfieldcreate">' .
"\n";
163 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_add.tpl.php';
166 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_add.tpl.php';
168 print
'</table>' .
"\n";
172 print $form->buttonsSaveCancel(
"Create");
180if (($id || $ref) && $action ==
'edit') {
181 print
load_fiche_titre($langs->trans(
"AssetModel"),
'',
'object_' . $object->picto);
183 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
184 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
185 print
'<input type="hidden" name="action" value="update">';
186 print
'<input type="hidden" name="id" value="' . $object->id .
'">';
188 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
190 if ($backtopageforcancel) {
191 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
196 print
'<table class="border centpercent tableforfieldedit">' .
"\n";
199 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_edit.tpl.php';
202 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_edit.tpl.php';
208 print $form->buttonsSaveCancel();
214if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
215 $res = $object->fetch_optionals();
218 print
dol_get_fiche_head($head,
'card', $langs->trans(
"AssetModel"), -1, $object->picto);
223 if ($action ==
'delete') {
224 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id, $langs->trans(
'DeleteAssetModel'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
225 } elseif ($action ==
'clone') {
228 $formquestion = array();
229 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
233 $parameters = array(
'formConfirm' => $formconfirm);
234 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
235 if (empty($reshook)) {
236 $formconfirm .= $hookmanager->resPrint;
237 } elseif ($reshook > 0) {
238 $formconfirm = $hookmanager->resPrint;
247 $linkback =
'<a href="' . DOL_URL_ROOT .
'/asset/model/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
249 $morehtmlref =
'<div class="refidno">';
250 $morehtmlref .=
'</div>';
253 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
256 print
'<div class="fichecenter">';
257 print
'<div class="fichehalfleft">';
258 print
'<div class="underbanner clearboth"></div>';
259 print
'<table class="border centpercent tableforfield">' .
"\n";
262 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_view.tpl.php';
265 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
271 print
'<div class="clearboth"></div>';
277 if ($action !=
'editline') {
278 print
'<div class="tabsAction">' .
"\n";
279 $parameters = array();
280 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
285 if (empty($reshook)) {
286 if ($object->status == $object::STATUS_DRAFT) {
287 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&action=edit&token=' . newToken(),
'', $permissiontoadd);
291 if ($object->status != $object::STATUS_DRAFT) {
292 print
dolGetButtonAction($langs->trans(
'SetToDraft'),
'',
'default', $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&action=confirm_setdraft&confirm=yes&token=' . newToken(),
'', $permissiontoadd);
295 if ($object->status != $object::STATUS_VALIDATED) {
296 print
dolGetButtonAction($langs->trans(
'Enable'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=confirm_validate&confirm=yes&token=' . newToken(),
'', $permissiontoadd);
299 if ($object->status != $object::STATUS_CANCELED) {
300 print
dolGetButtonAction($langs->trans(
'Disable'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_close&confirm=yes&token='.newToken(),
'', $permissiontoadd);
304 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id . (!empty($socid) ?
'&socid=' . $socid :
'') .
'&action=clone&token=' . newToken(),
'', $permissiontoadd);
307 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=delete&token=' . newToken(),
'', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
309 print
'</div>' .
"\n";
312 print
'<div class="fichecenter"><div class="fichehalfleft">';
313 print
'<a name="builddoc"></a>';
315 print
'</div><div class="fichehalfright">';
326 print
'</div></div>';
assetModelPrepareHead($object)
Prepare array of tabs for AssetModel.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
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.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.