Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ Simcard management for GLPI
* Updated by Anthony Piesset and Dethegeek for GLPi 0.84
* Updated by Thierry Bugier Pineau for GLPi 0.85 and 0.90

Integration in GLPI 9.4
-----------------------

Beside what they wrote, the way that GLPI handle SIM Card in core modules is really awful.
Plugin is a lot better for Sim Card Management.


Integration in GLPI 9.2
-----------------------

Expand Down
1 change: 1 addition & 0 deletions front/simcard.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
@link http://www.glpi-project.org/
@since 2009
---------------------------------------------------------------------- */
use Glpi\Event;

include ('../../../inc/includes.php');

Expand Down
8 changes: 4 additions & 4 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@
* @return number
*/
function plugin_simcard_currentVersion() {

global $DB;
// Saves the current version to not re-detect it on multiple calls
static $currentVersion = null;

if ($currentVersion === null) {
// result not cached
if (
!TableExists('glpi_plugin_simcard_simcards_items') &&
!TableExists('glpi_plugin_simcard_configs')
!$DB->tableExists('glpi_plugin_simcard_simcards_items') &&
!$DB->tableExists('glpi_plugin_simcard_configs')
) {
// the plugin seems not installed
$currentVersion = 0;
} else {
if (TableExists('glpi_plugin_simcard_configs')) {
if ($DB->TableExists('glpi_plugin_simcard_configs')) {
// The plugin is at least 1.3
// Get the current version in the plugin's configuration
$pluginSimcardConfig = new PluginSimcardConfig();
Expand Down
135 changes: 120 additions & 15 deletions inc/simcard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,16 @@ function showForm($ID, $options=array()) {
(isset($options['withtemplate']) && $options['withtemplate']?"*":"").
"</td>";
echo "<td>";
$objectName = autoName($this->fields["name"], "name",
/*$objectName = autoName($this->fields["name"], "name",
(isset($options['withtemplate']) && $options['withtemplate']==2),
$this->getType(), $this->fields["entities_id"]);
Html::autocompletionTextField($this, 'name', array('value' => $objectName));
Html::autocompletionTextField($this, 'name', array('value' => $objectName));*/

echo Html::input('name', ['type' => 'text',
'value' => $this->fields["name"]]);



echo "</td>";
echo "<td>".__s('Status')."</td>";
echo "<td>";
Expand Down Expand Up @@ -189,7 +195,8 @@ function showForm($ID, $options=array()) {
Group::dropdown(array('name' => 'groups_id_tech',
'value' => $this->fields['groups_id_tech'],
'entity' => $this->fields['entities_id'],
'condition' => '`is_assign`'));
'condition' => ['is_assign' => 1]
));
echo "</td>";

echo "<td>".__s('Voltage', 'simcard')."</td>";
Expand Down Expand Up @@ -224,10 +231,13 @@ function showForm($ID, $options=array()) {
(isset($options['withtemplate']) && $options['withtemplate']?"*":"").
"</td>";
echo "<td>";
$objectName = autoName($this->fields["otherserial"], "otherserial",
(isset($options['withtemplate']) && $options['withtemplate']==2),
$this->getType(), $this->fields["entities_id"]);
Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));


echo Html::input('otherserial', ['type' => 'text',
'value' => $this->fields["otherserial"]]);



echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>".__s('Group')."</td>";
Expand All @@ -240,7 +250,11 @@ function showForm($ID, $options=array()) {
echo "<tr class='tab_bg_1'>";
echo "<td>".__s('Phone number', 'simcard')."</td>";
echo "<td>";
Html::autocompletionTextField($this,'phonenumber');

echo Html::input('phonenumber', ['type' => 'text',
'value' => $this->fields["phonenumber"]]);


echo "</td>";
echo "<td rowspan='6'>".__s('Comments')."</td>";
echo "<td rowspan='6' class='middle'>";
Expand All @@ -250,33 +264,50 @@ function showForm($ID, $options=array()) {
echo "<tr class='tab_bg_1'>";
echo "<td>".__s('IMSI', 'simcard')."</td>";
echo "<td>";
Html::autocompletionTextField($this,'serial');

echo Html::input('serial', ['type' => 'text',
'value' => $this->fields["serial"]]);


echo "</td></tr>\n";

//Only show PIN and PUK code to users who can write (theses informations are highly sensible)
if (PluginSimcardSimcard::canUpdate()) {
echo "<tr class='tab_bg_1'>";
echo "<td>".__s('Pin 1', 'simcard')."</td>";
echo "<td>";
Html::autocompletionTextField($this,'pin');
echo Html::input('pin', ['type' => 'text',
'value' => $this->fields["pin"]]);

//Html::autocompletionTextField($this,'pin');
echo "</td></tr>\n";

echo "<tr class='tab_bg_1'>";
echo "<td>".__s('Pin 2', 'simcard')."</td>";
echo "<td>";
Html::autocompletionTextField($this,'pin2');
echo Html::input('pin2', ['type' => 'text',
'value' => $this->fields["pin2"]]);

//Html::autocompletionTextField($this,'pin2');

echo "</td></tr>\n";

echo "<tr class='tab_bg_1'>";
echo "<td>".__s('Puk 1', 'simcard')."</td>";
echo "<td>";
Html::autocompletionTextField($this,'puk');
echo Html::input('puk', ['type' => 'text',
'value' => $this->fields["puk"]]);

//Html::autocompletionTextField($this,'puk');
echo "</td></tr>\n";

echo "<tr class='tab_bg_1'>";
echo "<td>".__s('Puk 2', 'simcard')."</td>";
echo "<td>";
Html::autocompletionTextField($this,'puk2');
echo Html::input('puk2', ['type' => 'text',
'value' => $this->fields["puk2"]]);

//Html::autocompletionTextField($this,'puk2');
echo "</td></tr>\n";
}

Expand Down Expand Up @@ -317,6 +348,80 @@ function post_addItem() {

}


function rawSearchOptions() {
global $CFG_GLPI;

$tab = [];

$tab[] = [
'id' => 'common',
'name' => __('Plugin SIMCARD')
];

$tab[] = [
'id' => '1',
'table' => $this->getTable(),
'field' => 'name',
'name' => __('Name'),
'datatype' => 'itemlink',
'massiveaction' => false // implicit key==1
];



$tab[] = [
'id' => '2',
'table' => $this->getTable(),
'field' => 'phonenumber',
'name' => __('phonenumber'),
'datatype' => 'text'
];

$tab[] = [
'id' => '3',
'table' => $this->getTable(),
'field' => 'serial',
'name' => __('IMSI', 'simcard'),
'datatype' => 'string',
'checktype' => 'text',
'displaytype' => 'text',
'injectable' => true
];

$tab[] = [
'id' => '4',
'table' => 'glpi_users',
'field' => 'name',
'linkfield' => 'users_id',
'name' => __('User'),
'datatype' => 'dropdown',
'massiveaction' => false // implicit key==1
];


$tab[] = [
'id' => '5',
'table' => $this->getTable(),
'field' => 'otherserial',
'name' => __('Inventory Number'),
'datatype' => 'text'
];

$tab[] = [
'id' => '6',
'table' => 'glpi_states',
'field' => 'name',
'linkfield' => 'states_id',
'name' => __('Status'),
'datatype' => 'dropdown'
];


return $tab;

}

function getSearchOptions() {
global $CFG_GLPI, $LANG;

Expand Down Expand Up @@ -527,7 +632,7 @@ function getSearchOptions() {
static function install(Migration $migration) {
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
if (!$DB->tableExists($table)) {
$query = "CREATE TABLE IF NOT EXISTS `$table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`entities_id` int(11) NOT NULL DEFAULT '0',
Expand Down Expand Up @@ -626,7 +731,7 @@ static function uninstall() {
// Remove unicity constraints on simcards
FieldUnicity::deleteForItemtype("SimcardSimcard");

foreach (array('Notepad', 'DisplayPreference', 'Contract_Item', 'Infocom', 'Fieldblacklist', 'Document_Item', 'Bookmark', 'Log') as $itemtype) {
foreach (array('Notepad', 'DisplayPreference', 'Contract_Item', 'Infocom', 'Fieldblacklist', 'Document_Item', 'Log') as $itemtype) {
$item = new $itemtype();
$item->deleteByCriteria(array('itemtype' => __CLASS__));
}
Expand Down
Loading