Fix table creation + UI

remotes/angel/1.11.x
jmontoyaa 9 years ago
parent 1837f5baf3
commit d5f46bb6f1
  1. 10
      main/inc/lib/plugin.class.php
  2. 28
      plugin/ticket/database.php
  3. 5
      plugin/ticket/src/categories_add_user.php

@ -611,11 +611,11 @@ class Plugin
$tabNum = $customTabsNum + 1;
//Avoid Tab Name Spaces
// Avoid Tab Name Spaces
$tabNameNoSpaces = preg_replace('/\s+/', '', $tabName);
$subkeytext = "Tabs" . $tabNameNoSpaces;
//Check if it is already added
// Check if it is already added
$checkCondition = array(
'where' =>
array(
@ -624,11 +624,13 @@ class Plugin
)
)
);
$checkDuplicate = Database::select('*', 'settings_current', $checkCondition);
if (!empty($checkDuplicate)) {
return false;
}
//End Check
// End Check
$subkey = 'custom_tab_' . $tabNum;
$attributes = array(
'variable' => 'show_tabs',
@ -645,7 +647,7 @@ class Plugin
);
$resp = Database::insert('settings_current', $attributes);
//Save the id
// Save the id
$settings = $this->get_settings();
$setData = array (
'comment' => $subkey

@ -11,17 +11,6 @@ $objPlugin = TicketPlugin::create();
$table = Database::get_main_table(TABLE_TICKET_CATEGORY);
if (!Database::tableExists($table)) {
$table = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
id int UNSIGNED NOT NULL AUTO_INCREMENT,
ticket_id int UNSIGNED DEFAULT NULL,
user_id int UNSIGNED DEFAULT NULL,
assigned_date datetime DEFAULT NULL,
sys_insert_user_id int UNSIGNED DEFAULT NULL,
PRIMARY KEY PK_ticket_assigned_log (id),
KEY FK_ticket_assigned_log (ticket_id))";
Database::query($sql);
$sql = "CREATE TABLE IF NOT EXISTS $table (
id int UNSIGNED NOT NULL AUTO_INCREMENT,
category_id char(3) NOT NULL,
@ -37,6 +26,17 @@ if (!Database::tableExists($table)) {
PRIMARY KEY (id))";
$result = Database::query($sql);
$tableLog = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG);
$sql = "CREATE TABLE IF NOT EXISTS ".$tableLog." (
id int UNSIGNED NOT NULL AUTO_INCREMENT,
ticket_id int UNSIGNED DEFAULT NULL,
user_id int UNSIGNED DEFAULT NULL,
assigned_date datetime DEFAULT NULL,
sys_insert_user_id int UNSIGNED DEFAULT NULL,
PRIMARY KEY PK_ticket_assigned_log (id),
KEY FK_ticket_assigned_log (ticket_id))";
Database::query($sql);
// Default Categories
$categories = array(
$objPlugin->get_lang('Enrollment') => $objPlugin->get_lang('TicketsAboutEnrollment'),
@ -65,7 +65,8 @@ if (!Database::tableExists($table)) {
'category_id' => $i,
'project_id' => 1,
'description' => $description,
'name' => $category
'name' => $category,
'course_required' => 0
);
}
@ -236,8 +237,9 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
category_id INT NOT NULL,
user_id INT NOT NULL
)";
Database::query($sql);
//Menu main tabs
// Menu main tabs
$rsTab = $objPlugin->addTab('Ticket', 'plugin/ticket/src/myticket.php');
if ($rsTab) {

@ -12,11 +12,14 @@ $plugin = TicketPlugin::create();
api_protect_admin_script(true);
$categoryId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
if (empty($categoryId)) {
$categoryInfo = TicketManager::getCategory($categoryId);
if (empty($categoryInfo)) {
api_not_allowed(true);
}
$form = new FormValidator('edit', 'post', api_get_self().'?id='.$categoryId);
$form->addHeader($categoryInfo['name']);
$users = UserManager::get_user_list([], ['firstname']);
$users = array_column($users, 'complete_name', 'user_id');

Loading…
Cancel
Save