CODE STYLE changes...
FILES: gulliver/system/class.table.php workflow/engine/classes/class.propelTable.php workflow/engine/classes/entities/Base.php workflow/engine/classes/model/AppEvent.php
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -150,15 +150,18 @@ class propelTable
|
|||||||
foreach ($orderFields as $field => $fieldOrder) {
|
foreach ($orderFields as $field => $fieldOrder) {
|
||||||
$field = G::getUIDName( $field, '' );
|
$field = G::getUIDName( $field, '' );
|
||||||
$fieldOrder = strtoupper( $fieldOrder );
|
$fieldOrder = strtoupper( $fieldOrder );
|
||||||
if ($fieldOrder === 'A')
|
if ($fieldOrder === 'A') {
|
||||||
$fieldOrder = 'ASC';
|
$fieldOrder = 'ASC';
|
||||||
if ($fieldOrder === 'D')
|
}
|
||||||
|
if ($fieldOrder === 'D') {
|
||||||
$fieldOrder = 'DESC';
|
$fieldOrder = 'DESC';
|
||||||
|
}
|
||||||
switch ($fieldOrder) {
|
switch ($fieldOrder) {
|
||||||
case 'ASC':
|
case 'ASC':
|
||||||
case 'DESC':
|
case 'DESC':
|
||||||
if ($order !== '')
|
if ($order !== '') {
|
||||||
$order .= ', ';
|
$order .= ', ';
|
||||||
|
}
|
||||||
$order .= $field . ' ' . $fieldOrder;
|
$order .= $field . ' ' . $fieldOrder;
|
||||||
$this->aOrder[$field] = $fieldOrder;
|
$this->aOrder[$field] = $fieldOrder;
|
||||||
}
|
}
|
||||||
@@ -175,10 +178,11 @@ class propelTable
|
|||||||
$this->criteria->clearOrderByColumns();
|
$this->criteria->clearOrderByColumns();
|
||||||
}
|
}
|
||||||
foreach ($this->aOrder as $field => $ascending) {
|
foreach ($this->aOrder as $field => $ascending) {
|
||||||
if ($ascending == 'ASC')
|
if ($ascending == 'ASC') {
|
||||||
$this->criteria->addAscendingOrderByColumn( $field );
|
$this->criteria->addAscendingOrderByColumn( $field );
|
||||||
else
|
} else {
|
||||||
$this->criteria->addDescendingOrderByColumn( $field );
|
$this->criteria->addDescendingOrderByColumn( $field );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -215,18 +219,21 @@ class propelTable
|
|||||||
$this->name = $xmlForm->name;
|
$this->name = $xmlForm->name;
|
||||||
$this->id = $xmlForm->id;
|
$this->id = $xmlForm->id;
|
||||||
//$this->sqlConnection=((isset($this->xmlForm->sqlConnection))?$this->xmlForm->sqlConnection:'');
|
//$this->sqlConnection=((isset($this->xmlForm->sqlConnection))?$this->xmlForm->sqlConnection:'');
|
||||||
if (isset( $_GET['page'] ))
|
if (isset( $_GET['page'] )) {
|
||||||
$this->currentPage = $_GET['page'];
|
$this->currentPage = $_GET['page'];
|
||||||
else
|
} else {
|
||||||
$this->currentPage = 1;
|
$this->currentPage = 1;
|
||||||
if (isset( $_GET['order'] ))
|
}
|
||||||
|
if (isset( $_GET['order'] )) {
|
||||||
$this->orderBy = urldecode( $_GET['order'] );
|
$this->orderBy = urldecode( $_GET['order'] );
|
||||||
else
|
} else {
|
||||||
$this->orderBy = "";
|
$this->orderBy = "";
|
||||||
if (isset( $_GET['filter'] ))
|
}
|
||||||
|
if (isset( $_GET['filter'] )) {
|
||||||
$this->filter = urldecode( $_GET['filter'] );
|
$this->filter = urldecode( $_GET['filter'] );
|
||||||
else
|
} else {
|
||||||
$this->filter = "";
|
$this->filter = "";
|
||||||
|
}
|
||||||
if ($xmlForm->ajaxServer != '') {
|
if ($xmlForm->ajaxServer != '') {
|
||||||
$this->ajaxServer = G::encryptLink( $xmlForm->ajaxServer );
|
$this->ajaxServer = G::encryptLink( $xmlForm->ajaxServer );
|
||||||
} else {
|
} else {
|
||||||
@@ -235,12 +242,14 @@ class propelTable
|
|||||||
$this->ownerPage = G::encryptLink( SYS_CURRENT_URI );
|
$this->ownerPage = G::encryptLink( SYS_CURRENT_URI );
|
||||||
// Config attributes from XMLFORM file
|
// Config attributes from XMLFORM file
|
||||||
$myAttributes = get_class_vars( get_class( $this ) );
|
$myAttributes = get_class_vars( get_class( $this ) );
|
||||||
foreach ($this->xmlForm->xmlform->tree->attribute as $atrib => $value)
|
foreach ($this->xmlForm->xmlform->tree->attribute as $atrib => $value) {
|
||||||
if (array_key_exists( $atrib, $myAttributes )) {
|
if (array_key_exists( $atrib, $myAttributes )) {
|
||||||
eval( 'settype($value, gettype($this->' . $atrib . '));' );
|
eval( 'settype($value, gettype($this->' . $atrib . '));' );
|
||||||
if ($value !== '')
|
if ($value !== '') {
|
||||||
eval( '$this->' . $atrib . '=$value;' );
|
eval( '$this->' . $atrib . '=$value;' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($this->masterdetail != "") {
|
if ($this->masterdetail != "") {
|
||||||
$this->masterdetail = explode( ",", $this->masterdetail );
|
$this->masterdetail = explode( ",", $this->masterdetail );
|
||||||
foreach ($this->masterdetail as $keyMasterDetail => $valueMasterDetail) {
|
foreach ($this->masterdetail as $keyMasterDetail => $valueMasterDetail) {
|
||||||
@@ -258,8 +267,9 @@ class propelTable
|
|||||||
$r = $f;
|
$r = $f;
|
||||||
$this->fields[$r]['Name'] = $this->xmlForm->fields[$f]->name;
|
$this->fields[$r]['Name'] = $this->xmlForm->fields[$f]->name;
|
||||||
$this->fields[$r]['Type'] = $this->xmlForm->fields[$f]->type;
|
$this->fields[$r]['Type'] = $this->xmlForm->fields[$f]->type;
|
||||||
if (isset( $this->xmlForm->fields[$f]->size ))
|
if (isset( $this->xmlForm->fields[$f]->size )) {
|
||||||
$this->fields[$r]['Size'] = $this->xmlForm->fields[$f]->size;
|
$this->fields[$r]['Size'] = $this->xmlForm->fields[$f]->size;
|
||||||
|
}
|
||||||
$this->fields[$r]['Label'] = $this->xmlForm->fields[$f]->label;
|
$this->fields[$r]['Label'] = $this->xmlForm->fields[$f]->label;
|
||||||
}
|
}
|
||||||
//Set the default settings
|
//Set the default settings
|
||||||
@@ -283,9 +293,11 @@ class propelTable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$totalWidth = 0;
|
$totalWidth = 0;
|
||||||
foreach ($this->fields as $r => $rval)
|
foreach ($this->fields as $r => $rval) {
|
||||||
if ($this->style[$r]['showInTable'] != '0')
|
if ($this->style[$r]['showInTable'] != '0') {
|
||||||
$totalWidth += $this->style[$r]['colWidth'];
|
$totalWidth += $this->style[$r]['colWidth'];
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->totalWidth = $totalWidth;
|
$this->totalWidth = $totalWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,13 +325,14 @@ class propelTable
|
|||||||
{
|
{
|
||||||
//fix the bug about showing hidden fields in propel table.
|
//fix the bug about showing hidden fields in propel table.
|
||||||
foreach ($this->fields as $r => $rval) {
|
foreach ($this->fields as $r => $rval) {
|
||||||
if ($this->style[$r]['type'] == 'hidden')
|
if ($this->style[$r]['type'] == 'hidden') {
|
||||||
$this->style[$r]['showInTable'] = '0';
|
$this->style[$r]['showInTable'] = '0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Render headers
|
//Render headers
|
||||||
$this->colCount = 0;
|
$this->colCount = 0;
|
||||||
$this->shownFields = '[';
|
$this->shownFields = '[';
|
||||||
foreach ($this->fields as $r => $rval)
|
foreach ($this->fields as $r => $rval) {
|
||||||
if (($this->style[$r]['showInTable'] != '0') && (! (in_array( $this->fields[$r]['Name'], $this->masterdetail )))) {
|
if (($this->style[$r]['showInTable'] != '0') && (! (in_array( $this->fields[$r]['Name'], $this->masterdetail )))) {
|
||||||
//if (($this->style[$r]['showInTable'] != '0' ))
|
//if (($this->style[$r]['showInTable'] != '0' ))
|
||||||
$this->tpl->newBlock( "headers" );
|
$this->tpl->newBlock( "headers" );
|
||||||
@@ -327,26 +340,31 @@ class propelTable
|
|||||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? '' : $sortOrder);
|
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? '' : $sortOrder);
|
||||||
$this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? (G::createUID( '', $this->fields[$r]['Name'] ) . '=' . $sortOrder) : '') . '&page=' . $this->currentPage;
|
$this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? (G::createUID( '', $this->fields[$r]['Name'] ) . '=' . $sortOrder) : '') . '&page=' . $this->currentPage;
|
||||||
$this->style[$r]['onsort'] = $this->id . '.doSort("' . G::createUID( '', $this->fields[$r]['Name'] ) . '" , "' . $sortOrder . '");return false;';
|
$this->style[$r]['onsort'] = $this->id . '.doSort("' . G::createUID( '', $this->fields[$r]['Name'] ) . '" , "' . $sortOrder . '");return false;';
|
||||||
if (isset( $this->style[$r]['href'] ))
|
if (isset( $this->style[$r]['href'] )) {
|
||||||
$this->tpl->assign( "href", $this->style[$r]['href'] );
|
$this->tpl->assign( "href", $this->style[$r]['href'] );
|
||||||
if (isset( $this->style[$r]['onsort'] ))
|
}
|
||||||
|
if (isset( $this->style[$r]['onsort'] )) {
|
||||||
$this->tpl->assign( "onsort", htmlentities( $this->style[$r]['onsort'], ENT_QUOTES, 'UTF-8' ) );
|
$this->tpl->assign( "onsort", htmlentities( $this->style[$r]['onsort'], ENT_QUOTES, 'UTF-8' ) );
|
||||||
|
}
|
||||||
|
|
||||||
/* BUG 8080 - erik: don't setup onclick on page table header, doesn't have sense and causing problems
|
/* BUG 8080 - erik: don't setup onclick on page table header, doesn't have sense and causing problems
|
||||||
if (isset($this->style[$r]['onclick']))
|
if (isset($this->style[$r]['onclick']))
|
||||||
$this->tpl->assign( "onclick" , htmlentities( $this->style[$r]['onclick'] , ENT_QUOTES, 'UTF-8' ) );
|
$this->tpl->assign( "onclick" , htmlentities( $this->style[$r]['onclick'] , ENT_QUOTES, 'UTF-8' ) );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (isset( $this->style[$r]['colWidth'] ))
|
if (isset( $this->style[$r]['colWidth'] )) {
|
||||||
$this->tpl->assign( "width", $this->style[$r]['colWidth'] );
|
$this->tpl->assign( "width", $this->style[$r]['colWidth'] );
|
||||||
if (isset( $this->style[$r]['colWidth'] ))
|
}
|
||||||
|
if (isset( $this->style[$r]['colWidth'] )) {
|
||||||
$this->tpl->assign( "widthPercent", ($this->style[$r]['colWidth'] * 100 / $this->totalWidth) . "%" );
|
$this->tpl->assign( "widthPercent", ($this->style[$r]['colWidth'] * 100 / $this->totalWidth) . "%" );
|
||||||
//Hook for special skin with RTL languajes
|
//Hook for special skin with RTL languajes
|
||||||
|
}
|
||||||
if (defined( 'SYS_LANG_DIRECTION' ) && SYS_LANG_DIRECTION == 'R') {
|
if (defined( 'SYS_LANG_DIRECTION' ) && SYS_LANG_DIRECTION == 'R') {
|
||||||
$this->style[$r]['titleAlign'] = 'right';
|
$this->style[$r]['titleAlign'] = 'right';
|
||||||
}
|
}
|
||||||
if (isset( $this->style[$r]['titleAlign'] ))
|
if (isset( $this->style[$r]['titleAlign'] )) {
|
||||||
$this->tpl->assign( "align", 'text-align:' . $this->style[$r]['titleAlign'] . ';' );
|
$this->tpl->assign( "align", 'text-align:' . $this->style[$r]['titleAlign'] . ';' );
|
||||||
|
}
|
||||||
if ($this->style[$r]['titleVisibility'] != '0') {
|
if ($this->style[$r]['titleVisibility'] != '0') {
|
||||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? '<img src="/images/arrow-up.gif">' : '');
|
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? '<img src="/images/arrow-up.gif">' : '');
|
||||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? '<img src="/images/arrow-down.gif">' : $sortOrder);
|
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? '<img src="/images/arrow-down.gif">' : $sortOrder);
|
||||||
@@ -359,6 +377,7 @@ class propelTable
|
|||||||
$this->shownFields .= ($this->shownFields !== '[') ? ',' : '';
|
$this->shownFields .= ($this->shownFields !== '[') ? ',' : '';
|
||||||
$this->shownFields .= '"' . $r . '"';
|
$this->shownFields .= '"' . $r . '"';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$this->shownFields .= ']';
|
$this->shownFields .= ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,10 +399,11 @@ class propelTable
|
|||||||
$styleData = $this->style[$r];
|
$styleData = $this->style[$r];
|
||||||
$fielDataName = $styleData['data'];
|
$fielDataName = $styleData['data'];
|
||||||
$fieldClassName = isset( $styleData['colClassName'] ) && ($styleData['colClassName']) ? $styleData['colClassName'] : $this->tdClass;
|
$fieldClassName = isset( $styleData['colClassName'] ) && ($styleData['colClassName']) ? $styleData['colClassName'] : $this->tdClass;
|
||||||
if ($fielDataName != '')
|
if ($fielDataName != '') {
|
||||||
$value = ((isset( $result[$fielDataName] )) ? $result[$fielDataName] : '');
|
$value = ((isset( $result[$fielDataName] )) ? $result[$fielDataName] : '');
|
||||||
else
|
} else {
|
||||||
$value = $this->fields[$r]['Label'];
|
$value = $this->fields[$r]['Label'];
|
||||||
|
}
|
||||||
$this->tpl->newBlock( "field" );
|
$this->tpl->newBlock( "field" );
|
||||||
$this->tpl->assign( 'width', $this->style[$r]['colWidth'] );
|
$this->tpl->assign( 'width', $this->style[$r]['colWidth'] );
|
||||||
$classAttr = (trim( $fieldClassName ) != '') ? " class=\"$fieldClassName\"" : '';
|
$classAttr = (trim( $fieldClassName ) != '') ? " class=\"$fieldClassName\"" : '';
|
||||||
@@ -414,7 +434,7 @@ class propelTable
|
|||||||
$this->xmlForm->setDefaultValues();
|
$this->xmlForm->setDefaultValues();
|
||||||
$this->xmlForm->setValues( $result );
|
$this->xmlForm->setValues( $result );
|
||||||
//var_dump($fieldName, $fieldClass );echo '<br /><br />';
|
//var_dump($fieldName, $fieldClass );echo '<br /><br />';
|
||||||
if (array_search( 'renderTable', get_class_methods( $fieldClass ) ) !== FALSE) {
|
if (array_search( 'renderTable', get_class_methods( $fieldClass ) ) !== false) {
|
||||||
$htmlField = $this->xmlForm->fields[$fieldName]->renderTable( $value, $this->xmlForm, true );
|
$htmlField = $this->xmlForm->fields[$fieldName]->renderTable( $value, $this->xmlForm, true );
|
||||||
if (is_object( $value )) {
|
if (is_object( $value )) {
|
||||||
$value = '';
|
$value = '';
|
||||||
@@ -423,8 +443,9 @@ class propelTable
|
|||||||
$testValue = preg_match( "/<a ?.*>(.*)<\/a>/i", $htmlField, $value );
|
$testValue = preg_match( "/<a ?.*>(.*)<\/a>/i", $htmlField, $value );
|
||||||
$this->tpl->assign( "value", $htmlField );
|
$this->tpl->assign( "value", $htmlField );
|
||||||
if ($testValue > 0 && (isset( $value[1] ) && strlen( trim( $value[1] ) ) == 0)) {
|
if ($testValue > 0 && (isset( $value[1] ) && strlen( trim( $value[1] ) ) == 0)) {
|
||||||
if ((trim( $value[0] )) == '')
|
if ((trim( $value[0] )) == '') {
|
||||||
$this->tpl->assign( "value", " " );
|
$this->tpl->assign( "value", " " );
|
||||||
|
}
|
||||||
// $this->tpl->assign( "value" , (preg_match('^[[:space:]]^', $value) && (substr($fieldName,0,3)!="PRO"))? str_ireplace(" "," ",$htmlField):$htmlField );
|
// $this->tpl->assign( "value" , (preg_match('^[[:space:]]^', $value) && (substr($fieldName,0,3)!="PRO"))? str_ireplace(" "," ",$htmlField):$htmlField );
|
||||||
} else {
|
} else {
|
||||||
$this->tpl->assign( "value", $htmlField );
|
$this->tpl->assign( "value", $htmlField );
|
||||||
@@ -453,51 +474,60 @@ class propelTable
|
|||||||
$this->style[$r] = array ('showInTable' => '1','titleVisibility' => '1','colWidth' => '150','onclick' => '','event' => ''
|
$this->style[$r] = array ('showInTable' => '1','titleVisibility' => '1','colWidth' => '150','onclick' => '','event' => ''
|
||||||
);
|
);
|
||||||
//Some widths
|
//Some widths
|
||||||
if (! (strpos( ' date linknew ', ' ' . $this->fields[$r]['Type'] . ' ' ) === FALSE))
|
if (! (strpos( ' date linknew ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
||||||
$this->style[$r]['colWidth'] = '70';
|
$this->style[$r]['colWidth'] = '70';
|
||||||
|
}
|
||||||
//Data source:
|
//Data source:
|
||||||
if (! (strpos( ' title button linknew image-text jslink ', ' ' . $this->fields[$r]['Type'] . ' ' ) === FALSE))
|
if (! (strpos( ' title button linknew image-text jslink ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
||||||
$this->style[$r]['data'] = ''; //If the control is a link it shows the label
|
$this->style[$r]['data'] = ''; //If the control is a link it shows the label
|
||||||
else
|
} else {
|
||||||
$this->style[$r]['data'] = $this->fields[$r]['Name']; //ELSE: The data value for that field
|
$this->style[$r]['data'] = $this->fields[$r]['Name']; //ELSE: The data value for that field
|
||||||
//Hidden fields
|
//Hidden fields
|
||||||
|
}
|
||||||
if (! isset( $this->style[$r]['showInTable'] )) {
|
if (! isset( $this->style[$r]['showInTable'] )) {
|
||||||
if (! (strpos( ' title button endgrid2 submit password ', ' ' . $this->fields[$r]['Type'] . ' ' ) === FALSE)) {
|
if (! (strpos( ' title button endgrid2 submit password ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
||||||
$this->style[$r]['showInTable'] = '0';
|
$this->style[$r]['showInTable'] = '0';
|
||||||
} else {
|
} else {
|
||||||
$this->style[$r]['showInTable'] = '1';
|
$this->style[$r]['showInTable'] = '1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Hidden titles
|
//Hidden titles
|
||||||
if (! (strpos( ' linknew button endgrid2 ', ' ' . $this->fields[$r]['Type'] . ' ' ) === FALSE)) {
|
if (! (strpos( ' linknew button endgrid2 ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
||||||
$this->style[$r]['titleVisibility'] = '0';
|
$this->style[$r]['titleVisibility'] = '0';
|
||||||
}
|
}
|
||||||
//Align titles
|
//Align titles
|
||||||
$this->style[$r]['titleAlign'] = 'center';
|
$this->style[$r]['titleAlign'] = 'center';
|
||||||
//Align fields
|
//Align fields
|
||||||
if (defined( 'SYS_LANG_DIRECTION' ) && SYS_LANG_DIRECTION == 'R')
|
if (defined( 'SYS_LANG_DIRECTION' ) && SYS_LANG_DIRECTION == 'R') {
|
||||||
$this->style[$r]['align'] = 'right';
|
$this->style[$r]['align'] = 'right';
|
||||||
else
|
} else {
|
||||||
$this->style[$r]['align'] = 'left';
|
$this->style[$r]['align'] = 'left';
|
||||||
if (! (strpos( ' linknew date ', ' ' . $this->fields[$r]['Type'] . ' ' ) === FALSE)) {
|
}
|
||||||
|
if (! (strpos( ' linknew date ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
||||||
$this->style[$r]['align'] = 'center';
|
$this->style[$r]['align'] = 'center';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Adjust the columns width to prevent overflow the page width
|
// Adjust the columns width to prevent overflow the page width
|
||||||
//Render headers
|
//Render headers
|
||||||
$totalWidth = 0;
|
$totalWidth = 0;
|
||||||
foreach ($this->fields as $r => $rval)
|
foreach ($this->fields as $r => $rval) {
|
||||||
if ($this->style[$r]['showInTable'] != '0')
|
if ($this->style[$r]['showInTable'] != '0') {
|
||||||
$totalWidth += $this->style[$r]['colWidth'];
|
$totalWidth += $this->style[$r]['colWidth'];
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->totalWidth = $totalWidth;
|
$this->totalWidth = $totalWidth;
|
||||||
$maxWidth = 1800;
|
$maxWidth = 1800;
|
||||||
$proportion = $totalWidth / $maxWidth;
|
$proportion = $totalWidth / $maxWidth;
|
||||||
if ($proportion > 1)
|
if ($proportion > 1) {
|
||||||
$this->totalWidth = 1800;
|
$this->totalWidth = 1800;
|
||||||
if ($proportion > 1)
|
}
|
||||||
foreach ($this->fields as $r => $rval)
|
if ($proportion > 1) {
|
||||||
if ($this->style[$r]['showInTable'] != '0')
|
foreach ($this->fields as $r => $rval) {
|
||||||
|
if ($this->style[$r]['showInTable'] != '0') {
|
||||||
$this->style[$r]['colWidth'] = $this->style[$r]['colWidth'] / $proportion;
|
$this->style[$r]['colWidth'] = $this->style[$r]['colWidth'] / $proportion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -512,12 +542,13 @@ class propelTable
|
|||||||
{
|
{
|
||||||
//Render Title
|
//Render Title
|
||||||
$thereisnotitle = true;
|
$thereisnotitle = true;
|
||||||
foreach ($this->fields as $r => $rval)
|
foreach ($this->fields as $r => $rval) {
|
||||||
if ($this->fields[$r]['Type'] === 'title') {
|
if ($this->fields[$r]['Type'] === 'title') {
|
||||||
$this->title = $this->fields[$r]['Label'];
|
$this->title = $this->fields[$r]['Label'];
|
||||||
unset( $this->fields[$r] );
|
unset( $this->fields[$r] );
|
||||||
$thereisnotitle = false;
|
$thereisnotitle = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($thereisnotitle) {
|
if ($thereisnotitle) {
|
||||||
$this->title = '';
|
$this->title = '';
|
||||||
}
|
}
|
||||||
@@ -530,11 +561,12 @@ class propelTable
|
|||||||
// verify if there are templates folders registered, template and method folders are the same
|
// verify if there are templates folders registered, template and method folders are the same
|
||||||
$folderTemplate = explode( '/', $this->template );
|
$folderTemplate = explode( '/', $this->template );
|
||||||
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||||
if ($oPluginRegistry->isRegisteredFolder( $folderTemplate[0] ))
|
if ($oPluginRegistry->isRegisteredFolder( $folderTemplate[0] )) {
|
||||||
$templateFile = PATH_PLUGINS . $this->template . '.html';
|
$templateFile = PATH_PLUGINS . $this->template . '.html';
|
||||||
else
|
} else {
|
||||||
$templateFile = PATH_TPL . $this->template . '.html';
|
$templateFile = PATH_TPL . $this->template . '.html';
|
||||||
// Prepare the template
|
// Prepare the template
|
||||||
|
}
|
||||||
$this->tpl = new TemplatePower( $templateFile );
|
$this->tpl = new TemplatePower( $templateFile );
|
||||||
$this->tpl->prepare();
|
$this->tpl->prepare();
|
||||||
if (is_array( $fields )) {
|
if (is_array( $fields )) {
|
||||||
@@ -553,8 +585,9 @@ class propelTable
|
|||||||
$this->tpl->assign( "title", $this->title );
|
$this->tpl->assign( "title", $this->title );
|
||||||
if (file_exists( $this->xmlForm->home . $this->filterForm . '.xml' )) {
|
if (file_exists( $this->xmlForm->home . $this->filterForm . '.xml' )) {
|
||||||
$filterForm = new filterForm( $this->filterForm, $this->xmlForm->home );
|
$filterForm = new filterForm( $this->filterForm, $this->xmlForm->home );
|
||||||
if ($this->menu === '')
|
if ($this->menu === '') {
|
||||||
$this->menu = 'gulliver/pagedTable_Options';
|
$this->menu = 'gulliver/pagedTable_Options';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (file_exists( $this->xmlForm->home . $this->menu . '.xml' )) {
|
if (file_exists( $this->xmlForm->home . $this->menu . '.xml' )) {
|
||||||
$menu = new xmlMenu( $this->menu, $this->xmlForm->home );
|
$menu = new xmlMenu( $this->menu, $this->xmlForm->home );
|
||||||
@@ -585,8 +618,9 @@ class propelTable
|
|||||||
$this->tpl->assign( 'content', $filterForm->render( $template, $scriptCode ) );
|
$this->tpl->assign( 'content', $filterForm->render( $template, $scriptCode ) );
|
||||||
$oHeadPublisher->addScriptFile( $filterForm->scriptURL );
|
$oHeadPublisher->addScriptFile( $filterForm->scriptURL );
|
||||||
$oHeadPublisher->addScriptCode( $scriptCode );
|
$oHeadPublisher->addScriptCode( $scriptCode );
|
||||||
if (isset( $_SESSION ))
|
if (isset( $_SESSION )) {
|
||||||
$_SESSION[$filterForm->id] = $filterForm->values;
|
$_SESSION[$filterForm->id] = $filterForm->values;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -620,17 +654,17 @@ class propelTable
|
|||||||
}
|
}
|
||||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||||
/*
|
/*
|
||||||
print "<div class='pagedTableDefault'><table class='default'>";
|
print "<div class='pagedTableDefault'><table class='default'>";
|
||||||
$rs->next();
|
$rs->next();
|
||||||
$row = $rs->getRow();
|
$row = $rs->getRow();
|
||||||
while ( is_array ( $row ) ) {
|
while ( is_array ( $row ) ) {
|
||||||
print "<tr class='Row1'>";
|
print "<tr class='Row1'>";
|
||||||
foreach ( $row as $k=>$v ) print "<td>$v</td>";
|
foreach ( $row as $k=>$v ) print "<td>$v</td>";
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
$rs->next();
|
$rs->next();
|
||||||
$row = $rs->getRow();
|
$row = $rs->getRow();
|
||||||
}
|
}
|
||||||
print "</table></div>"; die;*/
|
print "</table></div>"; die;*/
|
||||||
$gridRows = 0;
|
$gridRows = 0;
|
||||||
$rs->next();
|
$rs->next();
|
||||||
//Initialize the array of breakFields for Master Detail View
|
//Initialize the array of breakFields for Master Detail View
|
||||||
@@ -677,14 +711,16 @@ class propelTable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->tpl->gotoblock( "row" );
|
$this->tpl->gotoblock( "row" );
|
||||||
if (! isset( $rowName ))
|
if (! isset( $rowName )) {
|
||||||
$rowName = array ();
|
$rowName = array ();
|
||||||
|
}
|
||||||
$this->tpl->assign( "rowName", implode( ",", $rowName ) );
|
$this->tpl->assign( "rowName", implode( ",", $rowName ) );
|
||||||
}
|
}
|
||||||
//End Master Detail: This enable the MasterDEtail view
|
//End Master Detail: This enable the MasterDEtail view
|
||||||
//Merge $result with $xmlForm values (for default valuesSettings)
|
//Merge $result with $xmlForm values (for default valuesSettings)
|
||||||
if (is_array( $this->xmlForm->values ))
|
if (is_array( $this->xmlForm->values )) {
|
||||||
$result = array_merge( $this->xmlForm->values, $result );
|
$result = array_merge( $this->xmlForm->values, $result );
|
||||||
|
}
|
||||||
foreach ($this->fields as $r => $rval) {
|
foreach ($this->fields as $r => $rval) {
|
||||||
if (strcasecmp( $this->fields[$r]['Type'], 'cellMark' ) == 0) {
|
if (strcasecmp( $this->fields[$r]['Type'], 'cellMark' ) == 0) {
|
||||||
$result1 = $result;
|
$result1 = $result;
|
||||||
@@ -695,8 +731,9 @@ class propelTable
|
|||||||
$this->tdStyle = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdStyle( $result1, $this->xmlForm );
|
$this->tdStyle = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdStyle( $result1, $this->xmlForm );
|
||||||
$this->tdClass = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdClass( $result1, $this->xmlForm );
|
$this->tdClass = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdClass( $result1, $this->xmlForm );
|
||||||
} elseif ($this->style[$r]['showInTable'] != '0') {
|
} elseif ($this->style[$r]['showInTable'] != '0') {
|
||||||
if (($this->style[$r]['showInTable'] != '0') && (! (in_array( $this->fields[$r]['Name'], $this->masterdetail ))))
|
if (($this->style[$r]['showInTable'] != '0') && (! (in_array( $this->fields[$r]['Name'], $this->masterdetail )))) {
|
||||||
$this->renderField( $j + 1, $r, $result );
|
$this->renderField( $j + 1, $r, $result );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -728,20 +765,23 @@ class propelTable
|
|||||||
$last = "<a class='noLastPage'> </a>";
|
$last = "<a class='noLastPage'> </a>";
|
||||||
}
|
}
|
||||||
$pagesEnum = '';
|
$pagesEnum = '';
|
||||||
for ($r = 1; $r <= $this->totPages; $r ++)
|
for ($r = 1; $r <= $this->totPages; $r ++) {
|
||||||
if (($r >= ($this->currentPage - 5)) && ($r <= ($this->currentPage + 5))) {
|
if (($r >= ($this->currentPage - 5)) && ($r <= ($this->currentPage + 5))) {
|
||||||
$pageAjax = $this->id . ".doGoToPage(" . $r . ");return false;";
|
$pageAjax = $this->id . ".doGoToPage(" . $r . ");return false;";
|
||||||
if ($r != $this->currentPage)
|
if ($r != $this->currentPage) {
|
||||||
$pagesEnum .= " <a href=\"" . htmlentities( $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $r, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $pageAjax . "\">" . $r . "</a>";
|
$pagesEnum .= " <a href=\"" . htmlentities( $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $r, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $pageAjax . "\">" . $r . "</a>";
|
||||||
else
|
} else {
|
||||||
$pagesEnum .= " <a>" . $r . "</a>";
|
$pagesEnum .= " <a>" . $r . "</a>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($this->totRows === 0) {
|
if ($this->totRows === 0) {
|
||||||
$this->tpl->newBlock( 'norecords' );
|
$this->tpl->newBlock( 'norecords' );
|
||||||
$this->tpl->assign( "columnCount", $this->colCount );
|
$this->tpl->assign( "columnCount", $this->colCount );
|
||||||
$noRecordsFound = 'ID_NO_RECORDS_FOUND';
|
$noRecordsFound = 'ID_NO_RECORDS_FOUND';
|
||||||
if (G::LoadTranslation( $noRecordsFound ))
|
if (G::LoadTranslation( $noRecordsFound )) {
|
||||||
$noRecordsFound = G::LoadTranslation( $noRecordsFound );
|
$noRecordsFound = G::LoadTranslation( $noRecordsFound );
|
||||||
|
}
|
||||||
$this->tpl->assign( "noRecordsFound", $noRecordsFound );
|
$this->tpl->assign( "noRecordsFound", $noRecordsFound );
|
||||||
}
|
}
|
||||||
if (! $this->disableFooter) {
|
if (! $this->disableFooter) {
|
||||||
@@ -770,32 +810,34 @@ class propelTable
|
|||||||
} else {
|
} else {
|
||||||
$this->tpl->assign( "fastSearchStyle", 'visibility:hidden;' );
|
$this->tpl->assign( "fastSearchStyle", 'visibility:hidden;' );
|
||||||
}
|
}
|
||||||
if ($this->addRow)
|
if ($this->addRow) {
|
||||||
if ($this->sqlInsert != '')
|
if ($this->sqlInsert != '') {
|
||||||
$this->tpl->assign( "insert", '<a href="#" onclick="pagedTable.event=\'Insert\';popup(\'' . $this->popupPage . '\');return false;">'./*G::LoadXml('labels','ID_ADD_NEW')*/ 'ID_ADD_NEW' . '</a>' );
|
$this->tpl->assign( "insert", '<a href="#" onclick="pagedTable.event=\'Insert\';popup(\'' . $this->popupPage . '\');return false;">'./*G::LoadXml('labels','ID_ADD_NEW')*/ 'ID_ADD_NEW' . '</a>' );
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->tpl->assign( "pagesEnum", $pagesEnum );
|
$this->tpl->assign( "pagesEnum", $pagesEnum );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<script language='JavaScript'>
|
<script language='JavaScript'>
|
||||||
var <?php echo $this->id?><?php echo ($this->name != '' ? '='.$this->name : '')?>=new G_PagedTable();
|
var <?php echo $this->id?><?php echo ($this->name != '' ? '='.$this->name : '')?>=new G_PagedTable();
|
||||||
<?php echo $this->id?>.id<?php echo '="'. addslashes($this->id) . '"'?>;
|
<?php echo $this->id?>.id<?php echo '="'. addslashes($this->id) . '"'?>;
|
||||||
<?php echo $this->id?>.name<?php echo '="'. addslashes($this->name) . '"'?>;
|
<?php echo $this->id?>.name<?php echo '="'. addslashes($this->name) . '"'?>;
|
||||||
<?php echo $this->id?>.ajaxUri<?php echo '="'. addslashes($this->ajaxServer) . '?ptID='.$this->id.'"'?>;
|
<?php echo $this->id?>.ajaxUri<?php echo '="'. addslashes($this->ajaxServer) . '?ptID='.$this->id.'"'?>;
|
||||||
<?php echo $this->id?>.currentOrder<?php echo '="'. addslashes($this->orderBy) . '"'?>;
|
<?php echo $this->id?>.currentOrder<?php echo '="'. addslashes($this->orderBy) . '"'?>;
|
||||||
<?php echo $this->id?>.currentFilter;
|
<?php echo $this->id?>.currentFilter;
|
||||||
<?php echo $this->id?>.currentPage<?php echo '='. $this->currentPage?>;
|
<?php echo $this->id?>.currentPage<?php echo '='. $this->currentPage?>;
|
||||||
<?php echo $this->id?>.totalRows<?php echo '='.$this->totRows ?>;
|
<?php echo $this->id?>.totalRows<?php echo '='.$this->totRows ?>;
|
||||||
<?php echo $this->id?>.rowsPerPage<?php echo '='.$this->rowsPerPage?>;
|
<?php echo $this->id?>.rowsPerPage<?php echo '='.$this->rowsPerPage?>;
|
||||||
<?php echo $this->id?>.popupPage<?php echo '="'. addslashes($this->popupPage) . '?ptID='.$this->id.'"'?>;
|
<?php echo $this->id?>.popupPage<?php echo '="'. addslashes($this->popupPage) . '?ptID='.$this->id.'"'?>;
|
||||||
<?php echo $this->id?>.onUpdateField<?php echo '="'. addslashes($this->onUpdateField) . '"'?>;
|
<?php echo $this->id?>.onUpdateField<?php echo '="'. addslashes($this->onUpdateField) . '"'?>;
|
||||||
<?php echo $this->id?>.shownFields<?php echo '='.$this->shownFields ?>;
|
<?php echo $this->id?>.shownFields<?php echo '='.$this->shownFields ?>;
|
||||||
|
|
||||||
var panelPopup;
|
var panelPopup;
|
||||||
var popupWidth<?php echo '='.$this->popupWidth?>;
|
var popupWidth<?php echo '='.$this->popupWidth?>;
|
||||||
var popupHeight<?php echo '='.$this->popupHeight?>;
|
var popupHeight<?php echo '='.$this->popupHeight?>;
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* ******** CLOSE BLOCK **************
|
* ******** CLOSE BLOCK **************
|
||||||
@@ -831,4 +873,5 @@ var popupHeight<?php echo '='.$this->popupHeight?>;
|
|||||||
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $filename, '', $data, $this->popupSubmit );
|
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $filename, '', $data, $this->popupSubmit );
|
||||||
G::RenderPage( "publish", "blank" );
|
G::RenderPage( "publish", "blank" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,156 +2,154 @@
|
|||||||
|
|
||||||
class Entity_Base
|
class Entity_Base
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this function check if a field is in the data sent in the constructor
|
* this function check if a field is in the data sent in the constructor
|
||||||
* you can specify an array, and this function will use like alias
|
* you can specify an array, and this function will use like alias
|
||||||
*/
|
*/
|
||||||
protected function validateField($field, $default = false)
|
protected function validateField ($field, $default = false)
|
||||||
{
|
{
|
||||||
$fieldIsEmpty = true;
|
$fieldIsEmpty = true;
|
||||||
|
|
||||||
// this is a trick, if $fields is a string, $fields will be an array with
|
// this is a trick, if $fields is a string, $fields will be an array with
|
||||||
// one element
|
// one element
|
||||||
if (is_array ($field)) {
|
if (is_array( $field )) {
|
||||||
$fields = $field;
|
$fields = $field;
|
||||||
}
|
} else {
|
||||||
else {
|
$fields = array ();
|
||||||
$fields = array ();
|
$fields[] = $field;
|
||||||
$fields [] = $field;
|
}
|
||||||
}
|
|
||||||
|
// if there are aliases for this field, evaluate all aliases and take the
|
||||||
// if there are aliases for this field, evaluate all aliases and take the
|
// first occurence
|
||||||
// first occurence
|
foreach ($fields as $k => $f) {
|
||||||
foreach ($fields as $k => $f) {
|
if (isset( $this->temp[$f] )) {
|
||||||
if (isset ($this->temp [$f])) {
|
$fieldIsEmpty = false;
|
||||||
$fieldIsEmpty = false;
|
return $this->temp[$f];
|
||||||
return $this->temp [$f];
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// field empty means the user has not sent a value for this Field, so we are
|
||||||
// field empty means the user has not sent a value for this Field, so we are
|
// using the default value
|
||||||
// using the default value
|
if ($fieldIsEmpty) {
|
||||||
if ($fieldIsEmpty) {
|
if ($default !== false) {
|
||||||
if ($default !== false) {
|
return $default;
|
||||||
return $default;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function validateRequiredFields($requiredFields = array())
|
|
||||||
{
|
|
||||||
foreach ($requiredFields as $k => $field) {
|
|
||||||
if ($this->{$field} === NULL) {
|
|
||||||
throw (new Exception ("Field $field is required in " . get_class ($this)));
|
|
||||||
die ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Copy the values of the Entity to the array of aliases
|
|
||||||
* The array of aliases must be defined.
|
|
||||||
*
|
|
||||||
* @return Array of alias with the Entity values
|
|
||||||
*/
|
|
||||||
public function getAliasDataArray()
|
|
||||||
{
|
|
||||||
$aAlias = array ();
|
|
||||||
// get aliases from class
|
|
||||||
$className = get_class ($this);
|
|
||||||
if (method_exists ($className, 'GetAliases')) {
|
|
||||||
$aliases = call_user_func (array (
|
|
||||||
$className,
|
|
||||||
'GetAliases'
|
|
||||||
));
|
|
||||||
// $aliases = $className::GetAliases ();
|
|
||||||
foreach ($this as $field => $value)
|
|
||||||
if (isset ($aliases [$field])) {
|
|
||||||
// echo "Field exists in Aliases: " . $field . "\n";
|
|
||||||
// echo "Alias Name:" . $aliases[$field] . "\n";
|
|
||||||
// echo "Alias value:" . $value . "\n";
|
|
||||||
$aAlias [$aliases [$field]] = $value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $aAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Set the data from array of alias to Entity
|
|
||||||
*
|
|
||||||
* @param $aAliasData array
|
|
||||||
* of data of aliases
|
|
||||||
*/
|
|
||||||
public function setAliasDataArray($aAliasData)
|
|
||||||
{
|
|
||||||
// get aliases from class
|
|
||||||
$className = get_class ($this);
|
|
||||||
if (method_exists ($className, 'GetAliases')) {
|
|
||||||
$aliases = call_user_func (array (
|
|
||||||
$className,
|
|
||||||
'GetAliases'
|
|
||||||
));
|
|
||||||
// $aliases = $className::GetAliases ();
|
|
||||||
foreach ($this as $field => $value)
|
|
||||||
if (isset ($aliases [$field]))
|
|
||||||
$this->{$field} = $aAliasData [$aliases [$field]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Initialize object with values from $data.
|
|
||||||
* The values from data use properties or alias array.
|
|
||||||
*
|
|
||||||
* @param
|
|
||||||
* $data
|
|
||||||
*/
|
|
||||||
protected function initializeObject($data)
|
|
||||||
{
|
|
||||||
// get aliases from class
|
|
||||||
$className = get_class ($this);
|
|
||||||
$aliases = array ();
|
|
||||||
$swAliases = false;
|
|
||||||
if (method_exists ($className, 'GetAliases')) {
|
|
||||||
$aliases = call_user_func (array (
|
|
||||||
$className,
|
|
||||||
'GetAliases'
|
|
||||||
));
|
|
||||||
// $aliases = $className::GetAliases ();
|
|
||||||
$swAliases = true;
|
|
||||||
}
|
|
||||||
// use object properties or aliases to initialize
|
|
||||||
foreach ($this as $field => $value)
|
|
||||||
if (isset ($data [$field])) {
|
|
||||||
$this->$field = $data [$field];
|
|
||||||
}
|
|
||||||
elseif ($swAliases && isset ($aliases [$field]) && isset ($data [$aliases [$field]])) {
|
|
||||||
$this->$field = $data [$aliases [$field]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function serialize()
|
|
||||||
{
|
|
||||||
if (isset ($this->temp))
|
|
||||||
unset ($this->temp);
|
|
||||||
return serialize ($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function unserialize($str)
|
|
||||||
{
|
|
||||||
$className = get_class ($this);
|
|
||||||
$data = unserialize ($str);
|
|
||||||
return new $className ($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
protected function validateRequiredFields ($requiredFields = array())
|
||||||
|
{
|
||||||
|
foreach ($requiredFields as $k => $field) {
|
||||||
|
if ($this->{$field} === null) {
|
||||||
|
throw (new Exception( "Field $field is required in " . get_class( $this ) ));
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Copy the values of the Entity to the array of aliases
|
||||||
|
* The array of aliases must be defined.
|
||||||
|
*
|
||||||
|
* @return Array of alias with the Entity values
|
||||||
|
*/
|
||||||
|
public function getAliasDataArray ()
|
||||||
|
{
|
||||||
|
$aAlias = array ();
|
||||||
|
// get aliases from class
|
||||||
|
$className = get_class( $this );
|
||||||
|
if (method_exists( $className, 'GetAliases' )) {
|
||||||
|
$aliases = call_user_func( array ($className,'GetAliases'
|
||||||
|
) );
|
||||||
|
// $aliases = $className::GetAliases ();
|
||||||
|
foreach ($this as $field => $value) {
|
||||||
|
if (isset( $aliases[$field] )) {
|
||||||
|
// echo "Field exists in Aliases: " . $field . "\n";
|
||||||
|
// echo "Alias Name:" . $aliases[$field] . "\n";
|
||||||
|
// echo "Alias value:" . $value . "\n";
|
||||||
|
$aAlias[$aliases[$field]] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $aAlias;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Set the data from array of alias to Entity
|
||||||
|
*
|
||||||
|
* @param $aAliasData array of data of aliases
|
||||||
|
*/
|
||||||
|
public function setAliasDataArray ($aAliasData)
|
||||||
|
{
|
||||||
|
// get aliases from class
|
||||||
|
$className = get_class( $this );
|
||||||
|
if (method_exists( $className, 'GetAliases' )) {
|
||||||
|
$aliases = call_user_func( array ($className,'GetAliases'
|
||||||
|
) );
|
||||||
|
// $aliases = $className::GetAliases ();
|
||||||
|
foreach ($this as $field => $value) {
|
||||||
|
if (isset( $aliases[$field] )) {
|
||||||
|
$this->{$field} = $aAliasData[$aliases[$field]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Initialize object with values from $data.
|
||||||
|
* The values from data use properties or alias array.
|
||||||
|
*
|
||||||
|
* @param $data
|
||||||
|
*/
|
||||||
|
protected function initializeObject ($data)
|
||||||
|
{
|
||||||
|
// get aliases from class
|
||||||
|
$className = get_class( $this );
|
||||||
|
$aliases = array ();
|
||||||
|
$swAliases = false;
|
||||||
|
if (method_exists( $className, 'GetAliases' )) {
|
||||||
|
$aliases = call_user_func( array ($className,'GetAliases'
|
||||||
|
) );
|
||||||
|
// $aliases = $className::GetAliases ();
|
||||||
|
$swAliases = true;
|
||||||
|
}
|
||||||
|
// use object properties or aliases to initialize
|
||||||
|
foreach ($this as $field => $value) {
|
||||||
|
if (isset( $data[$field] )) {
|
||||||
|
$this->$field = $data[$field];
|
||||||
|
} elseif ($swAliases && isset( $aliases[$field] ) && isset( $data[$aliases[$field]] )) {
|
||||||
|
$this->$field = $data[$aliases[$field]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function serialize ()
|
||||||
|
{
|
||||||
|
if (isset( $this->temp )) {
|
||||||
|
unset( $this->temp );
|
||||||
|
}
|
||||||
|
return serialize( $this );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function unserialize ($str)
|
||||||
|
{
|
||||||
|
$className = get_class( $this );
|
||||||
|
$data = unserialize( $str );
|
||||||
|
return new $className( $data );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,337 +1,358 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* AppEvent.php
|
* AppEvent.php
|
||||||
* @package workflow.engine.classes.model
|
*
|
||||||
|
* @package workflow.engine.classes.model
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once 'classes/model/om/BaseAppEvent.php';
|
require_once 'classes/model/om/BaseAppEvent.php';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Skeleton subclass for representing a row from the 'APP_EVENT' table.
|
* Skeleton subclass for representing a row from the 'APP_EVENT' table.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* You should add additional methods to this class to meet the
|
* You should add additional methods to this class to meet the
|
||||||
* application requirements. This class will only be generated as
|
* application requirements. This class will only be generated as
|
||||||
* long as it does not already exist in the output directory.
|
* long as it does not already exist in the output directory.
|
||||||
*
|
*
|
||||||
* @package workflow.engine.classes.model
|
* @package workflow.engine.classes.model
|
||||||
*/
|
*/
|
||||||
class AppEvent extends BaseAppEvent {
|
class AppEvent extends BaseAppEvent
|
||||||
public function load($sApplicationUID, $iDelegation) {
|
{
|
||||||
try {
|
|
||||||
$oAppEvent = AppEventPeer::retrieveByPK($sApplicationUID, $iDelegation);
|
|
||||||
if (!is_null($oAppEvent)) {
|
|
||||||
$aFields = $oAppEvent->toArray(BasePeer::TYPE_FIELDNAME);
|
|
||||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
|
||||||
return $aFields;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw(new Exception('This row doesn\'t exist!'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception $oError) {
|
|
||||||
throw($oError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function create($aData) {
|
public function load ($sApplicationUID, $iDelegation)
|
||||||
$oConnection = Propel::getConnection(AppEventPeer::DATABASE_NAME);
|
{
|
||||||
try {
|
try {
|
||||||
$oAppEvent = new AppEvent();
|
$oAppEvent = AppEventPeer::retrieveByPK( $sApplicationUID, $iDelegation );
|
||||||
$oAppEvent->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
if (! is_null( $oAppEvent )) {
|
||||||
if ($oAppEvent->validate()) {
|
$aFields = $oAppEvent->toArray( BasePeer::TYPE_FIELDNAME );
|
||||||
$oConnection->begin();
|
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
|
||||||
$iResult = $oAppEvent->save();
|
return $aFields;
|
||||||
$oConnection->commit();
|
} else {
|
||||||
return true;
|
throw (new Exception( 'This row doesn\'t exist!' ));
|
||||||
}
|
}
|
||||||
else {
|
} catch (Exception $oError) {
|
||||||
$sMessage = '';
|
throw ($oError);
|
||||||
$aValidationFailures = $oAppEvent->getValidationFailures();
|
|
||||||
foreach($aValidationFailures as $oValidationFailure) {
|
|
||||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
|
||||||
}
|
}
|
||||||
throw(new Exception('The registry cannot be created!<br />' . $sMessage));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception $oError) {
|
|
||||||
$oConnection->rollback();
|
|
||||||
throw($oError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function update($aData) {
|
function create ($aData)
|
||||||
$oConnection = Propel::getConnection(AppEventPeer::DATABASE_NAME);
|
{
|
||||||
try {
|
$oConnection = Propel::getConnection( AppEventPeer::DATABASE_NAME );
|
||||||
$oAppEvent = AppEventPeer::retrieveByPK($aData['APP_UID'], $aData['DEL_INDEX']);
|
try {
|
||||||
if (!is_null($oAppEvent)) {
|
$oAppEvent = new AppEvent();
|
||||||
$oAppEvent->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
$oAppEvent->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||||
if ($oAppEvent->validate()) {
|
if ($oAppEvent->validate()) {
|
||||||
$oConnection->begin();
|
$oConnection->begin();
|
||||||
$iResult = $oAppEvent->save();
|
$iResult = $oAppEvent->save();
|
||||||
$oConnection->commit();
|
$oConnection->commit();
|
||||||
return $iResult;
|
return true;
|
||||||
|
} else {
|
||||||
|
$sMessage = '';
|
||||||
|
$aValidationFailures = $oAppEvent->getValidationFailures();
|
||||||
|
foreach ($aValidationFailures as $oValidationFailure) {
|
||||||
|
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||||
|
}
|
||||||
|
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
|
||||||
|
}
|
||||||
|
} catch (Exception $oError) {
|
||||||
|
$oConnection->rollback();
|
||||||
|
throw ($oError);
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
$sMessage = '';
|
|
||||||
$aValidationFailures = $oAppEvent->getValidationFailures();
|
function update ($aData)
|
||||||
foreach($aValidationFailures as $oValidationFailure) {
|
{
|
||||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
$oConnection = Propel::getConnection( AppEventPeer::DATABASE_NAME );
|
||||||
}
|
try {
|
||||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
$oAppEvent = AppEventPeer::retrieveByPK( $aData['APP_UID'], $aData['DEL_INDEX'] );
|
||||||
|
if (! is_null( $oAppEvent )) {
|
||||||
|
$oAppEvent->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||||
|
if ($oAppEvent->validate()) {
|
||||||
|
$oConnection->begin();
|
||||||
|
$iResult = $oAppEvent->save();
|
||||||
|
$oConnection->commit();
|
||||||
|
return $iResult;
|
||||||
|
} else {
|
||||||
|
$sMessage = '';
|
||||||
|
$aValidationFailures = $oAppEvent->getValidationFailures();
|
||||||
|
foreach ($aValidationFailures as $oValidationFailure) {
|
||||||
|
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||||
|
}
|
||||||
|
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw (new Exception( 'This row doesn\'t exist!' ));
|
||||||
|
}
|
||||||
|
} catch (Exception $oError) {
|
||||||
|
$oConnection->rollback();
|
||||||
|
throw ($oError);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw(new Exception('This row doesn\'t exist!'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception $oError) {
|
|
||||||
$oConnection->rollback();
|
|
||||||
throw($oError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove($sApplicationUID, $iDelegation, $sEvnUid) {
|
function remove ($sApplicationUID, $iDelegation, $sEvnUid)
|
||||||
$oConnection = Propel::getConnection(AppEventPeer::DATABASE_NAME);
|
{
|
||||||
try {
|
$oConnection = Propel::getConnection( AppEventPeer::DATABASE_NAME );
|
||||||
$oAppEvent = AppEventPeer::retrieveByPK($sApplicationUID, $iDelegation, $sEvnUid);
|
try {
|
||||||
if (!is_null($oAppEvent)) {
|
$oAppEvent = AppEventPeer::retrieveByPK( $sApplicationUID, $iDelegation, $sEvnUid );
|
||||||
$oConnection->begin();
|
if (! is_null( $oAppEvent )) {
|
||||||
$iResult = $oAppEvent->delete();
|
$oConnection->begin();
|
||||||
$oConnection->commit();
|
$iResult = $oAppEvent->delete();
|
||||||
return $iResult;
|
$oConnection->commit();
|
||||||
}
|
return $iResult;
|
||||||
else {
|
} else {
|
||||||
throw(new Exception('This row doesn\'t exist!'));
|
throw (new Exception( 'This row doesn\'t exist!' ));
|
||||||
}
|
}
|
||||||
|
} catch (Exception $oError) {
|
||||||
|
$oConnection->rollback();
|
||||||
|
throw ($oError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception $oError) {
|
|
||||||
$oConnection->rollback();
|
|
||||||
throw($oError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getAppEventsCriteria($sProcessUid='', $sStatus = '', $EVN_ACTION='') {
|
function getAppEventsCriteria ($sProcessUid = '', $sStatus = '', $EVN_ACTION = '')
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
require_once 'classes/model/Event.php';
|
require_once 'classes/model/Event.php';
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria( 'workflow' );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::APP_UID);
|
$oCriteria->addSelectColumn( AppEventPeer::APP_UID );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::DEL_INDEX);
|
$oCriteria->addSelectColumn( AppEventPeer::DEL_INDEX );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::EVN_UID);
|
$oCriteria->addSelectColumn( AppEventPeer::EVN_UID );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ACTION_DATE);
|
$oCriteria->addSelectColumn( AppEventPeer::APP_EVN_ACTION_DATE );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ATTEMPTS);
|
$oCriteria->addSelectColumn( AppEventPeer::APP_EVN_ATTEMPTS );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_LAST_EXECUTION_DATE);
|
$oCriteria->addSelectColumn( AppEventPeer::APP_EVN_LAST_EXECUTION_DATE );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_STATUS);
|
$oCriteria->addSelectColumn( AppEventPeer::APP_EVN_STATUS );
|
||||||
$oCriteria->addSelectColumn(EventPeer::PRO_UID);
|
$oCriteria->addSelectColumn( EventPeer::PRO_UID );
|
||||||
$oCriteria->addSelectColumn(EventPeer::EVN_WHEN_OCCURS);
|
$oCriteria->addSelectColumn( EventPeer::EVN_WHEN_OCCURS );
|
||||||
$oCriteria->addSelectColumn(EventPeer::EVN_ACTION);
|
$oCriteria->addSelectColumn( EventPeer::EVN_ACTION );
|
||||||
$oCriteria->addAsColumn('EVN_DESCRIPTION', 'C1.CON_VALUE');
|
$oCriteria->addAsColumn( 'EVN_DESCRIPTION', 'C1.CON_VALUE' );
|
||||||
$oCriteria->addAsColumn('TAS_TITLE', 'C2.CON_VALUE');
|
$oCriteria->addAsColumn( 'TAS_TITLE', 'C2.CON_VALUE' );
|
||||||
$oCriteria->addAsColumn('APP_TITLE', 'C3.CON_VALUE');
|
$oCriteria->addAsColumn( 'APP_TITLE', 'C3.CON_VALUE' );
|
||||||
$oCriteria->addAsColumn('PRO_TITLE', 'C4.CON_VALUE');
|
$oCriteria->addAsColumn( 'PRO_TITLE', 'C4.CON_VALUE' );
|
||||||
$oCriteria->addAlias('C1', 'CONTENT');
|
$oCriteria->addAlias( 'C1', 'CONTENT' );
|
||||||
$oCriteria->addAlias('C2', 'CONTENT');
|
$oCriteria->addAlias( 'C2', 'CONTENT' );
|
||||||
$oCriteria->addAlias('C3', 'CONTENT');
|
$oCriteria->addAlias( 'C3', 'CONTENT' );
|
||||||
$oCriteria->addAlias('C4', 'CONTENT');
|
$oCriteria->addAlias( 'C4', 'CONTENT' );
|
||||||
$oCriteria->addJoin(AppEventPeer::EVN_UID, EventPeer::EVN_UID, Criteria::LEFT_JOIN);
|
$oCriteria->addJoin( AppEventPeer::EVN_UID, EventPeer::EVN_UID, Criteria::LEFT_JOIN );
|
||||||
$del = DBAdapter::getStringDelimiter();
|
$del = DBAdapter::getStringDelimiter();
|
||||||
$aConditions = array();
|
$aConditions = array ();
|
||||||
$aConditions[] = array(EventPeer::EVN_UID, 'C1.CON_ID');
|
$aConditions[] = array (EventPeer::EVN_UID,'C1.CON_ID'
|
||||||
$aConditions[] = array('C1.CON_CATEGORY', $del . 'EVN_DESCRIPTION' . $del);
|
);
|
||||||
$aConditions[] = array('C1.CON_LANG', $del . SYS_LANG . $del);
|
$aConditions[] = array ('C1.CON_CATEGORY',$del . 'EVN_DESCRIPTION' . $del
|
||||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
);
|
||||||
$aConditions = array();
|
$aConditions[] = array ('C1.CON_LANG',$del . SYS_LANG . $del
|
||||||
$aConditions[] = array(AppEventPeer::APP_UID, AppDelegationPeer::APP_UID);
|
);
|
||||||
$aConditions[] = array(AppEventPeer::DEL_INDEX, AppDelegationPeer::DEL_INDEX);
|
$oCriteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
|
||||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
$aConditions = array ();
|
||||||
$aConditions = array();
|
$aConditions[] = array (AppEventPeer::APP_UID,AppDelegationPeer::APP_UID
|
||||||
$aConditions[] = array(AppDelegationPeer::TAS_UID, 'C2.CON_ID');
|
);
|
||||||
$aConditions[] = array('C2.CON_CATEGORY', $del . 'TAS_TITLE' . $del);
|
$aConditions[] = array (AppEventPeer::DEL_INDEX,AppDelegationPeer::DEL_INDEX
|
||||||
$aConditions[] = array('C2.CON_LANG', $del . SYS_LANG . $del);
|
);
|
||||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
$oCriteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
|
||||||
$aConditions = array();
|
$aConditions = array ();
|
||||||
$aConditions[] = array(AppDelegationPeer::APP_UID, 'C3.CON_ID');
|
$aConditions[] = array (AppDelegationPeer::TAS_UID,'C2.CON_ID'
|
||||||
$aConditions[] = array('C3.CON_CATEGORY', $del . 'APP_TITLE' . $del);
|
);
|
||||||
$aConditions[] = array('C3.CON_LANG', $del . SYS_LANG . $del);
|
$aConditions[] = array ('C2.CON_CATEGORY',$del . 'TAS_TITLE' . $del
|
||||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
);
|
||||||
$aConditions = array();
|
$aConditions[] = array ('C2.CON_LANG',$del . SYS_LANG . $del
|
||||||
$aConditions[] = array(AppDelegationPeer::PRO_UID, 'C4.CON_ID');
|
);
|
||||||
$aConditions[] = array('C4.CON_CATEGORY', $del . 'PRO_TITLE' . $del);
|
$oCriteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
|
||||||
$aConditions[] = array('C4.CON_LANG', $del . SYS_LANG . $del);
|
$aConditions = array ();
|
||||||
|
$aConditions[] = array (AppDelegationPeer::APP_UID,'C3.CON_ID'
|
||||||
|
);
|
||||||
|
$aConditions[] = array ('C3.CON_CATEGORY',$del . 'APP_TITLE' . $del
|
||||||
|
);
|
||||||
|
$aConditions[] = array ('C3.CON_LANG',$del . SYS_LANG . $del
|
||||||
|
);
|
||||||
|
$oCriteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
|
||||||
|
$aConditions = array ();
|
||||||
|
$aConditions[] = array (AppDelegationPeer::PRO_UID,'C4.CON_ID'
|
||||||
|
);
|
||||||
|
$aConditions[] = array ('C4.CON_CATEGORY',$del . 'PRO_TITLE' . $del
|
||||||
|
);
|
||||||
|
$aConditions[] = array ('C4.CON_LANG',$del . SYS_LANG . $del
|
||||||
|
);
|
||||||
|
|
||||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
$oCriteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
|
||||||
$oCriteria->add(AppEventPeer::EVN_UID, '', Criteria::NOT_EQUAL);
|
$oCriteria->add( AppEventPeer::EVN_UID, '', Criteria::NOT_EQUAL );
|
||||||
if($sProcessUid != ''){
|
if ($sProcessUid != '') {
|
||||||
$oCriteria->add(EventPeer::PRO_UID, $sProcessUid);
|
$oCriteria->add( EventPeer::PRO_UID, $sProcessUid );
|
||||||
}
|
}
|
||||||
if($EVN_ACTION != ''){
|
if ($EVN_ACTION != '') {
|
||||||
$oCriteria->add(EventPeer::EVN_ACTION, $EVN_ACTION);
|
$oCriteria->add( EventPeer::EVN_ACTION, $EVN_ACTION );
|
||||||
}
|
}
|
||||||
switch ($sStatus) {
|
switch ($sStatus) {
|
||||||
case '':
|
case '':
|
||||||
//Nothing
|
//Nothing
|
||||||
break;
|
break;
|
||||||
case 'PENDING':
|
case 'PENDING':
|
||||||
$oCriteria->add(AppEventPeer::APP_EVN_STATUS, 'OPEN');
|
$oCriteria->add( AppEventPeer::APP_EVN_STATUS, 'OPEN' );
|
||||||
break;
|
break;
|
||||||
case 'COMPLETED':
|
case 'COMPLETED':
|
||||||
$oCriteria->add(AppEventPeer::APP_EVN_STATUS, 'CLOSE');
|
$oCriteria->add( AppEventPeer::APP_EVN_STATUS, 'CLOSE' );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//$oCriteria->addDescendingOrderByColumn(AppEventPeer::APP_EVN_ACTION_DATE);
|
//$oCriteria->addDescendingOrderByColumn(AppEventPeer::APP_EVN_ACTION_DATE);
|
||||||
return $oCriteria;
|
return $oCriteria;
|
||||||
}
|
} catch (Exception $oError) {
|
||||||
catch (Exception $oError) {
|
throw ($oError);
|
||||||
throw($oError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function executeEvents($sNow, $debug=false, &$log=array(), $cron=0) {
|
public function executeEvents ($sNow, $debug = false, &$log = array(), $cron = 0)
|
||||||
|
{
|
||||||
|
|
||||||
require_once 'classes/model/Configuration.php';
|
require_once 'classes/model/Configuration.php';
|
||||||
require_once 'classes/model/Triggers.php';
|
require_once 'classes/model/Triggers.php';
|
||||||
G::LoadClass('case');
|
G::LoadClass( 'case' );
|
||||||
|
|
||||||
$debug = 1;
|
$debug = 1;
|
||||||
$oCase = new Cases();
|
$oCase = new Cases();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria( 'workflow' );
|
||||||
|
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::APP_UID);
|
$oCriteria->addSelectColumn( AppEventPeer::APP_UID );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::DEL_INDEX);
|
$oCriteria->addSelectColumn( AppEventPeer::DEL_INDEX );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::EVN_UID);
|
$oCriteria->addSelectColumn( AppEventPeer::EVN_UID );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ACTION_DATE);
|
$oCriteria->addSelectColumn( AppEventPeer::APP_EVN_ACTION_DATE );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ATTEMPTS);
|
$oCriteria->addSelectColumn( AppEventPeer::APP_EVN_ATTEMPTS );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_LAST_EXECUTION_DATE);
|
$oCriteria->addSelectColumn( AppEventPeer::APP_EVN_LAST_EXECUTION_DATE );
|
||||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_STATUS);
|
$oCriteria->addSelectColumn( AppEventPeer::APP_EVN_STATUS );
|
||||||
$oCriteria->addSelectColumn(EventPeer::PRO_UID);
|
$oCriteria->addSelectColumn( EventPeer::PRO_UID );
|
||||||
$oCriteria->addSelectColumn(EventPeer::EVN_ACTION);
|
$oCriteria->addSelectColumn( EventPeer::EVN_ACTION );
|
||||||
$oCriteria->addSelectColumn(EventPeer::TRI_UID);
|
$oCriteria->addSelectColumn( EventPeer::TRI_UID );
|
||||||
$oCriteria->addSelectColumn(EventPeer::EVN_ACTION_PARAMETERS);
|
$oCriteria->addSelectColumn( EventPeer::EVN_ACTION_PARAMETERS );
|
||||||
$oCriteria->addSelectColumn(EventPeer::EVN_RELATED_TO);
|
$oCriteria->addSelectColumn( EventPeer::EVN_RELATED_TO );
|
||||||
$oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID);
|
$oCriteria->addSelectColumn( AppDelegationPeer::TAS_UID );
|
||||||
$oCriteria->addSelectColumn(AppDelegationPeer::USR_UID);
|
$oCriteria->addSelectColumn( AppDelegationPeer::USR_UID );
|
||||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
|
$oCriteria->addSelectColumn( AppDelegationPeer::DEL_TASK_DUE_DATE );
|
||||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
|
$oCriteria->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
|
||||||
|
|
||||||
|
$oCriteria->addJoin( AppEventPeer::EVN_UID, EventPeer::EVN_UID, Criteria::JOIN );
|
||||||
|
|
||||||
|
$aConditions = array ();
|
||||||
|
array_push( $aConditions, Array (AppEventPeer::APP_UID,AppDelegationPeer::APP_UID
|
||||||
|
) );
|
||||||
|
array_push( $aConditions, Array (AppEventPeer::DEL_INDEX,AppDelegationPeer::DEL_INDEX
|
||||||
|
) );
|
||||||
|
$oCriteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
|
||||||
|
|
||||||
|
$oCriteria->addJoin( ApplicationPeer::APP_UID, AppEventPeer::APP_UID );
|
||||||
|
|
||||||
|
$oCriteria->add( AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL ); //by me
|
||||||
|
$oCriteria->add( AppEventPeer::APP_EVN_STATUS, 'OPEN' );
|
||||||
|
$oCriteria->add( AppEventPeer::APP_EVN_ACTION_DATE, $sNow, Criteria::LESS_EQUAL );
|
||||||
|
|
||||||
|
$oDataset = AppEventPeer::doSelectRS( $oCriteria );
|
||||||
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||||
|
|
||||||
|
$c = 0;
|
||||||
|
while ($oDataset->next()) {
|
||||||
|
if ($cron == 1) {
|
||||||
|
$arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) );
|
||||||
|
$arrayCron["processcTimeStart"] = time();
|
||||||
|
@file_put_contents( PATH_DATA . "cron", serialize( $arrayCron ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$c ++;
|
||||||
|
$aRow = $oDataset->getRow();
|
||||||
|
$oTrigger = new Triggers();
|
||||||
|
$aFields = $oCase->loadCase( $aRow['APP_UID'] );
|
||||||
|
$oAppEvent = AppEventPeer::retrieveByPK( $aRow['APP_UID'], $aRow['DEL_INDEX'], $aRow['EVN_UID'] );
|
||||||
|
|
||||||
|
//g::pr($aRow); //die;
|
||||||
|
|
||||||
|
|
||||||
$oCriteria->addJoin(AppEventPeer::EVN_UID, EventPeer::EVN_UID, Criteria::JOIN);
|
if ($debug) {
|
||||||
|
require_once 'classes/model/Application.php';
|
||||||
|
$oApp = ApplicationPeer::retrieveByPk( $aRow['APP_UID'] );
|
||||||
|
$oEv = EventPeer::retrieveByPk( $aRow['EVN_UID'] );
|
||||||
|
$log[] = 'Event ' . $oEv->getEvnDescription() . ' with ID ' . $aRow['EVN_UID'];
|
||||||
|
|
||||||
$aConditions = array();
|
println( "\nOK+ event \"" . $oEv->getEvnDescription() . "\" with ID {} was found" );
|
||||||
array_push($aConditions, Array(AppEventPeer::APP_UID, AppDelegationPeer::APP_UID));
|
println( " - PROCESS................" . $aRow['PRO_UID'] );
|
||||||
array_push($aConditions, Array(AppEventPeer::DEL_INDEX, AppDelegationPeer::DEL_INDEX));
|
println( " - APPLICATION............" . $aRow['APP_UID'] . " CASE #" . $oApp->getAppNumber() );
|
||||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
println( " - ACTION DATE............" . $aRow['APP_EVN_ACTION_DATE'] );
|
||||||
|
println( " - ATTEMPTS..............." . $aRow['APP_EVN_ATTEMPTS'] );
|
||||||
|
println( " - INTERVAL WITH TASKS...." . $aRow['EVN_RELATED_TO'] );
|
||||||
|
}
|
||||||
|
|
||||||
$oCriteria->addJoin(ApplicationPeer::APP_UID, AppEventPeer::APP_UID);
|
if ($aRow['TRI_UID'] == '') {
|
||||||
|
//a rare case when the tri_uid is not set.
|
||||||
|
$log[] = " (!) Any trigger was set................................SKIPPED and will be CLOSED";
|
||||||
|
if ($debug) {
|
||||||
|
println( " (!) Any trigger was set................................SKIPPED and will be CLOSED" );
|
||||||
|
}
|
||||||
|
$oAppEvent->setAppEvnStatus( 'CLOSE' );
|
||||||
|
$oAppEvent->save();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); //by me
|
$oTrigger = TriggersPeer::retrieveByPk( $aRow['TRI_UID'] );
|
||||||
$oCriteria->add(AppEventPeer::APP_EVN_STATUS, 'OPEN');
|
if (! is_object( $oTrigger )) {
|
||||||
$oCriteria->add(AppEventPeer::APP_EVN_ACTION_DATE, $sNow, Criteria::LESS_EQUAL);
|
//the trigger record doesn't exist..
|
||||||
|
$log[] = ' (!) The trigger ' . $aRow['TRI_UID'] . ' ' . $oTrigger->getTriTitle() . " doesn't exist.......SKIPPED and will be CLOSED";
|
||||||
|
if ($debug) {
|
||||||
|
println( " (!) The trigger {$aRow['TRI_UID']} {$oTrigger->getTriTitle()} doesn't exist.......SKIPPED and will be CLOSED" );
|
||||||
|
}
|
||||||
|
$oAppEvent->setAppEvnStatus( 'CLOSE' );
|
||||||
|
$oAppEvent->save();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$oDataset = AppEventPeer::doSelectRS($oCriteria);
|
global $oPMScript;
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$oPMScript = new PMScript();
|
||||||
|
|
||||||
$c = 0;
|
$task = new Task();
|
||||||
while ($oDataset->next()){
|
$taskFields = $task->Load( $aRow['TAS_UID'] );
|
||||||
if ($cron == 1) {
|
$aFields['APP_DATA']['APP_NUMBER'] = $aFields['APP_NUMBER'];
|
||||||
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
$aFields['APP_DATA']['TAS_TITLE'] = $taskFields['TAS_TITLE'];
|
||||||
$arrayCron["processcTimeStart"] = time();
|
$aFields['APP_DATA']['DEL_TASK_DUE_DATE'] = $aRow['DEL_TASK_DUE_DATE'];
|
||||||
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
|
$oPMScript->setFields( $aFields['APP_DATA'] );
|
||||||
|
$oPMScript->setScript( $oTrigger->getTriWebbot() );
|
||||||
|
|
||||||
|
$oPMScript->execute();
|
||||||
|
|
||||||
|
$oAppEvent->setAppEvnLastExecutionDate( date( 'Y-m-d H:i:s' ) );
|
||||||
|
|
||||||
|
if (sizeof( $_SESSION['TRIGGER_DEBUG']['ERRORS'] ) == 0) {
|
||||||
|
$log[] = ' - The trigger ' . $oTrigger->getTriTitle() . ' was executed successfully!';
|
||||||
|
if ($debug) {
|
||||||
|
println( " - The trigger '{$oTrigger->getTriTitle()}' was executed successfully!" );
|
||||||
|
//g::pr($aFields);
|
||||||
|
}
|
||||||
|
$aFields['APP_DATA'] = $oPMScript->aFields;
|
||||||
|
$oCase->updateCase( $aRow['APP_UID'], $aFields );
|
||||||
|
$oAppEvent->setAppEvnStatus( 'CLOSE' );
|
||||||
|
} else {
|
||||||
|
if ($debug) {
|
||||||
|
$log[] = ' - The trigger ' . $aRow['TRI_UID'] . ' throw some errors!';
|
||||||
|
println( " - The trigger {$aRow['TRI_UID']} throw some errors!" );
|
||||||
|
print_r( $_SESSION['TRIGGER_DEBUG']['ERRORS'] );
|
||||||
|
}
|
||||||
|
if ($oAppEvent->getAppEvnAttempts() > 0) {
|
||||||
|
$oAppEvent->setAppEvnAttempts( $oAppEvent->getAppEvnAttempts() - 1 );
|
||||||
|
} else {
|
||||||
|
$oAppEvent->setAppEvnStatus( 'CLOSE' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$oAppEvent->save();
|
||||||
|
}
|
||||||
|
return $c;
|
||||||
|
} catch (Exception $oError) {
|
||||||
|
$log[] = ' Error execute event : ' . $oError->getMessage();
|
||||||
|
die( $oError->getMessage() );
|
||||||
|
return $oError->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$c++;
|
|
||||||
$aRow = $oDataset->getRow();
|
|
||||||
$oTrigger = new Triggers();
|
|
||||||
$aFields = $oCase->loadCase($aRow['APP_UID']);
|
|
||||||
$oAppEvent = AppEventPeer::retrieveByPK($aRow['APP_UID'], $aRow['DEL_INDEX'], $aRow['EVN_UID']);
|
|
||||||
|
|
||||||
//g::pr($aRow); //die;
|
|
||||||
|
|
||||||
if($debug){
|
|
||||||
require_once 'classes/model/Application.php';
|
|
||||||
$oApp = ApplicationPeer::retrieveByPk($aRow['APP_UID']);
|
|
||||||
$oEv = EventPeer::retrieveByPk($aRow['EVN_UID']);
|
|
||||||
$log[] = 'Event ' . $oEv->getEvnDescription() . ' with ID ' . $aRow['EVN_UID'];
|
|
||||||
|
|
||||||
println("\nOK+ event \"".$oEv->getEvnDescription()."\" with ID {} was found");
|
|
||||||
println(" - PROCESS................".$aRow['PRO_UID']);
|
|
||||||
println(" - APPLICATION............".$aRow['APP_UID']." CASE #".$oApp->getAppNumber());
|
|
||||||
println(" - ACTION DATE............".$aRow['APP_EVN_ACTION_DATE']);
|
|
||||||
println(" - ATTEMPTS...............".$aRow['APP_EVN_ATTEMPTS']);
|
|
||||||
println(" - INTERVAL WITH TASKS....".$aRow['EVN_RELATED_TO']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($aRow['TRI_UID'] == '') {
|
|
||||||
//a rare case when the tri_uid is not set.
|
|
||||||
$log[] = " (!) Any trigger was set................................SKIPPED and will be CLOSED";
|
|
||||||
if($debug) println(" (!) Any trigger was set................................SKIPPED and will be CLOSED");
|
|
||||||
$oAppEvent->setAppEvnStatus('CLOSE');
|
|
||||||
$oAppEvent->save();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$oTrigger = TriggersPeer::retrieveByPk($aRow['TRI_UID']);
|
|
||||||
if( !is_object($oTrigger) ){
|
|
||||||
//the trigger record doesn't exist..
|
|
||||||
$log[] = ' (!) The trigger ' . $aRow['TRI_UID'] . ' ' . $oTrigger->getTriTitle() . " doesn't exist.......SKIPPED and will be CLOSED";
|
|
||||||
if($debug) println(" (!) The trigger {$aRow['TRI_UID']} {$oTrigger->getTriTitle()} doesn't exist.......SKIPPED and will be CLOSED");
|
|
||||||
$oAppEvent->setAppEvnStatus('CLOSE');
|
|
||||||
$oAppEvent->save();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
global $oPMScript;
|
|
||||||
$oPMScript = new PMScript();
|
|
||||||
|
|
||||||
$task = new Task();
|
|
||||||
$taskFields = $task->Load($aRow['TAS_UID']);
|
|
||||||
$aFields['APP_DATA']['APP_NUMBER'] = $aFields['APP_NUMBER'];
|
|
||||||
$aFields['APP_DATA']['TAS_TITLE'] = $taskFields['TAS_TITLE'];
|
|
||||||
$aFields['APP_DATA']['DEL_TASK_DUE_DATE'] = $aRow['DEL_TASK_DUE_DATE'];
|
|
||||||
$oPMScript->setFields($aFields['APP_DATA']);
|
|
||||||
$oPMScript->setScript($oTrigger->getTriWebbot());
|
|
||||||
|
|
||||||
$oPMScript->execute();
|
|
||||||
|
|
||||||
$oAppEvent->setAppEvnLastExecutionDate(date('Y-m-d H:i:s'));
|
|
||||||
|
|
||||||
if( sizeof($_SESSION['TRIGGER_DEBUG']['ERRORS']) == 0 ){
|
|
||||||
$log[] = ' - The trigger ' . $oTrigger->getTriTitle() . ' was executed successfully!';
|
|
||||||
if($debug) println(" - The trigger '{$oTrigger->getTriTitle()}' was executed successfully!");
|
|
||||||
//g::pr($aFields);
|
|
||||||
$aFields['APP_DATA'] = $oPMScript->aFields;
|
|
||||||
$oCase->updateCase($aRow['APP_UID'], $aFields);
|
|
||||||
$oAppEvent->setAppEvnStatus('CLOSE');
|
|
||||||
} else {
|
|
||||||
if($debug) {
|
|
||||||
$log[] = ' - The trigger ' . $aRow['TRI_UID'] . ' throw some errors!';
|
|
||||||
println(" - The trigger {$aRow['TRI_UID']} throw some errors!");
|
|
||||||
print_r($_SESSION['TRIGGER_DEBUG']['ERRORS']);
|
|
||||||
}
|
|
||||||
if ( $oAppEvent->getAppEvnAttempts() > 0 ){
|
|
||||||
$oAppEvent->setAppEvnAttempts($oAppEvent->getAppEvnAttempts() - 1);
|
|
||||||
} else {
|
|
||||||
$oAppEvent->setAppEvnStatus('CLOSE');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$oAppEvent->save();
|
|
||||||
}
|
|
||||||
return $c;
|
|
||||||
}
|
}
|
||||||
catch (Exception $oError) {
|
|
||||||
$log[] = ' Error execute event : ' . $oError->getMessage();
|
function close ($APP_UID, $DEL_INDEX)
|
||||||
die($oError->getMessage());
|
{
|
||||||
return $oError->getMessage();
|
$aRow = $this->load( $APP_UID, $DEL_INDEX );
|
||||||
|
$aRow['APP_EVN_STATUS'] = 'CLOSE';
|
||||||
|
$this->update( $aRow );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// AppEvent
|
||||||
|
|
||||||
function close($APP_UID, $DEL_INDEX){
|
|
||||||
$aRow = $this->load($APP_UID, $DEL_INDEX);
|
|
||||||
$aRow['APP_EVN_STATUS'] = 'CLOSE';
|
|
||||||
$this->update($aRow);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // AppEvent
|
|
||||||
|
|||||||
Reference in New Issue
Block a user