|
@@ -34,15 +34,18 @@ $langs->loadLangs(array("asset"));
|
|
|
// Get parameters
|
|
|
$id = GETPOST('id', 'int');
|
|
|
$ref = GETPOST('ref', 'alpha');
|
|
|
-$action = GETPOST('action', 'alpha');
|
|
|
+$action = GETPOST('action', 'aZ09');
|
|
|
+$confirm = GETPOST('confirm', 'alpha');
|
|
|
$cancel = GETPOST('cancel', 'aZ09');
|
|
|
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search
|
|
|
$backtopage = GETPOST('backtopage', 'alpha');
|
|
|
+$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
|
|
|
|
|
|
// Initialize technical objects
|
|
|
$object = new Asset($db);
|
|
|
$extrafields = new ExtraFields($db);
|
|
|
$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id;
|
|
|
-$hookmanager->initHooks(array('assetcard')); // Note that conf->hooks_modules contains array
|
|
|
+$hookmanager->initHooks(array('assetcard', 'globalcard')); // Note that conf->hooks_modules contains array
|
|
|
|
|
|
// Fetch optionals attributes and labels
|
|
|
$extrafields->fetch_name_optionals_label($object->table_element);
|
|
@@ -59,23 +62,20 @@ foreach ($object->fields as $key => $val)
|
|
|
|
|
|
if (empty($action) && empty($id) && empty($ref)) $action = 'view';
|
|
|
|
|
|
-// Security check - Protection if external user
|
|
|
-//if ($user->socid > 0) accessforbidden();
|
|
|
-//if ($user->socid > 0) $socid = $user->socid;
|
|
|
-//$result = restrictedArea($user, 'asset', $id);
|
|
|
-
|
|
|
// Load object
|
|
|
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
|
|
|
|
|
|
+
|
|
|
+$permissiontoread = $user->rights->asset->read;
|
|
|
+$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
|
|
+$permissiontodelete = $user->rights->asset->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
|
|
$permissionnote = $user->rights->asset->write; // Used by the include of actions_setnotes.inc.php
|
|
|
$permissiondellink = $user->rights->asset->write; // Used by the include of actions_dellink.inc.php
|
|
|
-$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
|
|
+$upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object->entity : 1];
|
|
|
|
|
|
|
|
|
/*
|
|
|
* Actions
|
|
|
- *
|
|
|
- * Put here all code to do according to value of "action" parameter
|
|
|
*/
|
|
|
|
|
|
$parameters = array();
|
|
@@ -86,16 +86,35 @@ if (empty($reshook))
|
|
|
{
|
|
|
$error = 0;
|
|
|
|
|
|
- $permissiontoadd = $user->rights->asset->create;
|
|
|
- $permissiontodelete = $user->rights->asset->delete;
|
|
|
$backurlforlist = dol_buildpath('/asset/list.php', 1);
|
|
|
|
|
|
// Actions cancel, add, update or delete
|
|
|
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
|
|
|
|
|
+ // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
|
|
|
+ include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
|
|
+
|
|
|
+ // Actions when linking object each other
|
|
|
+ include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
|
|
|
+
|
|
|
// Actions when printing a doc from card
|
|
|
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
|
|
|
|
|
+ // Action to move up and down lines of object
|
|
|
+ //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
|
|
|
+
|
|
|
+ // Action to build doc
|
|
|
+ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
|
|
+
|
|
|
+ if ($action == 'set_thirdparty' && $permissiontoadd)
|
|
|
+ {
|
|
|
+ $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MYOBJECT_MODIFY');
|
|
|
+ }
|
|
|
+ if ($action == 'classin' && $permissiontoadd)
|
|
|
+ {
|
|
|
+ $object->setProject(GETPOST('projectid', 'int'));
|
|
|
+ }
|
|
|
+
|
|
|
// Actions to send emails
|
|
|
$triggersendname = 'ASSET_SENTBYMAIL';
|
|
|
$autocopy = 'MAIN_MAIL_AUTOCOPY_ASSET_TO';
|
|
@@ -143,11 +162,12 @@ if ($action == 'create')
|
|
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
|
print '<input type="hidden" name="action" value="add">';
|
|
|
- print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
|
|
-
|
|
|
+ if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
|
|
+ if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
|
|
|
+
|
|
|
dol_fiche_head(array(), '');
|
|
|
|
|
|
- print '<table class="border centpercent">'."\n";
|
|
|
+ print '<table class="border centpercent tableforfieldcreate">'."\n";
|
|
|
|
|
|
// Common attributes
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
|
|
@@ -166,6 +186,8 @@ if ($action == 'create')
|
|
|
print '</div>';
|
|
|
|
|
|
print '</form>';
|
|
|
+
|
|
|
+ //dol_set_focus('input[name="ref"]');
|
|
|
}
|
|
|
|
|
|
// Part to edit record
|
|
@@ -178,10 +200,12 @@ if (($id || $ref) && $action == 'edit')
|
|
|
print '<input type="hidden" name="action" value="update">';
|
|
|
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
|
|
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
|
|
-
|
|
|
+ if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
|
|
+ if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
|
|
|
+
|
|
|
dol_fiche_head();
|
|
|
|
|
|
- print '<table class="border centpercent">'."\n";
|
|
|
+ print '<table class="border centpercent tableforfieldedit">'."\n";
|
|
|
|
|
|
// Common attributes
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
|
|
@@ -206,7 +230,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|
|
$res = $object->fetch_optionals();
|
|
|
|
|
|
$head = asset_prepare_head($object);
|
|
|
- dol_fiche_head($head, 'card', $langs->trans("Asset"), -1, 'generic');
|
|
|
+ dol_fiche_head($head, 'card', $langs->trans("Asset"), -1, $object->picto);
|
|
|
|
|
|
$formconfirm = '';
|
|
|
|
|
@@ -255,10 +279,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|
|
print '<table class="border centpercent">'."\n";
|
|
|
|
|
|
// Common attributes
|
|
|
- //$keyforbreak='fieldkeytoswithonsecondcolumn';
|
|
|
+ //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just after this field
|
|
|
+ //unset($object->fields['fk_project']); // Hide field already shown in banner
|
|
|
+ //unset($object->fields['fk_soc']); // Hide field already shown in banner
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
|
|
|
|
|
|
- // Other attributes
|
|
|
+ // Other attributes. Fields from hook formObjectOptions and Extrafields.
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
|
|
|
|
|
|
print '</table>';
|
|
@@ -266,7 +292,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|
|
print '</div>';
|
|
|
print '</div>';
|
|
|
|
|
|
- print '<div class="clearboth"></div><br>';
|
|
|
+ print '<div class="clearboth"></div>';
|
|
|
|
|
|
dol_fiche_end();
|
|
|
|
|
@@ -349,14 +375,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|
|
}
|
|
|
|
|
|
//Select mail models is same action as presend
|
|
|
- /*
|
|
|
if (GETPOST('modelselected')) $action = 'presend';
|
|
|
|
|
|
// Presend form
|
|
|
- $modelmail='inventory';
|
|
|
+ /*
|
|
|
+ $modelmail='asset';
|
|
|
$defaulttopic='InformationMessage';
|
|
|
- $diroutput = $conf->product->dir_output.'/inventory';
|
|
|
- $trackid = 'stockinv'.$object->id;
|
|
|
+ $diroutput = $conf->asset->dir_output.'/asset';
|
|
|
+ $trackid = 'asset'.$object->id;
|
|
|
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
|
|
|
*/
|