26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/lib/asset.lib.php';
28require_once DOL_DOCUMENT_ROOT.
'/asset/class/asset.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') :
'assetcard';
42$backtopage =
GETPOST(
'backtopage',
'alpha');
43$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
46$object =
new Asset($db);
48$diroutputmassaction = $conf->asset->dir_output.
'/temp/massgeneration/'.$user->id;
49$hookmanager->initHooks(array(
'assetcard',
'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 = $user->hasRight(
'asset',
'read');
73$permissiontoadd = $user->hasRight(
'asset',
'write');
74$permissiontodelete = $user->hasRight(
'asset',
'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
75$permissionnote = $user->hasRight(
'asset',
'write');
76$permissiondellink = $user->hasRight(
'asset',
'write');
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, $object->element, $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/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/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
121 $object->oldcopy =
dol_clone($object, 2);
122 $triggermodname =
'ASSET_MODIFY';
125 if ($action ==
'confirm_disposal' && $confirm ==
'yes' && $permissiontoadd) {
126 $object->disposal_date =
dol_mktime(12, 0, 0,
GETPOST(
'disposal_datemonth',
'int'),
GETPOST(
'disposal_dateday',
'int'),
GETPOST(
'disposal_dateyear',
'int'));
127 $object->disposal_amount_ht =
GETPOST(
'disposal_amount',
'int');
128 $object->fk_disposal_type =
GETPOST(
'fk_disposal_type',
'int');
129 $disposal_invoice_id =
GETPOST(
'disposal_invoice_id',
'int');
130 $object->disposal_depreciated = ((
GETPOST(
'disposal_depreciated') ==
'1' ||
GETPOST(
'disposal_depreciated') ==
'on') ? 1 : 0);
131 $object->disposal_subject_to_vat = ((
GETPOST(
'disposal_subject_to_vat') ==
'1' ||
GETPOST(
'disposal_subject_to_vat') ==
'on') ? 1 : 0);
133 $result = $object->dispose($user, $disposal_invoice_id);
138 } elseif ($action ==
"add") {
139 $object->supplier_invoice_id =
GETPOST(
'supplier_invoice_id',
'int');
143 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
146 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
149 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
155 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
158 $triggersendname =
'ASSET_SENTBYMAIL';
159 $autocopy =
'MAIN_MAIL_AUTOCOPY_ASSET_TO';
160 $trackid =
'asset'.$object->id;
161 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
170$form =
new Form($db);
173$title = $langs->trans(
"Asset").
' - '.$langs->trans(
"Card");
178if ($action ==
'create') {
179 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Asset")),
'',
'object_'.$object->picto);
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="add">';
185 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
187 if ($backtopageforcancel) {
188 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
190 if (GETPOSTISSET(
'supplier_invoice_id')) {
191 $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',);
192 print
'<input type="hidden" name="supplier_invoice_id" value="' .
GETPOST(
'supplier_invoice_id',
'int') .
'">';
200 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
203 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
206 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
208 print
'</table>'.
"\n";
212 print $form->buttonsSaveCancel(
"Create");
220if (($id || $ref) && $action ==
'edit') {
221 print
load_fiche_titre($langs->trans(
"Asset"),
'',
'object_'.$object->picto);
223 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
224 print
'<input type="hidden" name="token" value="'.newToken().
'">';
225 print
'<input type="hidden" name="action" value="update">';
226 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
228 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
230 if ($backtopageforcancel) {
231 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
236 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
239 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
242 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
248 print $form->buttonsSaveCancel();
254if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
255 $res = $object->fetch_optionals();
263 if ($action ==
'delete') {
264 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteAsset'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
265 } elseif ($action ==
'disposal') {
267 $langs->load(
'bills');
270 $disposal_amount =
GETPOST(
'disposal_amount',
'int');
271 $fk_disposal_type =
GETPOST(
'fk_disposal_type',
'int');
272 $disposal_invoice_id =
GETPOST(
'disposal_invoice_id',
'int');
273 $disposal_depreciated = GETPOSTISSET(
'disposal_depreciated') ?
GETPOST(
'disposal_depreciated') : 1;
274 $disposal_depreciated = !empty($disposal_depreciated) ? 1 : 0;
275 $disposal_subject_to_vat = GETPOSTISSET(
'disposal_subject_to_vat') ?
GETPOST(
'disposal_subject_to_vat') : 1;
276 $disposal_subject_to_vat = !empty($disposal_subject_to_vat) ? 1 : 0;
278 $object->fields[
'fk_disposal_type'][
'visible'] = 1;
279 $disposal_type_form = $object->showInputField(
null,
'fk_disposal_type', $fk_disposal_type,
'',
'',
'', 0);
280 $object->fields[
'fk_disposal_type'][
'visible'] = -2;
282 $object->fields[
'disposal_invoice_id'] = array(
'type' =>
'integer:Facture:compta/facture/class/facture.class.php::entity IN (__SHARED_ENTITIES__)',
'enabled' =>
'1',
'notnull' => 1,
'visible' => 1,
'index' => 1,
'validate' =>
'1',);
283 $disposal_invoice_form = $object->showInputField(
null,
'disposal_invoice_id', $disposal_invoice_id,
'',
'',
'', 0);
284 unset($object->fields[
'disposal_invoice_id']);
287 $formquestion = array(
288 array(
'type' =>
'date',
'name' =>
'disposal_date',
'tdclass' =>
'fieldrequired',
'label' => $langs->trans(
"AssetDisposalDate"),
'value' => $disposal_date),
289 array(
'type' =>
'text',
'name' =>
'disposal_amount',
'tdclass' =>
'fieldrequired',
'label' => $langs->trans(
"AssetDisposalAmount"),
'value' => $disposal_amount),
290 array(
'type' =>
'other',
'name' =>
'fk_disposal_type',
'tdclass' =>
'fieldrequired',
'label' => $langs->trans(
"AssetDisposalType"),
'value' => $disposal_type_form),
291 array(
'type' =>
'other',
'name' =>
'disposal_invoice_id',
'label' => $langs->trans(
"InvoiceCustomer"),
'value' => $disposal_invoice_form),
292 array(
'type' =>
'checkbox',
'name' =>
'disposal_depreciated',
'label' => $langs->trans(
"AssetDisposalDepreciated"),
'value' => $disposal_depreciated),
293 array(
'type' =>
'checkbox',
'name' =>
'disposal_subject_to_vat',
'label' => $langs->trans(
"AssetDisposalSubjectToVat"),
'value' => $disposal_subject_to_vat),
295 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id, $langs->trans(
'AssetDisposal'), $langs->trans(
'AssetConfirmDisposalAsk', $object->ref .
' - ' . $object->label),
'confirm_disposal', $formquestion,
'yes', 1);
296 } elseif ($action ==
'reopen') {
299 $formquestion = array();
300 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'AssetConfirmReOpenAsk', $object->ref),
'confirm_reopen', $formquestion,
'yes', 1);
310 $parameters = array(
'formConfirm' => $formconfirm);
311 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
312 if (empty($reshook)) {
313 $formconfirm .= $hookmanager->resPrint;
314 } elseif ($reshook > 0) {
315 $formconfirm = $hookmanager->resPrint;
324 $linkback =
'<a href="'.DOL_URL_ROOT.
'/asset/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
326 $morehtmlref =
'<div class="refidno">';
327 $morehtmlref .=
'</div>';
330 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
333 print
'<div class="fichecenter">';
334 print
'<div class="fichehalfleft">';
335 print
'<div class="underbanner clearboth"></div>';
336 print
'<table class="border centpercent tableforfield">'.
"\n";
339 $keyforbreak=
'date_acquisition';
342 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
345 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
351 print
'<div class="clearboth"></div>';
356 if ($action !=
'presend' && $action !=
'editline') {
357 print
'<div class="tabsAction">' .
"\n";
358 $parameters = array();
359 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
364 if (empty($reshook)) {
366 if (empty($user->socid)) {
367 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&action=presend&mode=init&token=' . newToken() .
'#formmailbeforetitle');
370 if ($object->status == $object::STATUS_DRAFT) {
371 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&action=edit&token=' . newToken(),
'', $permissiontoadd);
377 if ($object->status == $object::STATUS_DRAFT) {
378 print
dolGetButtonAction($langs->trans(
'AssetDisposal'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=disposal&token=' . newToken(),
'', $permissiontoadd);
380 print
dolGetButtonAction($langs->trans(
'ReOpen'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=reopen&token=' . newToken(),
'', $permissiontoadd);
384 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=delete&token=' . newToken(),
'', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
386 print
'</div>' .
"\n";
390 if (
GETPOST(
'modelselected')) {
394 if ($action !=
'presend') {
395 print
'<div class="fichecenter"><div class="fichehalfleft">';
396 print
'<a name="builddoc"></a>';
398 $includedocgeneration = 0;
401 if ($includedocgeneration) {
403 $relativepath = $objref.
'/'.$objref.
'.pdf';
404 $filedir = $conf->asset->dir_output.
'/'.$objref;
405 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
406 $genallowed = $user->hasRight(
'asset',
'read');
407 $delallowed = $user->hasRight(
'asset',
'write');
408 print $formfile->showdocuments(
'asset:Asset', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
412 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'asset'));
413 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
416 print
'</div><div class="fichehalfright">';
418 $morehtmlcenter =
'';
421 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/asset/agenda.php?id='.$object->id);
424 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
426 $somethingshown =
$formactions->showactions($object, $object->element, 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
428 print
'</div></div>';
432 if (
GETPOST(
'modelselected')) {
437 $modelmail =
'asset';
438 $defaulttopic =
'InformationMessage';
439 $diroutput = $conf->asset->dir_output;
440 $trackid =
'asset'.$object->id;
442 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
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.
assetPrepareHead(Asset $object)
Prepare array of tabs for Asset.
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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
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.
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_get_fiche_end($notab=0)
Return tab footer of a card.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.