27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/asset.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/asset/class/asset.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
42$langs->loadLangs(array(
"assets",
"other"));
47$action =
GETPOST(
'action',
'aZ09');
48$confirm =
GETPOST(
'confirm',
'alpha');
49$cancel =
GETPOST(
'cancel',
'aZ09');
50$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'assetcard';
51$backtopage =
GETPOST(
'backtopage',
'alpha');
52$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
57$diroutputmassaction =
$conf->asset->dir_output.
'/temp/massgeneration/'.$user->id;
58$hookmanager->initHooks(array(
'assetcard',
'globalcard'));
61$extrafields->fetch_name_optionals_label(
$object->table_element);
63$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
66$search_all =
GETPOST(
"search_all",
'alpha');
68foreach (
$object->fields as $key => $val) {
69 if (
GETPOST(
'search_'.$key,
'alpha')) {
70 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
74if (empty($action) && empty($id) && empty($ref)) {
79include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
81$permissiontoread = $user->hasRight(
'asset',
'read');
82$permissiontoadd = $user->hasRight(
'asset',
'write');
83$permissiontodelete = $user->hasRight(
'asset',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
84$permissionnote = $user->hasRight(
'asset',
'write');
85$permissiondellink = $user->hasRight(
'asset',
'write');
89if ($user->socid > 0) {
92if ($user->socid > 0) {
93 $socid = $user->socid;
95$isdraft = ((
$object->status == $object::STATUS_DRAFT) ? 1 : 0);
97if (!isModEnabled(
'asset')) {
100if (!$permissiontoread) {
109$parameters = array();
110$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
115if (empty($reshook)) {
118 $backurlforlist = DOL_URL_ROOT.
'/asset/list.php';
120 if (empty($backtopage) || ($cancel && empty($id))) {
121 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
122 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
123 $backtopage = $backurlforlist;
125 $backtopage = DOL_URL_ROOT.
'/asset/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
131 $triggermodname =
'ASSET_MODIFY';
134 if ($action ==
'confirm_disposal' && $confirm ==
'yes' && $permissiontoadd) {
138 $disposal_invoice_id =
GETPOSTINT(
'disposal_invoice_id');
139 $object->disposal_depreciated = ((
GETPOST(
'disposal_depreciated') ==
'1' ||
GETPOST(
'disposal_depreciated') ==
'on') ? 1 : 0);
140 $object->disposal_subject_to_vat = ((
GETPOST(
'disposal_subject_to_vat') ==
'1' ||
GETPOST(
'disposal_subject_to_vat') ==
'on') ? 1 : 0);
142 $result =
$object->dispose($user, $disposal_invoice_id);
147 } elseif ($action ==
"add" && $permissiontoadd) {
152 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
155 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
158 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
164 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
167 $triggersendname =
'ASSET_SENTBYMAIL';
168 $autocopy =
'MAIN_MAIL_AUTOCOPY_ASSET_TO';
169 $trackid =
'asset'.$object->id;
170 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
179$form =
new Form($db);
182$title = $langs->trans(
"Asset").
' - '.$langs->trans(
"Card");
184llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-asset page-card');
187if ($action ==
'create') {
188 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Asset")),
'',
'object_'.$object->picto);
190 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
191 print
'<input type="hidden" name="token" value="'.newToken().
'">';
192 print
'<input type="hidden" name="action" value="add">';
194 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
196 if ($backtopageforcancel) {
197 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
199 if (GETPOSTISSET(
'supplier_invoice_id')) {
200 $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',);
201 print
'<input type="hidden" name="supplier_invoice_id" value="' .
GETPOSTINT(
'supplier_invoice_id') .
'">';
207 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
210 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
213 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
215 print
'</table>'.
"\n";
219 print $form->buttonsSaveCancel(
"Create");
227if (($id || $ref) && $action ==
'edit') {
228 print
load_fiche_titre($langs->trans(
"Asset"),
'',
'object_'.$object->picto);
230 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
231 print
'<input type="hidden" name="token" value="'.newToken().
'">';
232 print
'<input type="hidden" name="action" value="update">';
233 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
235 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
237 if ($backtopageforcancel) {
238 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
243 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
246 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
249 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
255 print $form->buttonsSaveCancel();
261if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
262 $res =
$object->fetch_optionals();
270 if ($action ==
'delete') {
271 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAsset'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
272 } elseif ($action ==
'disposal') {
274 $langs->load(
'bills');
277 $disposal_amount =
GETPOSTINT(
'disposal_amount');
278 $fk_disposal_type =
GETPOSTINT(
'fk_disposal_type');
279 $disposal_invoice_id =
GETPOSTINT(
'disposal_invoice_id');
280 $disposal_depreciated = GETPOSTISSET(
'disposal_depreciated') ?
GETPOST(
'disposal_depreciated') : 1;
281 $disposal_depreciated = !empty($disposal_depreciated) ? 1 : 0;
282 $disposal_subject_to_vat = GETPOSTISSET(
'disposal_subject_to_vat') ?
GETPOST(
'disposal_subject_to_vat') : 1;
283 $disposal_subject_to_vat = !empty($disposal_subject_to_vat) ? 1 : 0;
285 $object->fields[
'fk_disposal_type'][
'visible'] = 1;
286 $disposal_type_form =
$object->showInputField(
null,
'fk_disposal_type', $fk_disposal_type,
'',
'',
'', 0);
287 $object->fields[
'fk_disposal_type'][
'visible'] = -2;
289 $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',);
290 $disposal_invoice_form =
$object->showInputField(
null,
'disposal_invoice_id', $disposal_invoice_id,
'',
'',
'', 0);
291 unset(
$object->fields[
'disposal_invoice_id']);
294 $formquestion = array(
295 array(
'type' =>
'date',
'name' =>
'disposal_date',
'tdclass' =>
'fieldrequired',
'label' => $langs->trans(
"AssetDisposalDate"),
'value' => $disposal_date),
296 array(
'type' =>
'text',
'name' =>
'disposal_amount',
'tdclass' =>
'fieldrequired',
'label' => $langs->trans(
"AssetDisposalAmount"),
'value' => $disposal_amount),
297 array(
'type' =>
'other',
'name' =>
'fk_disposal_type',
'tdclass' =>
'fieldrequired',
'label' => $langs->trans(
"AssetDisposalType"),
'value' => $disposal_type_form),
298 array(
'type' =>
'other',
'name' =>
'disposal_invoice_id',
'label' => $langs->trans(
"InvoiceCustomer"),
'value' => $disposal_invoice_form),
299 array(
'type' =>
'checkbox',
'name' =>
'disposal_depreciated',
'label' => $langs->trans(
"AssetDisposalDepreciated"),
'value' => $disposal_depreciated),
300 array(
'type' =>
'checkbox',
'name' =>
'disposal_subject_to_vat',
'label' => $langs->trans(
"AssetDisposalSubjectToVat"),
'value' => $disposal_subject_to_vat),
302 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id, $langs->trans(
'AssetDisposal'), $langs->trans(
'AssetConfirmDisposalAsk',
$object->ref .
' - ' .
$object->label),
'confirm_disposal', $formquestion,
'yes', 1);
303 } elseif ($action ==
'reopen') {
306 $formquestion = array();
307 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'AssetConfirmReOpenAsk',
$object->ref),
'confirm_reopen', $formquestion,
'yes', 1);
317 $parameters = array(
'formConfirm' => $formconfirm);
318 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
319 if (empty($reshook)) {
320 $formconfirm .= $hookmanager->resPrint;
321 } elseif ($reshook > 0) {
322 $formconfirm = $hookmanager->resPrint;
331 $linkback =
'<a href="'.DOL_URL_ROOT.
'/asset/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
333 $morehtmlref =
'<div class="refidno">';
334 $morehtmlref .=
'</div>';
337 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
340 print
'<div class="fichecenter">';
341 print
'<div class="fichehalfleft">';
342 print
'<div class="underbanner clearboth"></div>';
343 print
'<table class="border centpercent tableforfield">'.
"\n";
346 $keyforbreak=
'date_acquisition';
349 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
352 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
358 print
'<div class="clearboth"></div>';
363 if ($action !=
'presend' && $action !=
'editline') {
364 print
'<div class="tabsAction">' .
"\n";
365 $parameters = array();
366 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
371 if (empty($reshook)) {
373 if (empty($user->socid)) {
374 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=presend&mode=init&token=' .
newToken() .
'#formmailbeforetitle');
377 if (
$object->status == $object::STATUS_DRAFT) {
378 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=edit&token=' .
newToken(),
'', $permissiontoadd);
384 if (
$object->status == $object::STATUS_DRAFT) {
385 print
dolGetButtonAction($langs->trans(
'AssetDisposal'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=disposal&token=' .
newToken(),
'', $permissiontoadd);
387 print
dolGetButtonAction($langs->trans(
'ReOpen'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=reopen&token=' .
newToken(),
'', $permissiontoadd);
391 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=delete&token=' .
newToken(),
'', $permissiontodelete || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd));
393 print
'</div>' .
"\n";
397 if (
GETPOST(
'modelselected')) {
401 if ($action !=
'presend') {
402 print
'<div class="fichecenter"><div class="fichehalfleft">';
403 print
'<a name="builddoc"></a>';
405 $includedocgeneration = 0;
408 if ($includedocgeneration) {
410 $relativepath = $objref.
'/'.$objref.
'.pdf';
411 $filedir =
$conf->asset->dir_output.
'/'.$objref;
412 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
413 $genallowed = $user->hasRight(
'asset',
'read');
414 $delallowed = $user->hasRight(
'asset',
'write');
415 print $formfile->showdocuments(
'asset:Asset', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
419 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'asset'), 1);
420 $linktoelem = $tmparray[
'linktoelem'];
421 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
422 print $htmltoenteralink;
424 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
427 print
'</div><div class="fichehalfright">';
429 $morehtmlcenter =
'';
432 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/asset/agenda.php?id='.
$object->id);
435 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
437 $somethingshown = $formactions->showactions(
$object,
$object->element, 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
439 print
'</div></div>';
443 if (
GETPOST(
'modelselected')) {
448 $modelmail =
'asset';
449 $defaulttopic =
'InformationMessage';
450 $diroutput =
$conf->asset->dir_output;
451 $trackid =
'asset'.$object->id;
453 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.