28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/asset.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/asset/class/asset.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44$langs->loadLangs(array(
"assets",
"other"));
49$action =
GETPOST(
'action',
'aZ09');
50$confirm =
GETPOST(
'confirm',
'alpha');
51$cancel =
GETPOST(
'cancel',
'alpha');
52$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'assetcard';
53$backtopage =
GETPOST(
'backtopage',
'alpha');
54$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
58$diroutputmassaction =
$conf->asset->dir_output.
'/temp/massgeneration/'.$user->id;
59$hookmanager->initHooks(array(
'assetcard',
'globalcard'));
62$extrafields->fetch_name_optionals_label(
$object->table_element);
64$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
67$search_all =
GETPOST(
"search_all",
'alpha');
69foreach (
$object->fields as $key => $val) {
70 if (
GETPOST(
'search_'.$key,
'alpha')) {
71 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
75if (empty($action) && empty($id) && empty($ref)) {
80include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
82$permissiontoread = $user->hasRight(
'asset',
'read');
83$permissiontoadd = $user->hasRight(
'asset',
'write');
84$permissiontodelete = $user->hasRight(
'asset',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
85$permissionnote = $user->hasRight(
'asset',
'write');
86$permissiondellink = $user->hasRight(
'asset',
'write');
90if ($user->socid > 0) {
93if ($user->socid > 0) {
94 $socid = $user->socid;
96$isdraft = ((
$object->status == $object::STATUS_DRAFT) ? 1 : 0);
101if (!$permissiontoread) {
110$parameters = array();
111$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
116if (empty($reshook)) {
119 $backurlforlist = DOL_URL_ROOT.
'/asset/list.php';
121 if (empty($backtopage) || ($cancel && empty($id))) {
122 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
123 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
124 $backtopage = $backurlforlist;
126 $backtopage = DOL_URL_ROOT.
'/asset/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
132 $triggermodname =
'ASSET_MODIFY';
135 if ($action ==
'confirm_disposal' && $confirm ==
'yes' && $permissiontoadd) {
139 $disposal_invoice_id =
GETPOSTINT(
'disposal_invoice_id');
140 $object->disposal_depreciated = ((
GETPOST(
'disposal_depreciated') ==
'1' ||
GETPOST(
'disposal_depreciated') ==
'on') ? 1 : 0);
141 $object->disposal_subject_to_vat = ((
GETPOST(
'disposal_subject_to_vat') ==
'1' ||
GETPOST(
'disposal_subject_to_vat') ==
'on') ? 1 : 0);
143 $result =
$object->dispose($user, $disposal_invoice_id);
148 } elseif ($action ==
"add" && $permissiontoadd) {
153 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
156 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
159 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
165 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
168 $triggersendname =
'ASSET_SENTBYMAIL';
169 $autocopy =
'MAIN_MAIL_AUTOCOPY_ASSET_TO';
170 $trackid =
'asset'.$object->id;
171 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
183$title = $langs->trans(
"Asset").
' - '.$langs->trans(
"Card");
185llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-asset page-card');
188if ($action ==
'create') {
189 print
load_fiche_titre($langs->trans(
"NewAsset"),
'',
'object_'.$object->picto);
191 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
192 print
'<input type="hidden" name="token" value="'.newToken().
'">';
193 print
'<input type="hidden" name="action" value="add">';
195 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
197 if ($backtopageforcancel) {
198 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
200 if (GETPOSTISSET(
'supplier_invoice_id')) {
201 $object->fields[
'supplier_invoice_id'] = array(
'type' =>
'integer:FactureFournisseur:fourn/class/fournisseur.facture.class.php:1:entity IN (__SHARED_ENTITIES__)',
'label' =>
'SupplierInvoice',
'enabled' =>
'1',
'noteditable' => 1,
'position' => 280,
'notnull' => 0,
'visible' => 1,
'index' => 1,
'validate' => 1,);
202 print
'<input type="hidden" name="supplier_invoice_id" value="' .
GETPOSTINT(
'supplier_invoice_id') .
'">';
208 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
211 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
214 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
216 print
'</table>'.
"\n";
220 print $form->buttonsSaveCancel(
"Create");
228if (($id || $ref) && $action ==
'edit') {
229 print
load_fiche_titre($langs->trans(
"Asset"),
'',
'object_'.$object->picto);
231 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
232 print
'<input type="hidden" name="token" value="'.newToken().
'">';
233 print
'<input type="hidden" name="action" value="update">';
234 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
236 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
238 if ($backtopageforcancel) {
239 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
244 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
247 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
250 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
256 print $form->buttonsSaveCancel();
262if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
263 $res =
$object->fetch_optionals();
271 if ($action ==
'delete') {
272 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAsset'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
276 if ($action ==
'validate') {
278 $ref = substr(
$object->ref, 1, 4);
279 if ($ref ==
'PROV') {
280 $numref =
$object->getNextNumRef();
285 $text = $langs->trans(
'ConfirmValidateAsset', $numref);
287 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
290 $text .= $notify->confirmMessage(
'ASSET_VALIDATE', 0, $object);
293 $formquestion = array();
295 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
299 if ($action ==
'disposal') {
301 $langs->load(
'bills');
304 $disposal_amount =
GETPOSTINT(
'disposal_amount');
305 $fk_disposal_type =
GETPOSTINT(
'fk_disposal_type');
306 $disposal_invoice_id =
GETPOSTINT(
'disposal_invoice_id');
307 $disposal_depreciated = GETPOSTISSET(
'disposal_depreciated') ?
GETPOST(
'disposal_depreciated') : 1;
308 $disposal_depreciated = !empty($disposal_depreciated) ? 1 : 0;
309 $disposal_subject_to_vat = GETPOSTISSET(
'disposal_subject_to_vat') ?
GETPOST(
'disposal_subject_to_vat') : 1;
310 $disposal_subject_to_vat = !empty($disposal_subject_to_vat) ? 1 : 0;
312 $object->fields[
'fk_disposal_type'][
'visible'] = 1;
313 $disposal_type_form =
$object->showInputField(
null,
'fk_disposal_type', (
string) $fk_disposal_type,
'',
'',
'', 0);
314 $object->fields[
'fk_disposal_type'][
'visible'] = -2;
316 $disposal_invoice_form = $form->selectForForms(
'Facture:compta/facture/class/facture.class.php::(entity:IN:__SHARED_ENTITIES__)',
'disposal_invoice_id', $disposal_invoice_id);
319 $formquestion = array(
320 array(
'type' =>
'date',
'name' =>
'disposal_date',
'tdclass' =>
'fieldrequired',
'label' => $langs->trans(
"AssetDisposalDate"),
'value' => $disposal_date),
321 array(
'type' =>
'text',
'name' =>
'disposal_amount',
'tdclass' =>
'fieldrequired',
'label' => $langs->trans(
"AssetDisposalAmount"),
'value' => $disposal_amount,
'morecss' =>
'maxwidth100'),
322 array(
'type' =>
'other',
'name' =>
'fk_disposal_type',
'tdclass' =>
'fieldrequired',
'label' => $langs->trans(
"AssetDisposalType"),
'value' => $disposal_type_form),
323 array(
'type' =>
'other',
'name' =>
'disposal_invoice_id',
'label' => $langs->trans(
"InvoiceCustomer"),
'value' => $disposal_invoice_form),
324 array(
'type' =>
'checkbox',
'name' =>
'disposal_depreciated',
'label' => $langs->trans(
"AssetDisposalDepreciated"),
'value' => $disposal_depreciated),
325 array(
'type' =>
'checkbox',
'name' =>
'disposal_subject_to_vat',
'label' => $langs->trans(
"AssetDisposalSubjectToVat"),
'value' => $disposal_subject_to_vat),
327 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'AssetDisposal'), $langs->trans(
'AssetConfirmDisposalAsk',
$object->ref .
' - ' .
$object->label),
'confirm_disposal', $formquestion,
'yes', 1, 350);
331 if ($action ==
'reopen') {
334 $formquestion = array();
335 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'AssetConfirmReOpenAsk',
$object->ref),
'confirm_reopen', $formquestion,
'yes', 1);
339 if ($action ==
'setdraft') {
340 $text = $langs->trans(
'ConfirmSetToDraft',
$object->ref);
342 $formquestion = array();
343 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'SetToDraft'), $text,
'confirm_setdraft', $formquestion, 0, 1, 220);
354 $parameters = array(
'formConfirm' => $formconfirm);
355 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
356 if (empty($reshook)) {
357 $formconfirm .= $hookmanager->resPrint;
358 } elseif ($reshook > 0) {
359 $formconfirm = $hookmanager->resPrint;
368 $linkback =
'<a href="'.DOL_URL_ROOT.
'/asset/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
370 $morehtmlref =
'<div class="refidno">';
371 $morehtmlref .=
'</div>';
374 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
377 print
'<div class="fichecenter">';
378 print
'<div class="fichehalfleft">';
379 print
'<div class="underbanner clearboth"></div>';
380 print
'<table class="border centpercent tableforfield">'.
"\n";
383 $keyforbreak =
'date_acquisition';
386 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
389 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
395 print
'<div class="clearboth"></div>';
400 if ($action !=
'presend' && $action !=
'editline') {
401 print
'<div class="tabsAction">' .
"\n";
402 $parameters = array();
403 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
408 if (empty($reshook)) {
410 if (empty($user->socid)) {
411 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=presend&mode=init&token=' . newToken() .
'#formmailbeforetitle');
415 if (
$object->status == $object::STATUS_VALIDATED) {
416 if ($permissiontoadd) {
417 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=setdraft&token='.newToken().
'">'.$langs->trans(
"SetToDraft").
'</a>'.
"\n";
422 if (
$object->status == $object::STATUS_DRAFT) {
423 print dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=edit&token=' . newToken(),
'', $permissiontoadd);
427 if (
$object->status == $object::STATUS_DRAFT) {
428 print dolGetButtonAction($langs->trans(
'Validate'),
'',
'default', $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=validate&token=' . newToken(),
'', $permissiontoadd);
431 if (
$object->status == $object::STATUS_VALIDATED) {
432 print dolGetButtonAction($langs->trans(
'AssetDisposal'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=disposal&token=' . newToken(),
'', $permissiontoadd);
436 if ($permissiontoadd &&
$object->status == $object::STATUS_DISPOSED) {
437 print dolGetButtonAction($langs->trans(
'ReOpen'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=reopen&token=' . newToken(),
'', $permissiontoadd);
444 print dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=delete&token=' . newToken(),
'', $permissiontodelete || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd));
446 print
'</div>' .
"\n";
450 if (
GETPOST(
'modelselected')) {
454 if ($action !=
'presend') {
455 print
'<div class="fichecenter"><div class="fichehalfleft">';
456 print
'<a name="builddoc"></a>';
458 $includedocgeneration = 0;
461 if ($includedocgeneration) {
463 $relativepath = $objref.
'/'.$objref.
'.pdf';
464 $filedir =
$conf->asset->dir_output.
'/'.$objref;
465 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
466 $genallowed = $user->hasRight(
'asset',
'read');
467 $delallowed = $user->hasRight(
'asset',
'write');
468 print $formfile->showdocuments(
'asset:Asset', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
472 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'asset'), 1);
473 $linktoelem = $tmparray[
'linktoelem'];
474 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
475 print $htmltoenteralink;
477 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
480 print
'</div><div class="fichehalfright">';
482 $morehtmlcenter =
'';
485 $morehtmlcenter = dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/asset/agenda.php?id='.
$object->id);
488 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
490 $somethingshown = $formactions->showactions($object,
$object->element, 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
492 print
'</div></div>';
496 if (
GETPOST(
'modelselected')) {
501 $modelmail =
'asset';
502 $defaulttopic =
'InformationMessage';
503 $diroutput =
$conf->asset->dir_output;
504 $trackid =
'asset'.$object->id;
506 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
assetPrepareHead(Asset $object)
Prepare array of tabs for Asset.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage the table of subscription to notifications.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isModEnabled($module)
Is Dolibarr module enabled.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.