.
*
* ------------------------------------------------------------------------
*
* This file is used to manage the hours in the timeslot.
*
* ------------------------------------------------------------------------
*
* @package FusionInventory
* @author David Durieux
* @copyright Copyright (c) 2010-2016 FusionInventory team
* @license AGPL License 3.0 or (at your option) any later version
* http://www.gnu.org/licenses/agpl-3.0-standalone.html
* @link http://www.fusioninventory.org/
* @link https://github.com/fusioninventory/fusioninventory-for-glpi
*
*/
if (!defined('GLPI_ROOT')) {
die("Sorry. You can't access directly to this file");
}
/**
* Manage the hours in the timeslot.
*/
class PluginFusioninventoryTimeslotEntry extends CommonDBTM {
/**
* We activate the history.
*
* @var boolean
*/
public $dohistory = true;
/**
* The right name for this class
*
* @var string
*/
static $rightname = 'plugin_fusioninventory_task';
/**
* Get name of this type by language of the user connected
*
* @param integer $nb number of elements
* @return string name of this type
*/
static function getTypeName($nb = 0) {
return __('Time slot entry', 'fusioninventory');
}
/**
* Get search function for the class
*
* @return array
*/
function rawSearchOptions() {
$tab = [];
$tab[] = [
'id' => 'common',
'name' => __('Time slot', 'fusioninventory')
];
$tab[] = [
'id' => '1',
'table' => $this->getTable(),
'field' => 'name',
'name' => __('Name'),
'datatype' => 'itemlink',
];
$tab[] = [
'id' => '2',
'table' => 'glpi_entities',
'field' => 'completename',
'name' => Entity::getTypeName(1),
'datatype' => 'dropdown',
];
$tab[] = [
'id' => '3',
'table' => $this->getTable(),
'field' => 'is_recursive',
'name' => __('Child entities'),
'datatype' => 'bool',
];
$tab[] = [
'id' => '4',
'table' => $this->getTable(),
'field' => 'name',
'name' => __('Name'),
'datatype' => 'string',
];
return $tab;
}
/**
* Display form to add a new time entry in timeslot
*
* @param integer $timeslots_id
*/
function formEntry($timeslots_id) {
$ID = 0;
$options = [];
$this->initForm($ID, $options);
$this->showFormHeader($options);
echo "
";
$this->showFormButtons($options);
$this->formDeleteEntry($timeslots_id);
$this->showTimeSlot($timeslots_id);
}
/**
* Display delete form
*
* @todo rename this method in showTimeslots() since it's not only used to delete but also to
* show the list of Timeslot Entries. -- Kevin 'kiniou' Roy
*
* @param integer $timeslots_id
*/
function formDeleteEntry($timeslots_id) {
$dbentries = getAllDataFromTable(
'glpi_plugin_fusioninventory_timeslotentries', [
'WHERE' => ['plugin_fusioninventory_timeslots_id' => $timeslots_id],
'ORDER' => ['day', 'begin ASC']
]
);
$options = [];
$ID = key($dbentries);
$canedit = $this->getFromDB($ID)
&& $this->can($ID, READ);
$this->showFormHeader($options);
foreach ($dbentries as $dbentry) {
echo "