update rakefile

Update rakefile to translations

update Rakefile for translations

update intervals in Task Schedule

update insert.sql error in instalation

add Translations in index.php task scheduler

fix timezone in execution on task scheduler

fix timezone

add translation to TASKSCHEDULER

control for intervals in task scheduler is last_update property

PMCORE-1549

PMCORE-1542

Revert "PMCORE-1542 (pull request #7355)"

This reverts pull request #7355.

> PMCORE-1542

fix schedule Run command
This commit is contained in:
Henry Jordan
2020-06-02 19:04:44 +00:00
parent f1b62b24e2
commit 848ff9a887
15 changed files with 2231 additions and 20 deletions

View File

@@ -1,5 +1,17 @@
require 'rubygems'
require 'json'
require "po_to_json"
class PoToJson
def _generate_for_json(language, overwrite = {})
@options = parse_options(overwrite.merge(language: language))
#parse_document
#@parsed ||= inject_meta(parse_document)
generated = build_json_for(parse_document)
end
end
desc "Default Task - Build Library"
task :default => [:required] do
Rake::Task['build'].execute
@@ -67,9 +79,20 @@ task :build => [:required] do
mafeHash = getHash(Dir.pwd + "/vendor/colosa/MichelangeloFE")
pmdynaformHash = getHash(Dir.pwd + "/vendor/colosa/pmDynaform")
puts "Building PO to JSON".cyan
Dir["#{Dir.pwd}/workflow/engine/content/translations/*.po"].each do |file|
lang = file.split('.')
json_string = PoToJson.new(file)._generate_for_json(lang[1], :pretty => true)
File.open("#{Dir.pwd}/workflow/public_html/translations/#{lang[1]}.json",'w').write(json_string)
puts file
end
puts "Building file: Task Scheduler".cyan
system "npm run build --prefix #{Dir.pwd}/vendor/colosa/taskscheduler"
system "cp -Rf #{Dir.pwd}/vendor/colosa/taskscheduler/taskscheduler #{targetDir}/taskscheduler"
system "cp #{Dir.pwd}/vendor/colosa/taskscheduler/taskscheduler/index.html #{targetDir}/taskscheduler"
system "cp #{Dir.pwd}/vendor/colosa/taskscheduler/public/index.html #{targetDir}/taskscheduler"
hashVendors = pmuiHash+"-"+mafeHash
## Building minified JS Files
@@ -469,3 +492,10 @@ def getLog
return output
end
def generate_for_json()
@overwrite = {pretty: false}
@options = parse_options(overwrite.merge(language: 'en'))
@parsed ||= inject_meta(parse_document)
generated = build_json_for(build_json_for(@parsed))
end

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Console\Commands;
use Maveriks\WebApplication;
@@ -6,14 +7,16 @@ use \Illuminate\Support\Carbon;
use Illuminate\Console\Scheduling\ScheduleRunCommand as BaseCommand;
use Illuminate\Support\Facades\Log;
use ProcessMaker\Model\TaskScheduler;
class ScheduleRunCommand extends BaseCommand
{
use AddParametersTrait;
/**
/**
* Create a new command instance.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
public function __construct(\Illuminate\Console\Scheduling\Schedule $schedule)
@@ -24,11 +27,10 @@ class ScheduleRunCommand extends BaseCommand
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
{--processmakerPath=./ : ProcessMaker path.}
';
$this->description .= ' (ProcessMaker has extended this command)';
$this->description .= ' (ProcessMaker has extended this command)';
parent::__construct($schedule);
}
/**
* Execute the console command.
*
@@ -43,13 +45,37 @@ class ScheduleRunCommand extends BaseCommand
$webApplication->setRootDir($this->option('processmakerPath'));
$webApplication->loadEnvironment($workspace, false);
}
TaskScheduler::all()->each(function($p) use ($that){
if($p->isDue()){
Log::info("Si se ejecuta" . $p->expression);
}
if($p->enable == '1'){
$that->schedule->exec($p->body)->cron($p->expression)->between($p->startingTime, $p->endingTime);
}
TaskScheduler::all()->each(function ($p) use ($that) {
$starting = isset($p->startingTime) ? $p->startingTime : "0:00";
$ending = isset($p->startingTime) ? $p->endingTime : "23:59";
$timezone = isset($p->timezone) && $p->timezone != ""? $p->timezone: date_default_timezone_get();
$that->schedule->exec($p->body)->cron($p->expression)->between($starting, $ending)->timezone($timezone)->when(function () use ($p) {
$now = Carbon::now();
$result = false;
$datework = Carbon::createFromFormat('Y-m-d H:i:s', $p->last_update);
if (isset($p->everyOn)) {
switch ($p->interval) {
case "day":
$interval = $now->diffInDays($datework);
$result = ($interval !== 0 && ($interval % intval($p->everyOn)) == 0);
break;
case "week":
$interval = $now->diffInDays($datework);
$result = ($interval !== 0 && $interval % (intval($p->everyOn) * 7) == 0);
break;
case "month":
$interval = $now->diffInMonths($datework);
$result = ($interval !== 0 && $interval % intval($p->everyOn) == 0);
break;
case "year":
$interval = $now->diffInYears($datework);
$result = ($interval !== 0 && $interval % intval($p->everyOn) == 0);
break;
}
return $result;
}
return true;
});
});
parent::handle();
}

View File

@@ -22,6 +22,10 @@
{
"type": "git",
"url": "git@bitbucket.org:colosa/pmui.git"
},
{
"type": "git",
"url": "git@bitbucket.org:colosa/taskscheduler.git"
}
],
"minimum-stability": "dev",
@@ -34,6 +38,7 @@
"colosa/pmui": "release/3.4.8-dev",
"colosa/michelangelofe": "release/3.4.8-dev",
"colosa/pmdynaform": "release/3.4.8-dev",
"colosa/taskscheduler": "0.1.0",
"google/apiclient": "1.1.6",
"dapphp/securimage": "^3.6",
"psr/log": "1.0.0",

15
composer.lock generated
View File

@@ -146,6 +146,21 @@
],
"time": "2020-03-10T12:38:14+00:00"
},
{
"name": "colosa/taskscheduler",
"version": "0.1.0",
"source": {
"type": "git",
"url": "git@bitbucket.org:colosa/taskscheduler.git",
"reference": "master"
},
"type": "library",
"description": "JS Library to render ProcessMaker Task Scheduler",
"homepage": "http://processmaker.com",
"keywords": [
"Vue js lib ProcessMaker Task Scheduler"
]
},
{
"name": "colosa/pmUI",
"version": "dev-release/3.4.8",

View File

@@ -615,6 +615,11 @@ class RBAC
'PER_UID' => '00000000000000000000000000000068',
'PER_CODE' => 'PM_FOLDERS_OWNER',
'PER_NAME' => 'View Your Folders'
],
[
'PER_UID' => '00000000000000000000000000000069',
'PER_CODE' => 'PM_TASK_SCHEDULER_ADMIN',
'PER_NAME' => 'View Task Scheduler'
]
];

4
rbac/engine/data/mysql/insert.sql Normal file → Executable file
View File

@@ -68,6 +68,9 @@ INSERT INTO `RBAC_PERMISSIONS` VALUES
('00000000000000000000000000000067','PM_SETUP_LOG_FILES','2018-02-06 00:00:00','2018-02-06 00:00:00',1,'00000000000000000000000000000002'),
('00000000000000000000000000000068','PM_FOLDERS_OWNER','2020-01-29 00:00:00','2020-01-29 00:00:00',1,'00000000000000000000000000000002');
INSERT INTO `RBAC_PERMISSIONS` VALUES
('00000000000000000000000000000069','PM_TASK_SCHEDULER_ADMIN','2020-01-29 00:00:00','2020-01-29 00:00:00',1,'00000000000000000000000000000002');
INSERT INTO `RBAC_ROLES` VALUES
('00000000000000000000000000000001','','00000000000000000000000000000001','RBAC_ADMIN','2007-07-31 19:10:22','2007-08-03 12:24:36',1),
('00000000000000000000000000000002','','00000000000000000000000000000002','PROCESSMAKER_ADMIN','2007-07-31 19:10:22','2007-08-03 12:24:36',1),
@@ -144,6 +147,7 @@ INSERT INTO `RBAC_ROLES_PERMISSIONS` VALUES
('00000000000000000000000000000002','00000000000000000000000000000065'),
('00000000000000000000000000000002','00000000000000000000000000000067'),
('00000000000000000000000000000002','00000000000000000000000000000068'),
('00000000000000000000000000000002','00000000000000000000000000000069'),
('00000000000000000000000000000003','00000000000000000000000000000001'),
('00000000000000000000000000000003','00000000000000000000000000000005'),
('00000000000000000000000000000003','00000000000000000000000000000040'),

View File

@@ -15,7 +15,7 @@ class VariableTest extends TestCase
/**
* Test it create variables related to the process
*
* @covers \ProcessMaker\BusinessModel\Variables::create()
* @covers \ProcessMaker\BusinessModel\Variable::create()
* @test
*/
public function it_create_variable_by_process()
@@ -62,7 +62,7 @@ class VariableTest extends TestCase
/**
* Tests the exception
*
* @covers \ProcessMaker\BusinessModel\Variables::create()
* @covers \ProcessMaker\BusinessModel\Variable::create()
* @test
*/
public function it_return_an_exception_when_var_name_is_empty()
@@ -94,7 +94,7 @@ class VariableTest extends TestCase
/**
* Tests the exception
*
* @covers \ProcessMaker\BusinessModel\Variables::create()
* @covers \ProcessMaker\BusinessModel\Variable::create()
* @test
*/
public function it_return_an_exception_when_var_field_type_is_empty()
@@ -126,7 +126,7 @@ class VariableTest extends TestCase
/**
* Tests the exception
*
* @covers \ProcessMaker\BusinessModel\Variables::create()
* @covers \ProcessMaker\BusinessModel\Variable::create()
* @test
*/
public function it_return_an_exception_when_var_label_is_empty()
@@ -158,7 +158,7 @@ class VariableTest extends TestCase
/**
* Test it return the variables related to the PRO_UID
*
* @covers \ProcessMaker\BusinessModel\Variables::getVariables()
* @covers \ProcessMaker\BusinessModel\Variable::getVariables()
* @test
*/
public function it_list_variables_by_process()

View File

@@ -233,7 +233,7 @@ class XmlImporterTest extends TestCase
* Test the import new option and the import new group option with repeated title.
* @test
* @covers \ProcessMaker\Importer\XmlImporter::import()
* @covers \ProcessMaker\Importer\XmlImporter::updateTheProcessOwner()
* @covers \ProcessMaker\Importer\XmlImporter::updateProcessInformation()
*/
public function it_should_matter_with_import_option_create_new_and_group_import_option_create_new_try_rename_title()
{

View File

@@ -73,6 +73,10 @@ class SchedulerMapBuilder
$tMap->addColumn('ENDINGTIME', 'Endingtime', 'string', CreoleTypes::VARCHAR, false, 100);
$tMap->addColumn('EVERYON', 'Everyon', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('INTERVAL', 'Interval', 'string', CreoleTypes::VARCHAR, false, 10);
$tMap->addColumn('DESCRIPTION', 'Description', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('EXPRESSION', 'Expression', 'string', CreoleTypes::VARCHAR, false, 255);
@@ -89,6 +93,10 @@ class SchedulerMapBuilder
$tMap->addColumn('ENABLE', 'Enable', 'int', CreoleTypes::TINYINT, false, 3);
$tMap->addColumn('CREATION_DATE', 'CreationDate', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('LAST_UPDATE', 'LastUpdate', 'int', CreoleTypes::TIMESTAMP, false, null);
} // doBuild()
} // SchedulerMapBuilder

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,644 @@
<?php
require_once 'propel/util/BasePeer.php';
// The object class -- needed for instanceof checks in this class.
// actual class may be a subclass -- as returned by SchedulerPeer::getOMClass()
include_once 'classes/model/Scheduler.php';
/**
* Base static class for performing query and update operations on the 'SCHEDULER' table.
*
*
*
* @package workflow.classes.model.om
*/
abstract class BaseSchedulerPeer
{
/** the default database name for this class */
const DATABASE_NAME = 'workflow';
/** the table name for this class */
const TABLE_NAME = 'SCHEDULER';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'classes.model.Scheduler';
/** The total number of columns. */
const NUM_COLUMNS = 16;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the ID field */
const ID = 'SCHEDULER.ID';
/** the column name for the TITLE field */
const TITLE = 'SCHEDULER.TITLE';
/** the column name for the STARTINGTIME field */
const STARTINGTIME = 'SCHEDULER.STARTINGTIME';
/** the column name for the ENDINGTIME field */
const ENDINGTIME = 'SCHEDULER.ENDINGTIME';
/** the column name for the EVERYON field */
const EVERYON = 'SCHEDULER.EVERYON';
/** the column name for the INTERVAL field */
const INTERVAL = 'SCHEDULER.INTERVAL';
/** the column name for the DESCRIPTION field */
const DESCRIPTION = 'SCHEDULER.DESCRIPTION';
/** the column name for the EXPRESSION field */
const EXPRESSION = 'SCHEDULER.EXPRESSION';
/** the column name for the BODY field */
const BODY = 'SCHEDULER.BODY';
/** the column name for the TYPE field */
const TYPE = 'SCHEDULER.TYPE';
/** the column name for the CATEGORY field */
const CATEGORY = 'SCHEDULER.CATEGORY';
/** the column name for the SYSTEM field */
const SYSTEM = 'SCHEDULER.SYSTEM';
/** the column name for the TIMEZONE field */
const TIMEZONE = 'SCHEDULER.TIMEZONE';
/** the column name for the ENABLE field */
const ENABLE = 'SCHEDULER.ENABLE';
/** the column name for the CREATION_DATE field */
const CREATION_DATE = 'SCHEDULER.CREATION_DATE';
/** the column name for the LAST_UPDATE field */
const LAST_UPDATE = 'SCHEDULER.LAST_UPDATE';
/** The PHP to DB Name Mapping */
private static $phpNameMap = null;
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'Title', 'Startingtime', 'Endingtime', 'Everyon', 'Interval', 'Description', 'Expression', 'Body', 'Type', 'Category', 'System', 'Timezone', 'Enable', 'CreationDate', 'LastUpdate', ),
BasePeer::TYPE_COLNAME => array (SchedulerPeer::ID, SchedulerPeer::TITLE, SchedulerPeer::STARTINGTIME, SchedulerPeer::ENDINGTIME, SchedulerPeer::EVERYON, SchedulerPeer::INTERVAL, SchedulerPeer::DESCRIPTION, SchedulerPeer::EXPRESSION, SchedulerPeer::BODY, SchedulerPeer::TYPE, SchedulerPeer::CATEGORY, SchedulerPeer::SYSTEM, SchedulerPeer::TIMEZONE, SchedulerPeer::ENABLE, SchedulerPeer::CREATION_DATE, SchedulerPeer::LAST_UPDATE, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'startingTime', 'endingTime', 'everyOn', 'interval', 'description', 'expression', 'body', 'type', 'category', 'system', 'timezone', 'enable', 'creation_date', 'last_update', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'Startingtime' => 2, 'Endingtime' => 3, 'Everyon' => 4, 'Interval' => 5, 'Description' => 6, 'Expression' => 7, 'Body' => 8, 'Type' => 9, 'Category' => 10, 'System' => 11, 'Timezone' => 12, 'Enable' => 13, 'CreationDate' => 14, 'LastUpdate' => 15, ),
BasePeer::TYPE_COLNAME => array (SchedulerPeer::ID => 0, SchedulerPeer::TITLE => 1, SchedulerPeer::STARTINGTIME => 2, SchedulerPeer::ENDINGTIME => 3, SchedulerPeer::EVERYON => 4, SchedulerPeer::INTERVAL => 5, SchedulerPeer::DESCRIPTION => 6, SchedulerPeer::EXPRESSION => 7, SchedulerPeer::BODY => 8, SchedulerPeer::TYPE => 9, SchedulerPeer::CATEGORY => 10, SchedulerPeer::SYSTEM => 11, SchedulerPeer::TIMEZONE => 12, SchedulerPeer::ENABLE => 13, SchedulerPeer::CREATION_DATE => 14, SchedulerPeer::LAST_UPDATE => 15, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'startingTime' => 2, 'endingTime' => 3, 'everyOn' => 4, 'interval' => 5, 'description' => 6, 'expression' => 7, 'body' => 8, 'type' => 9, 'category' => 10, 'system' => 11, 'timezone' => 12, 'enable' => 13, 'creation_date' => 14, 'last_update' => 15, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
);
/**
* @return MapBuilder the map builder for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getMapBuilder()
{
include_once 'classes/model/map/SchedulerMapBuilder.php';
return BasePeer::getMapBuilder('classes.model.map.SchedulerMapBuilder');
}
/**
* Gets a map (hash) of PHP names to DB column names.
*
* @return array The PHP to DB name map for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
*/
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = SchedulerPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
/**
* Translates a fieldname to another type
*
* @param string $name field name
* @param string $fromType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @param string $toType One of the class type constants
* @return string translated name of the field.
*/
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
/**
* Returns an array of of field names.
*
* @param string $type The type of fieldnames to return:
* One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return array A list of field names
*/
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
}
return self::$fieldNames[$type];
}
/**
* Convenience method which changes table.column to alias.column.
*
* Using this method you can maintain SQL abstraction while using column aliases.
* <code>
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string $alias The alias for the current table.
* @param string $column The column name for current table. (i.e. SchedulerPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(SchedulerPeer::TABLE_NAME.'.', $alias.'.', $column);
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param criteria object containing the columns to add.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(SchedulerPeer::ID);
$criteria->addSelectColumn(SchedulerPeer::TITLE);
$criteria->addSelectColumn(SchedulerPeer::STARTINGTIME);
$criteria->addSelectColumn(SchedulerPeer::ENDINGTIME);
$criteria->addSelectColumn(SchedulerPeer::EVERYON);
$criteria->addSelectColumn(SchedulerPeer::INTERVAL);
$criteria->addSelectColumn(SchedulerPeer::DESCRIPTION);
$criteria->addSelectColumn(SchedulerPeer::EXPRESSION);
$criteria->addSelectColumn(SchedulerPeer::BODY);
$criteria->addSelectColumn(SchedulerPeer::TYPE);
$criteria->addSelectColumn(SchedulerPeer::CATEGORY);
$criteria->addSelectColumn(SchedulerPeer::SYSTEM);
$criteria->addSelectColumn(SchedulerPeer::TIMEZONE);
$criteria->addSelectColumn(SchedulerPeer::ENABLE);
$criteria->addSelectColumn(SchedulerPeer::CREATION_DATE);
$criteria->addSelectColumn(SchedulerPeer::LAST_UPDATE);
}
const COUNT = 'COUNT(SCHEDULER.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT SCHEDULER.ID)';
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(SchedulerPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(SchedulerPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach ($criteria->getGroupByColumns() as $column) {
$criteria->addSelectColumn($column);
}
$rs = SchedulerPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Method to select one object from the DB.
*
* @param Criteria $criteria object used to create the SELECT statement.
* @param Connection $con
* @return Scheduler
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = SchedulerPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con
* @return array Array of selected Objects
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return SchedulerPeer::populateObjects(SchedulerPeer::doSelectRS($criteria, $con));
}
/**
* Prepares the Criteria object and uses the parent doSelect()
* method to get a ResultSet.
*
* Use this method directly if you want to just get the resultset
* (instead of an array of objects).
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return ResultSet The resultset object with numerically-indexed fields.
* @see BasePeer::doSelect()
*/
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
SchedulerPeer::addSelectColumns($criteria);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
// BasePeer returns a Creole ResultSet, set to return
// rows indexed numerically.
return BasePeer::doSelect($criteria, $con);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(ResultSet $rs)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = SchedulerPeer::getOMClass();
$cls = Propel::import($cls);
// populate the object(s)
while ($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
/**
* The class that the Peer will make instances of.
*
* This uses a dot-path notation which is tranalted into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @return string path.to.ClassName
*/
public static function getOMClass()
{
return SchedulerPeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a Scheduler or Criteria object.
*
* @param mixed $values Criteria or Scheduler object containing data that is used to create the INSERT statement.
* @param Connection $con the connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} else {
$criteria = $values->buildCriteria(); // build Criteria from Scheduler object
}
//$criteria->remove(SchedulerPeer::ID); // remove pkey col since this table uses auto-increment
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a Scheduler or Criteria object.
*
* @param mixed $values Criteria or Scheduler object containing data create the UPDATE statement.
* @param Connection $con The connection to use (specify Connection exert more control over transactions).
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(SchedulerPeer::ID);
$selectCriteria->add(SchedulerPeer::ID, $criteria->remove(SchedulerPeer::ID), $comparison);
} else {
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
/**
* Method to DELETE all rows from the SCHEDULER table.
*
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += BasePeer::doDeleteAll(SchedulerPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a Scheduler or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or Scheduler object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param Connection $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
* This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(SchedulerPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof Scheduler) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(SchedulerPeer::ID, (array) $values, Criteria::IN);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Validates all modified columns of given Scheduler object.
* If parameter $columns is either a single column name or an array of column names
* than only those columns are validated.
*
* NOTICE: This does not apply to primary or foreign keys for now.
*
* @param Scheduler $obj The object to validate.
* @param mixed $cols Column name or array of column names.
*
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
*/
public static function doValidate(Scheduler $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(SchedulerPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(SchedulerPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach ($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
return BasePeer::doValidate(SchedulerPeer::DATABASE_NAME, SchedulerPeer::TABLE_NAME, $columns);
}
/**
* Retrieve a single object by pkey.
*
* @param mixed $pk the primary key.
* @param Connection $con the connection to use
* @return Scheduler
*/
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(SchedulerPeer::DATABASE_NAME);
$criteria->add(SchedulerPeer::ID, $pk);
$v = SchedulerPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
/**
* Retrieve multiple objects by pkey.
*
* @param array $pks List of primary keys
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(SchedulerPeer::ID, $pks, Criteria::IN);
$objs = SchedulerPeer::doSelect($criteria, $con);
}
return $objs;
}
}
// static code to register the map builder for this Peer with the main Propel class
if (Propel::isInit()) {
// the MapBuilder classes register themselves with Propel during initialization
// so we need to load them here.
try {
BaseSchedulerPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
// even if Propel is not yet initialized, the map builder class can be registered
// now and then it will be loaded when Propel initializes.
require_once 'classes/model/map/SchedulerMapBuilder.php';
Propel::registerMapBuilder('classes.model.map.SchedulerMapBuilder');
}

View File

@@ -6033,7 +6033,9 @@
<column name="id" type="BIGINT" size="20" required="true" autoIncrement="true" primaryKey="true"/>
<column name="title" type="VARCHAR" size="255" required="false"/>
<column name="startingTime" type="VARCHAR" size="100" required="false"/>
<column name="endingTime" type="VARCHAR" size="100" required="false"/>}
<column name="endingTime" type="VARCHAR" size="100" required="false"/>
<column name="everyOn" type="VARCHAR" size="255" required="false"/>
<column name="interval" type="VARCHAR" size="10" required="false"/>
<column name="description" type="VARCHAR" size="255" required="false"/>
<column name="expression" type="VARCHAR" size="255" required="false"/>
<column name="body" type="VARCHAR" size="255" required="false"/>
@@ -6042,5 +6044,7 @@
<column name="system" type="TINYINT" size="3" required="false"/>
<column name="timezone" type="VARCHAR" size="255" required="false"/>
<column name="enable" type="TINYINT" size="3" required="false"/>
<column name="creation_date" type="TIMESTAMP" required="false"/>
<column name="last_update" type="TIMESTAMP" required="false"/>
</table>
</database>

View File

@@ -3325,5 +3325,32 @@ CREATE TABLE `JOBS_FAILED`
`failed_at` DATETIME NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET='utf8';
#-----------------------------------------------------------------------------
#-- SCHEDULER
#-----------------------------------------------------------------------------
DROP TABLE IF EXISTS `SCHEDULER`;
CREATE TABLE `SCHEDULER`
(
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255),
`startingTime` VARCHAR(100),
`endingTime` VARCHAR(100),
`everyOn` VARCHAR(255),
`interval` VARCHAR(10),
`description` VARCHAR(255),
`expression` VARCHAR(255),
`body` VARCHAR(255),
`type` VARCHAR(255),
`category` VARCHAR(255),
`system` TINYINT(3),
`timezone` VARCHAR(255),
`enable` TINYINT(3),
`creation_date` DATETIME,
`last_update` DATETIME,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET='utf8';
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -14,12 +14,15 @@ try {
"var timezoneArray = " . G::json_encode($arrayTimeZoneId) . ";\n" .
"</script>\n";
echo($js);
}
$js = "" .
"<script type=\"text/javascript\" src=/js/ext/translation.".SYS_LANG.".".G::browserCacheFilesGetUid() ."js></script>\n".
"<script type='text/javascript'>\n" .
"var server = '" . System::getHttpServerHostnameRequestsFrontEnd() . "';\n" .
"var credentials = " . G::json_encode($pmDynaform->getCredentials()) . ";\n" .
"var category = '" . $category . "';\n" .
"var lang = '" . SYS_LANG . "';\n" .
"</script>\n";
echo($js);

View File

@@ -17,7 +17,9 @@ use Illuminate\Console\Scheduling\Schedule;
class TaskScheduler extends Model
{
protected $table = 'SCHEDULER';
public $timestamps = false;
public $timestamps = true;
const CREATED_AT = 'creation_date';
const UPDATED_AT = 'last_update';
public function isDue(){
$date = Carbon::now();