25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/asset.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/asset/class/asset.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32 $langs->loadLangs(array(
"asset"));
37 $action =
GETPOST(
'action',
'aZ09');
38 $confirm =
GETPOST(
'confirm',
'alpha');
39 $cancel =
GETPOST(
'cancel',
'aZ09');
40 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'assetcard';
41 $backtopage =
GETPOST(
'backtopage',
'alpha');
42 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
45 $object =
new Asset($db);
47 $diroutputmassaction = $conf->asset->dir_output.
'/temp/massgeneration/'.$user->id;
48 $hookmanager->initHooks(array(
'assetcard',
'globalcard'));
51 $extrafields->fetch_name_optionals_label($object->table_element);
53 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
56 $search_all =
GETPOST(
"search_all",
'alpha');
58 foreach ($object->fields as $key => $val)
60 if (
GETPOST(
'search_'.$key,
'alpha')) $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
63 if (empty($action) && empty($id) && empty($ref)) $action =
'view';
66 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
69 if (!empty($user->socid)) $socid = $user->socid;
72 $permissiontoread = $user->rights->asset->read;
73 $permissiontoadd = $user->rights->asset->write;
74 $permissiontodelete = $user->rights->asset->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
75 $permissionnote = $user->rights->asset->write;
76 $permissiondellink = $user->rights->asset->write;
77 $upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object->entity : 1];
84 $parameters = array();
85 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
86 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
95 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
98 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
101 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
104 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
110 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
112 if ($action ==
'set_thirdparty' && $permissiontoadd)
114 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user,
'MYOBJECT_MODIFY');
116 if ($action ==
'classin' && $permissiontoadd)
118 $object->setProject(
GETPOST(
'projectid',
'int'));
122 $triggersendname =
'ASSET_SENTBYMAIL';
123 $autocopy =
'MAIN_MAIL_AUTOCOPY_ASSET_TO';
124 $trackid =
'asset'.$object->id;
125 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
133 $form =
new Form($db);
136 $title = $langs->trans(
"Asset").
' - '.$langs->trans(
"Card");
141 if ($action ==
'create')
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">';
148 if ($backtopage)
print '<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
149 if ($backtopageforcancel)
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
153 print '<table class="border centpercent tableforfieldcreate">'.
"\n";
156 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
159 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
161 print '</table>'.
"\n";
165 print '<div class="center">';
166 print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'">';
168 print '<input type="'.($backtopage ?
"submit" :
"button").
'" class="button button-cancel" name="cancel" value="'.
dol_escape_htmltag($langs->trans(
"Cancel")).
'"'.($backtopage ?
'' :
' onclick="javascript:history.go(-1)"').
'>';
177 if (($id || $ref) && $action ==
'edit')
181 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
182 print '<input type="hidden" name="token" value="'.newToken().
'">';
183 print '<input type="hidden" name="action" value="update">';
184 print '<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
185 print '<input type="hidden" name="id" value="'.$object->id.
'">';
186 if ($backtopage)
print '<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
187 if ($backtopageforcancel)
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
191 print '<table class="border centpercent tableforfieldedit">'.
"\n";
194 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
197 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
203 print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans(
"Save").
'">';
204 print ' <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
211 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create')))
213 $res = $object->fetch_optionals();
221 if ($action ==
'delete')
223 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteAssets'), $langs->trans(
'ConfirmDeleteAsset'),
'confirm_delete',
'', 0, 1);
227 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
228 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
229 if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
230 elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
238 $linkback = '<a href="'.
dol_buildpath('/asset/list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
240 $morehtmlref = '<div class="refidno">';
248 $morehtmlref .= '</div>';
250 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
252 print '<div class="fichecenter">';
253 print '<div class="fichehalfleft">';
254 print '<div class="underbanner clearboth"></div>';
255 print '<table class="border centpercent">'."\
n";
261 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
264 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
269 print '<div class="clearboth"></div>';
277 if ($user->socid == 0)
279 print '<div class="tabsAction">';
281 $parameters = array();
282 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
286 if ($user->rights->asset->write)
288 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit">'.$langs->trans(
"Modify").
'</a>'.
"\n";
290 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Modify').
'</a>'.
"\n";
293 if ($user->rights->asset->delete)
295 print '<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
'Delete').
'</a>'.
"\n";
297 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Delete').
'</a>'.
"\n";
303 if ($action !=
'presend')
305 print '<div class="fichecenter"><div class="fichehalfleft">';
306 print '<a name="builddoc"></a>';
311 $urlsource =
$_SERVER[
"PHP_SELF"].
"?id=".$object->id;
312 $genallowed = $user->rights->asset->read;
313 $delallowed = $user->rights->asset->write;
315 print $formfile->showdocuments(
'asset', $filename, $filedir, $urlsource, 0, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
318 $linktoelem = $form->showLinkToObjectBlock($object, null, array(
'asset'));
319 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
321 print '</div><div class="fichehalfright"><div class="ficheaddleft">';
325 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.
'/asset/info.php?id='.$object->id);
328 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
330 $somethingshown =
$formactions->showactions($object,
'asset', $socid, 1,
'', $MAXEVENT,
'', $morehtmlright);
332 print '</div></div></div>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
asset_prepare_head(Asset $object)
Prepare admin pages header.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
print $_SERVER["PHP_SELF"] n
Edit parameters.
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.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...