2011-07-08 19:06:32 -04:00
|
|
|
<?php
|
2012-10-18 15:22:01 -04:00
|
|
|
|
2011-07-11 18:06:32 -04:00
|
|
|
/**
|
|
|
|
|
* pmTables controller
|
2012-10-18 15:22:01 -04:00
|
|
|
*
|
2011-07-11 18:06:32 -04:00
|
|
|
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
|
|
|
* @inherits Controller
|
|
|
|
|
* @access public
|
|
|
|
|
*/
|
2011-07-08 19:06:32 -04:00
|
|
|
|
|
|
|
|
class pmTables extends Controller
|
|
|
|
|
{
|
2012-10-18 15:22:01 -04:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param boolean debug
|
|
|
|
|
*/
|
|
|
|
|
public $debug = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* getting default list
|
|
|
|
|
*
|
|
|
|
|
* @param string $httpData->PRO_UID (opional)
|
|
|
|
|
*/
|
|
|
|
|
public function index ($httpData)
|
|
|
|
|
{
|
|
|
|
|
global $RBAC;
|
2016-03-03 12:09:38 -04:00
|
|
|
$RBAC->requirePermissions( 'PM_SETUP_ADVANCE', 'PM_SETUP_PM_TABLES' );
|
2012-10-18 15:22:01 -04:00
|
|
|
|
|
|
|
|
$c = new Configurations();
|
|
|
|
|
$configPage = $c->getConfiguration( 'additionalTablesList', 'pageSize', '', $_SESSION['USER_LOGGED'] );
|
|
|
|
|
$Config['pageSize'] = isset( $configPage['pageSize'] ) ? $configPage['pageSize'] : 20;
|
|
|
|
|
|
|
|
|
|
$this->includeExtJS( 'pmTables/list', $this->debug );
|
|
|
|
|
$this->includeExtJS( 'pmTables/export', $this->debug );
|
|
|
|
|
$this->setView( 'pmTables/list' );
|
|
|
|
|
|
|
|
|
|
//assigning js variables
|
2013-07-11 14:27:49 -04:00
|
|
|
$this->setJSVar( 'flagProcessmap', (isset($_REQUEST['flagProcessmap'])) ? $_REQUEST['flagProcessmap'] : 0);
|
2012-10-18 15:22:01 -04:00
|
|
|
$this->setJSVar( 'FORMATS', $c->getFormats() );
|
|
|
|
|
$this->setJSVar( 'CONFIG', $Config );
|
|
|
|
|
$this->setJSVar( 'PRO_UID', isset( $_GET['PRO_UID'] ) ? $_GET['PRO_UID'] : false );
|
|
|
|
|
|
|
|
|
|
$this->setJSVar( '_PLUGIN_SIMPLEREPORTS', $this->_getSimpleReportPluginDef() );
|
|
|
|
|
|
|
|
|
|
if (isset( $_SESSION['_cache_pmtables'] )) {
|
|
|
|
|
unset( $_SESSION['_cache_pmtables'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset( $_SESSION['ADD_TAB_UID'] )) {
|
|
|
|
|
unset( $_SESSION['ADD_TAB_UID'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//render content
|
|
|
|
|
G::RenderPage( 'publish', 'extJs' );
|
2011-07-13 19:39:30 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 15:22:01 -04:00
|
|
|
/**
|
|
|
|
|
* edit pmtable
|
|
|
|
|
*
|
|
|
|
|
* @param string $httpData->id
|
|
|
|
|
*/
|
|
|
|
|
public function edit ($httpData)
|
|
|
|
|
{
|
|
|
|
|
$additionalTables = new AdditionalTables();
|
|
|
|
|
$table = false;
|
|
|
|
|
$addTabUid = isset( $httpData->id ) ? $httpData->id : false;
|
|
|
|
|
$dataNumRows = 0;
|
|
|
|
|
$repTabPluginPermissions = false;
|
|
|
|
|
$columnsTypes = PmTable::getPropelSupportedColumnTypes();
|
|
|
|
|
$jsFile = isset( $httpData->tableType ) && $httpData->tableType == 'report' ? 'editReport' : 'edit';
|
|
|
|
|
$columnsTypesList = array ();
|
|
|
|
|
|
|
|
|
|
foreach ($columnsTypes as $columnTypeName => $columnType) {
|
|
|
|
|
$columnsTypesList[] = array ($columnTypeName,$columnType
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($addTabUid) {
|
|
|
|
|
$tableData = $additionalTables->getAllData( $httpData->id, 0, 2 );
|
|
|
|
|
$dataNumRows = $tableData['count'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($addTabUid !== false) {
|
|
|
|
|
// if it is a edit request
|
|
|
|
|
$tableFields = array ();
|
|
|
|
|
$fieldsList = array ();
|
|
|
|
|
|
|
|
|
|
$table = $additionalTables->load( $addTabUid, true );
|
|
|
|
|
//fix for backware compatibility
|
|
|
|
|
$table['DBS_UID'] = $table['DBS_UID'] == null || $table['DBS_UID'] == '' ? 'workflow' : $table['DBS_UID'];
|
|
|
|
|
$_SESSION['ADD_TAB_UID'] = $addTabUid;
|
|
|
|
|
|
|
|
|
|
//list dynaform fields
|
|
|
|
|
if ($table['ADD_TAB_TYPE'] == 'NORMAL' || $table['ADD_TAB_TYPE'] == 'GRID') {
|
|
|
|
|
$repTabPluginPermissions = $this->_getSimpleReportPluginDef();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-30 11:44:24 -04:00
|
|
|
if (preg_match("/^PMT_(.*)$/", $table['ADD_TAB_NAME'], $match)) {
|
|
|
|
|
$table['ADD_TAB_NAME'] = $match[1];
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-18 15:22:01 -04:00
|
|
|
$this->includeExtJS( 'pmTables/' . $jsFile );
|
|
|
|
|
|
2013-07-11 14:27:49 -04:00
|
|
|
$this->setJSVar( 'flagProcessmap', (isset($_REQUEST['flagProcessmap'])) ? $_REQUEST['flagProcessmap'] : 0);
|
2012-10-18 15:22:01 -04:00
|
|
|
$this->setJSVar( 'ADD_TAB_UID', $addTabUid );
|
|
|
|
|
$this->setJSVar( 'PRO_UID', isset( $_GET['PRO_UID'] ) ? $_GET['PRO_UID'] : false );
|
|
|
|
|
$this->setJSVar( 'TABLE', $table );
|
|
|
|
|
$this->setJSVar( 'dbg', isset( $httpData->dbg ) );
|
|
|
|
|
$this->setJSVar( 'columnsTypes', $columnsTypesList );
|
|
|
|
|
$this->setJSVar( 'dataNumRows', $dataNumRows );
|
|
|
|
|
$this->setJSVar( '_plugin_permissions', $repTabPluginPermissions );
|
2013-03-18 17:36:10 -04:00
|
|
|
$this->setJSVar( 'sizeTableName', $this->getSizeTableName());
|
2015-04-15 10:09:39 -04:00
|
|
|
|
2012-10-18 15:22:01 -04:00
|
|
|
G::RenderPage( 'publish', 'extJs' );
|
2011-07-13 19:39:30 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 15:22:01 -04:00
|
|
|
/**
|
|
|
|
|
* show pmTable data list
|
|
|
|
|
*
|
|
|
|
|
* @param string $httpData->id
|
|
|
|
|
*/
|
|
|
|
|
public function data ($httpData)
|
|
|
|
|
{
|
|
|
|
|
require_once 'classes/model/AdditionalTables.php';
|
|
|
|
|
$additionalTables = new AdditionalTables();
|
|
|
|
|
$tableDef = $additionalTables->load( $httpData->id, true );
|
|
|
|
|
|
|
|
|
|
$this->includeExtJS( 'pmTables/data', $this->debug );
|
|
|
|
|
$this->setJSVar( 'tableDef', $tableDef );
|
|
|
|
|
|
|
|
|
|
//g::pr($tableDef['FIELDS']);
|
|
|
|
|
G::RenderPage( 'publish', 'extJs' );
|
2011-08-29 11:39:22 -04:00
|
|
|
}
|
2012-10-18 15:22:01 -04:00
|
|
|
|
|
|
|
|
public function export ($httpData)
|
|
|
|
|
{
|
|
|
|
|
$this->includeExtJS( 'pmTables/export', $this->debug ); //adding a javascript file .js
|
|
|
|
|
$this->setView( 'pmTables/export' ); //adding a html file .html.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$toSend = Array ();
|
|
|
|
|
$toSend['UID_LIST'] = $httpData->id;
|
|
|
|
|
|
|
|
|
|
$this->setJSVar( 'EXPORT_TABLES', $toSend );
|
|
|
|
|
G::RenderPage( 'publish', 'extJs' );
|
2011-08-29 11:39:22 -04:00
|
|
|
}
|
2011-07-08 19:06:32 -04:00
|
|
|
|
2012-10-18 15:22:01 -04:00
|
|
|
public function streamExported ($httpData)
|
|
|
|
|
{
|
|
|
|
|
$PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP;
|
|
|
|
|
$sFileName = $httpData->f;
|
|
|
|
|
|
|
|
|
|
$realPath = $PUBLIC_ROOT_PATH . $sFileName;
|
|
|
|
|
G::streamFile( $realPath, true );
|
|
|
|
|
unlink( $realPath );
|
2011-07-08 19:06:32 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 15:22:01 -04:00
|
|
|
/**
|
|
|
|
|
* - protected functions (non-callable from controller outside) -
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get simple report plugin definition
|
|
|
|
|
*
|
|
|
|
|
* @param $type
|
|
|
|
|
*/
|
|
|
|
|
protected function _getSimpleReportPluginDef ()
|
|
|
|
|
{
|
|
|
|
|
global $G_TMP_MENU;
|
|
|
|
|
$oMenu = new Menu();
|
|
|
|
|
$oMenu->load( 'setup' );
|
|
|
|
|
$repTabPluginPermissions = false;
|
|
|
|
|
|
|
|
|
|
foreach ($oMenu->Options as $i => $option) {
|
|
|
|
|
if ($oMenu->Types[$i] == 'private' && $oMenu->Id[$i] == 'PLUGIN_REPTAB_PERMISSIONS') {
|
|
|
|
|
$repTabPluginPermissions = array ();
|
|
|
|
|
$repTabPluginPermissions['label'] = $oMenu->Labels[$i];
|
|
|
|
|
$repTabPluginPermissions['fn'] = $oMenu->Options[$i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $repTabPluginPermissions;
|
2011-07-08 19:06:32 -04:00
|
|
|
}
|
2013-03-18 17:36:10 -04:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* Return of size ok the engine on course.
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
public function getSizeTableName()
|
|
|
|
|
{
|
|
|
|
|
switch (DB_ADAPTER) {
|
|
|
|
|
case 'mysql':
|
|
|
|
|
$tableSize = 64;
|
|
|
|
|
break;
|
|
|
|
|
case 'mssql':
|
|
|
|
|
$tableSize = 128;
|
|
|
|
|
break;
|
|
|
|
|
case 'oci8':
|
|
|
|
|
$tableSize = 30;
|
|
|
|
|
default:
|
|
|
|
|
$tableSize = 30;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-05-28 14:20:40 -04:00
|
|
|
$tableSize = $tableSize - 8; // Prefix PMT_
|
2013-03-18 17:36:10 -04:00
|
|
|
return $tableSize;
|
|
|
|
|
}
|
2012-09-07 16:15:56 -04:00
|
|
|
}
|
2011-07-12 12:32:14 -04:00
|
|
|
|