2018-04-01 21:26:52 +02:00
< ? php
/* Copyright ( C ) 2007 - 2017 Laurent Destailleur < eldy @ users . sourceforge . net >
2019-01-28 21:39:22 +01:00
* Copyright ( C ) 2018 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2018-04-01 21:26:52 +02:00
*
* 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
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2018-04-01 21:26:52 +02:00
*/
/**
2018-08-31 23:12:55 +02:00
* \file htdocs / asset / note . php
2018-04-29 19:52:14 +02:00
* \ingroup asset
* \brief Card with notes on Asset
2018-04-01 21:26:52 +02:00
*/
require '../main.inc.php' ;
2018-04-29 19:52:14 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php' ;
2018-04-01 21:26:52 +02:00
2018-05-26 18:41:16 +02:00
// Load translation files required by the page
2019-11-13 19:35:39 +01:00
$langs -> loadLangs ( array ( " asset " , " companies " ));
2018-04-01 21:26:52 +02:00
// Get parameters
2019-11-13 19:35:39 +01:00
$id = GETPOST ( 'id' , 'int' );
2018-04-01 21:26:52 +02:00
$ref = GETPOST ( 'ref' , 'alpha' );
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2018-04-01 21:26:52 +02:00
$cancel = GETPOST ( 'cancel' , 'aZ09' );
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
// Initialize technical objects
2019-11-13 19:35:39 +01:00
$object = new Asset ( $db );
2018-04-01 21:26:52 +02:00
$extrafields = new ExtraFields ( $db );
2019-11-13 19:35:39 +01:00
$diroutputmassaction = $conf -> asset -> dir_output . '/temp/massgeneration/' . $user -> id ;
$hookmanager -> initHooks ( array ( 'assetnote' )); // Note that conf->hooks_modules contains array
2019-09-28 10:55:09 +02:00
2018-04-01 21:26:52 +02:00
// Fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2018-04-01 21:26:52 +02:00
// Security check - Protection if external user
2019-11-22 15:35:19 +01:00
//if ($user->socid > 0) accessforbidden();
2019-10-31 20:46:31 +01:00
//if ($user->socid > 0) $socid = $user->socid;
2018-04-29 19:52:14 +02:00
//$result = restrictedArea($user, 'asset', $id);
2018-04-01 21:26:52 +02:00
// Load object
2019-11-13 19:35:39 +01:00
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
2021-02-22 18:38:03 +01:00
if ( $id > 0 || ! empty ( $ref )) {
$upload_dir = $conf -> asset -> multidir_output [ $object -> entity ] . " / " . $object -> id ;
}
2018-04-01 21:26:52 +02:00
2020-09-24 17:24:23 +02:00
// Security check
2021-02-22 18:38:03 +01:00
if ( ! empty ( $user -> socid )) {
$socid = $user -> socid ;
}
2020-09-24 17:24:23 +02:00
$result = restrictedArea ( $user , 'asset' , $id );
2019-11-13 19:35:39 +01:00
$permissionnote = 1 ;
2018-04-29 19:52:14 +02:00
//$permissionnote=$user->rights->asset->creer; // Used by the include of actions_setnotes.inc.php
2018-04-01 21:26:52 +02:00
/*
* Actions
*/
2019-11-13 19:35:39 +01:00
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php' ; // Must be include, not include_once
2018-04-01 21:26:52 +02:00
/*
* View
*/
$form = new Form ( $db );
//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes';
2019-11-13 19:35:39 +01:00
$help_url = '' ;
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $langs -> trans ( 'Assets' ), $help_url );
2018-04-01 21:26:52 +02:00
2021-02-22 18:38:03 +01:00
if ( $id > 0 || ! empty ( $ref )) {
2018-04-01 21:26:52 +02:00
$object -> fetch_thirdparty ();
2018-10-14 10:57:27 +02:00
$head = asset_prepare_head ( $object );
2018-04-01 21:26:52 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'note' , $langs -> trans ( " Asset " ), - 1 , 'generic' );
2018-04-01 21:26:52 +02:00
// Object card
// ------------------------------------------------------------
2019-11-13 19:35:39 +01:00
$linkback = '<a href="' . dol_buildpath ( '/asset/list.php' , 1 ) . '?restore_lastsearch_values=1' . ( ! empty ( $socid ) ? '&socid=' . $socid : '' ) . '">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2018-04-01 21:26:52 +02:00
2019-11-13 19:35:39 +01:00
$morehtmlref = '<div class="refidno">' ;
2018-04-01 21:26:52 +02:00
/*
// Ref customer
$morehtmlref .= $form -> editfieldkey ( " RefCustomer " , 'ref_client' , $object -> ref_client , $object , 0 , 'string' , '' , 0 , 1 );
$morehtmlref .= $form -> editfieldval ( " RefCustomer " , 'ref_client' , $object -> ref_client , $object , 0 , 'string' , '' , null , null , '' , 1 );
// Thirdparty
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' . $object -> thirdparty -> getNomUrl ( 1 );
// Project
if ( ! empty ( $conf -> projet -> enabled ))
{
2021-02-22 18:38:03 +01:00
$langs -> load ( " projects " );
$morehtmlref .= '<br>' . $langs -> trans ( 'Project' ) . ' ' ;
if ( $user -> rights -> asset -> creer )
{
if ( $action != 'classify' )
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ' ;
if ( $action == 'classify' ) {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '">' ;
$morehtmlref .= '<input type="hidden" name="action" value="classin">' ;
$morehtmlref .= '<input type="hidden" name="token" value="' . newToken () . '">' ;
$morehtmlref .= $formproject -> select_projects ( $object -> socid , $object -> fk_project , 'projectid' , $maxlength , 0 , 1 , 0 , 1 , 0 , 0 , '' , 1 );
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="' . $langs -> trans ( " Modify " ) . '">' ;
$morehtmlref .= '</form>' ;
} else {
$morehtmlref .= $form -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> socid , $object -> fk_project , 'none' , 0 , 0 , 0 , 1 );
}
} else {
if ( ! empty ( $object -> fk_project )) {
$proj = new Project ( $db );
$proj -> fetch ( $object -> fk_project );
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $object -> fk_project . '" title="' . $langs -> trans ( 'ShowProject' ) . '">' ;
$morehtmlref .= $proj -> ref ;
$morehtmlref .= '</a>' ;
} else {
$morehtmlref .= '' ;
}
}
2018-04-01 21:26:52 +02:00
} */
2019-11-13 19:35:39 +01:00
$morehtmlref .= '</div>' ;
2018-04-01 21:26:52 +02:00
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2019-11-13 19:35:39 +01:00
$cssclass = " titlefield " ;
2018-04-01 21:26:52 +02:00
include DOL_DOCUMENT_ROOT . '/core/tpl/notes.tpl.php' ;
print '</div>' ;
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2018-04-01 21:26:52 +02:00
}
2018-07-29 11:33:52 +02:00
// End of page
2018-04-01 21:26:52 +02:00
llxFooter ();
$db -> close ();