mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-19 16:02:15 +00:00
Merge branch 'feature-6656/Worker_queue'
This commit is contained in:
@@ -31,6 +31,13 @@ define('EXIT_VALIDATION_UDF_NOT_VALID_VAL', 17); // UDF validation has been fail
|
||||
define('EXIT_AUTO_MIN', 1000); // lowest automatically-assigned error code
|
||||
define('EXIT_AUTO_MAX', 2000); // highest automatically-assigned error code
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| General purpose
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
define('BEGINNING_OF_TIME', '1970-01-01');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication constants
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
// White list of permissions (write mode have to be set) that are able to store a specific job type in database
|
||||
$config['job_type_permissions_white_list'] = array(
|
||||
'SAPStammdatenUpdate' => array(
|
||||
'admin:rw',
|
||||
'developer:rw'
|
||||
),
|
||||
'OEHPayment' => 'developer:rw',
|
||||
'SAPPayment' => 'developer:rw'
|
||||
);
|
||||
|
||||
@@ -109,6 +109,13 @@ $config['navigation_header'] = array(
|
||||
'expand' => true,
|
||||
'sort' => 20,
|
||||
'requiredPermissions' => 'system/developer:r'
|
||||
),
|
||||
'jobsqueueviewer' => array(
|
||||
'link' => site_url('system/jq/JobsQueueViewer'),
|
||||
'description' => 'Jobs Queue Viewer',
|
||||
'expand' => true,
|
||||
'sort' => 20,
|
||||
'requiredPermissions' => 'system/developer:r'
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -35,7 +35,7 @@ class LogsViewer extends Auth_Controller
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Main page of the InfoCenter tool
|
||||
* Everything has a beginning
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller acts as REST JSON interface between the JobsQueueLib, that contains all the needed functionalities to
|
||||
* operate with the Jobs Queue System, and other tools that cannot access directly to such library
|
||||
*/
|
||||
class JobsQueueManager extends Auth_Controller
|
||||
{
|
||||
// Config entry name for White list of permissions...
|
||||
const JOB_TYPE_PERMISSIONS_WHITE_LIST = 'job_type_permissions_white_list';
|
||||
// Parameter names
|
||||
const PARAM_JOBS = 'jobs';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
array(
|
||||
'getLastJobs' => 'admin:r',
|
||||
'addNewJobsToQueue' => 'admin:rw',
|
||||
'updateJobsQueue' => 'admin:rw'
|
||||
)
|
||||
);
|
||||
|
||||
// Loading config file jqm
|
||||
$this->config->load('jqm');
|
||||
|
||||
// Loads JobsQueueLib
|
||||
$this->load->library('JobsQueueLib');
|
||||
// Loads permission lib
|
||||
$this->load->library('PermissionLib');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* To get all the most recently added jobs using the given job type
|
||||
*/
|
||||
public function getLastJobs()
|
||||
{
|
||||
$type = $this->input->get(JobsQueueLib::PROPERTY_TYPE);
|
||||
|
||||
$this->_checkPermissions($type);
|
||||
|
||||
$this->outputJson($this->jobsqueuelib->getLastJobs($type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new jobs in the jobs queue with the given type
|
||||
* jobs is an array of job objects
|
||||
*/
|
||||
public function addNewJobsToQueue()
|
||||
{
|
||||
$type = $this->input->post(JobsQueueLib::PROPERTY_TYPE);
|
||||
$jobs = $this->input->post(self::PARAM_JOBS);
|
||||
|
||||
$this->_checkPermissions($type);
|
||||
|
||||
// Otherwise convert jobs from json to php and call JobsQueueLib library
|
||||
$this->outputJson($this->jobsqueuelib->addNewJobsToQueue($type, $this->_convertJobs($jobs)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new jobs in the jobs queue with the given type
|
||||
* jobs is an array of job objects
|
||||
*/
|
||||
public function updateJobsQueue()
|
||||
{
|
||||
$type = $this->input->post(JobsQueueLib::PROPERTY_TYPE);
|
||||
$jobs = $this->input->post(self::PARAM_JOBS);
|
||||
|
||||
$this->_checkPermissions($type);
|
||||
|
||||
// Otherwise convert jobs from json to php and call JobsQueueLib library
|
||||
$this->outputJson($this->jobsqueuelib->updateJobsQueue($type, $this->_convertJobs($jobs)));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _checkPermissions($type)
|
||||
{
|
||||
// Checks if the caller has the permissions to add new jobs with the given type in the queue
|
||||
if (!$this->permissionlib->isEntitled($this->config->item(self::JOB_TYPE_PERMISSIONS_WHITE_LIST), $type))
|
||||
{
|
||||
// Permissions NOT valid
|
||||
$this->terminateWithJsonError('You are not allowed to access to this content');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _convertJobs($jobs)
|
||||
{
|
||||
if (isEmptyArray($jobs)) return null; // if not a valid array then return null
|
||||
|
||||
$convertedJobsArray = array(); // returned values
|
||||
|
||||
// Loops through all the provided jobs
|
||||
foreach ($jobs as $job)
|
||||
{
|
||||
$tmpObj = json_decode($job); // Try to decode json to php
|
||||
|
||||
// If decode was a success
|
||||
if ($tmpObj != null)
|
||||
{
|
||||
$convertedJobsArray[] = $tmpObj; // then store the decoded object in the result array
|
||||
}
|
||||
else // otherwise
|
||||
{
|
||||
// Create a new object and store the error message in it
|
||||
$tmpObj = new stdClass();
|
||||
$tmpObj->{JobsQueueLib::PROPERTY_ERROR} = 'A not valid json was provided';
|
||||
|
||||
$convertedJobsArray[] = $tmpObj; // store this object into the result array
|
||||
}
|
||||
}
|
||||
|
||||
return $convertedJobsArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Jobs Queue Viewer
|
||||
*
|
||||
* This controller renders a FilterWidget to monitor the current status of the Jobs Queue System
|
||||
*/
|
||||
class JobsQueueViewer extends Auth_Controller
|
||||
{
|
||||
const PARAM_START_DATE = 'startDate';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'system/developer:r'
|
||||
)
|
||||
);
|
||||
|
||||
// Loads WidgetLib
|
||||
$this->load->library('WidgetLib');
|
||||
|
||||
// Loads JobsQueueLib
|
||||
$this->load->library('JobsQueueLib');
|
||||
|
||||
// Loads phrases system
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
'ui',
|
||||
'filter'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Everything has a beginning
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('system/jq/jobsQueueViewer.php');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
/**
|
||||
* Job Queue Worker
|
||||
*
|
||||
* This controller acts as interface of the JobsQueueLib that contains all the needed functionalities to operate with
|
||||
* the Jobs Queue System
|
||||
* This is an abstract class that provide basic functionalities, it has to be extended to broaden its logic
|
||||
*/
|
||||
abstract class JQW_Controller extends JOB_Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Loads LogLib with different parameters
|
||||
$this->load->library('LogLib', array(
|
||||
'classIndex' => 5,
|
||||
'functionIndex' => 5,
|
||||
'lineIndex' => 4,
|
||||
'dbLogType' => 'job', // required
|
||||
'dbExecuteUser' => 'Jobs queue system'
|
||||
));
|
||||
|
||||
// Loads JobsQueueLib library
|
||||
$this->load->library('JobsQueueLib');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Protected methods
|
||||
|
||||
/**
|
||||
* To get all the most recently added jobs using the given job type
|
||||
*/
|
||||
protected function getLastJobs($type)
|
||||
{
|
||||
$jobs = $this->jobsqueuelib->getLastJobs($type);
|
||||
|
||||
// If an error occurred then log it in database
|
||||
if (isError($jobs)) $this->logError(getError($jobs), $type);
|
||||
|
||||
return $jobs;
|
||||
}
|
||||
|
||||
/**
|
||||
* To get all the jobs specified by the given parameters
|
||||
*/
|
||||
protected function getJobsByTypeStatusInput($type, $status, $input)
|
||||
{
|
||||
$jobs = $this->jobsqueuelib->getJobsByTypeStatusInput($type, $status, $input);
|
||||
|
||||
// If an error occurred then log it in database
|
||||
if (isError($jobs)) $this->logError(getError($jobs), array($type, $status, $input));
|
||||
|
||||
return $jobs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new jobs in the jobs queue with the given type
|
||||
* jobs is an array of job objects
|
||||
*/
|
||||
protected function addNewJobsToQueue($type, $jobs)
|
||||
{
|
||||
$result = $this->jobsqueuelib->addNewJobsToQueue($type, $jobs);
|
||||
|
||||
// If an error occurred then log it in database
|
||||
if (isError($result)) $this->logError(getError($result), $type);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates jobs already present in the jobs queue
|
||||
* jobs is an array of job objects
|
||||
*/
|
||||
protected function updateJobsQueue($type, $jobs)
|
||||
{
|
||||
$result = $this->jobsqueuelib->updateJobsQueue($type, $jobs);
|
||||
|
||||
// If an error occurred then log it in database
|
||||
if (isError($result)) $this->logError(getError($result), $type);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to update the specified properties of the given jobs with the given values
|
||||
*/
|
||||
protected function updateJobs($jobs, $properties, $values)
|
||||
{
|
||||
// If not valid arrays of properties and values arrays are not of the same size then exit
|
||||
if (isEmptyArray($jobs) || isEmptyArray($properties) || isEmptyArray($values)) return;
|
||||
if (count($properties) != count($values)) return;
|
||||
|
||||
// For each job
|
||||
foreach ($jobs as $job)
|
||||
{
|
||||
// For each propery of the job
|
||||
for ($pI = 0; $pI < count($properties); $pI++)
|
||||
{
|
||||
// If this property is present in the job object
|
||||
if (property_exists($job, $properties[$pI]))
|
||||
{
|
||||
$job->{$properties[$pI]} = $values[$pI]; // set a new value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to generate a job with the given parameters and return it inside an array
|
||||
* ready to be used by addNewJobsToQueue and updateJobsQueue
|
||||
*/
|
||||
protected function generateJobs($status, $input)
|
||||
{
|
||||
$job = new stdClass();
|
||||
|
||||
$job->{JobsQueueLib::PROPERTY_STATUS} = $status;
|
||||
$job->{JobsQueueLib::PROPERTY_INPUT} = $input;
|
||||
|
||||
return array($job);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ class FilterWidgetLib
|
||||
const OP_NOT_SET = 'nset';
|
||||
|
||||
// Filter options values
|
||||
const OPT_HOURS = 'hours';
|
||||
const OPT_DAYS = 'days';
|
||||
const OPT_MONTHS = 'months';
|
||||
|
||||
@@ -884,7 +885,8 @@ class FilterWidgetLib
|
||||
// It it's a date type
|
||||
if (is_numeric($filterDefinition->condition)
|
||||
&& isset($filterDefinition->option)
|
||||
&& ($filterDefinition->option == self::OPT_DAYS
|
||||
&& ($filterDefinition->option == self::OPT_HOURS
|
||||
|| $filterDefinition->option == self::OPT_DAYS
|
||||
|| $filterDefinition->option == self::OPT_MONTHS))
|
||||
{
|
||||
$condition = '< (NOW() - \''.$filterDefinition->condition.' '.$filterDefinition->option.'\'::interval)';
|
||||
@@ -899,7 +901,8 @@ class FilterWidgetLib
|
||||
// It it's a date type
|
||||
if (is_numeric($filterDefinition->condition)
|
||||
&& isset($filterDefinition->option)
|
||||
&& ($filterDefinition->option == self::OPT_DAYS
|
||||
&& ($filterDefinition->option == self::OPT_HOURS
|
||||
|| $filterDefinition->option == self::OPT_DAYS
|
||||
|| $filterDefinition->option == self::OPT_MONTHS))
|
||||
{
|
||||
$condition = '> (NOW() - \''.$filterDefinition->condition.' '.$filterDefinition->option.'\'::interval)';
|
||||
|
||||
@@ -0,0 +1,370 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Library that contains all the needed functionalities to operate with the Jobs Queue System
|
||||
*/
|
||||
class JobsQueueLib
|
||||
{
|
||||
// Job statuses
|
||||
const STATUS_NEW = 'new';
|
||||
const STATUS_RUNNING = 'running';
|
||||
const STATUS_DONE = 'done';
|
||||
const STATUS_FAILED = 'failed';
|
||||
|
||||
// Job object properties
|
||||
const PROPERTY_JOBID = 'jobid';
|
||||
const PROPERTY_CREATIONTIME = 'creationtime';
|
||||
const PROPERTY_TYPE = 'type';
|
||||
const PROPERTY_STATUS = 'status';
|
||||
const PROPERTY_INPUT = 'input';
|
||||
const PROPERTY_OUTPUT = 'output';
|
||||
const PROPERTY_START_TIME = 'starttime';
|
||||
const PROPERTY_END_TIME = 'endtime';
|
||||
const PROPERTY_ERROR = 'error';
|
||||
|
||||
private $_ci; // CI instance
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($authenticate = true)
|
||||
{
|
||||
// Gets CI instance
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
// Loads all needed models
|
||||
$this->_ci->load->model('system/JobsQueue_model', 'JobsQueueModel');
|
||||
$this->_ci->load->model('system/JobTypes_model', 'JobTypesModel');
|
||||
$this->_ci->load->model('system/JobStatuses_model', 'JobStatusesModel');
|
||||
$this->_ci->load->model('system/JobTriggers_model', 'JobTriggersModel');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* To get all the most recently added jobs using the given job type
|
||||
*/
|
||||
public function getLastJobs($type)
|
||||
{
|
||||
$this->_ci->JobsQueueModel->resetQuery();
|
||||
|
||||
$this->_ci->JobsQueueModel->addOrder('creationtime', 'DESC');
|
||||
|
||||
return $this->_ci->JobsQueueModel->loadWhere(array('status' => self::STATUS_NEW, 'type' => $type));
|
||||
}
|
||||
|
||||
/**
|
||||
* To get all the jobs specified by the given parameters
|
||||
*/
|
||||
public function getJobsByTypeStatusInput($type, $status, $input)
|
||||
{
|
||||
$this->_ci->JobsQueueModel->resetQuery();
|
||||
|
||||
$this->_ci->JobsQueueModel->addOrder('creationtime', 'DESC');
|
||||
|
||||
return $this->_ci->JobsQueueModel->loadWhere(array('status' => $status, 'type' => $type, 'input' => $input));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new jobs in the jobs queue with the given type
|
||||
* jobs is an array of job objects
|
||||
*/
|
||||
public function addNewJobsToQueue($type, $jobs)
|
||||
{
|
||||
// Checks parameters
|
||||
if (isEmptyString($type)) return error('The provided type parameter is not a valid string');
|
||||
if (isEmptyArray($jobs)) return error('The provided jobs parameter is not a valid array');
|
||||
|
||||
// Get all the job types
|
||||
$dbResult = $this->_ci->JobTypesModel->load();
|
||||
if (isError($dbResult)) return $dbResult;
|
||||
$types = getData($dbResult);
|
||||
|
||||
// If the given type is not present in database
|
||||
if (!$this->_checkJobType($type, $types)) return error('The provided type parameter is not valid');
|
||||
|
||||
$results = $jobs; // returned values
|
||||
$errorOccurred = false; // very optimistic
|
||||
|
||||
// Get all the job statuses
|
||||
$dbResult = $this->_ci->JobStatusesModel->load();
|
||||
if (isError($dbResult)) return $dbResult;
|
||||
$statuses = getData($dbResult);
|
||||
|
||||
// Loops through all the provided jobs
|
||||
foreach ($results as $job)
|
||||
{
|
||||
// If the structure of the job object is valid AND the type is valid AND the status is valid
|
||||
if ($this->_checkNewJobStructure($job) && $this->_checkJobStatus($job, $statuses))
|
||||
{
|
||||
$this->_dropNotAllowedPropertiesNewJob($job); // remove the black listed properties from this object
|
||||
|
||||
$job->{self::PROPERTY_TYPE} = $type; // What you asked is what you get!
|
||||
|
||||
// Try to insert the single job into database
|
||||
$dbNewJobResult = $this->_ci->JobsQueueModel->insert($job);
|
||||
|
||||
// If an error occurred during while inserting in database
|
||||
if (isError($dbNewJobResult))
|
||||
{
|
||||
$job->{self::PROPERTY_ERROR} = getError($dbNewJobResult); // retrieve the cause and store it in job object
|
||||
$errorOccurred = true; // set error occurred flag
|
||||
}
|
||||
else // otherwise
|
||||
{
|
||||
$job->{self::PROPERTY_JOBID} = getData($dbNewJobResult); // get the jobid and store it in job object
|
||||
|
||||
$dbNewTriggeredJobResult = $this->_addNewTriggeredJobToQueue($type, $job, array(self::STATUS_NEW));
|
||||
// If an error occurred during while inserting in database
|
||||
if (isError($dbNewTriggeredJobResult)) return $dbNewTriggeredJobResult;
|
||||
}
|
||||
}
|
||||
else // otherwise
|
||||
{
|
||||
$errorOccurred = true; // set error occurred flag
|
||||
}
|
||||
}
|
||||
|
||||
// If an error occurred then returns the results in an error object
|
||||
if ($errorOccurred) return error($results);
|
||||
|
||||
return success($results); // otherwise return results in a success object
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates jobs already present in the jobs queue
|
||||
* jobs is an array of job objects
|
||||
*/
|
||||
public function updateJobsQueue($type, $jobs)
|
||||
{
|
||||
// Checks parameters
|
||||
if (isEmptyArray($jobs)) return error('The provided jobs parameter is not a valid array');
|
||||
|
||||
$results = $jobs; // returned values
|
||||
$errorOccurred = false; // very optimistic
|
||||
|
||||
// Get all the job statuses
|
||||
$dbResultStatuses = $this->_ci->JobStatusesModel->load();
|
||||
if (isError($dbResultStatuses)) return $dbResultStatuses;
|
||||
$statuses = getData($dbResultStatuses);
|
||||
|
||||
// Loops through all the provided jobs
|
||||
foreach ($results as $job)
|
||||
{
|
||||
// Check if the required job is present in the database
|
||||
$dbResultJobs = $this->_ci->JobsQueueModel->load($job->{self::PROPERTY_JOBID});
|
||||
if (isError($dbResultJobs))
|
||||
{
|
||||
$job->{self::PROPERTY_ERROR} = getError($dbResultJobs); // retrieve the cause and store it in job object
|
||||
$errorOccurred = true; // set error occurred flag
|
||||
}
|
||||
elseif (!hasData($dbResultJobs)) // if no jobs were found
|
||||
{
|
||||
$job->{self::PROPERTY_ERROR} = 'The required job is not present';
|
||||
$errorOccurred = true; // set error occurred flag
|
||||
}
|
||||
else // if a job was found then it could be updated
|
||||
{
|
||||
// If the structure of the job object is valid
|
||||
if ($this->_checkUpdateJobStructure($job) && $this->_checkJobStatus($job, $statuses))
|
||||
{
|
||||
$this->_dropNotAllowedPropertiesUpdateJob($job); // remove the black listed properties from this object
|
||||
|
||||
$job->{self::PROPERTY_TYPE} = $type; // What you asked is what you get!
|
||||
|
||||
// Try to update the single job into database
|
||||
$dbResult = $this->_ci->JobsQueueModel->update($job->{self::PROPERTY_JOBID}, (array)$job);
|
||||
|
||||
// If an error occurred during while updating in database
|
||||
if (isError($dbResult))
|
||||
{
|
||||
$job->{self::PROPERTY_ERROR} = getError($dbResult); // retrieve the cause and store it in job object
|
||||
$errorOccurred = true; // set error occurred flag
|
||||
}
|
||||
else // otherwise
|
||||
{
|
||||
$dbNewTriggeredJobResult = $this->_addNewTriggeredJobToQueue(
|
||||
$type,
|
||||
$job,
|
||||
array($job->status)
|
||||
);
|
||||
// If an error occurred during while inserting in database
|
||||
if (isError($dbNewTriggeredJobResult)) return $dbNewTriggeredJobResult;
|
||||
}
|
||||
}
|
||||
else // otherwise
|
||||
{
|
||||
$errorOccurred = true; // set error occurred flag
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If an error occurred then returns the results in an error object
|
||||
if ($errorOccurred) return error($results);
|
||||
|
||||
return success($results); // otherwise return results in a success object
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* Checks the job object structure when needed for insert
|
||||
*/
|
||||
private function _checkNewJobStructure(&$job)
|
||||
{
|
||||
// If job is a valid object and contains the required properties AND does NOT already contain the property error
|
||||
if (is_object($job)
|
||||
&& property_exists($job, self::PROPERTY_STATUS)
|
||||
&& !property_exists($job, self::PROPERTY_ERROR))
|
||||
{
|
||||
return true; // it is valid!
|
||||
}
|
||||
|
||||
// If not object then object it!
|
||||
if (!is_object($job)) $job = new stdClass();
|
||||
|
||||
// If an error property was not already previously stored then store an error message in job object
|
||||
if (!property_exists($job, self::PROPERTY_ERROR))
|
||||
{
|
||||
$job->{self::PROPERTY_ERROR} = 'The structure of the provided job is not valid';
|
||||
}
|
||||
|
||||
return false; // better sorry than wrong
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the job object structure when needed for update
|
||||
*/
|
||||
private function _checkUpdateJobStructure(&$job)
|
||||
{
|
||||
// If job is a valid object
|
||||
if (is_object($job) && property_exists($job, self::PROPERTY_JOBID)) return true; // it is valid!
|
||||
|
||||
// If not object then object it!
|
||||
if (!is_object($job)) $job = new stdClass();
|
||||
|
||||
// If an error property was not already previously stored then store an error message in job object
|
||||
if (!property_exists($job, self::PROPERTY_ERROR))
|
||||
{
|
||||
$job->{self::PROPERTY_ERROR} = 'The structure of the provided job is not valid';
|
||||
}
|
||||
|
||||
return false; // better sorry than wrong
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given job contains a valid type
|
||||
*/
|
||||
private function _checkJobType($type, $types)
|
||||
{
|
||||
return $this->_inArray($type, $types, self::PROPERTY_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given job contains a valid status
|
||||
*/
|
||||
private function _checkJobStatus(&$job, $statuses)
|
||||
{
|
||||
// If the given job doesn't have the property status then it is not valid
|
||||
if (!isset($job->{self::PROPERTY_STATUS}))
|
||||
{
|
||||
$found = false;
|
||||
}
|
||||
else // otherwise test if it valid
|
||||
{
|
||||
$found = $this->_inArray($job->{self::PROPERTY_STATUS}, $statuses, self::PROPERTY_STATUS);
|
||||
}
|
||||
|
||||
// No status was found and does NOT already contain the property error
|
||||
if (!$found && !property_exists($job, self::PROPERTY_ERROR))
|
||||
{
|
||||
$job->{self::PROPERTY_ERROR} = 'The provided status of this job is not valid'; // store the error message in the object
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search in an array the given value
|
||||
* The elements of the given array are objects
|
||||
* The given value is compared with the property specified by the $propertyName parameter of each object of the given array
|
||||
*/
|
||||
private function _inArray($value, $array, $propertyName)
|
||||
{
|
||||
$found = false;
|
||||
|
||||
foreach ($array as $element)
|
||||
{
|
||||
if ($value == $element->{$propertyName})
|
||||
{
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop not allowed properties from the given job
|
||||
*/
|
||||
private function _dropNotAllowedPropertiesNewJob(&$job)
|
||||
{
|
||||
unset($job->{self::PROPERTY_JOBID});
|
||||
unset($job->{self::PROPERTY_CREATIONTIME});
|
||||
unset($job->{self::PROPERTY_TYPE});
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop not allowed properties from the given job
|
||||
*/
|
||||
private function _dropNotAllowedPropertiesUpdateJob(&$job)
|
||||
{
|
||||
unset($job->{self::PROPERTY_CREATIONTIME});
|
||||
unset($job->{self::PROPERTY_TYPE});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add e new triggered job to the jobs queue
|
||||
* NOTE:
|
||||
* - In this method there are less checks compared to addNewJobsToQueue method because
|
||||
* the new jobs that will be added are generate in this method
|
||||
* - Job ids in this case are not returned, therefore the caller is not going to be informed about these new jobs
|
||||
*/
|
||||
private function _addNewTriggeredJobToQueue($type, $job, $triggeredStatuses)
|
||||
{
|
||||
// Get all the job trigggers for the given type and for the given statuses
|
||||
$dbTriggersResult = $this->_ci->JobTriggersModel->getJobtriggersByTypeStatuses($type, $triggeredStatuses);
|
||||
|
||||
// If an error occurred while getting job triggers from database then return it
|
||||
if (isError($dbTriggersResult)) return $dbTriggersResult;
|
||||
if (hasData($dbTriggersResult)) // If triggers were retrieved
|
||||
{
|
||||
// The output of the trigging job is the input of the trigged job
|
||||
$triggeredJobInput = null;
|
||||
if (isset($job->{self::PROPERTY_OUTPUT})) $triggeredJobInput = $job->{self::PROPERTY_OUTPUT};
|
||||
|
||||
// For each trigger
|
||||
foreach (getData($dbTriggersResult) as $trigger)
|
||||
{
|
||||
$triggeredJob = array(
|
||||
self::PROPERTY_TYPE => $trigger->following_type, // the new type is the one defined in tbl_jobtriggers
|
||||
self::PROPERTY_STATUS => self::STATUS_NEW, // new job status is new
|
||||
self::PROPERTY_INPUT => $triggeredJobInput // new job input
|
||||
);
|
||||
|
||||
// Try to insert the single job into database
|
||||
$dbNewJob = $this->_ci->JobsQueueModel->insert($triggeredJob);
|
||||
// If an error occurred during while inserting in database
|
||||
if (isError($dbNewJob)) return $dbNewJob;
|
||||
}
|
||||
}
|
||||
|
||||
return success(); // if here then it was a success!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ class PermissionLib
|
||||
|
||||
$accessType = '';
|
||||
|
||||
// Checks if the required access type is compliant with the HTTP method (GET => r, POST => w)
|
||||
// Set the access type
|
||||
if (strpos($requiredAccessType, PermissionLib::READ_RIGHT) !== false)
|
||||
{
|
||||
$accessType = PermissionLib::SELECT_RIGHT; // S
|
||||
@@ -184,12 +184,12 @@ class PermissionLib
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('The given permission array does not contain the called method or is not correctly set');
|
||||
show_error('The given permission array does not contain the given method or is not correctly set');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('You must give the permissions array as parameter to the constructor of the controller');
|
||||
show_error('The given permissions is not a valid array or it is an empty one');
|
||||
}
|
||||
|
||||
return $checkPermissions;
|
||||
|
||||
@@ -41,4 +41,35 @@ class Bisverwendung_model extends DB_Model
|
||||
|
||||
return $this->loadWhere($condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Verwendungen of the user, optionally in a time span.
|
||||
* @param string $uid
|
||||
* @param string $beginn
|
||||
* @param string $ende
|
||||
* @return array
|
||||
*/
|
||||
public function getVerwendungen($uid, $beginn = null, $ende = null)
|
||||
{
|
||||
$params = array($uid);
|
||||
|
||||
$qry = 'SELECT * FROM bis.tbl_bisverwendung
|
||||
WHERE mitarbeiter_uid = ?';
|
||||
|
||||
if (isset($beginn))
|
||||
{
|
||||
$qry .= ' AND ( ende >= ? OR ende IS NULL )';
|
||||
$params[] = $beginn;
|
||||
}
|
||||
|
||||
if (isset($ende))
|
||||
{
|
||||
$qry .= ' AND ( beginn <= ? OR beginn IS NULL )';
|
||||
$params[] = $ende;
|
||||
}
|
||||
|
||||
$qry .= ' ORDER BY beginn, ende';
|
||||
|
||||
return $this->execQuery($qry, $params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,4 +182,30 @@ class Prestudentstatus_model extends DB_Model
|
||||
return success(array());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getLastStatuses
|
||||
*/
|
||||
public function getLastStatusPerson($person_id, $studiensemester_kurzbz = null)
|
||||
{
|
||||
$query = 'SELECT *
|
||||
FROM public.tbl_prestudent p
|
||||
JOIN (
|
||||
SELECT DISTINCT ON(prestudent_id) *
|
||||
FROM public.tbl_prestudentstatus
|
||||
WHERE prestudent_id IN (SELECT prestudent_id FROM public.tbl_prestudent WHERE person_id = ?)
|
||||
ORDER BY prestudent_id, datum desc, insertamum desc
|
||||
) ps USING(prestudent_id)
|
||||
JOIN public.tbl_status USING(status_kurzbz)';
|
||||
|
||||
$parametersArray = array($person_id);
|
||||
|
||||
if ($studiensemester_kurzbz != '')
|
||||
{
|
||||
array_push($parametersArray, $studiensemester_kurzbz);
|
||||
$query .= ' AND ps.studiensemester_kurzbz = ?';
|
||||
}
|
||||
|
||||
return $this->execQuery($query, $parametersArray);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class Studiensemester_model extends DB_Model
|
||||
$days = 60;
|
||||
}
|
||||
|
||||
$query = 'SELECT studiensemester_kurzbz
|
||||
$query = 'SELECT studiensemester_kurzbz, start, ende
|
||||
FROM public.tbl_studiensemester
|
||||
WHERE start < NOW() - \'' . $days . ' DAYS\'::INTERVAL
|
||||
ORDER BY start DESC
|
||||
|
||||
@@ -33,4 +33,96 @@ class Benutzer_model extends DB_Model
|
||||
|
||||
return $this->execQuery($sql, array($person_id, $oe_kurzbz));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if alias exists
|
||||
* @param $alias
|
||||
*/
|
||||
public function aliasExists($alias)
|
||||
{
|
||||
$this->addSelect('1');
|
||||
$result = $this->loadWhere(array('alias' => $alias));
|
||||
|
||||
if (!isError($result))
|
||||
{
|
||||
if (hasData($result))
|
||||
{
|
||||
$result = success(array(true));
|
||||
}
|
||||
else if (!hasData($result))
|
||||
{
|
||||
$result = success(array(false));
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates alias for a uid.
|
||||
* @param $uid
|
||||
* @return array the alias if newly generated
|
||||
*/
|
||||
public function generateAlias($uid)
|
||||
{
|
||||
$aliasres = '';
|
||||
$this->addSelect('vorname, nachname');
|
||||
$this->addJoin('public.tbl_person', 'person_id');
|
||||
$nameresult = $this->loadWhere(array('uid' => $uid));
|
||||
|
||||
if (hasData($nameresult))
|
||||
{
|
||||
$aliasdata = getData($nameresult);
|
||||
$alias = $this->_sanitizeAliasName($aliasdata[0]->vorname).'.'.$this->_sanitizeAliasName($aliasdata[0]->nachname);
|
||||
$aliasexists = $this->aliasExists($alias);
|
||||
|
||||
if (hasData($aliasexists) && !getData($aliasexists)[0])
|
||||
$aliasres = $alias;
|
||||
}
|
||||
return success($aliasres);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* Sanitizes a string used for alias. Replaces special characters, spaces, upper case.
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
private function _sanitizeAliasName($str)
|
||||
{
|
||||
$enc = 'UTF-8';
|
||||
|
||||
$acentos = array(
|
||||
'A' => '/À|Á|Â|Ã|Å/',
|
||||
'Ae' => '/Ä/',
|
||||
'a' => '/à|á|â|ã|å/',
|
||||
'ae'=> '/ä/',
|
||||
'C' => '/Ç/',
|
||||
'c' => '/ç/',
|
||||
'E' => '/È|É|Ê|Ë/',
|
||||
'e' => '/è|é|ê|ë/',
|
||||
'I' => '/Ì|Í|Î|Ï/',
|
||||
'i' => '/ì|í|î|ï/',
|
||||
'N' => '/Ñ/',
|
||||
'n' => '/ñ/',
|
||||
'O' => '/Ò|Ó|Ô|Õ/',
|
||||
'Oe' => '/Ö/',
|
||||
'o' => '/ò|ó|ô|õ/',
|
||||
'oe' => '/ö/',
|
||||
'U' => '/Ù|Ú|Û/',
|
||||
'Ue' => '/Ü/',
|
||||
'u' => '/ù|ú|û/',
|
||||
'ue' => '/ü/',
|
||||
'Y' => '/Ý/',
|
||||
'y' => '/ý|ÿ/',
|
||||
'a.' => '/ª/',
|
||||
'o.' => '/º/',
|
||||
'ss' => '/ß/',
|
||||
);
|
||||
|
||||
$str = preg_replace($acentos, array_keys($acentos), htmlentities($str,ENT_NOQUOTES, $enc));
|
||||
return mb_strtolower(str_replace(' ','_', $str));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,44 @@ class Benutzerfunktion_model extends DB_Model
|
||||
$this->pk = 'benutzerfunktion_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Lädt alle Benutzerfunktionen zu einer UID
|
||||
* @param type $uid UID des Mitarbeiters
|
||||
* @param type $funktion_kurzbz OPTIONAL Kurzbezeichnung der Funktion
|
||||
* @param type $startZeitraum OPTIONAL Start Zeitraum in dem die Funktion aktiv ist
|
||||
* @param type $endeZeitraum OPTIONAL Ende Zeitraum in dem die Funktion aktiv ist
|
||||
* @return boolean
|
||||
*/
|
||||
public function getBenutzerFunktionByUid($uid, $funktion_kurzbz=null, $startZeitraum=null, $endeZeitraum=null)
|
||||
{
|
||||
$params = array($uid);
|
||||
|
||||
$qry = "SELECT tbl_benutzerfunktion.*, tbl_organisationseinheit.bezeichnung as organisationseinheit_bezeichnung,
|
||||
tbl_organisationseinheit.organisationseinheittyp_kurzbz
|
||||
FROM public.tbl_benutzerfunktion
|
||||
LEFT JOIN public.tbl_organisationseinheit USING(oe_kurzbz)
|
||||
WHERE uid=?";
|
||||
if(!is_null($funktion_kurzbz))
|
||||
{
|
||||
$qry .= ' AND funktion_kurzbz = ?';
|
||||
$params[] = $funktion_kurzbz;
|
||||
}
|
||||
if(!is_null($startZeitraum))
|
||||
{
|
||||
$qry .=' AND (datum_bis IS NULL OR datum_bis >= ?)';
|
||||
$params[] = $startZeitraum;
|
||||
}
|
||||
if(!is_null($endeZeitraum))
|
||||
{
|
||||
$qry .=' AND (datum_von IS NULL OR datum_von <= ?)';
|
||||
$params[] = $endeZeitraum;
|
||||
}
|
||||
|
||||
$qry .= "ORDER BY datum_bis NULLS LAST, datum_von NULLS LAST;";
|
||||
|
||||
return $this->execQuery($qry, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Benutzerfunktion using the person_id
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,7 @@ class Kontakt_model extends DB_Model
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_kontakt';
|
||||
$this->pk = 'kontakt_id';
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
}
|
||||
|
||||
public function getWholeKontakt($kontakt_id, $person_id = null, $kontakttyp = null)
|
||||
@@ -59,7 +60,66 @@ class Kontakt_model extends DB_Model
|
||||
|
||||
return $this->execQuery($sql, array($person_id, $kontakttyp));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Laedt einen Kontakt eines Standortes
|
||||
* Es wird nur der erste Eintrag zurueckgeliefert!
|
||||
* @param $standort_id
|
||||
* @param $kontakttyp
|
||||
*/
|
||||
public function getFirmaKontakttyp($standort_id, $kontakttyp)
|
||||
{
|
||||
if (!is_numeric($standort_id))
|
||||
{
|
||||
return error('StandortID ist ungueltig');
|
||||
}
|
||||
|
||||
$qry = "SELECT kontakt, kontakt_id FROM public.tbl_kontakt WHERE standort_id=? AND kontakttyp=? ORDER BY kontakt_id LIMIT 1;";
|
||||
|
||||
return $this->execQuery($qry, array('standort_id' => $standort_id, 'kontakttyp' => $kontakttyp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Firmentelefon for a uid, can be Vorwahl with Telefonklappe or Firmenhandy
|
||||
* @param $uid
|
||||
*/
|
||||
public function getFirmentelefon($uid)
|
||||
{
|
||||
$firmentelefon = success(array());
|
||||
|
||||
$this->MitarbeiterModel->addSelect('standort_id, telefonklappe, person_id');
|
||||
$this->MitarbeiterModel->addJoin('public.tbl_benutzer', 'tbl_mitarbeiter.mitarbeiter_uid = tbl_benutzer.uid');
|
||||
$mitarbeiter = $this->MitarbeiterModel->load(array('uid' => $uid));
|
||||
|
||||
if (hasData($mitarbeiter))
|
||||
{
|
||||
$mitarbeiter = getData($mitarbeiter);
|
||||
if (isEmptyString($mitarbeiter[0]->telefonklappe))
|
||||
{
|
||||
$this->addSelect('kontakt');
|
||||
$this->addOrder('updateamum, insertamum', 'DESC');
|
||||
$this->addLimit(1);
|
||||
$firmenhandy = $this->loadWhere(array('person_id' => $mitarbeiter[0]->person_id, 'kontakttyp' => 'firmenhandy'));
|
||||
if (hasData($firmenhandy))
|
||||
{
|
||||
$firmenhandy = getData($firmenhandy);
|
||||
$firmentelefon = success(array('kontakt' => $firmenhandy[0]->kontakt, 'telefonklappe' => ''));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$firmaKontakttyp = $this->getFirmaKontakttyp($mitarbeiter[0]->standort_id, 'telefon');
|
||||
if (hasData($firmaKontakttyp))
|
||||
{
|
||||
$vorwahl = getData($firmaKontakttyp);
|
||||
$vorwahl = $vorwahl[0]->kontakt;
|
||||
$firmentelefon = success(array('kontakt' => $vorwahl, 'telefonklappe' => $mitarbeiter[0]->telefonklappe));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $firmentelefon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all latest contact data of person, where Zustellung is true
|
||||
* @param $person_id
|
||||
@@ -71,13 +131,13 @@ class Kontakt_model extends DB_Model
|
||||
$this->addJoin('public.tbl_standort', 'standort_id', 'LEFT');
|
||||
$this->addJoin('public.tbl_firma', 'firma_id', 'LEFT');
|
||||
$this->addOrder('kontakttyp, kontakt, tbl_kontakt.updateamum, tbl_kontakt.insertamum');
|
||||
|
||||
|
||||
return $this->loadWhere(array(
|
||||
'zustellung' => TRUE,
|
||||
'person_id' => $person_id
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all latest phones of person where zustellung is true. Ordered by
|
||||
* telefon > mobil > firmenhandy > else.
|
||||
@@ -96,7 +156,7 @@ class Kontakt_model extends DB_Model
|
||||
AND kontakttyp IN (\'telefon\', \'mobil\', \'firmenhandy\')
|
||||
ORDER BY kontakttyp, kontakt, kontakt.updateamum
|
||||
)
|
||||
|
||||
|
||||
SELECT * FROM latest_phones
|
||||
ORDER BY
|
||||
CASE
|
||||
@@ -106,7 +166,7 @@ class Kontakt_model extends DB_Model
|
||||
ELSE 3
|
||||
END
|
||||
';
|
||||
|
||||
|
||||
return $this->execQuery($qry, array($person_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,4 +40,96 @@ class Mitarbeiter_model extends DB_Model
|
||||
return success(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt das Personal
|
||||
*
|
||||
* @param $aktiv wenn true werden nur aktive geladen, wenn false dann nur inaktve, wenn null dann alle
|
||||
* @param $fix wenn true werden nur fixangestellte geladen
|
||||
* @param $verwendung wenn true werden alle geladen die eine BIS-Verwendung eingetragen haben
|
||||
* @param $personaccount wenn true werden alle geladen die personalnr >= 0 haben, also "echte" Personaccounts
|
||||
* @return array
|
||||
*/
|
||||
public function getPersonal($aktiv, $fix, $verwendung, $personaccount = null)
|
||||
{
|
||||
$qry = "SELECT DISTINCT ON(mitarbeiter_uid) staatsbuergerschaft, geburtsnation, sprache, anrede, titelpost, titelpre,
|
||||
nachname, vorname, vornamen, gebdatum, gebort, gebzeit, tbl_person.anmerkung AS person_anmerkung, homepage, svnr, ersatzkennzeichen, familienstand,
|
||||
geschlecht, anzahlkinder, tbl_person.insertamum AS person_insertamum, tbl_person.updateamum as person_updateamum,
|
||||
tbl_person.updatevon AS person_updatevon, kompetenzen, kurzbeschreibung, zugangscode, zugangscode_timestamp, bpk,
|
||||
tbl_benutzer.*, tbl_mitarbeiter.*, akt_funk.oe_kurzbz AS funktionale_zuordnung, akt_funk.wochenstunden
|
||||
FROM ((public.tbl_mitarbeiter JOIN public.tbl_benutzer ON(mitarbeiter_uid=uid))
|
||||
JOIN public.tbl_person USING(person_id))
|
||||
LEFT JOIN public.tbl_benutzerfunktion USING(uid)
|
||||
LEFT JOIN public.tbl_benutzerfunktion akt_funk ON tbl_mitarbeiter.mitarbeiter_uid = akt_funk.uid AND akt_funk.funktion_kurzbz = 'fachzuordnung'
|
||||
AND (akt_funk.datum_von IS NULL OR akt_funk.datum_von <= now()) AND (akt_funk.datum_bis IS NULL OR akt_funk.datum_bis >= now())
|
||||
WHERE true";
|
||||
|
||||
if ($fix === true)
|
||||
$qry .= " AND fixangestellt=true";
|
||||
elseif ($fix === false)
|
||||
$qry .= " AND fixangestellt=false";
|
||||
|
||||
if ($aktiv === true)
|
||||
$qry .= " AND tbl_benutzer.aktiv=true";
|
||||
elseif ($aktiv === false)
|
||||
$qry .= " AND tbl_benutzer.aktiv=false";
|
||||
|
||||
if ($verwendung === true)
|
||||
{
|
||||
$qry.=" AND EXISTS(SELECT * FROM bis.tbl_bisverwendung WHERE (ende>now() or ende is null) AND tbl_bisverwendung.mitarbeiter_uid=tbl_mitarbeiter.mitarbeiter_uid)";
|
||||
}
|
||||
elseif ($verwendung === false)
|
||||
{
|
||||
$qry.=" AND NOT EXISTS(SELECT * FROM bis.tbl_bisverwendung WHERE (ende>now() or ende is null) AND tbl_bisverwendung.mitarbeiter_uid=tbl_mitarbeiter.mitarbeiter_uid)";
|
||||
}
|
||||
|
||||
if ($personaccount === true)
|
||||
$qry .= " AND tbl_mitarbeiter.personalnummer >= 0";
|
||||
elseif ($personaccount === false)
|
||||
$qry .= " AND tbl_mitarbeiter.personalnummer < 0";
|
||||
|
||||
return $this->execQuery($qry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt ein Array mit den UIDs der Vorgesetzten zurück
|
||||
* @return object
|
||||
*/
|
||||
public function getVorgesetzte($uid, $datum_von = null, $datum_bis = null)
|
||||
{
|
||||
$datum_von_var = isset($datum_von) ? '?' : 'now()';
|
||||
$datum_bis_var = isset($datum_bis) ? '?' : 'now()';
|
||||
$qry = "SELECT
|
||||
DISTINCT uid as vorgesetzter
|
||||
FROM
|
||||
public.tbl_benutzerfunktion
|
||||
WHERE
|
||||
funktion_kurzbz='Leitung' AND
|
||||
(datum_von is null OR datum_von<=%s) AND
|
||||
(datum_bis is null OR datum_bis>=%s) AND
|
||||
oe_kurzbz in (SELECT oe_kurzbz
|
||||
FROM public.tbl_benutzerfunktion
|
||||
WHERE
|
||||
funktion_kurzbz='oezuordnung' AND uid=? AND
|
||||
(datum_von is null OR datum_von<=%s) AND
|
||||
(datum_bis is null OR datum_bis>=%s)
|
||||
);";
|
||||
|
||||
$qry = sprintf($qry, $datum_von_var, $datum_bis_var, $datum_von_var, $datum_bis_var);
|
||||
|
||||
$params = array();
|
||||
if (isset($datum_von))
|
||||
$params[] = $datum_von;
|
||||
if (isset($datum_bis))
|
||||
$params[] = $datum_bis;
|
||||
|
||||
$params[] = $uid;
|
||||
|
||||
if (isset($datum_von))
|
||||
$params[] = $datum_von;
|
||||
if (isset($datum_bis))
|
||||
$params[] = $datum_bis;
|
||||
|
||||
return $this->execQuery($qry, $params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,14 @@ class Zeitaufzeichnung_model extends DB_Model
|
||||
$this->dbTable = 'campus.tbl_zeitaufzeichnung';
|
||||
$this->pk = 'zeitaufzeichnung_id';
|
||||
}
|
||||
|
||||
public function deleteEntriesForCurrentDay()
|
||||
{
|
||||
$today = date('Y-m-d');
|
||||
$qry = "DELETE FROM " . $this->dbTable . "
|
||||
WHERE start >= '" . $today . " 00:00:00'
|
||||
AND start <= '" . $today . " 23:59:59';";
|
||||
|
||||
return $this->execQuery($qry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,13 @@ class Zeitsperre_model extends DB_Model
|
||||
$this->dbTable = 'campus.tbl_zeitsperre';
|
||||
$this->pk = 'zeitsperre_id';
|
||||
}
|
||||
|
||||
public function deleteEntriesForCurrentDay()
|
||||
{
|
||||
$today = date('Y-m-d');
|
||||
$qry = "DELETE FROM " . $this->dbTable . "
|
||||
WHERE vondatum = '" . $today . "';";
|
||||
|
||||
return $this->execQuery($qry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class JobStatuses_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->dbTable = 'system.tbl_jobstatuses';
|
||||
$this->pk = 'status';
|
||||
$this->hasSequence = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class JobTriggers_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->dbTable = 'system.tbl_jobtriggers';
|
||||
$this->pk = array('type', 'status', 'followingType');
|
||||
$this->hasSequence = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getJobtriggersByTypeStatuses($type, $triggeredStatuses)
|
||||
{
|
||||
$query = 'SELECT jt.type,
|
||||
jt.status,
|
||||
jt.following_type
|
||||
FROM system.tbl_jobtriggers jt
|
||||
WHERE jt.type = ?
|
||||
AND jt.status IN ?
|
||||
ORDER BY jt.type, jt.status';
|
||||
|
||||
return $this->execQuery($query, array($type, $triggeredStatuses));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class JobTypes_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->dbTable = 'system.tbl_jobtypes';
|
||||
$this->pk = 'type';
|
||||
$this->hasSequence = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
class JobsQueue_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->dbTable = 'system.tbl_jobsqueue';
|
||||
$this->pk = 'jobid';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
$this->load->view(
|
||||
'templates/FHC-Header',
|
||||
array(
|
||||
'title' => 'Jobs Queue Viewer',
|
||||
'jquery' => true,
|
||||
'jqueryui' => true,
|
||||
'bootstrap' => true,
|
||||
'fontawesome' => true,
|
||||
'sbadmintemplate' => true,
|
||||
'tablesorter' => true,
|
||||
'ajaxlib' => true,
|
||||
'filterwidget' => true,
|
||||
'navigationwidget' => true,
|
||||
'phrases' => array(
|
||||
'global' => array('mailAnXversandt'),
|
||||
'ui' => array('bitteEintragWaehlen')
|
||||
),
|
||||
'customCSSs' => 'public/css/sbadmin2/tablesort_bootstrap.css',
|
||||
'customJSs' => array('public/js/bootstrapper.js')
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
|
||||
<?php echo $this->widgetlib->widget('NavigationWidget'); ?>
|
||||
|
||||
<div id="page-wrapper">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h3 class="page-header">
|
||||
Jobs Queue Viewer
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<?php $this->load->view('system/jq/jobsQueueViewerData.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<?php $this->load->view('templates/FHC-Footer'); ?>
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
$filterWidgetArray = array(
|
||||
'query' => '
|
||||
SELECT jq.jobid AS "JobId",
|
||||
jq.creationtime AS "CreationTime",
|
||||
jq.type AS "Type",
|
||||
jq.status AS "Status",
|
||||
jq.starttime AS "StartTime",
|
||||
jq.endtime AS "EndTime",
|
||||
jq.insertvon AS "UserService"
|
||||
FROM system.tbl_jobsqueue jq
|
||||
ORDER BY jq.creationtime DESC, jq.starttime DESC, jq.endtime DESC
|
||||
',
|
||||
'requiredPermissions' => 'admin',
|
||||
'datasetRepresentation' => 'tablesorter',
|
||||
'columnsAliases' => array(
|
||||
'Job id',
|
||||
'Creation time',
|
||||
'Type',
|
||||
'Status',
|
||||
'Start time',
|
||||
'End time',
|
||||
'User/Service'
|
||||
),
|
||||
'formatRow' => function($datasetRaw) {
|
||||
|
||||
$datasetRaw->CreationTime = date_format(date_create($datasetRaw->CreationTime), 'd.m.Y H:i:s');
|
||||
$datasetRaw->StartTime = date_format(date_create($datasetRaw->StartTime), 'd.m.Y H:i:s');
|
||||
$datasetRaw->EndTime = date_format(date_create($datasetRaw->EndTime), 'd.m.Y H:i:s');
|
||||
|
||||
return $datasetRaw;
|
||||
},
|
||||
'markRow' => function($datasetRaw) {
|
||||
|
||||
$mark = '';
|
||||
|
||||
if ($datasetRaw->Status == JobsQueueLib::STATUS_FAILED)
|
||||
{
|
||||
$mark = 'text-red';
|
||||
}
|
||||
|
||||
if ($datasetRaw->Status == JobsQueueLib::STATUS_DONE)
|
||||
{
|
||||
$mark = 'text-green';
|
||||
}
|
||||
|
||||
if ($datasetRaw->Status == JobsQueueLib::STATUS_RUNNING)
|
||||
{
|
||||
$mark = 'text-orange';
|
||||
}
|
||||
|
||||
if ($datasetRaw->Status == JobsQueueLib::STATUS_NEW)
|
||||
{
|
||||
$mark = 'text-info';
|
||||
}
|
||||
|
||||
return $mark;
|
||||
}
|
||||
);
|
||||
|
||||
$filterWidgetArray['app'] = 'core';
|
||||
$filterWidgetArray['datasetName'] = 'jq';
|
||||
$filterWidgetArray['filter_id'] = $this->input->get('filter_id');
|
||||
|
||||
echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray);
|
||||
?>
|
||||
@@ -2,7 +2,7 @@
|
||||
$this->load->view(
|
||||
'templates/FHC-Header',
|
||||
array(
|
||||
'title' => 'Logs viewer',
|
||||
'title' => 'Logs Viewer',
|
||||
'jquery' => true,
|
||||
'jqueryui' => true,
|
||||
'bootstrap' => true,
|
||||
@@ -32,7 +32,7 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h3 class="page-header">
|
||||
JobsViewer
|
||||
Job Logs Viewer
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -295,6 +295,9 @@ define('STUDIENGANG_KZ_QUALIFIKATIONKURSE', null);
|
||||
// Gibt an ob der Login ins Testtool ueber das Bewerbungstool stattfindet oder nicht
|
||||
define('TESTTOOL_LOGIN_BEWERBUNGSTOOL', false);
|
||||
|
||||
// Prueft ob Buchungen bereits ins SAP uebertragen wurden und sperrt ggf die Bearbeitung
|
||||
define('BUCHUNGEN_CHECK_SAP', true);
|
||||
|
||||
// Gibt an, ob im FAS die Zahlungsbestaetigungen zum Download / im CIS generell die Zahlungen angezeigt werden
|
||||
define ('ZAHLUNGSBESTAETIGUNG_ANZEIGEN', true);
|
||||
?>
|
||||
|
||||
@@ -280,6 +280,35 @@ function NotePruefungAnlegen($studiensemester_kurzbz, $student_uid, $lehrveranst
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft ob die Kontobuchung bereits ins SAP Ubertragen wurde oder noch geändert werden darf
|
||||
*/
|
||||
function isBuchungAllowedToChange($buchung_obj)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if(defined('BUCHUNGEN_CHECK_SAP') && BUCHUNGEN_CHECK_SAP == true)
|
||||
{
|
||||
$qry = "SELECT * FROM sync.tbl_sap_salesorder WHERE buchungsnr=".$db->db_add_param($buchung_obj->buchungsnr);
|
||||
if ($buchung_obj->buchungsnr_verweis != '')
|
||||
$qry .= " OR buchungsnr=".$db->db_add_param($buchung_obj->buchungsnr_verweis);
|
||||
|
||||
if ($result = $db->db_query($qry))
|
||||
{
|
||||
if($db->db_num_rows($result) > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!$error)
|
||||
{
|
||||
|
||||
@@ -1952,27 +1981,35 @@ if(!$error)
|
||||
}
|
||||
else
|
||||
{
|
||||
$buchung->betrag = $_POST['betrag'];
|
||||
$buchung->buchungsdatum = $_POST['buchungsdatum'];
|
||||
$buchung->buchungstext = $_POST['buchungstext'];
|
||||
$buchung->mahnspanne = $_POST['mahnspanne'];
|
||||
$buchung->buchungstyp_kurzbz = $_POST['buchungstyp_kurzbz'];
|
||||
$buchung->studiensemester_kurzbz = $_POST['studiensemester_kurzbz'];
|
||||
$buchung->studiengang_kz = $_POST['studiengang_kz'];
|
||||
$buchung->credit_points = $_POST['credit_points'];
|
||||
$buchung->new = false;
|
||||
$buchung->updateamum = date('Y-m-d H:i:s');
|
||||
$buchung->updatevon = $user;
|
||||
$buchung->anmerkung = $_POST['anmerkung'];
|
||||
|
||||
if($buchung->save())
|
||||
if(isBuchungAllowedToChange($buchung))
|
||||
{
|
||||
$return = true;
|
||||
$buchung->betrag = $_POST['betrag'];
|
||||
$buchung->buchungsdatum = $_POST['buchungsdatum'];
|
||||
$buchung->buchungstext = $_POST['buchungstext'];
|
||||
$buchung->mahnspanne = $_POST['mahnspanne'];
|
||||
$buchung->buchungstyp_kurzbz = $_POST['buchungstyp_kurzbz'];
|
||||
$buchung->studiensemester_kurzbz = $_POST['studiensemester_kurzbz'];
|
||||
$buchung->studiengang_kz = $_POST['studiengang_kz'];
|
||||
$buchung->credit_points = $_POST['credit_points'];
|
||||
$buchung->new = false;
|
||||
$buchung->updateamum = date('Y-m-d H:i:s');
|
||||
$buchung->updatevon = $user;
|
||||
$buchung->anmerkung = $_POST['anmerkung'];
|
||||
|
||||
if($buchung->save())
|
||||
{
|
||||
$return = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$return = false;
|
||||
$errormsg = 'Fehler beim Speichern:'.$buchung->errormsg;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$return = false;
|
||||
$errormsg = 'Fehler beim Speichern:'.$buchung->errormsg;
|
||||
$errormsg = 'Buchung wurde bereits übertragen und darf nicht geändert werden';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2025,26 +2062,34 @@ if(!$error)
|
||||
{
|
||||
if($buchung->buchungsnr_verweis=='')
|
||||
{
|
||||
$kto = new konto();
|
||||
//$buchung->betrag*(-1);
|
||||
$buchung->betrag = $kto->getDifferenz($buchungsnr);
|
||||
$buchung->buchungsdatum = $gegenbuchungsdatum;
|
||||
$buchung->mahnspanne = '0';
|
||||
$buchung->buchungsnr_verweis = $buchung->buchungsnr;
|
||||
$buchung->new = true;
|
||||
$buchung->insertamum = date('Y-m-d H:i:s');
|
||||
$buchung->insertvon = $user;
|
||||
$buchung->anmerkung = '';
|
||||
|
||||
if($buchung->save())
|
||||
if(isBuchungAllowedToChange($buchung))
|
||||
{
|
||||
//$data = $buchung->buchungsnr;
|
||||
$return = true;
|
||||
$kto = new konto();
|
||||
//$buchung->betrag*(-1);
|
||||
$buchung->betrag = $kto->getDifferenz($buchungsnr);
|
||||
$buchung->buchungsdatum = $gegenbuchungsdatum;
|
||||
$buchung->mahnspanne = '0';
|
||||
$buchung->buchungsnr_verweis = $buchung->buchungsnr;
|
||||
$buchung->new = true;
|
||||
$buchung->insertamum = date('Y-m-d H:i:s');
|
||||
$buchung->insertvon = $user;
|
||||
$buchung->anmerkung = '';
|
||||
|
||||
if($buchung->save())
|
||||
{
|
||||
//$data = $buchung->buchungsnr;
|
||||
$return = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$return = false;
|
||||
$errormsg .= "\n".'Fehler beim Speichern:'.$buchung->errormsg;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$return = false;
|
||||
$errormsg .= "\n".'Fehler beim Speichern:'.$buchung->errormsg;
|
||||
$errormsg .= "\n".'Buchung wurde bereits Übertragen und darf nicht geändert werden';
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2094,14 +2139,23 @@ if(!$error)
|
||||
}
|
||||
else
|
||||
{
|
||||
if($buchung->delete($_POST['buchungsnr']))
|
||||
if(isBuchungAllowedToChange($buchung))
|
||||
{
|
||||
$return = true;
|
||||
if($buchung->delete($_POST['buchungsnr']))
|
||||
{
|
||||
$return = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$errormsg = $buchung->errormsg;
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$errormsg = $buchung->errormsg;
|
||||
$error = true;
|
||||
$return = false;
|
||||
$errormsg = 'Diese Buchung darf nicht gelöscht werden da diese bereits übertragen wurde';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+206
-1
@@ -3840,6 +3840,195 @@ if ($result = $db->db_query("SELECT 1 FROM pg_class WHERE relname = 'unq_idx_abl
|
||||
}
|
||||
}
|
||||
|
||||
// Creates table system.tbl_jobstatuses if it doesn't exist and grants privileges
|
||||
if (!$result = @$db->db_query('SELECT 1 FROM system.tbl_jobstatuses LIMIT 1'))
|
||||
{
|
||||
$qry = 'CREATE TABLE system.tbl_jobstatuses (
|
||||
status character varying(64) NOT NULL
|
||||
);
|
||||
|
||||
COMMENT ON TABLE system.tbl_jobstatuses IS \'All possible job statuses\';
|
||||
COMMENT ON COLUMN system.tbl_jobstatuses.status IS \'Job status value and primary key\';
|
||||
|
||||
ALTER TABLE ONLY system.tbl_jobstatuses ADD CONSTRAINT pk_jobstatuses PRIMARY KEY (status);
|
||||
|
||||
INSERT INTO system.tbl_jobstatuses(status) VALUES(\'new\');
|
||||
INSERT INTO system.tbl_jobstatuses(status) VALUES(\'running\');
|
||||
INSERT INTO system.tbl_jobstatuses(status) VALUES(\'done\');
|
||||
INSERT INTO system.tbl_jobstatuses(status) VALUES(\'failed\');
|
||||
';
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_jobstatuses: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>system.tbl_jobstatuses table created';
|
||||
|
||||
$qry = 'GRANT SELECT ON TABLE system.tbl_jobstatuses TO web;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_jobstatuses: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Granted privileges to <strong>web</strong> on system.tbl_jobstatuses';
|
||||
|
||||
$qry = 'GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE system.tbl_jobstatuses TO vilesci;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_jobstatuses: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Granted privileges to <strong>vilesci</strong> on system.tbl_jobstatuses';
|
||||
}
|
||||
|
||||
// Creates table system.tbl_jobtypes if it doesn't exist and grants privileges
|
||||
if (!$result = @$db->db_query('SELECT 1 FROM system.tbl_jobtypes LIMIT 1'))
|
||||
{
|
||||
$qry = 'CREATE TABLE system.tbl_jobtypes (
|
||||
type character varying(128) NOT NULL,
|
||||
description text NOT NULL
|
||||
);
|
||||
|
||||
COMMENT ON TABLE system.tbl_jobtypes IS \'All possible job types\';
|
||||
COMMENT ON COLUMN system.tbl_jobtypes.type IS \'Job type value and primary key\';
|
||||
COMMENT ON COLUMN system.tbl_jobtypes.description IS \'Job type description\';
|
||||
|
||||
ALTER TABLE ONLY system.tbl_jobtypes ADD CONSTRAINT pk_jobtypes PRIMARY KEY (type);
|
||||
';
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_jobtypes: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>system.tbl_jobtypes table created';
|
||||
|
||||
$qry = 'GRANT SELECT ON TABLE system.tbl_jobtypes TO web;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_jobtypes: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Granted privileges to <strong>web</strong> on system.tbl_jobtypes';
|
||||
|
||||
$qry = 'GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE system.tbl_jobtypes TO vilesci;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_jobtypes: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Granted privileges to <strong>vilesci</strong> on system.tbl_jobtypes';
|
||||
}
|
||||
|
||||
// Creates table system.tbl_jobsqueue if it doesn't exist and grants privileges
|
||||
if (!$result = @$db->db_query('SELECT 1 FROM system.tbl_jobsqueue LIMIT 1'))
|
||||
{
|
||||
$qry = 'CREATE TABLE system.tbl_jobsqueue (
|
||||
jobid integer NOT NULL,
|
||||
type character varying(128) NOT NULL,
|
||||
creationtime timestamp without time zone DEFAULT now(),
|
||||
status character varying(64) NOT NULL,
|
||||
input jsonb,
|
||||
output jsonb,
|
||||
starttime timestamp without time zone,
|
||||
endtime timestamp without time zone,
|
||||
insertvon character varying(32),
|
||||
insertamum timestamp without time zone DEFAULT now()
|
||||
);
|
||||
|
||||
COMMENT ON TABLE system.tbl_jobsqueue IS \'Table to schedule/manage the jobs queue\';
|
||||
COMMENT ON COLUMN system.tbl_jobsqueue.jobid IS \'Primary key\';
|
||||
COMMENT ON COLUMN system.tbl_jobsqueue.type IS \'Job type\';
|
||||
COMMENT ON COLUMN system.tbl_jobsqueue.creationtime IS \'Job creation timestamp\';
|
||||
COMMENT ON COLUMN system.tbl_jobsqueue.status IS \'Job current status\';
|
||||
COMMENT ON COLUMN system.tbl_jobsqueue.input IS \'Job input in JSON format\';
|
||||
COMMENT ON COLUMN system.tbl_jobsqueue.output IS \'Job output in JSON format\';
|
||||
COMMENT ON COLUMN system.tbl_jobsqueue.starttime IS \'Job start timestamp\';
|
||||
COMMENT ON COLUMN system.tbl_jobsqueue.endtime IS \'Job end timestamp\';
|
||||
COMMENT ON COLUMN system.tbl_jobsqueue.insertvon IS \'User/Service who/that inserted this record\';
|
||||
COMMENT ON COLUMN system.tbl_jobsqueue.insertamum IS \'Record insert time stamp\';
|
||||
|
||||
CREATE SEQUENCE system.seq_jobsqueue_jobid
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE system.seq_jobsqueue_jobid OWNED BY system.tbl_jobsqueue.jobid;
|
||||
|
||||
ALTER TABLE ONLY system.tbl_jobsqueue ALTER COLUMN jobid SET DEFAULT nextval(\'system.seq_jobsqueue_jobid\'::regclass);
|
||||
|
||||
GRANT SELECT, UPDATE ON SEQUENCE system.seq_jobsqueue_jobid TO vilesci;
|
||||
GRANT SELECT, UPDATE ON SEQUENCE system.seq_jobsqueue_jobid TO fhcomplete;
|
||||
|
||||
ALTER TABLE ONLY system.tbl_jobsqueue ADD CONSTRAINT pk_jobsqueue PRIMARY KEY (jobid);
|
||||
|
||||
ALTER TABLE ONLY system.tbl_jobsqueue ADD CONSTRAINT fk_jobsqueue_status FOREIGN KEY (status) REFERENCES system.tbl_jobstatuses(status) ON UPDATE CASCADE ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY system.tbl_jobsqueue ADD CONSTRAINT fk_jobsqueue_type FOREIGN KEY (type) REFERENCES system.tbl_jobtypes(type) ON UPDATE CASCADE ON DELETE RESTRICT;
|
||||
';
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_jobsqueue: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>system.tbl_jobsqueue table created';
|
||||
|
||||
$qry = 'GRANT SELECT ON TABLE system.tbl_jobsqueue TO web;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_jobsqueue: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Granted privileges to <strong>web</strong> on system.tbl_jobsqueue';
|
||||
|
||||
$qry = 'GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE system.tbl_jobsqueue TO vilesci;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_jobsqueue: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Granted privileges to <strong>vilesci</strong> on system.tbl_jobsqueue';
|
||||
}
|
||||
|
||||
// Creates table system.tbl_jobtriggers if it doesn't exist and grants privileges
|
||||
if (!$result = @$db->db_query('SELECT 1 FROM system.tbl_jobtriggers LIMIT 1'))
|
||||
{
|
||||
$qry = 'CREATE TABLE system.tbl_jobtriggers (
|
||||
type character varying(128) NOT NULL,
|
||||
status character varying(64) NOT NULL,
|
||||
following_type character varying(128) NOT NULL
|
||||
);
|
||||
|
||||
COMMENT ON TABLE system.tbl_jobtriggers IS \'Table to manage the job triggers\';
|
||||
COMMENT ON COLUMN system.tbl_jobtriggers.type IS \'Job type\';
|
||||
COMMENT ON COLUMN system.tbl_jobtriggers.status IS \'Job status\';
|
||||
COMMENT ON COLUMN system.tbl_jobtriggers.following_type IS \'New job type\';
|
||||
|
||||
ALTER TABLE ONLY system.tbl_jobtriggers ADD CONSTRAINT pk_jobtriggers PRIMARY KEY (type, status, following_type);
|
||||
|
||||
ALTER TABLE ONLY system.tbl_jobtriggers ADD CONSTRAINT fk_jobtriggers_status FOREIGN KEY (status) REFERENCES system.tbl_jobstatuses(status) ON UPDATE CASCADE ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY system.tbl_jobtriggers ADD CONSTRAINT fk_jobtriggers_type FOREIGN KEY (type) REFERENCES system.tbl_jobtypes(type) ON UPDATE CASCADE ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY system.tbl_jobtriggers ADD CONSTRAINT fk_jobtriggers_following_type FOREIGN KEY (following_type) REFERENCES system.tbl_jobtypes(type) ON UPDATE CASCADE ON DELETE RESTRICT;
|
||||
';
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_jobtriggers: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>system.tbl_jobtriggers table created';
|
||||
|
||||
$qry = 'GRANT SELECT ON TABLE system.tbl_jobtriggers TO web;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_jobtriggers: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Granted privileges to <strong>web</strong> on system.tbl_jobtriggers';
|
||||
|
||||
$qry = 'GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE system.tbl_jobtriggers TO vilesci;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_jobtriggers: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Granted privileges to <strong>vilesci</strong> on system.tbl_jobtriggers';
|
||||
}
|
||||
|
||||
// Add column iso3166_1_a2 to bis.tbl_nation
|
||||
if (!$result = @$db->db_query("SELECT iso3166_1_a2 FROM bis.tbl_nation LIMIT 1"))
|
||||
{
|
||||
$qry = "ALTER TABLE bis.tbl_nation ADD COLUMN iso3166_1_a2 character varying(2);";
|
||||
$qry .= "COMMENT ON COLUMN bis.tbl_nation.iso3166_1_a2 IS 'ISO 3166-1 alpha-2 country code';";
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong>bis.tbl_nation.iso3166_1_a2: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>bis.tbl_nation.iso3166_1_a2: Spalte iso3166_1_a2 hinzugefuegt';
|
||||
}
|
||||
|
||||
// Spalte bezeichnung_mehrsprachig in public.tbl_studiengangstyp
|
||||
if(!$result = @$db->db_query("SELECT bezeichnung_mehrsprachig FROM public.tbl_studiengangstyp LIMIT 1"))
|
||||
{
|
||||
@@ -4200,6 +4389,18 @@ if(!$result = @$db->db_query("SELECT sort FROM lehre.tbl_abschlussbeurteilung LI
|
||||
echo '<br>lehre.tbl_abschlussbeurteilung: Spalte sort hinzugefuegt!<br>';
|
||||
}
|
||||
|
||||
// Add column iso3166_1_a3 to tbl_nation
|
||||
if(!$result = @$db->db_query("SELECT iso3166_1_a3 FROM bis.tbl_nation LIMIT 1"))
|
||||
{
|
||||
$qry = "ALTER table bis.tbl_nation ADD COLUMN iso3166_1_a3 VARCHAR(3);
|
||||
COMMENT ON COLUMN bis.tbl_nation.iso3166_1_a3 IS 'ISO 3166-1 alpha-3 country code';";
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong>bis.tbl_nation: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>bis.tbl_nation: Spalte iso3166_1_a3 hinzugefuegt';
|
||||
}
|
||||
|
||||
// *** Pruefung und hinzufuegen der neuen Attribute und Tabellen
|
||||
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
|
||||
|
||||
@@ -4229,7 +4430,7 @@ $tabellen=array(
|
||||
"bis.tbl_mobilitaet" => array("mobilitaet_id","prestudent_id","mobilitaetstyp_kurzbz","studiensemester_kurzbz","mobilitaetsprogramm_code","gsprogramm_id","firma_id","status_kurzbz","ausbildungssemester","insertvon","insertamum","updatevon","updateamum"),
|
||||
"bis.tbl_mobilitaetstyp" => array("mobilitaetstyp_kurzbz","bezeichnung","aktiv"),
|
||||
"bis.tbl_mobilitaetsprogramm" => array("mobilitaetsprogramm_code","kurzbz","beschreibung","sichtbar","sichtbar_outgoing"),
|
||||
"bis.tbl_nation" => array("nation_code","entwicklungsstand","eu","ewr","kontinent","kurztext","langtext","engltext","sperre","nationengruppe_kurzbz"),
|
||||
"bis.tbl_nation" => array("nation_code","entwicklungsstand","eu","ewr","kontinent","kurztext","langtext","engltext","sperre","nationengruppe_kurzbz", "iso3166_1_a2","iso3166_1_a3"),
|
||||
"bis.tbl_nationengruppe" => array("nationengruppe_kurzbz","nationengruppe_bezeichnung","aktiv"),
|
||||
"bis.tbl_orgform" => array("orgform_kurzbz","code","bezeichnung","rolle","bisorgform_kurzbz","bezeichnung_mehrsprachig"),
|
||||
"bis.tbl_verwendung" => array("verwendung_code","verwendungbez"),
|
||||
@@ -4459,6 +4660,10 @@ $tabellen=array(
|
||||
"system.tbl_log" => array("log_id","person_id","zeitpunkt","app","oe_kurzbz","logtype_kurzbz","logdata","insertvon","taetigkeit_kurzbz"),
|
||||
"system.tbl_logtype" => array("logtype_kurzbz", "data_schema"),
|
||||
"system.tbl_filters" => array("filter_id","app","dataset_name","filter_kurzbz","person_id","description","sort","default_filter","filter","oe_kurzbz","statistik_kurzbz"),
|
||||
"system.tbl_jobsqueue" => array("jobid", "type", "creationtime", "status", "input", "output", "starttime", "endtime", "insertvon", "insertamum"),
|
||||
"system.tbl_jobstatuses" => array("status"),
|
||||
"system.tbl_jobtriggers" => array("type", "status", "following_type"),
|
||||
"system.tbl_jobtypes" => array("type", "description"),
|
||||
"system.tbl_phrase" => array("phrase_id","app","phrase","insertamum","insertvon","category"),
|
||||
"system.tbl_phrasentext" => array("phrasentext_id","phrase_id","sprache","orgeinheit_kurzbz","orgform_kurzbz","text","description","insertamum","insertvon"),
|
||||
"system.tbl_rolle" => array("rolle_kurzbz","beschreibung"),
|
||||
|
||||
@@ -633,6 +633,37 @@ $filters = array(
|
||||
}
|
||||
',
|
||||
'oe_kurzbz' => null,
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'dataset_name' => 'jq',
|
||||
'filter_kurzbz' => 'lastHour',
|
||||
'description' => '{Last hour queued jobs}',
|
||||
'sort' => 1,
|
||||
'default_filter' => true,
|
||||
'filter' => '
|
||||
{
|
||||
"name": "All jobs queued in the last hour",
|
||||
"columns": [
|
||||
{"name": "JobId"},
|
||||
{"name": "CreationTime"},
|
||||
{"name": "Type"},
|
||||
{"name": "Status"},
|
||||
{"name": "StartTime"},
|
||||
{"name": "EndTime"},
|
||||
{"name": "UserService"}
|
||||
],
|
||||
"filters": [
|
||||
{
|
||||
"name": "CreationTime",
|
||||
"operation": "lt",
|
||||
"condition": "1",
|
||||
"option": "hours"
|
||||
}
|
||||
]
|
||||
}
|
||||
',
|
||||
'oe_kurzbz' => null,
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user