Merge remote-tracking branch 'origin/feature/HOR-3559' into feature/HOR-3629
This commit is contained in:
@@ -233,7 +233,7 @@ class Admin extends Controller
|
||||
$dbNetView = new NET( DB_HOST );
|
||||
$dbNetView->loginDbServer( DB_USER, DB_PASS );
|
||||
|
||||
$dbConns = new dbConnections( '' );
|
||||
$dbConns = new DbConnections( '' );
|
||||
$availdb = '';
|
||||
foreach ($dbConns->getDbServicesAvailables() as $key => $val) {
|
||||
if ($availdb != '') {
|
||||
|
||||
@@ -91,8 +91,6 @@ class AppProxy extends HttpProxyController
|
||||
);
|
||||
}
|
||||
|
||||
//require_once ("classes/model/AppNotes.php");
|
||||
|
||||
$usrUid = isset( $_SESSION['USER_LOGGED'] ) ? $_SESSION['USER_LOGGED'] : "";
|
||||
$appNotes = new AppNotes();
|
||||
$response = $appNotes->getNotesList( $appUid, '', $httpData->start, $httpData->limit );
|
||||
@@ -113,9 +111,6 @@ class AppProxy extends HttpProxyController
|
||||
*/
|
||||
function postNote ($httpData)
|
||||
{
|
||||
//require_once ("classes/model/AppNotes.php");
|
||||
|
||||
//extract(getExtJSParams());
|
||||
if (isset( $httpData->appUid ) && trim( $httpData->appUid ) != "") {
|
||||
$appUid = $httpData->appUid;
|
||||
} else {
|
||||
|
||||
@@ -180,8 +180,6 @@ class Home extends Controller
|
||||
|
||||
public function indexSingle ($httpData)
|
||||
{
|
||||
require_once 'classes/model/Step.php';
|
||||
|
||||
$step = new Step();
|
||||
|
||||
$solrEnabled = false;
|
||||
@@ -377,7 +375,6 @@ class Home extends Controller
|
||||
$sort = "APP_CACHE_VIEW.APP_NUMBER",
|
||||
$category = null)
|
||||
{
|
||||
require_once ("classes/model/AppNotes.php");
|
||||
|
||||
$appNotes = new AppNotes();
|
||||
|
||||
@@ -638,7 +635,6 @@ class Home extends Controller
|
||||
|
||||
function getCategoryArray ()
|
||||
{
|
||||
require_once 'classes/model/ProcessCategory.php';
|
||||
$category = array();
|
||||
$category[] = array ("",G::LoadTranslation( "ID_ALL_CATEGORIES" ));
|
||||
|
||||
|
||||
@@ -698,7 +698,7 @@ class Main extends Controller
|
||||
$dbNetView = new NET( DB_HOST );
|
||||
$dbNetView->loginDbServer( DB_USER, DB_PASS );
|
||||
|
||||
$dbConns = new dbConnections( '' );
|
||||
$dbConns = new DbConnections( '' );
|
||||
$availdb = '';
|
||||
foreach ($dbConns->getDbServicesAvailables() as $key => $val) {
|
||||
if ($availdb != '') {
|
||||
|
||||
@@ -122,7 +122,6 @@ class pmTables extends Controller
|
||||
*/
|
||||
public function data ($httpData)
|
||||
{
|
||||
require_once 'classes/model/AdditionalTables.php';
|
||||
$additionalTables = new AdditionalTables();
|
||||
$tableDef = $additionalTables->load( $httpData->id, true );
|
||||
|
||||
|
||||
@@ -451,30 +451,32 @@ class pmTablesProxy extends HttpProxyController
|
||||
$this->message = $this->success ? G::loadTranslation( 'ID_DELETED_SUCCESSFULLY' ) : G::loadTranslation( 'ID_DELETE_FAILED' );
|
||||
}
|
||||
|
||||
public function importCSV ($httpData)
|
||||
/**
|
||||
* Import pmTable from CSV file
|
||||
* @param $httpData
|
||||
*/
|
||||
public function importCSV($httpData)
|
||||
{
|
||||
$filter = new InputFilter();
|
||||
$countRow = 250;
|
||||
$tmpfilename = $_FILES['form']['tmp_name']['CSV_FILE'];
|
||||
//$tmpfilename = $filter->xssFilterHard($tmpfilename, 'path');
|
||||
if (preg_match( '/[\x00-\x08\x0b-\x0c\x0e\x1f]/', file_get_contents( $tmpfilename ) ) === 0) {
|
||||
if (preg_match('/[\x00-\x08\x0b-\x0c\x0e\x1f]/', file_get_contents($tmpfilename)) === 0) {
|
||||
$filename = $_FILES['form']['name']['CSV_FILE'];
|
||||
//$filename = $filter->xssFilterHard($filename, 'path');
|
||||
if ($oFile = fopen( $filter->xssFilterHard($tmpfilename, 'path'), 'r' )) {
|
||||
if ($oFile = fopen($filter->xssFilterHard($tmpfilename, 'path'), 'r')) {
|
||||
require_once 'classes/model/AdditionalTables.php';
|
||||
$oAdditionalTables = new AdditionalTables();
|
||||
$aAdditionalTables = $oAdditionalTables->load( $_POST['form']['ADD_TAB_UID'], true );
|
||||
$aAdditionalTables = $oAdditionalTables->load($_POST['form']['ADD_TAB_UID'], true);
|
||||
$sErrorMessages = '';
|
||||
$i = 1;
|
||||
$conData = 0;
|
||||
$insert = 'REPLACE INTO ' . $aAdditionalTables['ADD_TAB_NAME'] . ' (';
|
||||
$query = '';
|
||||
$swHead = false;
|
||||
while (($aAux = fgetcsv( $oFile, 4096, $_POST['form']['CSV_DELIMITER'] )) !== false) {
|
||||
if (! is_null( $aAux[0] )) {
|
||||
if (count( $aAdditionalTables['FIELDS'] ) > count( $aAux )) {
|
||||
while (($aAux = fgetcsv($oFile, 4096, $_POST['form']['CSV_DELIMITER'], '"', '"')) !== false) {
|
||||
if (!is_null($aAux[0])) {
|
||||
if (count($aAdditionalTables['FIELDS']) > count($aAux)) {
|
||||
$this->success = false;
|
||||
$this->message = G::LoadTranslation( 'INVALID_FILE' );
|
||||
$this->message = G::LoadTranslation('INVALID_FILE');
|
||||
return 0;
|
||||
}
|
||||
if ($i == 1) {
|
||||
@@ -484,7 +486,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
if ($aField['FLD_NAME'] === $aAux[$j]) {
|
||||
$swHead = true;
|
||||
}
|
||||
$j ++;
|
||||
$j++;
|
||||
}
|
||||
$insert = substr($insert, 0, -2);
|
||||
$insert .= ') VALUES ';
|
||||
@@ -495,13 +497,11 @@ class pmTablesProxy extends HttpProxyController
|
||||
$j = 0;
|
||||
foreach ($aAdditionalTables['FIELDS'] as $aField) {
|
||||
$conData++;
|
||||
|
||||
if (array_key_exists($j, $aAux)) {
|
||||
$temp = '"' . addslashes(stripslashes(G::is_utf8($aAux[$j]) ? $aAux[$j] : utf8_encode($aAux[$j]))) . '"';
|
||||
$temp = '"' . addslashes(G::is_utf8($aAux[$j]) ? $aAux[$j] : utf8_encode($aAux[$j])) . '"';
|
||||
} else {
|
||||
$temp = '""';
|
||||
}
|
||||
|
||||
if ($temp == '') {
|
||||
switch ($aField['FLD_TYPE']) {
|
||||
case 'DATE':
|
||||
@@ -510,7 +510,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
break;
|
||||
}
|
||||
}
|
||||
$j ++;
|
||||
$j++;
|
||||
$queryRow .= $temp . ',';
|
||||
}
|
||||
$query .= substr($queryRow, 0, -1) . '),';
|
||||
@@ -522,15 +522,15 @@ class pmTablesProxy extends HttpProxyController
|
||||
$conData = 0;
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
$sErrorMessages .= G::LoadTranslation( 'ID_ERROR_INSERT_LINE' ) . ': ' . G::LoadTranslation( 'ID_LINE' ) . ' ' . $i . '. ';
|
||||
$sErrorMessages .= G::LoadTranslation('ID_ERROR_INSERT_LINE') . ': ' . G::LoadTranslation('ID_LINE') . ' ' . $i . '. ';
|
||||
}
|
||||
} else {
|
||||
$swHead = false;
|
||||
}
|
||||
$i ++;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
fclose( $oFile );
|
||||
fclose($oFile);
|
||||
if ($conData > 0) {
|
||||
$query = substr($query, 0, -1);
|
||||
executeQuery($insert . $query . ';', $aAdditionalTables['DBS_UID']);
|
||||
@@ -541,12 +541,12 @@ class pmTablesProxy extends HttpProxyController
|
||||
$this->message = $sErrorMessages;
|
||||
} else {
|
||||
$this->success = true;
|
||||
$this->message = G::loadTranslation( 'ID_FILE_IMPORTED_SUCCESSFULLY', array ($filename
|
||||
) );
|
||||
$this->message = G::loadTranslation('ID_FILE_IMPORTED_SUCCESSFULLY', array($filename
|
||||
));
|
||||
G::auditLog("ImportTable", $filename);
|
||||
}
|
||||
} else {
|
||||
$sMessage = G::LoadTranslation( 'ID_UPLOAD_VALID_CSV_FILE' );
|
||||
$sMessage = G::LoadTranslation('ID_UPLOAD_VALID_CSV_FILE');
|
||||
$this->success = false;
|
||||
$this->message = $sMessage;
|
||||
}
|
||||
@@ -637,11 +637,11 @@ class pmTablesProxy extends HttpProxyController
|
||||
}
|
||||
|
||||
/**
|
||||
* export a pm tables record to CSV
|
||||
*
|
||||
* @param string $httpData->id
|
||||
* Export pmTable to CSV format
|
||||
* @param $httpData
|
||||
* @return StdClass
|
||||
*/
|
||||
public function exportCSV ($httpData)
|
||||
public function exportCSV($httpData)
|
||||
{
|
||||
$result = new StdClass();
|
||||
try {
|
||||
@@ -653,50 +653,30 @@ class pmTablesProxy extends HttpProxyController
|
||||
|
||||
require_once 'classes/model/AdditionalTables.php';
|
||||
$oAdditionalTables = new AdditionalTables();
|
||||
$aAdditionalTables = $oAdditionalTables->load( $_POST['ADD_TAB_UID'], true );
|
||||
$aAdditionalTables = $oAdditionalTables->load($_POST['ADD_TAB_UID'], true);
|
||||
$sErrorMessages = '';
|
||||
$sDelimiter = $_POST['CSV_DELIMITER'];
|
||||
|
||||
$resultData = $oAdditionalTables->getAllData( $_POST['ADD_TAB_UID'], null, null, false );
|
||||
$resultData = $oAdditionalTables->getAllData($_POST['ADD_TAB_UID'], null, null, false);
|
||||
$rows = $resultData['rows'];
|
||||
$count = $resultData['count'];
|
||||
|
||||
$PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP;
|
||||
$filenameOnly = strtolower( $aAdditionalTables['ADD_TAB_NAME'] . "_" . date( "Y-m-d" ) . '_' . date( "Hi" ) . ".csv" );
|
||||
$filenameOnly = strtolower($aAdditionalTables['ADD_TAB_NAME'] . "_" . date("Y-m-d") . '_' . date("Hi") . ".csv");
|
||||
$filename = $PUBLIC_ROOT_PATH . $filenameOnly;
|
||||
$fp = fopen( $filename, "wb" );
|
||||
|
||||
$fp = fopen($filename, "wb");
|
||||
$swColumns = true;
|
||||
foreach ($rows as $keyCol => $cols) {
|
||||
$SDATA = "";
|
||||
$header = "";
|
||||
$cnt = $cntC = count( $cols );
|
||||
foreach ($cols as $key => $val) {
|
||||
if($swColumns){
|
||||
$header .= $key;
|
||||
if (-- $cntC > 0) {
|
||||
$header .= $sDelimiter;
|
||||
} else {
|
||||
$header .= "\n";
|
||||
$bytesSaved += fwrite( $fp, $header );
|
||||
$swColumns = false;
|
||||
}
|
||||
}
|
||||
$SDATA .= addslashes($val);
|
||||
if (-- $cnt > 0) {
|
||||
$SDATA .= $sDelimiter;
|
||||
}
|
||||
if ($swColumns) {
|
||||
fputcsv($fp, array_keys($cols), $sDelimiter, '"', "\\");
|
||||
$swColumns = false;
|
||||
}
|
||||
$SDATA .= "\n";
|
||||
$bytesSaved += fwrite( $fp, $SDATA );
|
||||
fputcsv($fp, $cols, $sDelimiter, '"');
|
||||
}
|
||||
|
||||
fclose( $fp );
|
||||
|
||||
// $filenameLink = "pmTables/streamExported?f=$filenameOnly";
|
||||
fclose($fp);
|
||||
$filenameLink = "streamExported?f=$filenameOnly";
|
||||
$size = round( ($bytesSaved / 1024), 2 ) . " Kb";
|
||||
$filename = $filenameOnly;
|
||||
$size = filesize($filename);
|
||||
$link = $filenameLink;
|
||||
|
||||
$result->success = true;
|
||||
@@ -1269,7 +1249,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
if (file_exists( PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml' )) {
|
||||
$dynaformHandler = new dynaformHandler( PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '.xml' );
|
||||
$dynaformHandler = new DynaformHandler( PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '.xml' );
|
||||
$nodeFieldsList = $dynaformHandler->getFields();
|
||||
|
||||
foreach ($nodeFieldsList as $node) {
|
||||
@@ -1579,7 +1559,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$dynaformHandler = new dynaformHandler(PATH_DYNAFORM . $record['DYN_FILENAME'] . '.xml');
|
||||
$dynaformHandler = new DynaformHandler(PATH_DYNAFORM . $record['DYN_FILENAME'] . '.xml');
|
||||
$nodeFieldsList = $dynaformHandler->getFields();
|
||||
|
||||
foreach ($nodeFieldsList as $node) {
|
||||
|
||||
Reference in New Issue
Block a user