mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-25 23:05:30 +02:00
PEN management
This commit is contained in:
parent
161c1eb643
commit
3a74e25068
@ -36,11 +36,11 @@ CREATE TABLE `tdiscovery_tmp_connections` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
CREATE TABLE `tpen` (
|
CREATE TABLE `tpen` (
|
||||||
`id_np` int(10) unsigned NOT NULL,
|
|
||||||
`pen` int(10) unsigned NOT NULL,
|
`pen` int(10) unsigned NOT NULL,
|
||||||
`manufacturer` TEXT NOT NULL,
|
`manufacturer` TEXT,
|
||||||
`description` TEXT NULL,
|
`description` TEXT,
|
||||||
PRIMARY KEY (`id_np`,`pen`),
|
`id_np` int(10) unsigned,
|
||||||
|
PRIMARY KEY (`pen`),
|
||||||
CONSTRAINT `fk_np_id` FOREIGN KEY (`id_np`)
|
CONSTRAINT `fk_np_id` FOREIGN KEY (`id_np`)
|
||||||
REFERENCES `tnetwork_profile` (`id_np`) ON DELETE CASCADE ON UPDATE CASCADE
|
REFERENCES `tnetwork_profile` (`id_np`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
@ -1480,11 +1480,11 @@ ALTER TABLE `tnetwork_component` MODIFY COLUMN `ff_type` tinyint(1) unsigned NUL
|
|||||||
-- Table `tpen`
|
-- Table `tpen`
|
||||||
-- ----------------------------------------------------------------------
|
-- ----------------------------------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS `tpen` (
|
CREATE TABLE IF NOT EXISTS `tpen` (
|
||||||
`id_np` int(10) unsigned NOT NULL,
|
|
||||||
`pen` int(10) unsigned NOT NULL,
|
`pen` int(10) unsigned NOT NULL,
|
||||||
`manufacturer` TEXT NOT NULL,
|
`manufacturer` TEXT,
|
||||||
`description` TEXT NULL,
|
`description` TEXT,
|
||||||
PRIMARY KEY (`id_np`,`pen`),
|
`id_np` int(10) unsigned,
|
||||||
|
PRIMARY KEY (`pen`),
|
||||||
CONSTRAINT `fk_np_id` FOREIGN KEY (`id_np`)
|
CONSTRAINT `fk_np_id` FOREIGN KEY (`id_np`)
|
||||||
REFERENCES `tnetwork_profile` (`id_np`) ON DELETE CASCADE ON UPDATE CASCADE
|
REFERENCES `tnetwork_profile` (`id_np`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
@ -1,127 +1,68 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Private Enterprise Number managemtn.
|
||||||
|
*
|
||||||
|
* @category PEN management.
|
||||||
|
* @package Pandora FMS
|
||||||
|
* @subpackage Opensource
|
||||||
|
* @version 1.0.0
|
||||||
|
* @license See below
|
||||||
|
*
|
||||||
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||||
|
* Please see http://pandorafms.org for full contribution list
|
||||||
|
* 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 for version 2.
|
||||||
|
* 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.
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
// Pandora FMS - http://pandorafms.com
|
// Begin.
|
||||||
// ==================================================
|
|
||||||
// Copyright (c) 2005-2020 Artica Soluciones Tecnologicas
|
|
||||||
// Please see http://pandorafms.org for full contribution list
|
|
||||||
// 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 for version 2.
|
|
||||||
// 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.
|
|
||||||
// Load global vars
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
check_login();
|
|
||||||
|
|
||||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
|
||||||
db_pandora_audit(
|
|
||||||
'ACL Violation',
|
|
||||||
'Trying to access Wizard Setup'
|
|
||||||
);
|
|
||||||
include 'general/noaccess.php';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once $config['homedir'].'/include/class/ConfigPEN.class.php';
|
require_once $config['homedir'].'/include/class/ConfigPEN.class.php';
|
||||||
|
|
||||||
|
// This page.
|
||||||
|
$ajaxPage = 'godmode/modules/private_enterprise_numbers';
|
||||||
|
|
||||||
|
// Control call flow.
|
||||||
try {
|
try {
|
||||||
$configPEN = new ConfigPEN();
|
// User access and validation is being processed on class constructor.
|
||||||
// Run the page.
|
$obj = new ConfigPEN($ajaxPage);
|
||||||
$configPEN->run();
|
} catch (Exception $e) {
|
||||||
} catch (Exception $ex) {
|
if (is_ajax()) {
|
||||||
ui_print_error_message(__('Something went wrong. Please, take a look in the Pandora FMS log'));
|
echo json_encode(['error' => '[ConfigPEN]'.$e->getMessage() ]);
|
||||||
echo '[PEN Configuration]'.$ex->getMessage();
|
exit;
|
||||||
|
} else {
|
||||||
|
echo '[ConfigPEN]'.$e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop this execution, but continue 'globally'.
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
<script>
|
|
||||||
|
|
||||||
function SendPENsAjax(action, id, number, manufacturer, description){
|
// AJAX controller.
|
||||||
$.ajax({
|
if (is_ajax()) {
|
||||||
async: true,
|
$method = get_parameter('method');
|
||||||
type: "POST",
|
|
||||||
url: $("#hidden-ajax_file").val(),
|
|
||||||
data: {
|
|
||||||
page: "include/ajax/wizardSetup.ajax",
|
|
||||||
action: action,
|
|
||||||
pen_id: id,
|
|
||||||
pen_number: number,
|
|
||||||
pen_manufacturer: manufacturer,
|
|
||||||
pen_description: description,
|
|
||||||
},
|
|
||||||
success: function(d) {
|
|
||||||
$('#main_table_area').html(d);
|
|
||||||
},
|
|
||||||
error: function(d) {
|
|
||||||
alert('Failed trying update database -> '+String(data)); // True, must change the message
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
if (method_exists($obj, $method) === true) {
|
||||||
|
$obj->{$method}();
|
||||||
|
} else {
|
||||||
|
$obj->error('Method not found. ['.$method.']');
|
||||||
}
|
}
|
||||||
|
|
||||||
function addNewPEN(){
|
// Stop any execution.
|
||||||
var action = 'add';
|
exit;
|
||||||
var pen_id = '2'; // Temporary solution
|
} else {
|
||||||
var success = true;
|
// Run.
|
||||||
var pen_number = $('#text-pen_number');
|
$obj->run();
|
||||||
var pen_number_val = pen_number.val();
|
}
|
||||||
var pen_manufacturer = $('#text-pen_manufacturer');
|
|
||||||
var pen_manufacturer_val = pen_manufacturer.val();
|
|
||||||
var pen_description = $('#text-pen_description');
|
|
||||||
var pen_description_val = pen_description.val();
|
|
||||||
// Test if the data is correct.
|
|
||||||
if (pen_number_val == '' || isNaN(pen_number_val)) {
|
|
||||||
success = false;
|
|
||||||
pen_number.css('border','1px solid red');
|
|
||||||
}
|
|
||||||
if (pen_manufacturer_val == '') {
|
|
||||||
success = false;
|
|
||||||
pen_manufacturer.css('border','1px solid red');
|
|
||||||
}
|
|
||||||
if (pen_description_val == '') {
|
|
||||||
pen_description.css('border','1px solid red');
|
|
||||||
}
|
|
||||||
// Number and Manuacturer are enought for save data.
|
|
||||||
if (success) {
|
|
||||||
SendPENsAjax(action, pen_id, pen_number_val, pen_manufacturer_val, pen_description_val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function modifyPENLine(e){
|
|
||||||
var action = 'update';
|
|
||||||
var pen_id = e.target.value;
|
|
||||||
var changed = false;
|
|
||||||
// Enable the label for be editable.
|
|
||||||
$("span[id$='_"+pen_id+"']").each(function(){
|
|
||||||
let thisElement = $(this);
|
|
||||||
if (thisElement.attr('contenteditable') === 'false') {
|
|
||||||
thisElement.attr('contenteditable', 'true');
|
|
||||||
thisElement.css('border', '1px solid #e2e2e2').css('background-color','ghostwhite');
|
|
||||||
$('#'+e.target.id).attr('src','images/file.png');
|
|
||||||
} else {
|
|
||||||
thisElement.attr('contenteditable', 'false');
|
|
||||||
thisElement.css('border', '0').css('background-color','transparent');
|
|
||||||
changed = true;
|
|
||||||
$('#'+e.target.id).attr('src','images/edit.png')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// If select the red pill.
|
|
||||||
if (changed === true) {
|
|
||||||
let pen_number = $('#pen_number_'+pen_id).html();
|
|
||||||
let pen_manufacturer = $('#pen_manufacturer_'+pen_id).html();
|
|
||||||
let pen_description = $('#pen_description_'+pen_id).html();
|
|
||||||
// Modify the data. // Temporary solution
|
|
||||||
SendPENsAjax(action, '2', pen_number, pen_manufacturer, pen_description);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function deletePEN(e){
|
|
||||||
var action = 'delete';
|
|
||||||
var pen_id = e.target.value;
|
|
||||||
//Is not necessary pass more data.
|
|
||||||
SendPENsAjax(action, '2', pen_id, '', '');
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
@ -35,6 +35,13 @@ require_once $config['homedir'].'/include/class/HTML.class.php';
|
|||||||
class ConfigPEN extends HTML
|
class ConfigPEN extends HTML
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Url of controller.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $ajaxController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL Base
|
* URL Base
|
||||||
*
|
*
|
||||||
@ -44,9 +51,11 @@ class ConfigPEN extends HTML
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Contructor.
|
||||||
|
*
|
||||||
|
* @param string $ajax_page Target ajax page.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct($ajax_page)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -63,8 +72,228 @@ class ConfigPEN extends HTML
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->ajaxController = $ajax_page;
|
||||||
$this->offset = '';
|
$this->offset = '';
|
||||||
$this->baseUrl = 'index.php?sec=configuration_wizard_setup&sec2=godmode/modules/private_enterprise_numbers';
|
$this->baseUrl = ui_get_full_url(
|
||||||
|
'index.php?sec=configuration_wizard_setup&sec2=godmode/modules/private_enterprise_numbers'
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array with all the credentials matching filter and ACL.
|
||||||
|
*
|
||||||
|
* @param array $fields Fields array or 'count' keyword to retrieve count.
|
||||||
|
* @param array $filter Filters to be applied.
|
||||||
|
* @param integer $offset Offset (pagination).
|
||||||
|
* @param integer $limit Limit (pagination).
|
||||||
|
* @param string $order Sort order.
|
||||||
|
* @param string $sort_field Sort field.
|
||||||
|
*
|
||||||
|
* @return array With all results or false if error.
|
||||||
|
* @throws Exception On error.
|
||||||
|
*/
|
||||||
|
public static function getAll(
|
||||||
|
$fields,
|
||||||
|
$filter=null,
|
||||||
|
$offset=null,
|
||||||
|
$limit=null,
|
||||||
|
$order=null,
|
||||||
|
$sort_field=null
|
||||||
|
) {
|
||||||
|
$sql_filters = [];
|
||||||
|
$order_by = '';
|
||||||
|
$pagination = '';
|
||||||
|
|
||||||
|
$count = false;
|
||||||
|
if (!is_array($fields) && $fields == 'count') {
|
||||||
|
$fields = ['*'];
|
||||||
|
$count = true;
|
||||||
|
} else if (!is_array($fields)) {
|
||||||
|
error_log('[configPEN.getAll] Fields must be an array or "count".');
|
||||||
|
throw new Exception('[configPEN.getAll] Fields must be an array or "count".');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($filter)) {
|
||||||
|
if (!empty($filter['free_search'])) {
|
||||||
|
$sql_filters[] = vsprintf(
|
||||||
|
' AND (lower(`manufacturer`) like lower("%%%s%%")
|
||||||
|
OR pen = "%s") ',
|
||||||
|
array_fill(0, 2, $filter['free_search'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($filter['pen'])) {
|
||||||
|
$sql_filters[] = sprintf(
|
||||||
|
' AND `pen` = %d',
|
||||||
|
$filter['pen']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($order)) {
|
||||||
|
$dir = 'asc';
|
||||||
|
if ($order == 'desc') {
|
||||||
|
$dir = 'desc';
|
||||||
|
};
|
||||||
|
|
||||||
|
if (in_array(
|
||||||
|
$sort_field,
|
||||||
|
[
|
||||||
|
'pen',
|
||||||
|
'manufacturer',
|
||||||
|
'description',
|
||||||
|
]
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
$order_by = sprintf(
|
||||||
|
'ORDER BY `%s` %s',
|
||||||
|
$sort_field,
|
||||||
|
$dir
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($limit) && $limit > 0
|
||||||
|
&& isset($offset) && $offset >= 0
|
||||||
|
) {
|
||||||
|
$pagination = sprintf(
|
||||||
|
' LIMIT %d OFFSET %d ',
|
||||||
|
$limit,
|
||||||
|
$offset
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = sprintf(
|
||||||
|
'SELECT %s
|
||||||
|
FROM `tpen`
|
||||||
|
WHERE 1=1
|
||||||
|
%s
|
||||||
|
%s
|
||||||
|
%s',
|
||||||
|
join(',', $fields),
|
||||||
|
join(' ', $sql_filters),
|
||||||
|
$order_by,
|
||||||
|
$pagination
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($count) {
|
||||||
|
$sql = sprintf('SELECT count(*) as n FROM ( %s ) tt', $sql);
|
||||||
|
|
||||||
|
return db_get_value_sql($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
return db_get_all_rows_sql($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AJAX: Return JSON content for datatable.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function draw()
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
// Datatables offset, limit and order.
|
||||||
|
$filter = get_parameter('filter', []);
|
||||||
|
$start = get_parameter('start', 0);
|
||||||
|
$length = get_parameter('length', $config['block_size']);
|
||||||
|
$order = get_datatable_order(true);
|
||||||
|
try {
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
$fields = ['*'];
|
||||||
|
|
||||||
|
// Retrieve data.
|
||||||
|
$data = $this->getAll(
|
||||||
|
// Fields.
|
||||||
|
$fields,
|
||||||
|
// Filter.
|
||||||
|
$filter,
|
||||||
|
// Offset.
|
||||||
|
$start,
|
||||||
|
// Limit.
|
||||||
|
$length,
|
||||||
|
// Order.
|
||||||
|
$order['direction'],
|
||||||
|
// Sort field.
|
||||||
|
$order['field']
|
||||||
|
);
|
||||||
|
|
||||||
|
// Retrieve counter.
|
||||||
|
$count = $this->getAll(
|
||||||
|
'count',
|
||||||
|
$filter
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($data) {
|
||||||
|
$data = array_reduce(
|
||||||
|
$data,
|
||||||
|
function ($carry, $item) {
|
||||||
|
// Transforms array of arrays $data into an array
|
||||||
|
// of objects, making a post-process of certain fields.
|
||||||
|
$tmp = (object) $item;
|
||||||
|
|
||||||
|
$tmp->description = io_safe_output($tmp->description);
|
||||||
|
$tmp->manufacturer = io_safe_output($tmp->manufacturer);
|
||||||
|
|
||||||
|
$tmp->options = '';
|
||||||
|
|
||||||
|
$tmp->options = '<a href="javascript:" onclick="showForm(\'';
|
||||||
|
$tmp->options .= $tmp->pen;
|
||||||
|
$tmp->options .= '\')" >';
|
||||||
|
$tmp->options .= html_print_image(
|
||||||
|
'images/eye.png',
|
||||||
|
true,
|
||||||
|
['title' => __('Show')]
|
||||||
|
);
|
||||||
|
$tmp->options .= '</a>';
|
||||||
|
$tmp->options .= '<a href="javascript:" onclick="deletePEN(\'';
|
||||||
|
$tmp->options .= $tmp->pen;
|
||||||
|
$tmp->options .= '\')" >';
|
||||||
|
$tmp->options .= html_print_image(
|
||||||
|
'images/cross.png',
|
||||||
|
true,
|
||||||
|
['title' => __('Delete')]
|
||||||
|
);
|
||||||
|
$tmp->options .= '</a>';
|
||||||
|
|
||||||
|
$carry[] = $tmp;
|
||||||
|
return $carry;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Datatables format: RecordsTotal && recordsfiltered.
|
||||||
|
echo json_encode(
|
||||||
|
[
|
||||||
|
'data' => $data,
|
||||||
|
'recordsTotal' => $count,
|
||||||
|
'recordsFiltered' => $count,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
// Capture output.
|
||||||
|
$response = ob_get_clean();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['error' => $e->getMessage()]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not valid, show error with issue.
|
||||||
|
json_decode($response);
|
||||||
|
if (json_last_error() == JSON_ERROR_NONE) {
|
||||||
|
// If valid dump.
|
||||||
|
echo $response;
|
||||||
|
} else {
|
||||||
|
echo json_encode(
|
||||||
|
['error' => $response]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +308,7 @@ class ConfigPEN extends HTML
|
|||||||
// Require specific CSS and JS.
|
// Require specific CSS and JS.
|
||||||
ui_require_css_file('wizard');
|
ui_require_css_file('wizard');
|
||||||
ui_require_css_file('discovery');
|
ui_require_css_file('discovery');
|
||||||
|
ui_require_css_file('pen');
|
||||||
|
|
||||||
// Header section.
|
// Header section.
|
||||||
// Breadcrums.
|
// Breadcrums.
|
||||||
@ -120,6 +350,12 @@ class ConfigPEN extends HTML
|
|||||||
ui_get_full_url('ajax.php', false, false, false)
|
ui_get_full_url('ajax.php', false, false, false)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Ajax page (hidden).
|
||||||
|
html_print_input_hidden(
|
||||||
|
'ajax_page',
|
||||||
|
$this->ajaxController
|
||||||
|
);
|
||||||
|
|
||||||
// Allow message area.
|
// Allow message area.
|
||||||
html_print_div(['id' => 'message_show_area']);
|
html_print_div(['id' => 'message_show_area']);
|
||||||
// Prints the main table.
|
// Prints the main table.
|
||||||
@ -132,6 +368,175 @@ class ConfigPEN extends HTML
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load modal information for PEN management.
|
||||||
|
*
|
||||||
|
* Ajax. Direct HTML.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function loadModal()
|
||||||
|
{
|
||||||
|
$values = [];
|
||||||
|
$id = (int) get_parameter('pen', 0);
|
||||||
|
if ($id > 0) {
|
||||||
|
$values = $this->getAll(
|
||||||
|
// Fields.
|
||||||
|
['*'],
|
||||||
|
// Filter.
|
||||||
|
['pen' => $id]
|
||||||
|
);
|
||||||
|
if (is_array($values)) {
|
||||||
|
$values = $values[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = [
|
||||||
|
'action' => '#',
|
||||||
|
'id' => 'modal_form',
|
||||||
|
'onsubmit' => 'return false;',
|
||||||
|
'class' => '',
|
||||||
|
];
|
||||||
|
|
||||||
|
$inputs = [];
|
||||||
|
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('PEN'),
|
||||||
|
'class' => 'flex-row',
|
||||||
|
'id' => 'div-pen',
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'pen',
|
||||||
|
'type' => 'number',
|
||||||
|
'value' => $values['pen'],
|
||||||
|
'required' => true,
|
||||||
|
'return' => true,
|
||||||
|
'size' => 50,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Manufacturer'),
|
||||||
|
'class' => 'flex-row',
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'manufacturer',
|
||||||
|
'id' => 'manufacturer',
|
||||||
|
'type' => 'text',
|
||||||
|
'required' => true,
|
||||||
|
'value' => io_safe_output($values['manufacturer']),
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Description'),
|
||||||
|
'class' => 'flex-row',
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'description',
|
||||||
|
'id' => 'description',
|
||||||
|
'type' => 'textarea',
|
||||||
|
'value' => io_safe_output($values['description']),
|
||||||
|
'return' => true,
|
||||||
|
'rows' => 50,
|
||||||
|
'columns' => 30,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
echo '<div id="div-form">';
|
||||||
|
echo parent::printForm(
|
||||||
|
[
|
||||||
|
'form' => $form,
|
||||||
|
'inputs' => $inputs,
|
||||||
|
],
|
||||||
|
true
|
||||||
|
);
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a manufacturer register from db.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$pen = get_parameter('pen', 0);
|
||||||
|
|
||||||
|
if (empty($pen)) {
|
||||||
|
echo json_encode(['error' => __('PEN is required')]);
|
||||||
|
} else {
|
||||||
|
if (db_process_sql_delete('tpen', ['pen' => $pen]) !== false) {
|
||||||
|
echo json_encode(['result' => __('Successfully deleted')]);
|
||||||
|
} else {
|
||||||
|
global $config;
|
||||||
|
echo json_encode(['error' => $config['dbconnection']->error]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a manufacturer to private enterprise numbers.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$pen = get_parameter('pen', 0);
|
||||||
|
$manufacturer = get_parameter('manufacturer', '');
|
||||||
|
$description = get_parameter('description', '');
|
||||||
|
|
||||||
|
if (empty($pen)) {
|
||||||
|
$error = __('PEN is required.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($manufacturer)) {
|
||||||
|
$error = __('Manufacturer is required');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($error)) {
|
||||||
|
echo json_encode(
|
||||||
|
['error' => $error]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add if not exists.
|
||||||
|
$current = $this->getAll(['pen'], ['pen' => $pen]);
|
||||||
|
|
||||||
|
if ($current === false) {
|
||||||
|
// New.
|
||||||
|
$rs = db_process_sql_insert(
|
||||||
|
'tpen',
|
||||||
|
[
|
||||||
|
'pen' => $pen,
|
||||||
|
'manufacturer' => io_safe_input($manufacturer),
|
||||||
|
'description' => io_safe_input($description),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$str = __('created');
|
||||||
|
} else {
|
||||||
|
// Update.
|
||||||
|
$rs = db_process_sql_update(
|
||||||
|
'tpen',
|
||||||
|
[
|
||||||
|
'manufacturer' => io_safe_input($manufacturer),
|
||||||
|
'description' => io_safe_input($description),
|
||||||
|
],
|
||||||
|
['pen' => $pen]
|
||||||
|
);
|
||||||
|
$str = __('updated');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rs === false) {
|
||||||
|
global $config;
|
||||||
|
echo json_encode(['error' => $config['dbconnection']->error]);
|
||||||
|
} else {
|
||||||
|
echo json_encode(['result' => __('Succesfully %s', $str)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the main table with the PENs info
|
* Create the main table with the PENs info
|
||||||
*
|
*
|
||||||
@ -140,110 +545,217 @@ class ConfigPEN extends HTML
|
|||||||
public function createMainTable()
|
public function createMainTable()
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
// Get the count of PENs.
|
|
||||||
$countPENs = db_get_value(
|
|
||||||
'count(*)',
|
|
||||||
'tpen'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get all the data.
|
$output = '';
|
||||||
$resultPENs = db_get_all_rows_filter(
|
|
||||||
'tpen',
|
|
||||||
[
|
|
||||||
'order' => 'id_np',
|
|
||||||
'limit' => $config['block_size'],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$output = ui_pagination($countPENs, false, $this->offset, 0, true);
|
// Datatables list.
|
||||||
// Create the table with Module Block list.
|
try {
|
||||||
$table = new StdClasS();
|
$columns = [
|
||||||
$table->class = 'databox data';
|
'pen',
|
||||||
$table->width = '75%';
|
'manufacturer',
|
||||||
$table->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;background: white;';
|
'description',
|
||||||
$table->rowid = [];
|
'options',
|
||||||
$table->data = [];
|
];
|
||||||
|
|
||||||
$table->cellpadding = 0;
|
$column_names = [
|
||||||
$table->cellspacing = 0;
|
__('PEN'),
|
||||||
$table->width = '100%';
|
__('Manufacturer'),
|
||||||
$table->class = 'info_table';
|
__('Description'),
|
||||||
|
|
||||||
$table->head = [];
|
|
||||||
$table->head[0] = html_print_checkbox('all_delete', 0, false, true, false);
|
|
||||||
$table->head[1] = __('PEN');
|
|
||||||
$table->head[2] = __('Manufacturer ID');
|
|
||||||
$table->head[3] = __('Description');
|
|
||||||
$table->head[4] = '<span style="margin-right:7%;">'.__('Action').'</span>';
|
|
||||||
|
|
||||||
$table->size = [];
|
|
||||||
$table->size[0] = '20px';
|
|
||||||
$table->size[1] = '10%';
|
|
||||||
$table->size[2] = '25%';
|
|
||||||
$table->size[4] = '70px';
|
|
||||||
|
|
||||||
$table->align = [];
|
|
||||||
$table->align[3] = 'left';
|
|
||||||
|
|
||||||
$table->data = [];
|
|
||||||
|
|
||||||
foreach ($resultPENs as $row) {
|
|
||||||
$data = [];
|
|
||||||
$data[0] = html_print_checkbox_extended('delete_multiple[]', $row['pen'], false, false, '', 'class="check_delete"', true);
|
|
||||||
$data[1] = '<span id="pen_number_'.$row['pen'].'" style="padding: 5px;" contenteditable="false">'.$row['pen'].'</span>';
|
|
||||||
$data[2] = '<span id="pen_manufacturer_'.$row['pen'].'" style="padding: 5px;" contenteditable="false">'.$row['manufacturer'].'</span>';
|
|
||||||
$data[3] = '<span id="pen_description_'.$row['pen'].'" style="padding: 5px;" contenteditable="false">'.ui_print_truncate_text(io_safe_output($row['description']), 'description', true, true, true, '[…]').'</span>';
|
|
||||||
$table->cellclass[][4] = 'action_buttons';
|
|
||||||
$data[4] = html_print_input_image(
|
|
||||||
'edit_pen_',
|
|
||||||
'images/edit.png',
|
|
||||||
$row['pen'],
|
|
||||||
'max-width: 27px;',
|
|
||||||
true,
|
|
||||||
[
|
[
|
||||||
'title' => 'Edit',
|
'text' => __('Options'),
|
||||||
'onclick' => 'modifyPENLine(event)',
|
'class' => 'action_buttons',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->tableId = 'keystore';
|
||||||
|
// Load datatables user interface.
|
||||||
|
$output .= ui_print_datatable(
|
||||||
|
[
|
||||||
|
'id' => $this->tableId,
|
||||||
|
'return' => true,
|
||||||
|
'class' => 'info_table',
|
||||||
|
'style' => 'width: 100%',
|
||||||
|
'columns' => $columns,
|
||||||
|
'column_names' => $column_names,
|
||||||
|
'ajax_url' => $this->ajaxController,
|
||||||
|
'ajax_data' => ['method' => 'draw'],
|
||||||
|
'no_sortable_columns' => [-1],
|
||||||
|
'order' => [
|
||||||
|
'field' => 'pen',
|
||||||
|
'direction' => 'asc',
|
||||||
|
],
|
||||||
|
'search_button_class' => 'sub filter float-right',
|
||||||
|
'form' => [
|
||||||
|
'inputs' => [
|
||||||
|
[
|
||||||
|
'label' => __('Free search'),
|
||||||
|
'type' => 'text',
|
||||||
|
'class' => 'mw250px',
|
||||||
|
'id' => 'free_search',
|
||||||
|
'name' => 'free_search',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$data[4] .= html_print_input_image(
|
} catch (Exception $e) {
|
||||||
'delete_pen_',
|
echo $e->getMessage();
|
||||||
'images/cross.png',
|
|
||||||
$row['pen'],
|
|
||||||
'',
|
|
||||||
true,
|
|
||||||
[
|
|
||||||
'title' => 'Delete PEN',
|
|
||||||
'onclick' => 'if (confirm(\''.sprintf(__('Are you sure to remove the PEN: %s?'), $row['pen']).'\')) deletePEN(event);',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
array_push($table->data, $data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last line for adding new PENs.
|
// Auxiliar div.
|
||||||
$data = [];
|
$output .= '<div id="modal" style="display: none"></div>';
|
||||||
$data[0] = '';
|
$output .= '<div id="msg" style="display: none"></div>';
|
||||||
$data[1] = html_print_input_text('pen_number', '', '', 10, 255, true);
|
$output .= '<div id="aux" style="display: none"></div>';
|
||||||
$data[2] = html_print_input_text('pen_manufacturer', '', '', 30, 255, true);
|
|
||||||
$data[3] = html_print_input_text('pen_description', '', '', 80, 255, true);
|
// Create button.
|
||||||
$table->cellclass[][4] = 'action_buttons';
|
$output .= parent::printInput(
|
||||||
$data[4] = html_print_input_image(
|
|
||||||
'add_new_pen',
|
|
||||||
'images/add_mc.png',
|
|
||||||
'',
|
|
||||||
'margin: 0 auto; display: block;',
|
|
||||||
true,
|
|
||||||
[
|
[
|
||||||
'title' => 'Add new PEN',
|
'type' => 'submit',
|
||||||
'onclick' => 'addNewPEN()',
|
'name' => 'create',
|
||||||
|
'label' => __('Register manufacturer'),
|
||||||
|
'attributes' => 'class="sub next"',
|
||||||
|
'return' => true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add last line.
|
ob_start();
|
||||||
array_push($table->data, $data);
|
?>
|
||||||
// Return the entire table.
|
<script type="text/javascript">
|
||||||
$output .= html_print_table($table, true);
|
function cleanupDOM() {
|
||||||
// $output = 'mis huevos morenos';
|
$("#div-form").empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
function deletePEN(id) {
|
||||||
|
confirmDialog({
|
||||||
|
title: "<?php echo __('Are you sure?'); ?>",
|
||||||
|
message: "<?php echo __('Are you sure you want to delete this PEN?'); ?>",
|
||||||
|
ok: "<?php echo __('OK'); ?>",
|
||||||
|
cancel: "<?php echo __('Cancel'); ?>",
|
||||||
|
onAccept: function() {
|
||||||
|
$.ajax({
|
||||||
|
method: "post",
|
||||||
|
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
|
data: {
|
||||||
|
page: "<?php echo $this->ajaxController; ?>",
|
||||||
|
method: "delete",
|
||||||
|
pen: id
|
||||||
|
},
|
||||||
|
datatype: "json",
|
||||||
|
success: function(data) {
|
||||||
|
showMsg(data);
|
||||||
|
},
|
||||||
|
error: function(e) {
|
||||||
|
showMsg(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showForm(id) {
|
||||||
|
var btn_ok_text = "<?php echo __('OK'); ?>";
|
||||||
|
var btn_cancel_text = "<?php echo __('Cancel'); ?>";
|
||||||
|
var title = "<?php echo __('Register new manufacturer'); ?>";
|
||||||
|
if (id) {
|
||||||
|
btn_ok_text = "<?php echo __('Update'); ?>";
|
||||||
|
title = "<?php echo __('Update'); ?> " + id;
|
||||||
|
}
|
||||||
|
load_modal({
|
||||||
|
target: $("#modal"),
|
||||||
|
form: "modal_form",
|
||||||
|
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
|
ajax_callback: showMsg,
|
||||||
|
cleanup: cleanupDOM,
|
||||||
|
modal: {
|
||||||
|
title: title,
|
||||||
|
ok: btn_ok_text,
|
||||||
|
cancel: btn_cancel_text
|
||||||
|
},
|
||||||
|
extradata: [
|
||||||
|
{
|
||||||
|
name: "pen",
|
||||||
|
value: id
|
||||||
|
}
|
||||||
|
],
|
||||||
|
onshow: {
|
||||||
|
page: "<?php echo $this->ajaxController; ?>",
|
||||||
|
method: "loadModal"
|
||||||
|
},
|
||||||
|
onsubmit: {
|
||||||
|
page: "<?php echo $this->ajaxController; ?>",
|
||||||
|
method: "add"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process ajax responses and shows a dialog with results.
|
||||||
|
*/
|
||||||
|
function showMsg(data) {
|
||||||
|
var title = "<?php echo __('Success'); ?>";
|
||||||
|
var text = "";
|
||||||
|
var failed = 0;
|
||||||
|
try {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
text = data["result"];
|
||||||
|
} catch (err) {
|
||||||
|
title = "<?php echo __('Failed'); ?>";
|
||||||
|
text = err.message;
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
if (!failed && data["error"] != undefined) {
|
||||||
|
title = "<?php echo __('Failed'); ?>";
|
||||||
|
text = data["error"];
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
if (data["report"] != undefined) {
|
||||||
|
data["report"].forEach(function(item) {
|
||||||
|
text += "<br>" + item;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$("#msg").empty();
|
||||||
|
$("#msg").html(text);
|
||||||
|
$("#msg").dialog({
|
||||||
|
width: 450,
|
||||||
|
position: {
|
||||||
|
my: "center",
|
||||||
|
at: "center",
|
||||||
|
of: window,
|
||||||
|
collision: "fit"
|
||||||
|
},
|
||||||
|
title: title,
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
class:
|
||||||
|
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||||
|
text: "OK",
|
||||||
|
click: function(e) {
|
||||||
|
if (!failed) {
|
||||||
|
$(".ui-dialog-content").dialog("close");
|
||||||
|
$(".info").hide();
|
||||||
|
cleanupDOM();
|
||||||
|
dt_keystore.draw(false);
|
||||||
|
} else {
|
||||||
|
$(this).dialog("close");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("#submit-create").click(function() {
|
||||||
|
showForm();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
$output .= ob_get_clean();
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,6 +443,8 @@ class CredentialStore extends Wizard
|
|||||||
*/
|
*/
|
||||||
public function draw()
|
public function draw()
|
||||||
{
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
// Datatables offset, limit and order.
|
// Datatables offset, limit and order.
|
||||||
$filter = get_parameter('filter', []);
|
$filter = get_parameter('filter', []);
|
||||||
$start = get_parameter('start', 0);
|
$start = get_parameter('start', 0);
|
||||||
|
@ -3498,24 +3498,6 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'text':
|
|
||||||
$output .= html_print_input_text(
|
|
||||||
$data['name'],
|
|
||||||
$data['value'],
|
|
||||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
|
||||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
|
||||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
|
||||||
((isset($data['return']) === true) ? $data['return'] : false),
|
|
||||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
|
||||||
((isset($data['required']) === true) ? $data['required'] : false),
|
|
||||||
((isset($data['function']) === true) ? $data['function'] : ''),
|
|
||||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
|
||||||
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
|
||||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : ''),
|
|
||||||
((isset($data['autofocus']) === true) ? $data['autofocus'] : false)
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'email':
|
case 'email':
|
||||||
$output .= html_print_input_email($data);
|
$output .= html_print_input_email($data);
|
||||||
break;
|
break;
|
||||||
|
@ -3504,10 +3504,13 @@ function ui_print_datatable(array $parameters)
|
|||||||
ui_require_javascript_file('buttons.html5.min');
|
ui_require_javascript_file('buttons.html5.min');
|
||||||
ui_require_javascript_file('buttons.print.min');
|
ui_require_javascript_file('buttons.print.min');
|
||||||
|
|
||||||
$output = $include.$output;
|
if (isset($parameters['return']) && $parameters['return'] == true) {
|
||||||
|
// Compat.
|
||||||
|
$parameters['print'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Print datatable if needed.
|
// Print datatable if needed.
|
||||||
if (isset($parameters['print']) === false || $parameters['print'] === false) {
|
if (isset($parameters['print']) === false || $parameters['print'] === true) {
|
||||||
echo $output;
|
echo $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,6 +319,21 @@ function load_modal(settings) {
|
|||||||
contentType: false,
|
contentType: false,
|
||||||
data: data,
|
data: data,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
|
if (settings.onshow.parser) {
|
||||||
|
data = settings.onshow.parser(data);
|
||||||
|
} else {
|
||||||
|
data = (function(d) {
|
||||||
|
try {
|
||||||
|
d = JSON.parse(d);
|
||||||
|
} catch (e) {
|
||||||
|
// Not JSON
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
if (d.error) return d.error;
|
||||||
|
|
||||||
|
if (d.result) return d.result;
|
||||||
|
})(data);
|
||||||
|
}
|
||||||
settings.target.html(data);
|
settings.target.html(data);
|
||||||
if (settings.onload != undefined) {
|
if (settings.onload != undefined) {
|
||||||
settings.onload(data);
|
settings.onload(data);
|
||||||
|
38
pandora_console/include/styles/pen.css
Normal file
38
pandora_console/include/styles/pen.css
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
ul.wizard li > label:not(.p-switch) {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
form.top-action-buttons ul.wizard {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.wizard li {
|
||||||
|
margin-right: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
form.modal ul.wizard li {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
width: 90%;
|
||||||
|
margin: 0 auto;
|
||||||
|
justify-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
form.modal ul.wizard li * {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.wizard li.flex-indep {
|
||||||
|
flex: 1;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#div-form {
|
||||||
|
padding: 0 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#div-form textarea {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
@ -944,16 +944,6 @@ CREATE TABLE IF NOT EXISTS `tnetwork_profile` (
|
|||||||
PRIMARY KEY (`id_np`)
|
PRIMARY KEY (`id_np`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
-- ----------------------------------------------------------------------
|
|
||||||
-- Table `tpen`
|
|
||||||
-- ----------------------------------------------------------------------
|
|
||||||
CREATE TABLE `tpen` (
|
|
||||||
`id_np` int(10) unsigned NOT NULL,
|
|
||||||
`pen` int(10) unsigned NOT NULL,
|
|
||||||
PRIMARY KEY (`id_np`,`pen`),
|
|
||||||
CONSTRAINT `fk_np_id` FOREIGN KEY (`id_np`) REFERENCES `tnetwork_profile` (`id_np`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
||||||
|
|
||||||
-- ----------------------------------------------------------------------
|
-- ----------------------------------------------------------------------
|
||||||
-- Table `tnetwork_profile_component`
|
-- Table `tnetwork_profile_component`
|
||||||
-- ----------------------------------------------------------------------
|
-- ----------------------------------------------------------------------
|
||||||
@ -967,11 +957,11 @@ CREATE TABLE IF NOT EXISTS `tnetwork_profile_component` (
|
|||||||
-- Table `tpen`
|
-- Table `tpen`
|
||||||
-- ----------------------------------------------------------------------
|
-- ----------------------------------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS `tpen` (
|
CREATE TABLE IF NOT EXISTS `tpen` (
|
||||||
`id_np` int(10) unsigned NOT NULL,
|
|
||||||
`pen` int(10) unsigned NOT NULL,
|
`pen` int(10) unsigned NOT NULL,
|
||||||
`manufacturer` TEXT NOT NULL,
|
`manufacturer` TEXT,
|
||||||
`description` TEXT NULL,
|
`description` TEXT,
|
||||||
PRIMARY KEY (`id_np`,`pen`),
|
`id_np` int(10) unsigned,
|
||||||
|
PRIMARY KEY (`pen`),
|
||||||
CONSTRAINT `fk_np_id` FOREIGN KEY (`id_np`)
|
CONSTRAINT `fk_np_id` FOREIGN KEY (`id_np`)
|
||||||
REFERENCES `tnetwork_profile` (`id_np`) ON DELETE CASCADE ON UPDATE CASCADE
|
REFERENCES `tnetwork_profile` (`id_np`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user