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 = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'asset',
'read')) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'asset',
'model_advance',
'read')));
73$permissiontoadd = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'asset',
'write')) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'asset',
'model_advance',
'write')));
74$permissiontodelete = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'asset',
'delete')) || (
getDolGlobalString(
'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];
80if ($user->socid > 0) {
83if ($user->socid > 0) {
84 $socid = $user->socid;
86$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
87restrictedArea($user,
'asset', $object->id, $object->table_element,
'',
'fk_soc',
'rowid', $isdraft);
88if (!isModEnabled(
'asset')) {
91if (!$permissiontoread) {
100$parameters = array();
101$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
106if (empty($reshook)) {
109 $backurlforlist = DOL_URL_ROOT .
'/asset/model/list.php';
111 if (empty($backtopage) || ($cancel && empty($id))) {
112 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
113 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
114 $backtopage = $backurlforlist;
116 $backtopage = DOL_URL_ROOT .
'/asset/model/card.php?id=' . ((!empty($id) && $id > 0) ? $id :
'__ID__');
121 $triggermodname =
'ASSETMODEL_MODIFY';
123 if (($action ==
'edit' && !($permissiontoadd && $object->status == $object::STATUS_DRAFT)) ||
124 ($action ==
'confirm_setdraft' && !($permissiontoadd && $object->status != $object::STATUS_DRAFT)) ||
125 ($action ==
'confirm_validate' && !($permissiontoadd && $object->status != $object::STATUS_VALIDATED)) ||
126 ($action ==
'confirm_close' && !($permissiontoadd && $object->status != $object::STATUS_CANCELED))
132 include DOL_DOCUMENT_ROOT .
'/core/actions_addupdatedelete.inc.php';
142$form =
new Form($db);
145$title = $langs->trans(
"AssetModel") .
' - ' . $langs->trans(
"Card");
150if ($action ==
'create') {
151 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"AssetModel")),
'',
'object_' . $object->picto);
153 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
154 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
155 print
'<input type="hidden" name="action" value="add">';
157 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
159 if ($backtopageforcancel) {
160 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
168 print
'<table class="border centpercent tableforfieldcreate">' .
"\n";
171 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_add.tpl.php';
174 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_add.tpl.php';
176 print
'</table>' .
"\n";
180 print $form->buttonsSaveCancel(
"Create");
188if (($id || $ref) && $action ==
'edit') {
189 print
load_fiche_titre($langs->trans(
"AssetModel"),
'',
'object_' . $object->picto);
191 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
192 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
193 print
'<input type="hidden" name="action" value="update">';
194 print
'<input type="hidden" name="id" value="' . $object->id .
'">';
196 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
198 if ($backtopageforcancel) {
199 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
204 print
'<table class="border centpercent tableforfieldedit">' .
"\n";
207 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_edit.tpl.php';
210 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_edit.tpl.php';
216 print $form->buttonsSaveCancel();
222if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
223 $res = $object->fetch_optionals();
226 print
dol_get_fiche_head($head,
'card', $langs->trans(
"AssetModel"), -1, $object->picto);
231 if ($action ==
'delete') {
232 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id, $langs->trans(
'DeleteAssetModel'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
233 } elseif ($action ==
'clone') {
236 $formquestion = array();
237 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
241 $parameters = array(
'formConfirm' => $formconfirm);
242 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
243 if (empty($reshook)) {
244 $formconfirm .= $hookmanager->resPrint;
245 } elseif ($reshook > 0) {
246 $formconfirm = $hookmanager->resPrint;
255 $linkback =
'<a href="' . DOL_URL_ROOT .
'/asset/model/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
257 $morehtmlref =
'<div class="refidno">';
258 $morehtmlref .=
'</div>';
261 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
264 print
'<div class="fichecenter">';
265 print
'<div class="fichehalfleft">';
266 print
'<div class="underbanner clearboth"></div>';
267 print
'<table class="border centpercent tableforfield">' .
"\n";
270 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_view.tpl.php';
273 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
279 print
'<div class="clearboth"></div>';
285 if ($action !=
'editline') {
286 print
'<div class="tabsAction">' .
"\n";
287 $parameters = array();
288 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
293 if (empty($reshook)) {
294 if ($object->status == $object::STATUS_DRAFT) {
295 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&action=edit&token=' . newToken(),
'', $permissiontoadd);
299 if ($object->status != $object::STATUS_DRAFT) {
300 print
dolGetButtonAction($langs->trans(
'SetToDraft'),
'',
'default', $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&action=confirm_setdraft&confirm=yes&token=' . newToken(),
'', $permissiontoadd);
303 if ($object->status != $object::STATUS_VALIDATED) {
304 print
dolGetButtonAction($langs->trans(
'Enable'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=confirm_validate&confirm=yes&token=' . newToken(),
'', $permissiontoadd);
307 if ($object->status != $object::STATUS_CANCELED) {
308 print
dolGetButtonAction($langs->trans(
'Disable'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_close&confirm=yes&token='.newToken(),
'', $permissiontoadd);
312 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id . (!empty($socid) ?
'&socid=' . $socid :
'') .
'&action=clone&token=' . newToken(),
'', $permissiontoadd);
315 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=delete&token=' . newToken(),
'', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
317 print
'</div>' .
"\n";
320 print
'<div class="fichecenter"><div class="fichehalfleft">';
321 print
'<a name="builddoc"></a>';
323 print
'</div><div class="fichehalfright">';
334 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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.