-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add config for add task description
Feature/task description cost
- Loading branch information
Showing
11 changed files
with
388 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
include ( "../../../inc/includes.php"); | ||
|
||
$config = new PluginCostsConfig(); | ||
if (isset($_POST["update"])) { | ||
$config->check($_POST['id'], UPDATE); | ||
|
||
// save | ||
$config->update($_POST); | ||
|
||
|
||
Html::back(); | ||
|
||
} else if (isset($_POST["refresh"])) { | ||
$config->refresh($_POST); // used to refresh process list, task category list | ||
Html::back(); | ||
} | ||
|
||
Html::redirect($CFG_GLPI["root_doc"]."/front/config.form.php?forcetab=".urlencode('PluginCostsConfig$1')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
<?php | ||
|
||
if(!defined('GLPI_ROOT')){ | ||
die("Sorry. You can't access directly to this file"); | ||
} | ||
|
||
class PluginCostsConfig extends CommonDBTM { | ||
static private $_instance = null; | ||
|
||
public function __construct() { | ||
global $DB; | ||
if ($DB->tableExists(self::getTable())) { | ||
$this->getFromDB(1); | ||
} | ||
} | ||
/** | ||
* Summary of canCreate | ||
* @return boolean | ||
*/ | ||
static function canCreate() { | ||
return Session::haveRight('config', UPDATE); | ||
} | ||
|
||
/** | ||
* Summary of canView | ||
* @return boolean | ||
*/ | ||
static function canView() { | ||
return Session::haveRight('config', READ); | ||
} | ||
|
||
/** | ||
* Summary of canUpdate | ||
* @return boolean | ||
*/ | ||
static function canUpdate() { | ||
return Session::haveRight('config', UPDATE); | ||
} | ||
|
||
/** | ||
* Summary of getTypeName | ||
* @param mixed $nb plural | ||
* @return mixed | ||
*/ | ||
static function getTypeName($nb = 0) { | ||
return __("Costs", "costs"); | ||
} | ||
|
||
/** | ||
* Summary of getInstance | ||
* @return PluginProcessmakerConfig | ||
*/ | ||
static function getInstance() { | ||
|
||
if (!isset(self::$_instance)) { | ||
self::$_instance = new self(); | ||
if (!self::$_instance->getFromDB(1)) { | ||
self::$_instance->getEmpty(); | ||
} | ||
} | ||
return self::$_instance; | ||
} | ||
|
||
public static function getConfig($update = false) { | ||
static $config = null; | ||
if (is_null($config)) { | ||
$config = new self(); | ||
} | ||
if ($update) { | ||
$config->getFromDB(1); | ||
} | ||
return $config; | ||
} | ||
|
||
/** | ||
* Summary of showConfigForm | ||
* @param mixed $item is the config | ||
* @return boolean | ||
*/ | ||
static function showConfigForm() { | ||
global $CFG_GLPI; | ||
|
||
$config = new self(); | ||
$config->getFromDB(1); | ||
|
||
$config->showFormHeader(['colspan' => 4]); | ||
|
||
echo "<tr class='tab_bg_1'>"; | ||
echo "<td >".__("Add task description on cost", "cost")."</td><td >"; | ||
Dropdown::showYesNo("taskdescription", $config->fields["taskdescription"]); | ||
echo "</td></tr>\n"; | ||
|
||
$config->showFormButtons(['candel'=>false]); | ||
|
||
return false; | ||
} | ||
|
||
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { | ||
global $LANG; | ||
|
||
if ($item->getType()=='Config') { | ||
return __("Costs", "costs"); | ||
} | ||
return ''; | ||
} | ||
|
||
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { | ||
|
||
if ($item->getType()=='Config') { | ||
self::showConfigForm($item); | ||
} | ||
return true; | ||
} | ||
|
||
public static function install(Migration $migration) { | ||
global $DB; | ||
|
||
$table = self::getTable(); | ||
$config = new self(); | ||
|
||
if (!$DB->tableExists($table)) { | ||
$migration->displayMessage("Installing $table"); | ||
//Install | ||
|
||
$query = "CREATE TABLE `$table` ( | ||
`id` int(11) NOT NULL auto_increment, | ||
`taskdescription` tinyint(1) NOT NULL default '0', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; | ||
|
||
$DB->query($query) or die ($DB->error()); | ||
$config->add([ | ||
'id' => 1, | ||
'taskdescription' => 0, | ||
]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Cost Glpi Plugin. | ||
# Copyright (C) 2020 TICgal | ||
# This file is distributed under the same license as the PACKAGE package. | ||
# TICgal, 2020 | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2020-05-08 14:32+0200\n" | ||
"PO-Revision-Date: 2020-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"Language: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=CHARSET\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
|
||
#: inc/config.class.php:46 inc/config.class.php:102 inc/entity.class.php:46 | ||
#: inc/ticket.class.php:41 | ||
msgid "Costs" | ||
msgstr "" | ||
|
||
#: inc/config.class.php:89 | ||
msgid "Add task description on cost" | ||
msgstr "" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Cost Glpi Plugin. | ||
# Copyright (C) 2020 TICgal | ||
# This file is distributed under the same license as the PACKAGE package. | ||
# TICgal, 2020 | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: \n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2020-05-08 14:32+0200\n" | ||
"PO-Revision-Date: 2020-05-08 14:33+0200\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"X-Generator: Poedit 2.0.6\n" | ||
"Last-Translator: \n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
"Language: en_GB\n" | ||
|
||
#: inc/config.class.php:46 inc/config.class.php:102 inc/entity.class.php:46 | ||
#: inc/ticket.class.php:41 | ||
msgid "Costs" | ||
msgstr "Costs" | ||
|
||
#: inc/config.class.php:89 | ||
msgid "Add task description on cost" | ||
msgstr "Add task description on cost" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Cost Glpi Plugin. | ||
# Copyright (C) 2020 TICgal | ||
# This file is distributed under the same license as the PACKAGE package. | ||
# TICgal, 2020 | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: \n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2020-05-08 14:32+0200\n" | ||
"PO-Revision-Date: 2020-05-08 14:34+0200\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"X-Generator: Poedit 2.0.6\n" | ||
"Last-Translator: \n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
"Language: es_ES\n" | ||
|
||
#: inc/config.class.php:46 inc/config.class.php:102 inc/entity.class.php:46 | ||
#: inc/ticket.class.php:41 | ||
msgid "Costs" | ||
msgstr "Costes" | ||
|
||
#: inc/config.class.php:89 | ||
msgid "Add task description on cost" | ||
msgstr "Añadir la descripción de la tarea en el coste" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
CUR_PATH="`dirname \"$0\"`" | ||
|
||
cd "$CUR_PATH/.." | ||
|
||
xgettext *.php */*.php -o locales/costs.pot -L PHP --add-comments=TRANS --from-code=UTF-8 --force-po -k --keyword=__:1,2t --keyword=_x:1,2,3t --keyword=__s:1,2t --keyword=_sx:1,2,3t --keyword=_n:1,2,3,4t --keyword=_sn:1,2t --keyword=_nx:1,2,3t --copyright-holder "TICgal" | ||
|
||
cd locales | ||
|
||
sed -i "s/SOME DESCRIPTIVE TITLE/Cost Glpi Plugin/" costs.pot | ||
sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR./TICgal, $(date +%Y)/" costs.pot | ||
sed -i "s/YEAR/$(date +%Y)/" costs.pot | ||
|
||
for a in $(ls *.po); do | ||
msgmerge -U $a costs.pot | ||
msgfmt $a -o "${a%.*}.mo" | ||
done | ||
rm -f *.po~ |
Oops, something went wrong.