Skip to content
Snippets Groups Projects
Commit 5d81b07c authored by Giovannoni Laurent's avatar Giovannoni Laurent
Browse files

FEAT #6490 module convert begin

parent efca3c41
No related branches found
No related tags found
No related merge requests found
Showing
with 2424 additions and 2 deletions
...@@ -30,5 +30,5 @@ if (!defined('V2_ENABLED')) { ...@@ -30,5 +30,5 @@ if (!defined('V2_ENABLED')) {
define('V2_ENABLED', false); define('V2_ENABLED', false);
} }
if (!defined('PROD_MODE')) { if (!defined('PROD_MODE')) {
define('PROD_MODE', true); define('PROD_MODE', false);
} }
...@@ -307,4 +307,8 @@ ...@@ -307,4 +307,8 @@
<moduleid>export_seda</moduleid> <moduleid>export_seda</moduleid>
<comment>_EXPORT_SEDA_COMMENT</comment> <comment>_EXPORT_SEDA_COMMENT</comment>
</MODULES> </MODULES>
<MODULES>
<moduleid>convert</moduleid>
<comment>_CONVERT_COMMENT</comment>
</MODULES>
</ROOT> </ROOT>
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"Apps\\": "apps/maarch_entreprise/", "Apps\\": "apps/maarch_entreprise/",
"Attachments\\": "modules/attachments/", "Attachments\\": "modules/attachments/",
"Baskets\\": "modules/basket/", "Baskets\\": "modules/basket/",
"Convert\\": "modules/convert/",
"Entities\\": "modules/entities/", "Entities\\": "modules/entities/",
"Notes\\": "modules/notes/", "Notes\\": "modules/notes/",
"Notifications\\": "modules/notifications/", "Notifications\\": "modules/notifications/",
......
...@@ -219,4 +219,20 @@ class HistoryController ...@@ -219,4 +219,20 @@ class HistoryController
return $response->withJson($return); return $response->withJson($return);
} }
/*
timestart : timestamp Debut
timeend : timestamp Fin
level : level log4php
message : message dans les logs
*/
public function executionTimeLog($timestart, $timeend, $level, $message){
if (empty($timeend)){
$timeend = microtime(true);
}
$time = $timeend - $timestart;
self::$level(['message' => $message.'. Done in ' . number_format($time, 3) . ' secondes.']);
}
} }
...@@ -139,4 +139,35 @@ class DocserverModelAbstract ...@@ -139,4 +139,35 @@ class DocserverModelAbstract
return $aReturn; return $aReturn;
} }
/**
* Get docservers to insert a new doc converted.
* Can return null if no corresponding object.
* @param $collId string Collection identifier
* @param string $typeId [description]
* @return docservers
*/
public function findTargetDs(array $aArgs = [])
{
ValidatorModel::notEmpty($aArgs, ['collId']);
ValidatorModel::stringType($aArgs, ['collId']);
if (empty($aArgs['typeId'])) {
$aArgs['typeId'] = 'CONVERT';
}
$aReturn = DatabaseModel::select([
'select' => ['*'],
'table' => ['docservers'],
'where' => [
"is_readonly = 'N' and enabled = 'Y' and " .
"coll_id = ? and docserver_type_id = ?"
],
'data' => [$aArgs['collId'], $aArgs['typeId']],
'order_by' => ['priority_number'],
'limit' => 1,
]);
return $aReturn;
}
} }
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief Res and docserver association Model
* @author dev@maarch.org
* @ingroup core
*/
namespace Core\Models;
class ResDocserverModel extends ResDocserverModelAbstract
{
// Do your stuff in this class
}
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief Res Docserver association Model
* @author dev@maarch.org
* @ingroup core
*/
namespace Core\Models;
class ResDocserverModelAbstract
{
/**
* Retrieve the path of source file to process
* @param string $resTable resource table
* @param string $adrTable adr table
* @param bigint $resId Id of the resource to process
* @param string $adrType type of the address
* $resTable, $adrTable, $resId, $adrType = 'DOC'
* @return string
*/
public static function getSourceResourcePath(array $aArgs = [])
{
ValidatorModel::notEmpty($aArgs, ['resTable']);
ValidatorModel::notEmpty($aArgs, ['adrTable']);
ValidatorModel::notEmpty($aArgs, ['resId']);
if (!isset($aArgs['adrType'])) {
$aArgs['adrType'] = 'DOC';
}
if ($aArgs['adrType'] == 'DOC') {
$table = $aArgs['resTable'];
$where = ['res_id=?'];
$data = [$aArgs['resId']];
} else {
$table = $aArgs['adrTable'];
$where = ['res_id = ?', 'adr_type = ?'];
$data = [$aArgs['resId'], $aArgs['adrType']];
}
$aReturn = DatabaseModel::select([
'select' => [$table.'.path', $table.'.filename', $table.'.offset_doc', 'docservers.path_template'],
'table' => [$table, 'docservers'],
'where' => $where,
'data' => $data,
'left_join' => [$table.'.docserver_id = docservers.docserver_id']
]);
if (empty($aReturn)) {
return false;
}
$resPath = '';
$resFilename = '';
if (isset($aReturn[0]['path'])) {
$resPath = $aReturn[0]['path'];
}
if (isset($aReturn[0]['filename'])) {
$resFilename = $aReturn[0]['filename'];
}
if (isset($aReturn[0]['offset_doc'])
&& $aReturn[0]['offset_doc'] <> ''
&& $aReturn[0]['offset_doc'] <> ' '
) {
$sourceFilePath = $aReturn[0]['path']
. $aReturn[0]['filename']
. DIRECTORY_SEPARATOR . $aReturn[0]['offset_doc'];
} else {
$sourceFilePath = $resPath . $resFilename;
}
$resPathTemplate = '';
if (isset($aReturn[0]['path_template'])) {
$resPathTemplate = $aReturn[0]['path_template'];
}
$sourceFilePath = $resPathTemplate . $sourceFilePath;
$sourceFilePath = str_replace('#', DIRECTORY_SEPARATOR, $sourceFilePath);
return $sourceFilePath;
}
}
...@@ -120,6 +120,6 @@ class ReconciliationControllerTest extends TestCase ...@@ -120,6 +120,6 @@ class ReconciliationControllerTest extends TestCase
$response = $action->storeAttachmentResource($aArgs); $response = $action->storeAttachmentResource($aArgs);
$this->assertTrue($response; $this->assertTrue($response);
} }
} }
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief Process Convert Model
* @author dev@maarch.org
* @ingroup convert
*/
namespace Convert\Models;
class ProcessConvertModel extends ProcessConvertModelAbstract
{
// Do your stuff in this class
}
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief ProcessConvert Model
* @author dev@maarch.org
* @ingroup convert
*/
namespace Convert\Models;
class ProcessConverttextModelAbstract
{
public static function getById(array $aArgs = [])
{
ValidatorModel::notEmpty($aArgs, ['resId']);
ValidatorModel::intVal($aArgs, ['resId']);
$aReturn = DatabaseModel::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'table' => ['res_letterbox'],
'where' => ['res_id = ?'],
'data' => [$aArgs['resId']]
]);
if (empty($aReturn[0])) {
return [];
}
return $aReturn[0];
}
}
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief Process Fulltext Model
* @author dev@maarch.org
* @ingroup convert
*/
namespace Convert\Models;
class ProcessFulltextModel extends ProcessFulltextModelAbstract
{
// Do your stuff in this class
}
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief ProcessFulltext Model
* @author dev@maarch.org
* @ingroup convert
*/
namespace Convert\Models;
class ProcessFulltextModelAbstract
{
public static function getById(array $aArgs = [])
{
ValidatorModel::notEmpty($aArgs, ['resId']);
ValidatorModel::intVal($aArgs, ['resId']);
$aReturn = DatabaseModel::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'table' => ['res_letterbox'],
'where' => ['res_id = ?'],
'data' => [$aArgs['resId']]
]);
if (empty($aReturn[0])) {
return [];
}
return $aReturn[0];
}
}
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
namespace MaarchTest;
use PHPUnit\Framework\TestCase;
use MaarchTest\DocserverControllerTest;
class ProcessConvertTest extends TestCase
{
public function testconvert ()
{
$action = new \Convert\Controllers\ProcessConvertController();
$aArgs = [
'collId' => 'letterbox_coll',
'resTable' => 'res_letterbox',
'adrTable' => 'adr_x',
'resId' => 100,
'tmpDir' => $_SESSION['config']['tmppath']
];
$response = $action->convert($aArgs);
var_dump($response);
$this->assertArrayHasKey('status', $response);
}
}
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
namespace MaarchTest;
use PHPUnit\Framework\TestCase;
use MaarchTest\DocserverControllerTest;
class ProcessFulltextTest extends TestCase
{
public function testfulltext ()
{
$action = new \Convert\Controllers\ProcessFulltextController();
$aArgs = [
'collId' => 'letterbox_coll',
'resTable' => 'res_letterbox',
'adrTable' => 'adr_x',
'resId' => 100,
'tmpDir' => $_SESSION['config']['tmppath']
];
$response = $action->fulltext($aArgs);
$this->assertArrayHasKey('status', $response);
}
}
<?php
// sample for attachments in allMode :
// http://urltomaarch/apps/maarch_entreprise/index.php?page=ajax_convert&module=convert&id=1&collId=attachments_coll
$func = new functions();
for ($i=0;$i<count($_SESSION['collections']);$i++) {
if ($_SESSION['collections'][$i]['id'] == $_REQUEST['collId']) {
$resTable = $_SESSION['collections'][$i]['table'];
$adrTable = $_SESSION['collections'][$i]['adr'];
}
}
// echo $_REQUEST['collId'] . '<br />';
// echo $resTable . PHP_EOL . '<br />';
// echo $adrTable . PHP_EOL . '<br />';
// echo $_REQUEST['id'] . PHP_EOL . '<br />';
$params = array(
'collId' => $_REQUEST['collId'],
'resTable' => $resTable,
'adrTable' => $adrTable,
'resId' => $_REQUEST['id'],
'tmpDir' => $_SESSION['config']['tmppath']
);
require_once 'core/services/ManageDocservers.php';
$ManageDocservers = new Core_ManageDocservers_Service();
require_once 'modules/convert/services/ManageConvert.php';
$ManageConvertService = new Convert_ManageConvert_Service();
$resultOfConversion = $ManageConvertService->convertAll($params);
//var_dump($resultOfConversion);
<?php
/** Logger class
*
* @author Laurent Giovannoni <dev@maarch.org>
**/
class Logger4Php
{
/**
* Array of errors levels
*
* @protected
**/
protected $error_levels = array('DEBUG' => 0, 'INFO' => 1, 'NOTICE' => 2, 'WARNING' => 3, 'ERROR' => 4);
/**
* Maps each handler with its log threshold.
*
* @protected
**/
protected $mapping;
/**
* Minimum log level
*
* @protected
**/
protected $threshold_level;
/**
* Path to log4Php library
*
* @protected
**/
protected $log4PhpLibrary;
/**
* Name of the logger
*
* @protected
**/
protected $log4PhpLogger;
/**
* Name of the business code
*
* @protected
**/
protected $log4PhpBusinessCode;
/**
* Path of the param of log4php
*
* @protected
**/
protected $log4PhpConfigPath;
/**
* Name of the batch
*
* @protected
**/
protected $log4PhpBatchName;
/** Class constructor
*
* Inits the threshold level
*
* @param $threshold_level (string) Threshold level (set to 'INFO' by default)
**/
function __construct($threshold_level = 'WARNING')
{
$this->threshold_level = $threshold_level;
$this->mapping = array_fill(0, count($this->error_levels), array());
}
/** Writes error message in current handlers
*
* writes only if the error level is greater or equal the threshold level
*
* @param $msg (string) Error message
* @param $error_level (string) Error level (set to 'INFO' by default)
* @param $error_code (integer) Error code (set to 0 by default)
**/
public function write($msg, $error_level = 'INFO', $error_code = 0, $other_params = array())
{
if (!array_key_exists($error_level, $this->error_levels)) {
$error_level = 'INFO';
}
$foundLogger = false;
if ($this->error_levels[$error_level] >= $this->error_levels[$this->threshold_level]) {
for ($i=$this->error_levels[$error_level];$i>=0;$i--) {
foreach ($this->mapping[$i] as $handler) {
$handler->write($msg, $error_level, $error_code, $other_params);
if (
get_class($handler) == 'FileHandler'
&& (isset($this->log4PhpLibrary)
&& !empty($this->log4PhpLibrary))
) {
if ($error_code == 0) {
$result = 'OK';
} else {
$result = 'KO';
$msg = '%error_code:' . $error_code . '% ' . $msg;
}
require_once($this->log4PhpLibrary);
$remote_ip = '127.0.0.1';
Logger::configure($this->log4PhpConfigPath);
$logger = Logger::getLogger($this->log4PhpLogger);
$searchPatterns = array('%ACCESS_METHOD%',
'%RESULT%',
'%BUSINESS_CODE%',
'%HOW%',
'%WHAT%',
'%REMOTE_IP%',
'%BATCH_NAME%'
);
$replacePatterns = array('Script',
$result,
$this->log4PhpBusinessCode,
'UP',
$msg,
$remote_ip,
$this->log4PhpBatchName
);
$logLine = str_replace($searchPatterns,
$replacePatterns,
'[%ACCESS_METHOD%][%RESULT%]'
. '[%BUSINESS_CODE%][%HOW%][%WHAT%][%BATCH_NAME%]'
);
$this->writeLog4php($logger, $logLine, $error_level);
}
}
}
}
}
/**
*
* write a log entry with a specific log level
* @param object $logger Log4php logger
* @param string $logLine Line we want to trace
* @param enum $level Log level
*/
function writeLog4php($logger, $logLine, $level) {
switch ($level) {
case 'DEBUG':
$logger->debug($logLine);
break;
case 'INFO':
$logger->info($logLine);
break;
case 'WARNING':
$logger->warn($logLine);
break;
case 'ERROR':
$logger->error($logLine);
break;
case 'FATAL':
$logger->fatal($logLine);
break;
}
}
/** Adds a new handler in the current handlers array
*
* @param $handler (object) Handler object
**/
public function add_handler(&$handler, $error_level = NULL)
{
if(!isset($handler))
return false;
if(!isset($error_level) || !array_key_exists($error_level, $this->error_levels))
{
$error_level = $this->threshold_level;
}
$this->mapping[$this->error_levels[$error_level]][] = $handler;
return true;
}
/** Adds a new handler in the current handlers array
*
* @param $handler (object) Handler object
**/
public function change_handler_log_level(&$handler, $log_level )
{
if (!isset($handler) || !isset($log_level))
return false;
if (!array_key_exists($log_level, $this->error_levels)) {
return false;
}
for ($i=0; $i<count($this->mapping);$i++) {
for($j=0;$j<count($this->mapping[$i]);$j++) {
if($handler == $this->mapping[$i][$j]) {
unset($this->mapping[$i][$j]);
}
}
}
$this->mapping = array_values($this->mapping);
$this->mapping[$this->error_levels[$log_level]][] = $handler;
return true;
}
/** Sets treshold level
*
* @param $treshold (string) treshold level
**/
public function set_threshold_level($treshold)
{
if (isset($treshold) && array_key_exists($treshold, $this->error_levels)) {
$this->threshold_level = $treshold;
return true;
}
$this->threshold_level = 'WARNING';
return false;
}
/** Sets log4Php library path
*
* @param $log4PhpLibrary (string) path
**/
public function set_log4PhpLibrary($log4PhpLibrary)
{
if (isset($log4PhpLibrary) && !empty($log4PhpLibrary)) {
if (file_exists($log4PhpLibrary)) {
$this->log4PhpLibrary = $log4PhpLibrary;
return true;
} else {
return false;
}
}
return false;
}
/** Sets log4php logger name
*
* @param $log4PhpLogger (string) logger name
**/
public function set_log4PhpLogger($log4PhpLogger)
{
if (isset($log4PhpLogger) && !empty($log4PhpLogger)) {
$this->log4PhpLogger = $log4PhpLogger;
return true;
}
$this->log4PhpLogger = 'loggerTechnique';
return false;
}
/** Sets log4php path to log4php xml config
*
* @param $log4PhpPath (string) path to log4php xml config
**/
public function set_log4PhpConfigPath($log4PhpConfigPath)
{
if (isset($log4PhpConfigPath) && !empty($log4PhpConfigPath)) {
if (file_exists($log4PhpConfigPath)) {
$this->log4PhpConfigPath = $log4PhpConfigPath;
return true;
} else {
return false;
}
}
return false;
}
/** Sets log4php business code
*
* @param $log4PhpBusinessCode (string) business code
**/
public function set_log4PhpBusinessCode($log4PhpBusinessCode)
{
if (isset($log4PhpBusinessCode) && !empty($log4PhpBusinessCode)) {
$this->log4PhpBusinessCode = $log4PhpBusinessCode;
return true;
}
$this->log4PhpBusinessCode = 'Maarch';
return false;
}
/** Sets log4php batch name
*
* @param $log4PhpBatchName (string) BatchName
**/
public function set_log4PhpBatchName($log4PhpBatchName)
{
if (isset($log4PhpBatchName) && !empty($log4PhpBatchName)) {
$this->log4PhpBatchName = $log4PhpBatchName;
return true;
}
$this->log4PhpBatchName = 'MaarchBatch';
return false;
}
/** Class destructor
*
* Calls handlers destructors
**/
function __destruct()
{
for($i=0; $i<count($this->mapping);$i++)
{
foreach($this->mapping[$i] as $handler)
{
unset($handler);
}
}
}
}
<?php
/*
* Copyright 2008-2016 Maarch
*
* This file is part of Maarch Framework.
*
* Maarch Framework 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, either version 3 of the License, or
* (at your option) any later version.
*
* Maarch Framework 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.
*
* You should have received a copy of the GNU General Public License
* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @brief API to manage batchs
*
* @file
* @author Laurent Giovannoni
* @date $date$
* @version $Revision$
* @ingroup convert
*/
/**
* Execute a sql query
*
* @param object $dbConn connection object to the database
* @param string $queryTxt path of the file to include
* @param boolean $transaction for rollback if error
* @return true if ok, exit if ko and rollback if necessary
*/
function Bt_doQuery($dbConn, $queryTxt, $param=array(), $transaction=false)
{
if (count($param) > 0) {
$stmt = $dbConn->query($queryTxt, $param);
} else {
$stmt = $dbConn->query($queryTxt);
}
if (!$stmt) {
if ($transaction) {
$GLOBALS['logger']->write('ROLLBACK', 'INFO');
$dbConn->query('ROLLBACK');
}
$GLOBALS['logger']->write('SQL query error:' . $queryTxt, 'WARNING');
}
$GLOBALS['logger']->write('SQL query:' . $queryTxt, 'DEBUG');
return $stmt;
}
/**
* Exit the batch with a return code, message in the log and
* in the database if necessary
*
* @param int $returnCode code to exit (if > O error)
* @param string $message message to the log and the DB
* @return nothing, exit the program
*/
function Bt_exitBatch($returnCode, $message='', $logLevel='')
{
if (file_exists($GLOBALS['lckFile'])) {
unlink($GLOBALS['lckFile']);
}
if ($returnCode > 0) {
$GLOBALS['totalProcessedResources']--;
if ($GLOBALS['totalProcessedResources'] == -1) {
$GLOBALS['totalProcessedResources'] = 0;
}
if($returnCode < 100) {
if (file_exists($GLOBALS['errorLckFile'])) {
unlink($GLOBALS['errorLckFile']);
}
$semaphore = fopen($GLOBALS['errorLckFile'], "a");
fwrite($semaphore, '1');
fclose($semaphore);
}
if($logLevel == 'WARNING'){
$GLOBALS['logger']->write($message, 'WARNING', $returnCode);
} else {
$GLOBALS['logger']->write($message, 'ERROR', $returnCode);
}
Bt_logInDataBase($GLOBALS['totalProcessedResources'], 1, 'return code:'
. $returnCode . ', ' . $message);
} elseif ($message <> '') {
$GLOBALS['logger']->write($message, 'INFO', $returnCode);
Bt_logInDataBase($GLOBALS['totalProcessedResources'], 0, 'return code:'
. $returnCode . ', ' . $message);
}
$query = "delete from convert_stack "
. " where coll_id = ? ";
$stmt = Bt_doQuery(
$GLOBALS['db'],
$query,
array(
$GLOBALS['collection']
)
);
exit($returnCode);
}
/**
* Insert in the database the report of the batch
* @param long $totalProcessed total of resources processed in the batch
* @param long $totalErrors total of errors in the batch
* @param string $info message in db
*/
function Bt_logInDataBase($totalProcessed=0, $totalErrors=0, $info='')
{
$query = "insert into history_batch(module_name, batch_id, event_date, "
. "total_processed, total_errors, info) values(?, ?, "
. $GLOBALS['db']->current_datetime() . ", ?, ?, ?)";
$stmt = $GLOBALS['dbLog']->query(
$query,
array(
$GLOBALS['batchName'],
$GLOBALS['wb'],
$totalProcessed,
$totalErrors,
substr(str_replace('\\', '\\\\', str_replace("'", "`", $info)), 0, 999)
)
);
}
/**
* Get the batch if of the batch
*
* @return nothing
*/
function Bt_getWorkBatch()
{
$req = "select param_value_int from parameters where id = ?";
$stmt = $GLOBALS['db']->query($req, array($GLOBALS['batchName'] . "_id"));
while ($reqResult = $stmt->fetchObject()) {
$GLOBALS['wbCompute'] = $reqResult->param_value_int + 1;
}
if ($GLOBALS['wbCompute'] == '') {
$req = "insert into parameters(id, param_value_int) values "
. "(?, 1)";
$stmt = $GLOBALS['db']->query($req, array($GLOBALS['batchName'] . "_id"));
$GLOBALS['wbCompute'] = 1;
}
}
/**
* Update the database with the new batch id of the batch
*
* @return nothing
*/
function Bt_updateWorkBatch()
{
$req = "update parameters set param_value_int = ? where id = ?";
$stmt = $GLOBALS['db']->query($req, array($GLOBALS['wbCompute'], $GLOBALS['batchName'] . "_id"));
}
/**
* Include the file requested if exists
*
* @param string $file path of the file to include
* @return nothing
*/
function Bt_myInclude($file)
{
if (file_exists($file)) {
include_once ($file);
} else {
throw new IncludeFileError($file);
}
}
/**
* Get the current date to process
*
* @return nothing
*/
function Bt_getCurrentDateToProcess()
{
$req = "select param_value_date from parameters where id = ?";
$stmt = $GLOBALS['db']->query(
$req,
array(
$GLOBALS['batchName'] . "_" . $GLOBALS['collection'] . "_current_date"
)
);
$reqResult = $stmt->fetchObject();
if ($reqResult->param_value_date == '') {
$req = "insert into parameters(id, param_value_date) values (?, ?)";
$stmt = $GLOBALS['db']->query(
$req,
array(
$GLOBALS['batchName'] . "_" . $GLOBALS['collection'] . "_current_date",
$GLOBALS['startDateRecovery']
)
);
$GLOBALS['currentDate'] = $GLOBALS['startDateRecovery'];
} else {
$resultDate = formatDateFromDb($reqResult->param_value_date);
if (
$GLOBALS['func']->compare_date(
$GLOBALS['startDateRecovery'],
$resultDate
) == 'date1'
) {
$GLOBALS['currentDate'] = $GLOBALS['startDateRecovery'];
} else {
$GLOBALS['currentDate'] = $resultDate;
}
}
}
/**
* Update the database with the current date to process
*
* @return nothing
*/
function Bt_updateCurrentDateToProcess()
{
$req = "update parameters set param_value_date = ? where id = ?";
$stmt = $GLOBALS['db']->query(
$req,
array(
$GLOBALS['currentDate'],
$GLOBALS['batchName'] . "_" . $GLOBALS['collection'] . "_current_date"
)
);
}
/**
* Compute the end current date to process
*
* @return nothing
*/
function Bt_getEndCurrentDateToProcess()
{
$dateArray = array();
$tabDate = explode('/' , $GLOBALS['currentDate']);
$theDate = $tabDate[2] . '-' . $tabDate[1] . '-' . $tabDate[0];
$dateArray = date_parse($theDate);
$GLOBALS['endCurrentDate'] = strftime(
"%d/%m/%Y", mktime(0, 0, 0, $dateArray['month'] +1 , 0, $dateArray['year'])
);
}
/**
* Compute the next month currentDate
*
* @return nothing
*/
function Bt_computeNextMonthCurrentDate()
{
$tabDate = array();
$tabDate = explode('/' , $GLOBALS['currentDate']);
$theDate = $tabDate[2] . '-' . $tabDate[1] . '-' . $tabDate[0];
$GLOBALS['currentDate'] = date("d/m/Y", strtotime('+1 month', strtotime($theDate)));
Bt_getEndCurrentDateToProcess();
}
/**
* Compute the creation date clause
*
* @return nothing
*/
function Bt_computeCreationDateClause()
{
$GLOBALS['creationDateClause'] = '';
if ($GLOBALS['currentDate'] <> '') {
$GLOBALS['creationDateClause'] = " and (creation_date >= '" . $GLOBALS['currentDate'] . "'";
if ($GLOBALS['endCurrentDate'] <> '') {
$GLOBALS['creationDateClause'] .= " and creation_date <= '" . $GLOBALS['endCurrentDate'] . "'";
}
$GLOBALS['creationDateClause'] .= ")";
}
}
/**
* Formats a datetime to a dd/mm/yyyy format (date)
*
* @param $date datetime The date to format
* @return datetime The formated date
*/
function formatDateFromDb($date)
{
$lastDate = '';
if ($date <> "") {
if (strpos($date," ")) {
$date_ex = explode(" ",$date);
$theDate = explode("-",$date_ex[0]);
$lastDate = $theDate[0] . "/" . $theDate[1] . "/" . $theDate[2];
} else {
$theDate = explode("-",$date);
$lastDate = $theDate[0] . "/" . $theDate[1] . "/" . $theDate[2];
}
}
return $lastDate;
}
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<CONFIG>
<Lang>fr</Lang> <!-- fr, en-->
<MaarchDirectory>/var/www/html/oem_V2/</MaarchDirectory>
<TmpDirectory>/var/www/html/oem_V2/modules/convert/batch/tmp/</TmpDirectory>
<LogLevel>INFO</LogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR-->
<DisplayedLogLevel>INFO</DisplayedLogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR-->
<StackSizeLimit>50</StackSizeLimit>
<ApacheUserAndGroup>lgi:lgi</ApacheUserAndGroup>
<UnoconvPath>unoconv</UnoconvPath> <!-- only for Windows -->
<OpenOfficePath>soffice</OpenOfficePath> <!-- only for Windows -->
<UnoconvOptions>--port 8100</UnoconvOptions>
<RegExResId>false</RegExResId>
<StartDateRecovery>false</StartDateRecovery> <!-- false or date dd/mm/yyyy -->
<CurrentMonthOnly>false</CurrentMonthOnly> <!-- true or false -->
</CONFIG>
<CONVERT>
<OutputFormat>pdf</OutputFormat>
<InputFormat>odt,ott,odm,html,oth,ods,ots,odg,otg,odp,otp,odf,doc,docx,xls,xlsx,ppt,pptx,tiff,tif,png,jpeg,jpg,gif</InputFormat>
</CONVERT>
<CONVERT>
<OutputFormat>html</OutputFormat>
<InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat>
</CONVERT>
<CONVERT>
<OutputFormat>png</OutputFormat>
<InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat>
</CONVERT>
<CONFIG_BASE>
<databaseserver>127.0.0.1</databaseserver>
<databaseserverport>5432</databaseserverport>
<databasetype>POSTGRESQL</databasetype>
<databasename>sipol_v2</databasename>
<databaseuser>maarch</databaseuser>
<databasepassword>maarch</databasepassword>
</CONFIG_BASE>
<COLLECTION>
<Id>letterbox_coll</Id>
<Table>res_letterbox</Table>
<View>res_view_letterbox</View>
<Adr>adr_letterbox</Adr>
<path_to_lucene_index>/opt/maarch/docservers/indexes/letterbox_coll/</path_to_lucene_index>
</COLLECTION>
<COLLECTION>
<Id>attachments_coll</Id>
<Table>res_attachments</Table>
<View>res_view_attachments</View>
<Adr>adr_attachments</Adr>
<path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_coll/</path_to_lucene_index>
</COLLECTION>
<COLLECTION>
<Id>attachments_version_coll</Id>
<Table>res_version_attachments</Table>
<View>res_version_attachments</View>
<Adr>adr_attachments_version</Adr>
<path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_version_coll/</path_to_lucene_index>
</COLLECTION>
<COLLECTION>
<Id>calendar_coll</Id>
<Table>calendar_event_attachments</Table>
<View>calendar_event_attachments</View>
<Adr>calendar_event_adr_attachments</Adr>
<path_to_lucene_index>/opt/maarch/docservers/indexes/calendar_coll/</path_to_lucene_index>
</COLLECTION>
<COLLECTION>
<Id>folder_coll</Id>
<Table>res_folder</Table>
<View>res_folder</View>
<Adr>adr_folder</Adr>
<path_to_lucene_index>/opt/maarch/docservers/indexes/folder_coll/</path_to_lucene_index>
</COLLECTION>
<COLLECTION>
<Id>chrono_coll</Id>
<Table>res_chrono</Table>
<View>res_chrono</View>
<Adr>adr_chrono</Adr>
<path_to_lucene_index>/opt/maarch/docservers/indexes/chrono_coll/</path_to_lucene_index>
</COLLECTION>
<COLLECTION>
<Id>reprise_coll</Id>
<Table>res_reprise</Table>
<View>res_reprise</View>
<Adr>adr_reprise</Adr>
<path_to_lucene_index>/opt/maarch/docservers/indexes/reprise_coll/</path_to_lucene_index>
</COLLECTION>
<LOG4PHP>
<enabled>true</enabled>
<Log4PhpLogger>loggerTechnique</Log4PhpLogger>
<Log4PhpBusinessCode>Convert</Log4PhpBusinessCode>
<Log4PhpConfigPath>/var/www/html/oem_V2/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath>
</LOG4PHP>
</ROOT>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment