diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php
index 58307781cf2..96cb7baff73 100644
--- a/htdocs/asset/card.php
+++ b/htdocs/asset/card.php
@@ -125,38 +125,18 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
}
-
-
-
/*
* View
*
- * Put here all code to build page
*/
$form = new Form($db);
$formfile = new FormFile($db);
-$title = $langs->trans("Assets").' - '.$langs->trans("Card");
+$title = $langs->trans("Asset").' - '.$langs->trans("Card");
$help_url = '';
llxHeader('', $title, $help_url);
-// Example : Adding jquery code
-print '';
-
-
// Part to create
if ($action == 'create')
{
@@ -240,14 +220,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Confirmation to delete
if ($action == 'delete')
{
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAssets'), 'confirm_delete', '', 0, 1);
- }
-
- // Confirmation of action xxxx
- if ($action == 'xxx')
- {
- $formquestion = array();
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAsset'), 'confirm_delete', '', 0, 1);
}
// Call Hook formConfirm
@@ -292,28 +265,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '';
print '';
- print '';
- print '';
print '
';
print dol_get_fiche_end();
- // Buttons for actions
- if ($action != 'presend' && $action != 'editline') {
- print ''."\n";
+ /*
+ * Buttons
+ */
+ if ($user->socid == 0)
+ {
+ print '
'."\n";
- }
-
-
- // Select mail models is same action as presend
- if (GETPOST('modelselected')) {
- $action = 'presend';
+ print "
";
}
if ($action != 'presend')
@@ -343,27 +306,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print ''; // ancre
// Documents
- /*$objref = dol_sanitizeFileName($object->ref);
- $relativepath = $comref . '/' . $comref . '.pdf';
- $filedir = $conf->asset->dir_output . '/' . $objref;
- $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
+ $filename = dol_sanitizeFileName($object->ref);
+ $filedir = $conf->contrat->dir_output."/".dol_sanitizeFileName($object->ref);
+ $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = $user->rights->asset->read; // If you can read, you can build the PDF to read content
- $delallowed = $user->rights->asset->create; // If you can create/edit, you can remove a file on card
- print $formfile->showdocuments('asset', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
- */
+ $delallowed = $user->rights->asset->write; // If you can create/edit, you can remove a file on card
+
+ print $formfile->showdocuments('asset', $filename, $filedir, $urlsource, 0, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('asset'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
-
print '';
$MAXEVENT = 10;
- $morehtmlright = '
';
- $morehtmlright .= $langs->trans("SeeAll");
- $morehtmlright .= '';
+ $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/asset/info.php?id='.$object->id);
// List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
@@ -372,19 +331,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '
';
}
-
- //Select mail models is same action as presend
- if (GETPOST('modelselected')) $action = 'presend';
-
- // Presend form
- /*
- $modelmail='asset';
- $defaulttopic='InformationMessage';
- $diroutput = $conf->asset->dir_output.'/asset';
- $trackid = 'asset'.$object->id;
-
- include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
- */
}
diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php
index 4c2e36aed9a..f82c8fea5f1 100644
--- a/htdocs/asset/document.php
+++ b/htdocs/asset/document.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2018 Alexandre Spangaro
+ * Copyright (C) 2018-2021 Alexandre Spangaro
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
/**
* \file htdocs/asset/document.php
* \ingroup asset
- * \brief Tab for documents linked to Assets
+ * \brief Page for attached files on assets
*/
require '../main.inc.php';
@@ -31,18 +31,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page
-$langs->loadLangs(array("assets", "companies"));
+$langs->loadLangs(array('assets', 'companies', 'other'));
-$action = GETPOST('action', 'aZ09');
-$confirm = GETPOST('confirm');
-$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
+$id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
$ref = GETPOST('ref', 'alpha');
+$socid = GETPOST('socid', 'int');
+$action = GETPOST('action', 'aZ09');
+$confirm = GETPOST('confirm', 'alpha');
-// Security check - Protection if external user
-//if ($user->socid > 0) accessforbidden();
-//if ($user->socid > 0) $socid = $user->socid;
-//$result = restrictedArea($user, 'asset', $id);
+// Security check
+if ($user->socid)
+{
+ $socid = $user->socid;
+}
+$result=restrictedArea($user, 'asset', $id, '');
// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
@@ -56,100 +59,79 @@ $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name";
-// Initialize technical objects
$object = new Asset($db);
-$extrafields = new ExtraFields($db);
-$diroutputmassaction = $conf->assets->dir_output.'/temp/massgeneration/'.$user->id;
-$hookmanager->initHooks(array('assetdocument')); // Note that conf->hooks_modules contains array
-
-// Fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label($object->table_element);
-
-// Load object
-include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
-
-// Security check
-if (!empty($user->socid)) $socid = $user->socid;
-$result = restrictedArea($user, 'asset', $id);
-
-//if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/packages/" . dol_sanitizeFileName($object->id);
-if ($id > 0 || !empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity]."/packages/".dol_sanitizeFileName($object->ref);
-
+if ($object->fetch($id))
+{
+ $upload_dir = $conf->asset->dir_output."/".dol_sanitizeFileName($object->ref);
+}
/*
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
* View
*/
+$title = $langs->trans('Assets')." - ".$langs->trans('Documents');
+$helpurl = '';
+llxHeader('', $title, $helpurl);
+
$form = new Form($db);
-$title = $langs->trans("Assets").' - '.$langs->trans("Files");
-$help_url = '';
-//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
-llxHeader('', $title, $help_url);
-if ($object->id)
+
+if ($id > 0 || !empty($ref))
{
- /*
- * Show tabs
- */
- if (!empty($conf->notification->enabled)) $langs->load("mails");
- $head = asset_prepare_head($object);
-
- print dol_get_fiche_head($head, 'document', $langs->trans("Asset"), -1, 'generic');
-
-
- // Build file list
- $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
- $totalsize = 0;
- foreach ($filearray as $key => $file)
+ if ($object->fetch($id, $ref) > 0)
{
- $totalsize += $file['size'];
+ $upload_dir = $conf->asset->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
+
+ $head = asset_prepare_head($object);
+ print dol_get_fiche_head($head, 'documents', $langs->trans('Asset'), -1, 'accounting');
+
+ // Build file list
+ $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
+ $totalsize = 0;
+ foreach ($filearray as $key => $file)
+ {
+ $totalsize += $file['size'];
+ }
+
+ // Asset content
+
+ $linkback = ''.$langs->trans("BackToList").'';
+
+ $morehtmlref = '';
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
+
+ print '';
+ print '
';
+
+ print '
';
+
+ print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize, 1, 1).' |
';
+ print "
\n";
+
+ print "
\n";
+
+ print dol_get_fiche_end();
+
+ $modulepart = 'asset';
+ $permission = $user->rights->asset->write;
+ $permtoedit = $user->rights->asset->write;
+ $param = '&id='.$object->id;
+ include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
+ } else {
+ dol_print_error($db);
}
-
- // Object card
- // ------------------------------------------------------------
- $linkback = ''.$langs->trans("BackToList").'';
-
- dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
-
- print '';
-
- print '
';
- print '
';
-
- // Number of files
- print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
-
- // Total size
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
-
- print '
';
-
- print '
';
-
- print dol_get_fiche_end();
-
- $modulepart = 'asset';
- //$permission = $user->rights->asset->create;
- $permission = 1;
- //$permtoedit = $user->rights->asset->create;
- $permtoedit = 1;
- $param = '&id='.$object->id;
-
- //$relativepathwithnofile='asset/' . dol_sanitizeFileName($object->id).'/';
- $relativepathwithnofile = 'asset/'.dol_sanitizeFileName($object->ref).'/';
-
- include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
} else {
- accessforbidden('', 0, 1);
+ print $langs->trans("ErrorUnknown");
}
// End of page
diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php
index fecebb676a8..38969d65182 100644
--- a/htdocs/asset/type.php
+++ b/htdocs/asset/type.php
@@ -157,7 +157,7 @@ if ($action == 'update' && $user->rights->asset->write)
if ($ret >= 0 && !count($object->errors))
{
- setEventMessages($langs->trans("AssetsTypeModified"), null, 'mesgs');
+ setEventMessages($langs->trans("AssetTypeModified"), null, 'mesgs');
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php
index 5fddf4f1c46..96355704c96 100644
--- a/htdocs/core/lib/asset.lib.php
+++ b/htdocs/core/lib/asset.lib.php
@@ -80,7 +80,7 @@ function asset_prepare_head(Asset $object)
$h = 0;
$head = array();
- $head[$h][0] = DOL_URL_ROOT.'/asset/card.php';
+ $head[$h][0] = DOL_URL_ROOT.'/asset/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index 46950bdc50c..31d4baa38f1 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -1451,7 +1451,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->rights->asset->read);
$newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type');
if ($usemenuhider || empty($leftmenu) || preg_match('/asset_type/', $leftmenu)) {
- $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create", $langs->trans("MenuNewTypeAssets"), 2, (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->setup_advance));
+ $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create", $langs->trans("MenuNewTypeAssets"), 2, $user->rights->asset->setup_advance);
$newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuListTypeAssets"), 2, $user->rights->asset->read);
}
}
diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php
index 50fe71ef390..9f20ae44f86 100644
--- a/htdocs/core/modules/modAsset.class.php
+++ b/htdocs/core/modules/modAsset.class.php
@@ -79,7 +79,7 @@ class modAsset extends DolibarrModules
// Data directories to create when module is enabled.
// Example: this->dirs = array("/asset/temp","/asset/subdir");
- $this->dirs = array();
+ $this->dirs = array("/asset/temp");
// Config pages. Put here list of php page, stored into asset/admin directory, to use to setup module.
$this->config_page_url = array("setup.php@asset");
diff --git a/htdocs/langs/en_US/assets.lang b/htdocs/langs/en_US/assets.lang
index ef04723c6c2..afafc98503f 100644
--- a/htdocs/langs/en_US/assets.lang
+++ b/htdocs/langs/en_US/assets.lang
@@ -61,5 +61,7 @@ MenuListTypeAssets = List
#
# Module
#
+Asset=Asset
NewAssetType=New asset type
NewAsset=New asset
+ConfirmDeleteAsset=Are you sure you want to delete this asset ?