BUG 0000 Adjustment for the standardization of code. CODE_STYLE

This commit is contained in:
Hector Cortez
2013-03-14 12:36:34 -04:00
parent 5cc9925075
commit b7e254b425
9 changed files with 864 additions and 897 deletions

View File

@@ -35,183 +35,176 @@
* date Aug 31th, 2010 * date Aug 31th, 2010
* @copyright (C) 2002 by Colosa Development Team. * @copyright (C) 2002 by Colosa Development Team.
*/ */
class i18n_PO class i18n_PO
{ {
private $_file = null; private $_file = null;
private $_string = ''; private $_string = '';
private $_meta; private $_meta;
private $_fp; private $_fp;
private $_fileComments; private $_fileComments;
protected $_editingHeader; protected $_editingHeader;
protected $_fileLine; protected $_fileLine;
protected $flagEndHeaders; protected $flagEndHeaders;
protected $flagError; protected $flagError;
protected $flagInit; protected $flagInit;
protected $lineNumber; protected $lineNumber;
public $translatorComments; public $translatorComments;
public $extractedComments; public $extractedComments;
public $references; public $references;
public $flags; public $flags;
public $previousUntranslatedStrings; public $previousUntranslatedStrings;
function __construct ($file) public function __construct($file)
{ {
$this->file = $file; $this->file = $file;
} }
function buildInit () public function buildInit()
{ {
$this->_fp = fopen( $this->file, 'w' ); $this->_fp = fopen($this->file, 'w');
if (! is_resource( $this->_fp )) { if (!is_resource($this->_fp)) {
throw new Exception( 'Could\'t open ' . $this->file . ' file' ); throw new Exception('Could\'t open ' . $this->file . ' file');
} }
// lock PO file exclusively // lock PO file exclusively
if (! flock( $this->_fp, LOCK_EX )) { if (!flock($this->_fp, LOCK_EX)) {
fclose( $this->_fp ); fclose($this->_fp);
return false; return false;
} }
$this->_meta = 'msgid ""'; $this->_meta = 'msgid ""';
$this->_writeLine( $this->_meta ); $this->_writeLine($this->_meta);
$this->_meta = 'msgstr ""'; $this->_meta = 'msgstr ""';
$this->_writeLine( $this->_meta ); $this->_writeLine($this->_meta);
$this->_editingHeader = true; $this->_editingHeader = true;
} }
function readInit () public function readInit()
{ {
$this->_fp = fopen( $this->file, 'r' ); $this->_fp = fopen($this->file, 'r');
if (! is_resource( $this->_fp )) { if (!is_resource($this->_fp)) {
throw new Exception( 'Could\'t open ' . $this->file . ' file' ); throw new Exception('Could\'t open ' . $this->file . ' file');
} }
//skipping comments //skipping comments
$this->skipCommets(); $this->skipCommets();
//deaing headers //deaing headers
$this->readHeaders(); $this->readHeaders();
$this->translatorComments = Array (); $this->translatorComments = Array();
$this->extractedComments = Array (); $this->extractedComments = Array();
$this->references = Array (); $this->references = Array();
$this->flags = Array (); $this->flags = Array();
$this->previousUntranslatedStrings = Array (); $this->previousUntranslatedStrings = Array();
} }
function addHeader ($id, $value) public function addHeader($id, $value)
{ {
if ($this->_editingHeader) { if ($this->_editingHeader) {
$meta = '"' . trim( $id ) . ': ' . trim( $value ) . '\n"'; $meta = '"' . trim($id) . ': ' . trim($value) . '\n"';
$this->_writeLine( $meta ); $this->_writeLine($meta);
} }
} }
function addTranslatorComment ($str) public function addTranslatorComment($str)
{ {
$this->headerStroke(); $this->headerStroke();
$comment = '# ' . trim( $str ); $comment = '# ' . trim($str);
$this->_writeLine( $comment ); $this->_writeLine($comment);
} }
function addExtractedComment ($str) public function addExtractedComment($str)
{ {
$this->headerStroke(); $this->headerStroke();
$comment = '#. ' . trim( $str ); $comment = '#. ' . trim($str);
$this->_writeLine( $comment ); $this->_writeLine($comment);
} }
function addReference ($str) public function addReference($str)
{ {
$this->headerStroke(); $this->headerStroke();
$reference = '#: ' . trim( $str ); $reference = '#: ' . trim($str);
$this->_writeLine( $reference ); $this->_writeLine($reference);
} }
function addFlag ($str) public function addFlag($str)
{ {
$this->headerStroke(); $this->headerStroke();
$flag = '#, ' . trim( $str ); $flag = '#, ' . trim($str);
$this->_writeLine( $flag ); $this->_writeLine($flag);
} }
function addPreviousUntranslatedString ($str) public function addPreviousUntranslatedString($str)
{ {
$this->headerStroke(); $this->headerStroke();
$str = '#| ' . trim( $str ); $str = '#| ' . trim($str);
$this->_writeLine( $str ); $this->_writeLine($str);
} }
function addTranslation ($msgid, $msgstr) public function addTranslation($msgid, $msgstr)
{ {
$this->headerStroke(); $this->headerStroke();
$this->_writeLine( 'msgid "' . $this->prepare( $msgid, true ) . '"' ); $this->_writeLine('msgid "' . $this->prepare($msgid, true) . '"');
$this->_writeLine( 'msgstr "' . $this->prepare( $msgstr, true ) . '"' ); $this->_writeLine('msgstr "' . $this->prepare($msgstr, true) . '"');
$this->_writeLine( '' ); $this->_writeLine('');
} }
function _writeLine ($str) public function _writeLine($str)
{ {
$this->_write( $str . "\n" ); $this->_write($str . "\n");
} }
function _write ($str) public function _write($str)
{ {
fwrite( $this->_fp, $str ); fwrite($this->_fp, $str);
} }
function prepare ($string, $reverse = false) public function prepare($string, $reverse = false)
{ {
//$string = str_replace('\"', '"', $string); //$string = str_replace('\"', '"', $string);
//$string = stripslashes($string); //$string = stripslashes($string);
if ($reverse) { if ($reverse) {
$smap = array ('"',"\n","\t","\r" $smap = array('"', "\n", "\t", "\r");
); $rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r');
$rmap = array ('\"','\\n"' . "\n" . '"','\\t','\\r' return (string) str_replace($smap, $rmap, $string);
);
return (string) str_replace( $smap, $rmap, $string );
} else { } else {
$string = preg_replace( '/"\s+"/', '', $string ); $string = preg_replace('/"\s+"/', '', $string);
$smap = array ('\\n','\\r','\\t','\"' $smap = array('\\n', '\\r', '\\t', '\"');
); $rmap = array("\n", "\r", "\t", '"');
$rmap = array ("\n","\r","\t",'"' return (string) str_replace($smap, $rmap, $string);
);
return (string) str_replace( $smap, $rmap, $string );
} }
} }
function headerStroke () public function headerStroke()
{ {
if ($this->_editingHeader) { if ($this->_editingHeader) {
$this->_editingHeader = false; $this->_editingHeader = false;
$this->_writeLine( '' ); $this->_writeLine('');
;
} }
} }
/** /**
* read funtions * * read funtions *
*/ */
private function skipCommets () private function skipCommets()
{ {
$this->_fileComments = ''; $this->_fileComments = '';
do { do {
$lastPos = ftell( $this->_fp ); $lastPos = ftell($this->_fp);
$line = fgets( $this->_fp ); $line = fgets($this->_fp);
$this->_fileComments .= $line; $this->_fileComments .= $line;
} while ((substr( $line, 0, 1 ) == '#' || trim( $line ) == '') && ! feof( $this->_fp )); } while ((substr($line, 0, 1) == '#' || trim($line) == '') && !feof($this->_fp));
fseek( $this->_fp, $lastPos ); fseek($this->_fp, $lastPos);
} }
private function readHeaders () private function readHeaders()
{ {
$this->flagEndHeaders = false; $this->flagEndHeaders = false;
$this->flagError = false; $this->flagError = false;
@@ -219,18 +212,17 @@ class i18n_PO
$this->lineNumber = 0; $this->lineNumber = 0;
$errMsg = ''; $errMsg = '';
while (! $this->flagError && ! $this->flagEndHeaders) { while (!$this->flagError && !$this->flagEndHeaders) {
if ($this->flagInit) { //in first instance if ($this->flagInit) {
//in first instance
$this->flagInit = false; //unset init flag $this->flagInit = false; //unset init flag
//read the first and second line of the file //read the first and second line of the file
$firstLine = fgets( $this->_fp ); $firstLine = fgets($this->_fp);
$secondLine = fgets( $this->_fp ); $secondLine = fgets($this->_fp);
//verifying the file head //verifying the file head
if (strpos( $firstLine, 'msgid ""' ) === false || strpos( $secondLine, 'msgstr ""' ) === false) { if (strpos($firstLine, 'msgid ""') === false || strpos($secondLine, 'msgstr ""') === false) {
$this->flagError = true; $this->flagError = true;
$errMsg = 'Misplace for firts msgid "" and msgstr "" in the header'; $errMsg = 'Misplace for firts msgid "" and msgstr "" in the header';
} }
@@ -238,36 +230,34 @@ class i18n_PO
} }
//getting the new line //getting the new line
$this->_fileLine = trim( fgets( $this->_fp ) ); $this->_fileLine = trim(fgets($this->_fp));
//set line number //set line number
$this->lineNumber ++; $this->lineNumber++;
//verifying that is not end of file and applying a restriction for to read just the twenty firsts lines //verifying that is not end of file and applying a restriction for to read just the twenty firsts lines
if (trim( $this->_fileLine ) == '' || ! $this->_fileLine || $this->lineNumber >= 20) { if (trim($this->_fileLine) == '' || !$this->_fileLine || $this->lineNumber >= 20) {
$this->flagEndHeaders = true; // set ending to read the headers $this->flagEndHeaders = true; // set ending to read the headers
continue; continue;
} }
//verify if has a valid mask header line //verify if has a valid mask header line
preg_match( '/^"([a-z0-9\._-]+)\s*:\s*([\W\w]+)\\\n"$/i', $this->_fileLine, $match ); preg_match('/^"([a-z0-9\._-]+)\s*:\s*([\W\w]+)\\\n"$/i', $this->_fileLine, $match);
//for a valid header line the $match size should three //for a valid header line the $match size should three
if (sizeof( $match ) == 3) { if (sizeof($match) == 3) {
$key = trim( $match[1] ); //getting the key of the header $key = trim($match[1]); //getting the key of the header
$value = trim( $match[2] ); //getting the value of the header $value = trim($match[2]); //getting the value of the header
$this->_meta[$key] = $value; //setting a new header $this->_meta[$key] = $value; //setting a new header
} else { } else {
$this->flagEndHeaders = true; //otherwise set the ending to read the headers $this->flagEndHeaders = true; //otherwise set the ending to read the headers
break; break;
} }
} //end looking for headeers } //end looking for headeers
//verifying the headers data //verifying the headers data
if (! isset( $this->_meta['X-Poedit-Language'] )) { if (!isset($this->_meta['X-Poedit-Language'])) {
if (! isset( $this->_meta['Language'] )) { if (!isset($this->_meta['Language'])) {
$this->flagError = true; $this->flagError = true;
$errMsg = "X-Poedit-Language and Language meta doesn't exist"; $errMsg = "X-Poedit-Language and Language meta doesn't exist";
} else if ($this->_meta['Language'] == '') { } elseif ($this->_meta['Language'] == '') {
$this->flagError = true; $this->flagError = true;
$errMsg = "Language meta is empty"; $errMsg = "Language meta is empty";
} else { } else {
@@ -275,85 +265,85 @@ class i18n_PO
unset($this->_meta['Language']); unset($this->_meta['Language']);
$this->flagError = false; $this->flagError = false;
} }
} else if ($this->_meta['X-Poedit-Language'] == '') { } elseif ($this->_meta['X-Poedit-Language'] == '') {
$this->flagError = true; $this->flagError = true;
$errMsg = "X-Poedit-Language meta is empty"; $errMsg = "X-Poedit-Language meta is empty";
} }
//if the country is not present in metadata //if the country is not present in metadata
if (! isset( $this->_meta['X-Poedit-Country'] )) { if (!isset($this->_meta['X-Poedit-Country'])) {
$this->_meta['X-Poedit-Country'] = '.'; $this->_meta['X-Poedit-Country'] = '.';
} else if ($this->_meta['X-Poedit-Country'] == '') { } elseif ($this->_meta['X-Poedit-Country'] == '') {
$this->_meta['X-Poedit-Country'] = '.'; $this->_meta['X-Poedit-Country'] = '.';
} }
//thowing the exception if is necesary //thowing the exception if is necesary
if ($this->flagError) { if ($this->flagError) {
throw new Exception( "This file is not a valid PO file. ($errMsg)" ); throw new Exception("This file is not a valid PO file. ($errMsg)");
} }
} }
function getHeaders () public function getHeaders()
{ {
return $this->_meta; return $this->_meta;
} }
public function getTranslation () public function getTranslation()
{ {
$flagReadingComments = true; $flagReadingComments = true;
$this->translatorComments = Array (); $this->translatorComments = Array();
$this->extractedComments = Array (); $this->extractedComments = Array();
$this->references = Array (); $this->references = Array();
$this->flags = Array (); $this->flags = Array();
//getting the new line //getting the new line
while ($flagReadingComments && ! $this->flagError) { while ($flagReadingComments && !$this->flagError) {
$this->_fileLine = trim( fgets( $this->_fp ) ); $this->_fileLine = trim(fgets($this->_fp));
//set line number //set line number
$this->lineNumber ++; $this->lineNumber++;
if (! $this->_fileLine) { if (!$this->_fileLine) {
return false; return false;
} }
$prefix = substr( $this->_fileLine, 0, 2 ); $prefix = substr($this->_fileLine, 0, 2);
switch ($prefix) { switch ($prefix) {
case '# ': case '# ':
$lineItem = str_replace( '# ', '', $this->_fileLine ); $lineItem = str_replace('# ', '', $this->_fileLine);
$this->translatorComments[] = $lineItem; $this->translatorComments[] = $lineItem;
break; break;
case '#.': case '#.':
if (substr_count( $this->_fileLine, '#. ' ) == 0) { if (substr_count($this->_fileLine, '#. ') == 0) {
$this->flagError = true; $this->flagError = true;
} else { } else {
$lineItem = str_replace( '#. ', '', $this->_fileLine ); $lineItem = str_replace('#. ', '', $this->_fileLine);
$this->extractedComments[] = $lineItem; $this->extractedComments[] = $lineItem;
} }
break; break;
case '#:': case '#:':
if (substr_count( $this->_fileLine, '#: ' ) == 0) { if (substr_count($this->_fileLine, '#: ') == 0) {
$this->flagError = true; $this->flagError = true;
} else { } else {
$lineItem = str_replace( '#: ', '', $this->_fileLine ); $lineItem = str_replace('#: ', '', $this->_fileLine);
$this->references[] = $lineItem; $this->references[] = $lineItem;
} }
break; break;
case '#,': case '#,':
if (substr_count( $this->_fileLine, '#, ' ) == 0) { if (substr_count($this->_fileLine, '#, ') == 0) {
$this->flagError = true; $this->flagError = true;
} else { } else {
$lineItem = str_replace( '#, ', '', $this->_fileLine ); $lineItem = str_replace('#, ', '', $this->_fileLine);
$this->flags[] = $lineItem; $this->flags[] = $lineItem;
} }
break; break;
case '#|': case '#|':
if (substr_count( $this->_fileLine, '#| ' ) == 0) { if (substr_count($this->_fileLine, '#| ') == 0) {
$this->flagError = true; $this->flagError = true;
} else { } else {
$lineItem = str_replace( '#| ', '', $this->_fileLine ); $lineItem = str_replace('#| ', '', $this->_fileLine);
$this->previousUntranslatedStrings[] = $lineItem; $this->previousUntranslatedStrings[] = $lineItem;
} }
break; break;
@@ -362,15 +352,15 @@ class i18n_PO
} }
} }
if (! $this->_fileLine) { if (!$this->_fileLine) {
return false; return false;
} }
//Getting the msgid //Getting the msgid
preg_match( '/\s*msgid\s*"(.*)"\s*/s', $this->_fileLine, $match ); preg_match('/\s*msgid\s*"(.*)"\s*/s', $this->_fileLine, $match);
if (sizeof( $match ) != 2) { if (sizeof($match) != 2) {
throw new Exception( 'Invalid PO file format1' ); throw new Exception('Invalid PO file format1');
} }
$msgid = ''; $msgid = '';
@@ -378,15 +368,15 @@ class i18n_PO
do { do {
//g::pr($match); //g::pr($match);
$msgid .= $match[1]; $msgid .= $match[1];
$this->_fileLine = trim( fgets( $this->_fp ) ); $this->_fileLine = trim(fgets($this->_fp));
preg_match( '/^"(.*)"\s*/s', $this->_fileLine, $match ); preg_match('/^"(.*)"\s*/s', $this->_fileLine, $match);
} while (sizeof( $match ) == 2); } while (sizeof($match) == 2);
//Getting the msgstr //Getting the msgstr
preg_match( '/\s*msgstr\s*"(.*)"\s*/s', $this->_fileLine, $match ); preg_match('/\s*msgstr\s*"(.*)"\s*/s', $this->_fileLine, $match);
if (sizeof( $match ) != 2) { if (sizeof($match) != 2) {
throw new Exception( 'Invalid PO file format2' ); throw new Exception('Invalid PO file format2');
} }
$msgstr = ''; $msgstr = '';
@@ -394,24 +384,23 @@ class i18n_PO
do { do {
//g::pr($match); //g::pr($match);
$msgstr .= $match[1] . "\n"; $msgstr .= $match[1] . "\n";
$this->_fileLine = trim( fgets( $this->_fp ) ); $this->_fileLine = trim(fgets($this->_fp));
preg_match( '/^"(.*)"\s*/s', $this->_fileLine, $match ); preg_match('/^"(.*)"\s*/s', $this->_fileLine, $match);
} while (sizeof( $match ) == 2); } while (sizeof($match) == 2);
/*g::pr($this->translatorComments); /* g::pr($this->translatorComments);
g::pr($this->references); g::pr($this->references);
g::pr($match); g::pr($match);
die;*/ die; */
return Array ('msgid' => trim( $msgid ),'msgstr' => trim( $msgstr ) return Array('msgid' => trim($msgid), 'msgstr' => trim($msgstr));
);
} }
//garbage //garbage
function __destruct () public function __destruct()
{ {
if ($this->_fp) { if ($this->_fp) {
fclose( $this->_fp ); fclose($this->_fp);
} }
} }
} }

View File

@@ -34,11 +34,11 @@
*/ */
class Xml_Node class Xml_Node
{ {
var $name = ''; public $name = '';
var $type = ''; public $type = '';
var $value = ''; //maybe not necesary public $value = ''; //maybe not necesary
var $attributes = array (); public $attributes = array ();
var $children = array (); public $children = array ();
/** /**
* Function Xml_Node * Function Xml_Node
@@ -51,7 +51,7 @@ class Xml_Node
* @param eter string attributes * @param eter string attributes
* @return string * @return string
*/ */
function Xml_Node ($name, $type, $value, $attributes = array()) public function Xml_Node ($name, $type, $value, $attributes = array())
{ {
$this->name = $name; $this->name = $name;
$this->type = $type; $this->type = $type;
@@ -68,7 +68,7 @@ class Xml_Node
* @param eter string value * @param eter string value
* @return string * @return string
*/ */
function addAttribute ($name, $value) public function addAttribute ($name, $value)
{ {
$this->attributes[$name] = $value; $this->attributes[$name] = $value;
return true; return true;
@@ -82,7 +82,7 @@ class Xml_Node
* @param eter string childNode * @param eter string childNode
* @return string * @return string
*/ */
function addChildNode ($childNode) public function addChildNode ($childNode)
{ {
if (is_object( $childNode ) && strcasecmp( get_class( $childNode ), 'Xml_Node' ) == 0) { if (is_object( $childNode ) && strcasecmp( get_class( $childNode ), 'Xml_Node' ) == 0) {
$this->type = 'open'; $this->type = 'open';
@@ -101,7 +101,7 @@ class Xml_Node
* @access public * @access public
* @return string * @return string
*/ */
function toTree () public function toTree ()
{ {
$arr = new Xml_Node( $this->name, $this->type, $this->value, $this->attributes ); $arr = new Xml_Node( $this->name, $this->type, $this->value, $this->attributes );
unset( $arr->parent ); unset( $arr->parent );
@@ -112,7 +112,7 @@ class Xml_Node
return $arr; return $arr;
} }
function toArray ($obj = null) public function toArray ($obj = null)
{ {
$arr = array (); $arr = array ();
if (! isset( $obj )) { if (! isset( $obj )) {
@@ -136,7 +136,7 @@ class Xml_Node
* @param eter string xpath * @param eter string xpath
* @return string * @return string
*/ */
function &findNode ($xpath) public function &findNode ($xpath)
{ {
$n = null; $n = null;
$p = explode( '/', $xpath ); $p = explode( '/', $xpath );
@@ -180,7 +180,7 @@ class Xml_Node
* @param eter string xpath * @param eter string xpath
* @return string * @return string
*/ */
function getXML () public function getXML ()
{ {
switch ($this->type) { switch ($this->type) {
case 'open': case 'open':
@@ -237,7 +237,7 @@ class Xml_Node
return $xml; return $xml;
} }
function getCDATAValue () public function getCDATAValue ()
{ {
$cdata = htmlentities( $this->value, ENT_QUOTES, 'utf-8' ); $cdata = htmlentities( $this->value, ENT_QUOTES, 'utf-8' );
if ($this->value === $cdata) { if ($this->value === $cdata) {
@@ -257,7 +257,7 @@ class Xml_Node
*/ */
class Xml_document extends Xml_Node class Xml_document extends Xml_Node
{ {
var $currentNode; public $currentNode;
/** /**
* Function Xml_document * Function Xml_document
@@ -266,7 +266,7 @@ class Xml_document extends Xml_Node
* @access public * @access public
* @return string * @return string
*/ */
function Xml_document () public function Xml_document ()
{ {
$this->currentNode = &$this; $this->currentNode = &$this;
} }
@@ -280,7 +280,7 @@ class Xml_document extends Xml_Node
* @param eter string content * @param eter string content
* @return string * @return string
*/ */
function parseXmlFile ($filename, $content = "") public function parseXmlFile ($filename, $content = "")
{ //$content is a new variable, if it has any value then use it instead of the file content. { //$content is a new variable, if it has any value then use it instead of the file content.
if ($content == "") { if ($content == "") {
if (! file_exists( $filename )) { if (! file_exists( $filename )) {
@@ -333,7 +333,7 @@ class Xml_document extends Xml_Node
* @param eter string xpath * @param eter string xpath
* @return string * @return string
*/ */
function &findNode ($xpath) public function &findNode ($xpath)
{ {
if (substr( $xpath, 0, 1 ) == '/') { if (substr( $xpath, 0, 1 ) == '/') {
return parent::findNode( substr( $xpath, 1 ) ); return parent::findNode( substr( $xpath, 1 ) );
@@ -357,7 +357,7 @@ class Xml_document extends Xml_Node
* @access public * @access public
* @return string $xml * @return string $xml
*/ */
function getXML () public function getXML ()
{ {
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$xml .= $this->children[0]->getXML(); $xml .= $this->children[0]->getXML();
@@ -370,7 +370,7 @@ class Xml_document extends Xml_Node
* @access public * @access public
* @return void * @return void
*/ */
function save ($filename) public function save ($filename)
{ {
$xml = $this->getXML(); $xml = $this->getXML();
$fp = fopen( $filename, 'w' ); $fp = fopen( $filename, 'w' );

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* class.dates.php * class.dates.php
* *
@@ -30,7 +31,6 @@
* *
* @author David Callizaya <davidsantos@colosa.com> * @author David Callizaya <davidsantos@colosa.com>
*/ */
require_once ("classes/model/TaskPeer.php"); require_once ("classes/model/TaskPeer.php");
require_once ("classes/model/HolidayPeer.php"); require_once ("classes/model/HolidayPeer.php");
@@ -40,14 +40,14 @@ require_once ("classes/model/HolidayPeer.php");
*/ */
class dates class dates
{ {
private $holidays = array ();
private $weekends = array (); private $holidays = array();
private $range = array (); private $weekends = array();
private $range = array();
private $skipEveryYear = true; private $skipEveryYear = true;
private $calendarDays = false; //by default we are using working days private $calendarDays = false; //by default we are using working days
private $hoursPerDay = 8; //you should change this private $hoursPerDay = 8; //you should change this
/** /**
* Function that calculate a final date based on $sInitDate and $iDuration * Function that calculate a final date based on $sInitDate and $iDuration
* This function also uses a Calendar component (class.calendar.php) where all the definition of * This function also uses a Calendar component (class.calendar.php) where all the definition of
@@ -70,14 +70,14 @@ class dates
* *
* *
*/ */
function calculateDate ($sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid = NULL, $ProUid = NULL, $TasUid = NULL) public function calculateDate($sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid = null, $ProUid = null, $TasUid = null)
{ {
//$oldDate=$this->calculateDate_noCalendar( $sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid, $ProUid, $TasUid); //$oldDate=$this->calculateDate_noCalendar( $sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid, $ProUid, $TasUid);
//Set Calendar when the object is instanced in this order/priority (Task, User, Process, Default) //Set Calendar when the object is instanced in this order/priority (Task, User, Process, Default)
G::LoadClass( 'calendar' ); G::LoadClass('calendar');
$calendarObj = new calendar( $UsrUid, $ProUid, $TasUid ); $calendarObj = new calendar($UsrUid, $ProUid, $TasUid);
//Get next Business Hours/Range based on : //Get next Business Hours/Range based on :
switch (strtoupper( $sTimeUnit )) { switch (strtoupper($sTimeUnit)) {
case 'DAYS': case 'DAYS':
$hoursToProcess = $iDuration * 8; $hoursToProcess = $iDuration * 8;
break; //In Hours break; //In Hours
@@ -85,75 +85,75 @@ class dates
$hoursToProcess = $iDuration; $hoursToProcess = $iDuration;
break; //In Hours break; //In Hours
} }
$dateArray = explode( " ", $sInitDate ); $dateArray = explode(" ", $sInitDate);
$currentDate = $dateArray[0]; $currentDate = $dateArray[0];
$currentTime = isset( $dateArray[1] ) ? $dateArray[1] : "00:00:00"; $currentTime = isset($dateArray[1]) ? $dateArray[1] : "00:00:00";
$startTime = (float) array_sum( explode( ' ', microtime() ) ); $startTime = (float) array_sum(explode(' ', microtime()));
$calendarObj->addCalendarLog( "* Starting at: $startTime" ); $calendarObj->addCalendarLog("* Starting at: $startTime");
$calendarObj->addCalendarLog( ">>>>> Hours to Process: $hoursToProcess" ); $calendarObj->addCalendarLog(">>>>> Hours to Process: $hoursToProcess");
$calendarObj->addCalendarLog( ">>>>> Current Date: $currentDate" ); $calendarObj->addCalendarLog(">>>>> Current Date: $currentDate");
$calendarObj->addCalendarLog( ">>>>> Current Time: $currentTime" ); $calendarObj->addCalendarLog(">>>>> Current Time: $currentTime");
$array_hours = explode( ":", $currentTime ); $array_hours = explode(":", $currentTime);
$seconds2 = $array_hours[2]; $seconds2 = $array_hours[2];
$minutes2 = 0; $minutes2 = 0;
while ($hoursToProcess > 0) { while ($hoursToProcess > 0) {
$validBusinessHour = $calendarObj->getNextValidBusinessHoursRange( $currentDate, $currentTime ); $validBusinessHour = $calendarObj->getNextValidBusinessHoursRange($currentDate, $currentTime);
//For Date/Time operations //For Date/Time operations
$currentDateA = explode( "-", $validBusinessHour['DATE'] ); $currentDateA = explode("-", $validBusinessHour['DATE']);
$currentTimeA = explode( ":", $validBusinessHour['TIME'] ); $currentTimeA = explode(":", $validBusinessHour['TIME']);
$hour = $currentTimeA[0]; $hour = $currentTimeA[0];
$minute = $currentTimeA[1]; $minute = $currentTimeA[1];
$second = isset( $currentTimeA[2] ) ? $currentTimeA[2] : 0; $second = isset($currentTimeA[2]) ? $currentTimeA[2] : 0;
$month = $currentDateA[1]; $month = $currentDateA[1];
$day = $currentDateA[2]; $day = $currentDateA[2];
$year = $currentDateA[0]; $year = $currentDateA[0];
$normalizedDate = date( "Y-m-d H:i:s", mktime( $hour, $minute, $second, $month, $day, $year ) ); $normalizedDate = date("Y-m-d H:i:s", mktime($hour, $minute, $second, $month, $day, $year));
$normalizedDateInt = mktime( $hour, $minute, $second, $month, $day, $year ); $normalizedDateInt = mktime($hour, $minute, $second, $month, $day, $year);
$normalizedDateSeconds = ($hour * 60 * 60) + ($minute * 60); $normalizedDateSeconds = ($hour * 60 * 60) + ($minute * 60);
$arrayHour = explode( ".", $hoursToProcess ); $arrayHour = explode(".", $hoursToProcess);
if (isset( $arrayHour[1] )) { if (isset($arrayHour[1])) {
$minutes1 = $arrayHour[1]; $minutes1 = $arrayHour[1];
$cadm = strlen( $minutes1 ); $cadm = strlen($minutes1);
$minutes2 = (($minutes1 / pow( 10, $cadm )) * 60); $minutes2 = (($minutes1 / pow(10, $cadm)) * 60);
} }
$possibleTime = date( "Y-m-d H:i:s", mktime( $hour + $hoursToProcess, $minute + $minutes2, $second + $seconds2, $month, $day, $year ) ); $possibleTime = date("Y-m-d H:i:s", mktime($hour + $hoursToProcess, $minute + $minutes2, $second + $seconds2, $month, $day, $year));
$possibleTimeInt = mktime( $hour + $hoursToProcess, $minute + $minutes2, $second + $seconds2, $month, $day, $year ); $possibleTimeInt = mktime($hour + $hoursToProcess, $minute + $minutes2, $second + $seconds2, $month, $day, $year);
$offsetPermitedMinutes = "0"; $offsetPermitedMinutes = "0";
$calendarBusinessEndA = explode( ":", $validBusinessHour['BUSINESS_HOURS']['CALENDAR_BUSINESS_END'] ); $calendarBusinessEndA = explode(":", $validBusinessHour['BUSINESS_HOURS']['CALENDAR_BUSINESS_END']);
$calendarBusinessEndNormalized = date( "Y-m-d H:i:s", mktime( $calendarBusinessEndA[0], $calendarBusinessEndA[1] + $offsetPermitedMinutes, 0, $month, $day, $year ) ); $calendarBusinessEndNormalized = date("Y-m-d H:i:s", mktime($calendarBusinessEndA[0], $calendarBusinessEndA[1] + $offsetPermitedMinutes, 0, $month, $day, $year));
$calendarBusinessEndInt = mktime( $calendarBusinessEndA[0], $calendarBusinessEndA[1] + $offsetPermitedMinutes, 0, $month, $day, $year ); $calendarBusinessEndInt = mktime($calendarBusinessEndA[0], $calendarBusinessEndA[1] + $offsetPermitedMinutes, 0, $month, $day, $year);
$calendarBusinessEndSeconds = ($calendarBusinessEndA[0] * 60 * 60) + ($calendarBusinessEndA[1] * 60); $calendarBusinessEndSeconds = ($calendarBusinessEndA[0] * 60 * 60) + ($calendarBusinessEndA[1] * 60);
$calendarObj->addCalendarLog( "Possible time: $possibleTime" ); $calendarObj->addCalendarLog("Possible time: $possibleTime");
$calendarObj->addCalendarLog( "Current Start Date/Time: $normalizedDate" ); $calendarObj->addCalendarLog("Current Start Date/Time: $normalizedDate");
$calendarObj->addCalendarLog( "Calendar Business End: $calendarBusinessEndNormalized" ); $calendarObj->addCalendarLog("Calendar Business End: $calendarBusinessEndNormalized");
if ($possibleTimeInt > $calendarBusinessEndInt) { if ($possibleTimeInt > $calendarBusinessEndInt) {
$currentDateTimeB = explode( " ", $calendarBusinessEndNormalized ); $currentDateTimeB = explode(" ", $calendarBusinessEndNormalized);
$currentDate = $currentDateTimeB[0]; $currentDate = $currentDateTimeB[0];
$currentTime = $currentDateTimeB[1]; $currentTime = $currentDateTimeB[1];
$diff = abs( $normalizedDateSeconds - $calendarBusinessEndSeconds ); $diff = abs($normalizedDateSeconds - $calendarBusinessEndSeconds);
$diffHours = $diff / 3600; $diffHours = $diff / 3600;
$hoursToProcess = $hoursToProcess - $diffHours; $hoursToProcess = $hoursToProcess - $diffHours;
} else { } else {
$currentDateTimeA = explode( " ", $possibleTime ); $currentDateTimeA = explode(" ", $possibleTime);
$currentDate = $currentDateTimeA[0]; $currentDate = $currentDateTimeA[0];
$currentTime = $currentDateTimeA[1]; $currentTime = $currentDateTimeA[1];
$hoursToProcess = 0; $hoursToProcess = 0;
} }
$calendarObj->addCalendarLog( "** Hours to Process: $hoursToProcess" ); $calendarObj->addCalendarLog("** Hours to Process: $hoursToProcess");
} }
$calendarObj->addCalendarLog( "+++++++++++ Calculated Due Date $currentDate $currentTime" ); $calendarObj->addCalendarLog("+++++++++++ Calculated Due Date $currentDate $currentTime");
$result['DUE_DATE'] = $currentDate . " " . $currentTime; $result['DUE_DATE'] = $currentDate . " " . $currentTime;
$result['DUE_DATE_SECONDS'] = strtotime( $currentDate . " " . $currentTime ); $result['DUE_DATE_SECONDS'] = strtotime($currentDate . " " . $currentTime);
//$result['OLD_DUE_DATE'] = date("Y-m-d H:i:s",$oldDate); //$result['OLD_DUE_DATE'] = date("Y-m-d H:i:s",$oldDate);
//$result['OLD_DUE_DATE_SECONDS']= $oldDate; //$result['OLD_DUE_DATE_SECONDS']= $oldDate;
$endTime = (float) array_sum( explode( ' ', microtime() ) ); $endTime = (float) array_sum(explode(' ', microtime()));
$calendarObj->addCalendarLog( "* Ending at: $endTime" ); $calendarObj->addCalendarLog("* Ending at: $endTime");
$calcTime = round( $endTime - $startTime, 3 ); $calcTime = round($endTime - $startTime, 3);
$calendarObj->addCalendarLog( "** Processing time: " . sprintf( "%.4f", ($endTime - $startTime) ) . " seconds" ); $calendarObj->addCalendarLog("** Processing time: " . sprintf("%.4f", ($endTime - $startTime)) . " seconds");
$result['DUE_DATE_LOG'] = $calendarObj->calendarLog; $result['DUE_DATE_LOG'] = $calendarObj->calendarLog;
return $result; return $result;
} }
@@ -175,34 +175,35 @@ class dates
* @return integer timestamp of the result * @return integer timestamp of the result
* @deprecated renamed by Hugo Loza (see calculateDate new function) * @deprecated renamed by Hugo Loza (see calculateDate new function)
*/ */
public function calculateDate_noCalendar($sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid = null, $ProUid = null, $TasUid = null)
function calculateDate_noCalendar ($sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid = NULL, $ProUid = NULL, $TasUid = NULL)
{ {
//load in class variables the config of working days, holidays etc.. //load in class variables the config of working days, holidays etc..
$this->prepareInformation( $UsrUid, $ProUid, $TasUid ); $this->prepareInformation($UsrUid, $ProUid, $TasUid);
$iHours = 0; $iHours = 0;
$iDays = 0; $iDays = 0;
//convert the $iDuration and $sTimeUnit in hours and days, take in mind 8 hours = 1 day. and then we will have similar for 5 days = 1 weekends //convert the $iDuration and $sTimeUnit in hours and days, take in mind 8 hours = 1 day. and then we will have similar for 5 days = 1 weekends
if (strtolower( $sTimeUnit ) == 'hours') { if (strtolower($sTimeUnit) == 'hours') {
$iAux = intval( abs( $iDuration ) ); $iAux = intval(abs($iDuration));
$iHours = $iAux % $this->hoursPerDay; $iHours = $iAux % $this->hoursPerDay;
$iDays = intval( $iAux / $this->hoursPerDay ); $iDays = intval($iAux / $this->hoursPerDay);
} }
if (strtolower( $sTimeUnit ) == 'days') { if (strtolower($sTimeUnit) == 'days') {
$iAux = intval( abs( $iDuration * $this->hoursPerDay ) ); $iAux = intval(abs($iDuration * $this->hoursPerDay));
$iHours = $iAux % 8; $iHours = $iAux % 8;
$iDays = intval( $iAux / 8 ); $iDays = intval($iAux / 8);
} }
$addSign = ($iDuration >= 0) ? '+' : '-'; $addSign = ($iDuration >= 0) ? '+' : '-';
$iInitDate = strtotime( $sInitDate ); $iInitDate = strtotime($sInitDate);
if ($iTypeDay == 1) { // working days if ($iTypeDay == 1) {
// working days
// if there are days calculate the days, // if there are days calculate the days,
$iEndDate = $this->addDays( $iInitDate, $iDays, $addSign ); $iEndDate = $this->addDays($iInitDate, $iDays, $addSign);
// if there are hours calculate the hours, and probably add a day if the quantity of hours for last day > 8 hours // if there are hours calculate the hours, and probably add a day if the quantity of hours for last day > 8 hours
$iEndDate = $this->addHours( $iEndDate, $iHours, $addSign ); $iEndDate = $this->addHours($iEndDate, $iHours, $addSign);
} else { // $task->getTasTypeDay() == 2 // calendar days } else {
$iEndDate = strtotime( $addSign . $iDays . ' days ', $iInitDate ); // $task->getTasTypeDay() == 2 // calendar days
$iEndDate = strtotime( $addSign . $iHours . ' hours ', $iEndDate ); $iEndDate = strtotime($addSign . $iDays . ' days ', $iInitDate);
$iEndDate = strtotime($addSign . $iHours . ' hours ', $iEndDate);
} }
return $iEndDate; return $iEndDate;
} }
@@ -218,59 +219,57 @@ class dates
* @return int * @return int
* *
*/ */
function calculateDuration ($sInitDate, $sEndDate = '', $UsrUid = NULL, $ProUid = NULL, $TasUid = NULL) public function calculateDuration($sInitDate, $sEndDate = '', $UsrUid = null, $ProUid = null, $TasUid = null)
{ {
$this->prepareInformation( $UsrUid, $ProUid, $TasUid ); $this->prepareInformation($UsrUid, $ProUid, $TasUid);
if ((string) $sEndDate == '') { if ((string) $sEndDate == '') {
$sEndDate = date( 'Y-m-d H:i:s' ); $sEndDate = date('Y-m-d H:i:s');
} }
if (strtotime( $sInitDate ) > strtotime( $sEndDate )) { if (strtotime($sInitDate) > strtotime($sEndDate)) {
$sAux = $sInitDate; $sAux = $sInitDate;
$sInitDate = $sEndDate; $sInitDate = $sEndDate;
$sEndDate = $sAux; $sEndDate = $sAux;
} }
$aAux1 = explode( ' ', $sInitDate ); $aAux1 = explode(' ', $sInitDate);
$aAux2 = explode( ' ', $sEndDate ); $aAux2 = explode(' ', $sEndDate);
$aInitDate = explode( '-', $aAux1[0] ); $aInitDate = explode('-', $aAux1[0]);
$aEndDate = explode( '-', $aAux2[0] ); $aEndDate = explode('-', $aAux2[0]);
$i = 1; $i = 1;
$iWorkedDays = 0; $iWorkedDays = 0;
$bFinished = false; $bFinished = false;
$fHours1 = 0.0; $fHours1 = 0.0;
$fHours2 = 0.0; $fHours2 = 0.0;
if (count( $aInitDate ) != 3) { if (count($aInitDate) != 3) {
$aInitDate = array (0,0,0 $aInitDate = array(0, 0, 0);
);
} }
if (count( $aEndDate ) != 3) { if (count($aEndDate) != 3) {
$aEndDate = array (0,0,0 $aEndDate = array(0, 0, 0);
);
} }
if ($aInitDate !== $aEndDate) { if ($aInitDate !== $aEndDate) {
while (! $bFinished && ($i < 10000)) { while (!$bFinished && ($i < 10000)) {
$sAux = date( 'Y-m-d', mktime( 0, 0, 0, $aInitDate[1], $aInitDate[2] + $i, $aInitDate[0] ) ); $sAux = date('Y-m-d', mktime(0, 0, 0, $aInitDate[1], $aInitDate[2] + $i, $aInitDate[0]));
if ($sAux != implode( '-', $aEndDate )) { if ($sAux != implode('-', $aEndDate)) {
if (! in_array( $sAux, $this->holidays )) { if (!in_array($sAux, $this->holidays)) {
if (! in_array( date( 'w', mktime( 0, 0, 0, $aInitDate[1], $aInitDate[2] + $i, $aInitDate[0] ) ), $this->weekends )) { if (!in_array(date('w', mktime(0, 0, 0, $aInitDate[1], $aInitDate[2] + $i, $aInitDate[0])), $this->weekends)) {
$iWorkedDays ++; $iWorkedDays++;
} }
} }
$i ++; $i++;
} else { } else {
$bFinished = true; $bFinished = true;
} }
} }
if (isset( $aAux1[1] )) { if (isset($aAux1[1])) {
$aAux1[1] = explode( ':', $aAux1[1] ); $aAux1[1] = explode(':', $aAux1[1]);
$fHours1 = 24 - ($aAux1[1][0] + ($aAux1[1][1] / 60) + ($aAux1[1][2] / 3600)); $fHours1 = 24 - ($aAux1[1][0] + ($aAux1[1][1] / 60) + ($aAux1[1][2] / 3600));
} }
if (isset( $aAux2[1] )) { if (isset($aAux2[1])) {
$aAux2[1] = explode( ':', $aAux2[1] ); $aAux2[1] = explode(':', $aAux2[1]);
$fHours2 = $aAux2[1][0] + ($aAux2[1][1] / 60) + ($aAux2[1][2] / 3600); $fHours2 = $aAux2[1][0] + ($aAux2[1][1] / 60) + ($aAux2[1][2] / 3600);
} }
$fDuration = ($iWorkedDays * 24) + $fHours1 + $fHours2; $fDuration = ($iWorkedDays * 24) + $fHours1 + $fHours2;
} else { } else {
$fDuration = (strtotime( $sEndDate ) - strtotime( $sInitDate )) / 3600; $fDuration = (strtotime($sEndDate) - strtotime($sInitDate)) / 3600;
} }
return $fDuration; return $fDuration;
} }
@@ -283,25 +282,25 @@ class dates
* @param string $TasUid * @param string $TasUid
* @return void * @return void
*/ */
function prepareInformation ($UsrUid = NULL, $ProUid = NULL, $TasUid = NULL) public function prepareInformation($UsrUid = null, $ProUid = null, $TasUid = null)
{ {
// setup calendarDays according the task // setup calendarDays according the task
if (isset( $TasUid )) { if (isset($TasUid)) {
$task = TaskPeer::retrieveByPK( $TasUid ); $task = TaskPeer::retrieveByPK($TasUid);
if (! is_null( $task )) { if (!is_null($task)) {
$this->calendarDays = ($task->getTasTypeDay() == 2); $this->calendarDays = ($task->getTasTypeDay() == 2);
} }
} }
//get an array with all holidays. //get an array with all holidays.
$aoHolidays = HolidayPeer::doSelect( new Criteria() ); $aoHolidays = HolidayPeer::doSelect(new Criteria());
$holidays = array (); $holidays = array();
foreach ($aoHolidays as $holiday) foreach ($aoHolidays as $holiday) {
$holidays[] = strtotime( $holiday->getHldDate() ); $holidays[] = strtotime($holiday->getHldDate());
}
// by default the weekdays are from monday to friday // by default the weekdays are from monday to friday
$this->weekends = array (0,6 $this->weekends = array(0, 6);
);
$this->holidays = $holidays; $this->holidays = $holidays;
return; return;
} }
@@ -312,7 +311,7 @@ class dates
* @param $bSkipEveryYear * @param $bSkipEveryYear
* @return void * @return void
*/ */
function setSkipEveryYear ($bSkipEveryYear) public function setSkipEveryYear($bSkipEveryYear)
{ {
$this->skipEveryYear = $bSkipEveryYear === true; $this->skipEveryYear = $bSkipEveryYear === true;
} }
@@ -323,12 +322,13 @@ class dates
* @param data $sDate * @param data $sDate
* @return void * @return void
*/ */
function addHoliday ($sDate) public function addHoliday($sDate)
{ {
if ($date = strtotime( $sDate )) if ($date = strtotime($sDate)) {
$this->holidays[] = self::truncateTime( $date ); $this->holidays[] = self::truncateTime($date);
else } else {
throw new Exception( "Invalid date: $sDate." ); throw new Exception("Invalid date: $sDate.");
}
} }
/** /**
@@ -337,10 +337,11 @@ class dates
* @param date/array $aDate must be an array of (strtotime type) dates * @param date/array $aDate must be an array of (strtotime type) dates
* @return void * @return void
*/ */
function setHolidays ($aDates) public function setHolidays($aDates)
{ {
foreach ($aDates as $sDate) foreach ($aDates as $sDate) {
$this->holidays = $aDates; $this->holidays = $aDates;
}
} }
/** /**
@@ -351,7 +352,7 @@ class dates
* 7=Saturday * 7=Saturday
* @return void * @return void
*/ */
function setWeekends ($aWeekends) public function setWeekends($aWeekends)
{ {
$this->weekends = $aWeekends; $this->weekends = $aWeekends;
} }
@@ -364,10 +365,11 @@ class dates
* 7=Saturday * 7=Saturday
* @return void * @return void
*/ */
function skipDayOfWeek ($iDayNumber) public function skipDayOfWeek($iDayNumber)
{ {
if ($iDayNumber < 1 || $iDayNumber > 7) if ($iDayNumber < 1 || $iDayNumber > 7) {
throw new Exception( "The day of week must be a number from 1 to 7." ); throw new Exception("The day of week must be a number from 1 to 7.");
}
$this->weekends[] = $iDayNumber; $this->weekends[] = $iDayNumber;
} }
@@ -378,24 +380,24 @@ class dates
* @param date $sDateB must be a (strtotime type) dates * @param date $sDateB must be a (strtotime type) dates
* @return void * @return void
*/ */
function addNonWorkingRange ($sDateA, $sDateB) public function addNonWorkingRange($sDateA, $sDateB)
{ {
if ($date = strtotime( $sDateA )) if ($date = strtotime($sDateA)) {
$iDateA = self::truncateTime( $date ); $iDateA = self::truncateTime($date);
else } else {
throw new Exception( "Invalid date: $sDateA." ); throw new Exception("Invalid date: $sDateA.");
if ($date = strtotime( $sDateB )) }
$iDateB = self::truncateTime( $date ); if ($date = strtotime($sDateB)) {
else $iDateB = self::truncateTime($date);
throw new Exception( "Invalid date: $sDateB." ); } else {
throw new Exception("Invalid date: $sDateB.");
}
if ($iDateA > $iDateB) { if ($iDateA > $iDateB) {
$s = $iDateA; $s = $iDateA;
$iDateA = $iDateB; $iDateA = $iDateB;
$iDateB = $s; $iDateB = $s;
} }
; $this->range[] = array($iDateA, $iDateB);
$this->range[] = array ($iDateA,$iDateB
);
} }
/** /**
@@ -407,15 +409,16 @@ class dates
* @param string $addSign * @param string $addSign
* @return date $iEndDate * @return date $iEndDate
*/ */
private function addDays ($iInitDate, $iDaysCount, $addSign = '+') private function addDays($iInitDate, $iDaysCount, $addSign = '+')
{ {
$iEndDate = $iInitDate; $iEndDate = $iInitDate;
$aList = $this->holidays; $aList = $this->holidays;
for ($r = 1; $r <= $iDaysCount; $r ++) { for ($r = 1; $r <= $iDaysCount; $r++) {
$iEndDate = strtotime( $addSign . "1 day", $iEndDate ); $iEndDate = strtotime($addSign . "1 day", $iEndDate);
$dayOfWeek = idate( 'w', $iEndDate ); //now sunday=0 $dayOfWeek = idate('w', $iEndDate); //now sunday=0
if (array_search( $dayOfWeek, $this->weekends ) !== false) if (array_search($dayOfWeek, $this->weekends) !== false) {
$r --; //continue loop, but we are adding one more day. $r--; //continue loop, but we are adding one more day.
}
} }
return $iEndDate; return $iEndDate;
} }
@@ -428,10 +431,9 @@ class dates
* @param string $addSign * @param string $addSign
* @return $iEndDate * @return $iEndDate
*/ */
private function addHours($sInitDate, $iHoursCount, $addSign = '+')
private function addHours ($sInitDate, $iHoursCount, $addSign = '+')
{ {
$iEndDate = strtotime( $addSign . $iHoursCount . " hours", $sInitDate ); $iEndDate = strtotime($addSign . $iHoursCount . " hours", $sInitDate);
return $iEndDate; return $iEndDate;
} }
@@ -441,18 +443,19 @@ class dates
* @param $iDate = valid timestamp * @param $iDate = valid timestamp
* @return true if it is within any of the ranges defined. * @return true if it is within any of the ranges defined.
*/ */
private function inRange ($iDate) private function inRange($iDate)
{ {
$aRange = $this->range; $aRange = $this->range;
$iYear = idate( 'Y', $iDate ); $iYear = idate('Y', $iDate);
foreach ($aRange as $key => $rang) { foreach ($aRange as $key => $rang) {
if ($this->skipEveryYear) { if ($this->skipEveryYear) {
$deltaYears = idate( 'Y', $rang[1] ) - idate( 'Y', $rang[0] ); $deltaYears = idate('Y', $rang[1]) - idate('Y', $rang[0]);
$rang[0] = self::changeYear( $rang[0], $iYear ); $rang[0] = self::changeYear($rang[0], $iYear);
$rang[1] = self::changeYear( $rang[1], $iYear + $deltaYears ); $rang[1] = self::changeYear($rang[1], $iYear + $deltaYears);
} }
if (($iDate >= $rang[0]) && ($iDate <= $rang[1])) if (($iDate >= $rang[0]) && ($iDate <= $rang[1])) {
return true; return true;
}
} }
return false; return false;
} }
@@ -463,9 +466,9 @@ class dates
* @param $iDate = valid timestamp * @param $iDate = valid timestamp
* @return date * @return date
*/ */
private function truncateTime ($iDate) private function truncateTime($iDate)
{ {
return mktime( 0, 0, 0, idate( 'm', $iDate ), idate( 'd', $iDate ), idate( 'Y', $iDate ) ); return mktime(0, 0, 0, idate('m', $iDate), idate('d', $iDate), idate('Y', $iDate));
} }
/** /**
@@ -474,10 +477,9 @@ class dates
* @param timestamp $iDate * @param timestamp $iDate
* @return date * @return date
*/ */
private function getTime ($iDate) private function getTime($iDate)
{ {
return array (idate( 'H', $iDate ),idate( 'm', $iDate ),idate( 's', $iDate ) return array(idate('H', $iDate), idate('m', $iDate), idate('s', $iDate));
);
} }
/** /**
@@ -487,9 +489,9 @@ class dates
* @param timestamp $aTime * @param timestamp $aTime
* @return date * @return date
*/ */
private function setTime ($iDate, $aTime) private function setTime($iDate, $aTime)
{ {
return mktime( $aTime[0], $aTime[1], $aTime[2], idate( 'm', $iDate ), idate( 'd', $iDate ), idate( 'Y', $iDate ) ); return mktime($aTime[0], $aTime[1], $aTime[2], idate('m', $iDate), idate('d', $iDate), idate('Y', $iDate));
} }
/** /**
@@ -501,11 +503,11 @@ class dates
* @param List $iYear * @param List $iYear
* @return array * @return array
*/ */
private function listForYear ($iYear) private function listForYear($iYear)
{ {
$aList = $this->holidays; $aList = $this->holidays;
foreach ($aList as $k => $v) { foreach ($aList as $k => $v) {
$aList[$k] = self::changeYear( $v, $iYear ); $aList[$k] = self::changeYear($v, $iYear);
} }
return $aList; return $aList;
} }
@@ -520,12 +522,12 @@ class dates
* @param date $iDate * @param date $iDate
* @return array * @return array
*/ */
private function changeYear ($iDate, $iYear) private function changeYear($iDate, $iYear)
{ {
if ($delta = ($iYear - idate( 'Y', $iDate ))) { if ($delta = ($iYear - idate('Y', $iDate))) {
$iDate = strtotime( "$delta year", $iDate ); $iDate = strtotime("$delta year", $iDate);
} }
return $iDate; return $iDate;
} }
} }
?>

View File

@@ -1,53 +1,49 @@
<?php <?php
try {
$form = $_POST['form']; try {
$FolderUid = $form['FOLDER_UID']; $form = $_POST['form'];
$FolderParentUid = $form['FOLDER_PARENT_UID']; $FolderUid = $form['FOLDER_UID'];
$FolderName = $form['FOLDER_NAME']; $FolderParentUid = $form['FOLDER_PARENT_UID'];
$FolderCreateDate = 'now'; $FolderName = $form['FOLDER_NAME'];
$FolderUpdateDate = 'now'; $FolderCreateDate = 'now';
$FolderUpdateDate = 'now';
require_once ( "classes/model/AppFolder.php" ); require_once ( "classes/model/AppFolder.php" );
//if exists the row in the database propel will update it, otherwise will insert. //if exists the row in the database propel will update it, otherwise will insert.
$tr = AppFolderPeer::retrieveByPK( $FolderUid ); $tr = AppFolderPeer::retrieveByPK($FolderUid);
if ( ! ( is_object ( $tr ) && get_class ($tr) == 'AppFolder' ) ) { if (!( is_object($tr) && get_class($tr) == 'AppFolder' )) {
$tr = new AppFolder(); $tr = new AppFolder();
} }
$tr->setFolderUid( $FolderUid ); $tr->setFolderUid($FolderUid);
$tr->setFolderParentUid( $FolderParentUid ); $tr->setFolderParentUid($FolderParentUid);
$tr->setFolderName( $FolderName ); $tr->setFolderName($FolderName);
$tr->setFolderCreateDate( $FolderCreateDate ); $tr->setFolderCreateDate($FolderCreateDate);
$tr->setFolderUpdateDate( $FolderUpdateDate ); $tr->setFolderUpdateDate($FolderUpdateDate);
if ($tr->validate() ) { if ($tr->validate()) {
// we save it, since we get no validation errors, or do whatever else you like. // we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save(); $res = $tr->save();
} } else {
else { // Something went wrong. We can now get the validationFailures and handle them.
// Something went wrong. We can now get the validationFailures and handle them. $msg = '';
$msg = ''; $validationFailuresArray = $tr->getValidationFailures();
$validationFailuresArray = $tr->getValidationFailures(); foreach ($validationFailuresArray as $objValidationFailure) {
foreach($validationFailuresArray as $objValidationFailure) { $msg .= $objValidationFailure->getMessage() . "<br/>";
$msg .= $objValidationFailure->getMessage() . "<br/>"; }
} //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); }
}
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
//to do: uniform coderror structures for all classes //to do: uniform coderror structures for all classes
//if ( $res['codError'] < 0 ) {
//if ( $res['codError'] < 0 ) { // G::SendMessageText ( $res['message'] , 'error' );
// G::SendMessageText ( $res['message'] , 'error' ); //}
//} G::Header('location: appFolderList');
G::Header('location: appFolderList'); } catch (Exception $e) {
}
catch ( Exception $e ) {
$G_PUBLISH = new Publisher; $G_PUBLISH = new Publisher;
$aMessage['MESSAGE'] = $e->getMessage(); $aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage);
G::RenderPage( 'publish', 'blank' ); G::RenderPage('publish', 'blank');
} }

View File

@@ -27,7 +27,6 @@
* @author Erik Amaru Ortiz <erik@colosa.com> * @author Erik Amaru Ortiz <erik@colosa.com>
* @date Jan 3th, 2010 * @date Jan 3th, 2010
*/ */
//require_once 'classes/model/Application.php'; //require_once 'classes/model/Application.php';
//require_once 'classes/model/Users.php'; //require_once 'classes/model/Users.php';
//require_once 'classes/model/AppThread.php'; //require_once 'classes/model/AppThread.php';
@@ -38,26 +37,26 @@
class Ajax class Ajax
{ {
public function getCaseMenu ($params) public function getCaseMenu($params)
{ {
G::LoadClass( "configuration" ); G::LoadClass("configuration");
G::LoadClass( "case" ); G::LoadClass("case");
global $G_TMP_MENU; global $G_TMP_MENU;
global $sStatus; global $sStatus;
$sStatus = $params['app_status']; $sStatus = $params['app_status'];
$oCase = new Cases(); $oCase = new Cases();
$conf = new Configurations(); $conf = new Configurations();
$oMenu = new Menu(); $oMenu = new Menu();
$oMenu->load( 'caseOptions' ); $oMenu->load('caseOptions');
$menuOptions = Array (); $menuOptions = Array();
foreach ($oMenu->Options as $i => $action) { foreach ($oMenu->Options as $i => $action) {
$option = Array ('id' => $oMenu->Id[$i],'label' => $oMenu->Labels[$i],'action' => $action); $option = Array('id' => $oMenu->Id[$i], 'label' => $oMenu->Labels[$i], 'action' => $action);
switch ($option['id']) { switch ($option['id']) {
case 'STEPS': case 'STEPS':
$option['options'] = Array (); $option['options'] = Array();
break; break;
case 'ACTIONS': case 'ACTIONS':
$option['options'] = $this->getActionOptions(); $option['options'] = $this->getActionOptions();
@@ -69,20 +68,20 @@ class Ajax
$menuOptions[] = $option; $menuOptions[] = $option;
} }
echo G::json_encode( $menuOptions ); echo G::json_encode($menuOptions);
} }
public function steps () public function steps()
{ {
G::LoadClass( 'applications' ); G::LoadClass('applications');
$applications = new Applications(); $applications = new Applications();
$proUid = isset( $_SESSION['PROCESS'] ) ? $_SESSION['PROCESS'] : ''; $proUid = isset($_SESSION['PROCESS']) ? $_SESSION['PROCESS'] : '';
$tasUid = isset( $_SESSION['TASK'] ) ? $_SESSION['TASK'] : ''; $tasUid = isset($_SESSION['TASK']) ? $_SESSION['TASK'] : '';
$appUid = isset( $_SESSION['APPLICATION'] ) ? $_SESSION['APPLICATION'] : ''; $appUid = isset($_SESSION['APPLICATION']) ? $_SESSION['APPLICATION'] : '';
$index = isset( $_SESSION['INDEX'] ) ? $_SESSION['INDEX'] : ''; $index = isset($_SESSION['INDEX']) ? $_SESSION['INDEX'] : '';
$steps = $applications->getSteps( $appUid, $index, $tasUid, $proUid ); $steps = $applications->getSteps($appUid, $index, $tasUid, $proUid);
$list = array (); $list = array();
foreach ($steps as $step) { foreach ($steps as $step) {
$item['id'] = $item['idtodraw'] = $step['id']; $item['id'] = $item['idtodraw'] = $step['id'];
@@ -112,89 +111,89 @@ class Ajax
$list[] = $item; $list[] = $item;
} }
echo G::json_encode( $list ); echo G::json_encode($list);
} }
public function getInformationOptions () public function getInformationOptions()
{ {
$options = Array (); $options = Array();
$options[] = Array ('text' => G::LoadTranslation( 'ID_PROCESS_MAP' ),'fn' => 'processMap' ); $options[] = Array('text' => G::LoadTranslation('ID_PROCESS_MAP'), 'fn' => 'processMap');
$options[] = Array ('text' => G::LoadTranslation( 'ID_PROCESS_INFORMATION' ),'fn' => 'processInformation'); $options[] = Array('text' => G::LoadTranslation('ID_PROCESS_INFORMATION'), 'fn' => 'processInformation');
$options[] = Array ('text' => G::LoadTranslation( 'ID_TASK_INFORMATION' ),'fn' => 'taskInformation'); $options[] = Array('text' => G::LoadTranslation('ID_TASK_INFORMATION'), 'fn' => 'taskInformation');
$options[] = Array ('text' => G::LoadTranslation( 'ID_CASE_HISTORY' ),'fn' => 'caseHistory'); $options[] = Array('text' => G::LoadTranslation('ID_CASE_HISTORY'), 'fn' => 'caseHistory');
$options[] = Array ('text' => G::LoadTranslation( 'ID_HISTORY_MESSAGE_CASE' ),'fn' => 'messageHistory'); $options[] = Array('text' => G::LoadTranslation('ID_HISTORY_MESSAGE_CASE'), 'fn' => 'messageHistory');
$options[] = Array ('text' => G::LoadTranslation( 'ID_DYNAFORMS' ),'fn' => 'dynaformHistory' ); $options[] = Array('text' => G::LoadTranslation('ID_DYNAFORMS'), 'fn' => 'dynaformHistory');
$options[] = Array ('text' => G::LoadTranslation( 'ID_UPLOADED_DOCUMENTS' ),'fn' => 'uploadedDocuments'); $options[] = Array('text' => G::LoadTranslation('ID_UPLOADED_DOCUMENTS'), 'fn' => 'uploadedDocuments');
$options[] = Array ('text' => G::LoadTranslation( 'ID_GENERATED_DOCUMENTS' ),'fn' => 'generatedDocuments'); $options[] = Array('text' => G::LoadTranslation('ID_GENERATED_DOCUMENTS'), 'fn' => 'generatedDocuments');
return $options; return $options;
} }
public function getActionOptions () public function getActionOptions()
{ {
$APP_UID = $_SESSION['APPLICATION']; $APP_UID = $_SESSION['APPLICATION'];
$c = new Criteria( 'workflow' ); $c = new Criteria('workflow');
$c->clearSelectColumns(); $c->clearSelectColumns();
$c->addSelectColumn( AppThreadPeer::APP_THREAD_PARENT ); $c->addSelectColumn(AppThreadPeer::APP_THREAD_PARENT);
$c->add( AppThreadPeer::APP_UID, $APP_UID ); $c->add(AppThreadPeer::APP_UID, $APP_UID);
$c->add( AppThreadPeer::APP_THREAD_STATUS, 'OPEN' ); $c->add(AppThreadPeer::APP_THREAD_STATUS, 'OPEN');
$cant = AppThreadPeer::doCount( $c ); $cant = AppThreadPeer::doCount($c);
$oCase = new Cases(); $oCase = new Cases();
$aFields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); $aFields = $oCase->loadCase($_SESSION['APPLICATION'], $_SESSION['INDEX']);
GLOBAL $RBAC; GLOBAL $RBAC;
$options = Array (); $options = Array();
switch ($aFields['APP_STATUS']) { switch ($aFields['APP_STATUS']) {
case 'DRAFT': case 'DRAFT':
if (! AppDelay::isPaused( $_SESSION['APPLICATION'], $_SESSION['INDEX'] )) { if (!AppDelay::isPaused($_SESSION['APPLICATION'], $_SESSION['INDEX'])) {
$options[] = Array ('text' => G::LoadTranslation( 'ID_PAUSED_CASE' ),'fn' => 'setUnpauseCaseDate'); $options[] = Array('text' => G::LoadTranslation('ID_PAUSED_CASE'), 'fn' => 'setUnpauseCaseDate');
} else { } else {
$options[] = Array ('text' => G::LoadTranslation( 'ID_UNPAUSE' ),'fn' => 'unpauseCase'); $options[] = Array('text' => G::LoadTranslation('ID_UNPAUSE'), 'fn' => 'unpauseCase');
} }
$options[] = Array ('text' => G::LoadTranslation( 'ID_DELETE' ),'fn' => 'deleteCase'); $options[] = Array('text' => G::LoadTranslation('ID_DELETE'), 'fn' => 'deleteCase');
if ($RBAC->userCanAccess( 'PM_REASSIGNCASE' ) == 1) { if ($RBAC->userCanAccess('PM_REASSIGNCASE') == 1) {
$options[] = Array ('text' => G::LoadTranslation( 'ID_REASSIGN' ),'fn' => 'getUsersToReassign'); $options[] = Array('text' => G::LoadTranslation('ID_REASSIGN'), 'fn' => 'getUsersToReassign');
} }
break; break;
case 'TO_DO': case 'TO_DO':
if (! AppDelay::isPaused( $_SESSION['APPLICATION'], $_SESSION['INDEX'] )) { if (!AppDelay::isPaused($_SESSION['APPLICATION'], $_SESSION['INDEX'])) {
$options[] = Array ('text' => G::LoadTranslation( 'ID_PAUSED_CASE' ),'fn' => 'setUnpauseCaseDate'); $options[] = Array('text' => G::LoadTranslation('ID_PAUSED_CASE'), 'fn' => 'setUnpauseCaseDate');
if ($cant == 1) { if ($cant == 1) {
if ($RBAC->userCanAccess( 'PM_CANCELCASE' ) == 1) { if ($RBAC->userCanAccess('PM_CANCELCASE') == 1) {
$options[] = Array ('text' => G::LoadTranslation( 'ID_CANCEL' ),'fn' => 'cancelCase'); $options[] = Array('text' => G::LoadTranslation('ID_CANCEL'), 'fn' => 'cancelCase');
} else { } else {
$options[] = Array ('text' => G::LoadTranslation( 'ID_CANCEL' ),'fn' => 'cancelCase','hide' => 'hiden'); $options[] = Array('text' => G::LoadTranslation('ID_CANCEL'), 'fn' => 'cancelCase', 'hide' => 'hiden');
} }
} }
} else { } else {
$options[] = Array ('text' => G::LoadTranslation( 'ID_UNPAUSE' ),'fn' => 'unpauseCase'); $options[] = Array('text' => G::LoadTranslation('ID_UNPAUSE'), 'fn' => 'unpauseCase');
} }
if ($RBAC->userCanAccess( 'PM_REASSIGNCASE' ) == 1) { if ($RBAC->userCanAccess('PM_REASSIGNCASE') == 1) {
$options[] = Array ('text' => G::LoadTranslation( 'ID_REASSIGN' ),'fn' => 'getUsersToReassign'); $options[] = Array('text' => G::LoadTranslation('ID_REASSIGN'), 'fn' => 'getUsersToReassign');
} }
break; break;
case 'CANCELLED': case 'CANCELLED':
$options[] = Array ('text' => G::LoadTranslation( 'ID_REACTIVATE' ),'fn' => 'reactivateCase'); $options[] = Array('text' => G::LoadTranslation('ID_REACTIVATE'), 'fn' => 'reactivateCase');
break; break;
} }
if ($_SESSION['TASK'] != '-1') { if ($_SESSION['TASK'] != '-1') {
$oTask = new Task(); $oTask = new Task();
$aTask = $oTask->load( $_SESSION['TASK'] ); $aTask = $oTask->load($_SESSION['TASK']);
if ($aTask['TAS_TYPE'] == 'ADHOC') { if ($aTask['TAS_TYPE'] == 'ADHOC') {
$options[] = Array ('text' => G::LoadTranslation( 'ID_ADHOC_ASSIGNMENT' ),'fn' => 'adhocAssignmentUsers'); $options[] = Array('text' => G::LoadTranslation('ID_ADHOC_ASSIGNMENT'), 'fn' => 'adhocAssignmentUsers');
} }
} }
return $options; return $options;
} }
public function processMap () public function processMap()
{ {
global $G_PUBLISH; global $G_PUBLISH;
global $G_CONTENT; global $G_CONTENT;
@@ -202,17 +201,17 @@ class Ajax
global $G_TABLE; global $G_TABLE;
global $RBAC; global $RBAC;
G::LoadClass( 'processMap' ); G::LoadClass('processMap');
$oTemplatePower = new TemplatePower( PATH_TPL . 'processes/processes_Map.html' ); $oTemplatePower = new TemplatePower(PATH_TPL . 'processes/processes_Map.html');
$oTemplatePower->prepare(); $oTemplatePower->prepare();
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower ); $G_PUBLISH->AddContent('template', '', '', '', $oTemplatePower);
$oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher = & headPublisher::getSingleton();
//$oHeadPublisher->addScriptfile('/jscore/processmap/core/processmap.js'); //$oHeadPublisher->addScriptfile('/jscore/processmap/core/processmap.js');
$oHeadPublisher->addScriptCode( ' $oHeadPublisher->addScriptCode('
var maximunX = ' . processMap::getMaximunTaskX( $_SESSION['PROCESS'] ) . '; var maximunX = ' . processMap::getMaximunTaskX($_SESSION['PROCESS']) . ';
window.onload = function(){ window.onload = function(){
var pb=leimnud.dom.capture("tag.body 0"); var pb=leimnud.dom.capture("tag.body 0");
Pm=new processmap(); Pm=new processmap();
@@ -290,146 +289,146 @@ class Ajax
oLeyendsPanel.addContent(rpc.xmlhttp.responseText); oLeyendsPanel.addContent(rpc.xmlhttp.responseText);
}.extend(this); }.extend(this);
oRPC.make(); oRPC.make();
}' ); }');
G::RenderPage( 'publish', 'blank' ); G::RenderPage('publish', 'blank');
} }
public function getProcessInformation () public function getProcessInformation()
{ {
$process = new Process(); $process = new Process();
$processData = $process->load( $_SESSION['PROCESS'] ); $processData = $process->load($_SESSION['PROCESS']);
require_once 'classes/model/Users.php'; require_once 'classes/model/Users.php';
$user = new Users(); $user = new Users();
try { try {
$userData = $user->load( $processData['PRO_CREATE_USER'] ); $userData = $user->load($processData['PRO_CREATE_USER']);
$processData['PRO_AUTHOR'] = $userData['USR_FIRSTNAME'] . ' ' . $userData['USR_LASTNAME']; $processData['PRO_AUTHOR'] = $userData['USR_FIRSTNAME'] . ' ' . $userData['USR_LASTNAME'];
} catch (Exception $oError) { } catch (Exception $oError) {
$processData['PRO_AUTHOR'] = '(USER DELETED)'; $processData['PRO_AUTHOR'] = '(USER DELETED)';
} }
$processData['PRO_CREATE_DATE'] = date( 'F j, Y', strtotime( $processData['PRO_CREATE_DATE'] ) ); $processData['PRO_CREATE_DATE'] = date('F j, Y', strtotime($processData['PRO_CREATE_DATE']));
print (G::json_encode( $processData )) ; print (G::json_encode($processData));
} }
public function getTaskInformation () public function getTaskInformation()
{ {
$task = new Task(); $task = new Task();
if ($_SESSION['TASK'] == '-1') { if ($_SESSION['TASK'] == '-1') {
$_SESSION['TASK'] = $_SESSION['CURRENT_TASK']; $_SESSION['TASK'] = $_SESSION['CURRENT_TASK'];
} }
$taskData = $task->getDelegatedTaskData( $_SESSION['TASK'], $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); $taskData = $task->getDelegatedTaskData($_SESSION['TASK'], $_SESSION['APPLICATION'], $_SESSION['INDEX']);
print (G::json_encode( $taskData )) ; print (G::json_encode($taskData));
} }
public function caseHistory () public function caseHistory()
{ {
global $G_PUBLISH; global $G_PUBLISH;
G::loadClass( 'configuration' ); G::loadClass('configuration');
$oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher = & headPublisher::getSingleton();
$conf = new Configurations(); $conf = new Configurations();
$oHeadPublisher->addExtJsScript( 'cases/caseHistory', true ); //adding a javascript file .js $oHeadPublisher->addExtJsScript('cases/caseHistory', true); //adding a javascript file .js
$oHeadPublisher->addContent( 'cases/caseHistory' ); //adding a html file .html. $oHeadPublisher->addContent('cases/caseHistory'); //adding a html file .html.
$oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber'));
G::RenderPage( 'publish', 'extJs' ); G::RenderPage('publish', 'extJs');
} }
public function messageHistory () public function messageHistory()
{ {
global $G_PUBLISH; global $G_PUBLISH;
G::loadClass( 'configuration' ); G::loadClass('configuration');
$oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher = & headPublisher::getSingleton();
$conf = new Configurations(); $conf = new Configurations();
$oHeadPublisher->addExtJsScript( 'cases/caseMessageHistory', true ); //adding a javascript file .js $oHeadPublisher->addExtJsScript('cases/caseMessageHistory', true); //adding a javascript file .js
$oHeadPublisher->addContent( 'cases/caseMessageHistory' ); //adding a html file .html. $oHeadPublisher->addContent('cases/caseMessageHistory'); //adding a html file .html.
$oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber'));
G::RenderPage( 'publish', 'extJs' ); G::RenderPage('publish', 'extJs');
} }
public function dynaformHistory () public function dynaformHistory()
{ {
global $G_PUBLISH; global $G_PUBLISH;
G::loadClass( 'configuration' ); G::loadClass('configuration');
$oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher = & headPublisher::getSingleton();
$conf = new Configurations(); $conf = new Configurations();
$oHeadPublisher->addExtJsScript( 'cases/caseHistoryDynaformPage', true ); //adding a javascript file .js $oHeadPublisher->addExtJsScript('cases/caseHistoryDynaformPage', true); //adding a javascript file .js
$oHeadPublisher->addContent( 'cases/caseHistoryDynaformPage' ); //adding a html file .html. $oHeadPublisher->addContent('cases/caseHistoryDynaformPage'); //adding a html file .html.
$oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber'));
G::RenderPage( 'publish', 'extJs' ); G::RenderPage('publish', 'extJs');
} }
public function uploadedDocuments () public function uploadedDocuments()
{ {
global $G_PUBLISH; global $G_PUBLISH;
G::loadClass( 'configuration' ); G::loadClass('configuration');
$oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher = & headPublisher::getSingleton();
$conf = new Configurations(); $conf = new Configurations();
$oHeadPublisher->addExtJsScript( 'cases/casesUploadedDocumentsPage', true ); //adding a javascript file .js $oHeadPublisher->addExtJsScript('cases/casesUploadedDocumentsPage', true); //adding a javascript file .js
$oHeadPublisher->addContent( 'cases/casesUploadedDocumentsPage' ); //adding a html file .html. $oHeadPublisher->addContent('cases/casesUploadedDocumentsPage'); //adding a html file .html.
$oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber'));
G::RenderPage( 'publish', 'extJs' ); G::RenderPage('publish', 'extJs');
} }
public function uploadedDocumentsSummary () public function uploadedDocumentsSummary()
{ {
global $G_PUBLISH; global $G_PUBLISH;
G::loadClass( 'configuration' ); G::loadClass('configuration');
$oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher = & headPublisher::getSingleton();
$conf = new Configurations(); $conf = new Configurations();
$oHeadPublisher->addExtJsScript( 'cases/casesUploadedDocumentsPage', true ); //adding a javascript file .js $oHeadPublisher->addExtJsScript('cases/casesUploadedDocumentsPage', true); //adding a javascript file .js
$oHeadPublisher->addContent( 'cases/casesUploadedDocumentsPage' ); //adding a html file .html. $oHeadPublisher->addContent('cases/casesUploadedDocumentsPage'); //adding a html file .html.
$oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber'));
G::RenderPage( 'publish', 'extJs' ); G::RenderPage('publish', 'extJs');
} }
public function generatedDocuments () public function generatedDocuments()
{ {
global $G_PUBLISH; global $G_PUBLISH;
G::loadClass( 'configuration' ); G::loadClass('configuration');
$oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher = & headPublisher::getSingleton();
$conf = new Configurations(); $conf = new Configurations();
$oHeadPublisher->addExtJsScript( 'cases/casesGenerateDocumentPage', true ); //adding a javascript file .js $oHeadPublisher->addExtJsScript('cases/casesGenerateDocumentPage', true); //adding a javascript file .js
$oHeadPublisher->addContent( 'cases/casesGenerateDocumentPage' ); //adding a html file .html. $oHeadPublisher->addContent('cases/casesGenerateDocumentPage'); //adding a html file .html.
$oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber'));
G::RenderPage( 'publish', 'extJs' ); G::RenderPage('publish', 'extJs');
} }
public function generatedDocumentsSummary () public function generatedDocumentsSummary()
{ {
global $G_PUBLISH; global $G_PUBLISH;
G::loadClass( 'configuration' ); G::loadClass('configuration');
$oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher = & headPublisher::getSingleton();
$conf = new Configurations(); $conf = new Configurations();
$oHeadPublisher->addExtJsScript( 'cases/casesGenerateDocumentPage', true ); //adding a javascript file .js $oHeadPublisher->addExtJsScript('cases/casesGenerateDocumentPage', true); //adding a javascript file .js
$oHeadPublisher->addContent( 'cases/casesGenerateDocumentPage' ); //adding a html file .html. $oHeadPublisher->addContent('cases/casesGenerateDocumentPage'); //adding a html file .html.
$oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber'));
G::RenderPage( 'publish', 'extJs' ); G::RenderPage('publish', 'extJs');
} }
public function cancelCase () public function cancelCase()
{ {
$oCase = new Cases(); $oCase = new Cases();
$multiple = false; $multiple = false;
if (isset( $_POST['APP_UID'] ) && isset( $_POST['DEL_INDEX'] )) { if (isset($_POST['APP_UID']) && isset($_POST['DEL_INDEX'])) {
$APP_UID = $_POST['APP_UID']; $APP_UID = $_POST['APP_UID'];
$DEL_INDEX = $_POST['DEL_INDEX']; $DEL_INDEX = $_POST['DEL_INDEX'];
$appUids = explode( ',', $APP_UID ); $appUids = explode(',', $APP_UID);
$delIndexes = explode( ',', $DEL_INDEX ); $delIndexes = explode(',', $DEL_INDEX);
if (count( $appUids ) > 1 && count( $delIndexes ) > 1) { if (count($appUids) > 1 && count($delIndexes) > 1) {
$multiple = true; $multiple = true;
} }
} elseif (isset( $_POST['sApplicationUID'] ) && isset( $_POST['iIndex'] )) { } elseif (isset($_POST['sApplicationUID']) && isset($_POST['iIndex'])) {
$APP_UID = $_POST['sApplicationUID']; $APP_UID = $_POST['sApplicationUID'];
$DEL_INDEX = $_POST['iIndex']; $DEL_INDEX = $_POST['iIndex'];
} else { } else {
@@ -441,31 +440,30 @@ class Ajax
if ($_POST['NOTE_REASON'] != '') { if ($_POST['NOTE_REASON'] != '') {
require_once ("classes/model/AppNotes.php"); require_once ("classes/model/AppNotes.php");
$appNotes = new AppNotes(); $appNotes = new AppNotes();
$noteContent = addslashes( $_POST['NOTE_REASON'] ); $noteContent = addslashes($_POST['NOTE_REASON']);
$appNotes->postNewNote( $APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_POST['NOTIFY_PAUSE'] ); $appNotes->postNewNote($APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_POST['NOTIFY_PAUSE']);
} }
// End save // End save
if ($multiple) { if ($multiple) {
foreach ($appUids as $i => $appUid) { foreach ($appUids as $i => $appUid) {
$oCase->cancelCase( $appUid, $delIndexes[$i], $_SESSION['USER_LOGGED'] ); $oCase->cancelCase($appUid, $delIndexes[$i], $_SESSION['USER_LOGGED']);
} }
} else { } else {
$oCase->cancelCase( $APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'] ); $oCase->cancelCase($APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED']);
} }
} }
public function getUsersToReassign () public function getUsersToReassign()
{ {
$case = new Cases(); $case = new Cases();
$result->data = $case->getUsersToReassign( $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ); $result->data = $case->getUsersToReassign($_SESSION['TASK'], $_SESSION['USER_LOGGED']);
print G::json_encode( $result );
print G::json_encode($result);
} }
public function reassignCase () public function reassignCase()
{ {
$cases = new Cases(); $cases = new Cases();
$user = new Users(); $user = new Users();
@@ -473,31 +471,31 @@ class Ajax
$TO_USR_UID = $_POST['USR_UID']; $TO_USR_UID = $_POST['USR_UID'];
try { try {
$cases->reassignCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], $TO_USR_UID ); $cases->reassignCase($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], $TO_USR_UID);
$caseData = $app->load( $_SESSION['APPLICATION'] ); $caseData = $app->load($_SESSION['APPLICATION']);
$userData = $user->load( $TO_USR_UID ); $userData = $user->load($TO_USR_UID);
//print_r($caseData); //print_r($caseData);
$data['APP_NUMBER'] = $caseData['APP_NUMBER']; $data['APP_NUMBER'] = $caseData['APP_NUMBER'];
$data['USER'] = $userData['USR_LASTNAME'] . ' ' . $userData['USR_FIRSTNAME']; //TODO change with the farmated username from environment conf $data['USER'] = $userData['USR_LASTNAME'] . ' ' . $userData['USR_FIRSTNAME']; //TODO change with the farmated username from environment conf
$result->status = 0; $result->status = 0;
$result->msg = G::LoadTranslation( 'ID_REASSIGNMENT_SUCCESS', SYS_LANG, $data ); $result->msg = G::LoadTranslation('ID_REASSIGNMENT_SUCCESS', SYS_LANG, $data);
} catch (Exception $e) { } catch (Exception $e) {
$result->status = 1; $result->status = 1;
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
print G::json_encode( $result ); print G::json_encode($result);
} }
public function pauseCase () public function pauseCase()
{ {
try { try {
$unpauseDate = $_REQUEST['unpauseDate']; $unpauseDate = $_REQUEST['unpauseDate'];
$oCase = new Cases(); $oCase = new Cases();
if (isset( $_POST['APP_UID'] ) && isset( $_POST['DEL_INDEX'] )) { if (isset($_POST['APP_UID']) && isset($_POST['DEL_INDEX'])) {
$APP_UID = $_POST['APP_UID']; $APP_UID = $_POST['APP_UID'];
$DEL_INDEX = $_POST['DEL_INDEX']; $DEL_INDEX = $_POST['DEL_INDEX'];
} elseif (isset( $_POST['sApplicationUID'] ) && isset( $_POST['iIndex'] )) { } elseif (isset($_POST['sApplicationUID']) && isset($_POST['iIndex'])) {
$APP_UID = $_POST['sApplicationUID']; $APP_UID = $_POST['sApplicationUID'];
$DEL_INDEX = $_POST['iIndex']; $DEL_INDEX = $_POST['iIndex'];
} else { } else {
@@ -509,92 +507,92 @@ class Ajax
if ($_REQUEST['NOTE_REASON'] != '') { if ($_REQUEST['NOTE_REASON'] != '') {
require_once ("classes/model/AppNotes.php"); require_once ("classes/model/AppNotes.php");
$appNotes = new AppNotes(); $appNotes = new AppNotes();
$noteContent = addslashes( $_REQUEST['NOTE_REASON'] ); $noteContent = addslashes($_REQUEST['NOTE_REASON']);
$appNotes->postNewNote( $APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_REQUEST['NOTIFY_PAUSE'] ); $appNotes->postNewNote($APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_REQUEST['NOTIFY_PAUSE']);
} }
// End save // End save
$oCase->pauseCase( $APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'], $unpauseDate ); $oCase->pauseCase($APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'], $unpauseDate);
$app = new Application(); $app = new Application();
$caseData = $app->load( $APP_UID ); $caseData = $app->load($APP_UID);
$data['APP_NUMBER'] = $caseData['APP_NUMBER']; $data['APP_NUMBER'] = $caseData['APP_NUMBER'];
$data['UNPAUSE_DATE'] = $unpauseDate; $data['UNPAUSE_DATE'] = $unpauseDate;
$result->success = true; $result->success = true;
$result->msg = G::LoadTranslation( 'ID_CASE_PAUSED_SUCCESSFULLY', SYS_LANG, $data ); $result->msg = G::LoadTranslation('ID_CASE_PAUSED_SUCCESSFULLY', SYS_LANG, $data);
} catch (Exception $e) { } catch (Exception $e) {
$result->success = false; $result->success = false;
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
echo G::json_encode( $result ); echo G::json_encode($result);
} }
public function unpauseCase () public function unpauseCase()
{ {
try { try {
$applicationUID = (isset( $_POST['APP_UID'] )) ? $_POST['APP_UID'] : $_SESSION['APPLICATION']; $applicationUID = (isset($_POST['APP_UID'])) ? $_POST['APP_UID'] : $_SESSION['APPLICATION'];
$delIndex = (isset( $_POST['DEL_INDEX'] )) ? $_POST['DEL_INDEX'] : $_SESSION['INDEX']; $delIndex = (isset($_POST['DEL_INDEX'])) ? $_POST['DEL_INDEX'] : $_SESSION['INDEX'];
$oCase = new Cases(); $oCase = new Cases();
$oCase->unpauseCase( $applicationUID, $delIndex, $_SESSION['USER_LOGGED'] ); $oCase->unpauseCase($applicationUID, $delIndex, $_SESSION['USER_LOGGED']);
$app = new Application(); $app = new Application();
$caseData = $app->load( $applicationUID ); $caseData = $app->load($applicationUID);
$data['APP_NUMBER'] = $caseData['APP_NUMBER']; $data['APP_NUMBER'] = $caseData['APP_NUMBER'];
$result->success = true; $result->success = true;
$result->msg = G::LoadTranslation( 'ID_CASE_UNPAUSED_SUCCESSFULLY', SYS_LANG, $data ); $result->msg = G::LoadTranslation('ID_CASE_UNPAUSED_SUCCESSFULLY', SYS_LANG, $data);
} catch (Exception $e) { } catch (Exception $e) {
$result->success = false; $result->success = false;
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
print G::json_encode( $result ); print G::json_encode($result);
} }
public function deleteCase () public function deleteCase()
{ {
try { try {
$applicationUID = (isset( $_POST['APP_UID'] )) ? $_POST['APP_UID'] : $_SESSION['APPLICATION']; $applicationUID = (isset($_POST['APP_UID'])) ? $_POST['APP_UID'] : $_SESSION['APPLICATION'];
$app = new Application(); $app = new Application();
$caseData = $app->load( $applicationUID ); $caseData = $app->load($applicationUID);
$data['APP_NUMBER'] = $caseData['APP_NUMBER']; $data['APP_NUMBER'] = $caseData['APP_NUMBER'];
$oCase = new Cases(); $oCase = new Cases();
$oCase->removeCase( $applicationUID ); $oCase->removeCase($applicationUID);
$result->success = true; $result->success = true;
$result->msg = G::LoadTranslation( 'ID_CASE_DELETED_SUCCESSFULLY', SYS_LANG, $data ); $result->msg = G::LoadTranslation('ID_CASE_DELETED_SUCCESSFULLY', SYS_LANG, $data);
} catch (Exception $e) { } catch (Exception $e) {
$result->success = false; $result->success = false;
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
print G::json_encode( $result ); print G::json_encode($result);
} }
public function reactivateCase () public function reactivateCase()
{ {
try { try {
$applicationUID = (isset( $_POST['APP_UID'] )) ? $_POST['APP_UID'] : $_SESSION['APPLICATION']; $applicationUID = (isset($_POST['APP_UID'])) ? $_POST['APP_UID'] : $_SESSION['APPLICATION'];
$delIndex = (isset( $_POST['DEL_INDEX'] )) ? $_POST['DEL_INDEX'] : $_SESSION['INDEX']; $delIndex = (isset($_POST['DEL_INDEX'])) ? $_POST['DEL_INDEX'] : $_SESSION['INDEX'];
$app = new Application(); $app = new Application();
$caseData = $app->load( $applicationUID ); $caseData = $app->load($applicationUID);
$data['APP_NUMBER'] = $caseData['APP_NUMBER']; $data['APP_NUMBER'] = $caseData['APP_NUMBER'];
$oCase = new Cases(); $oCase = new Cases();
$oCase->reactivateCase( $applicationUID, $delIndex, $_SESSION['USER_LOGGED'] ); $oCase->reactivateCase($applicationUID, $delIndex, $_SESSION['USER_LOGGED']);
$result->success = true; $result->success = true;
$result->msg = G::LoadTranslation( 'ID_CASE_REACTIVATED_SUCCESSFULLY', SYS_LANG, $data ); $result->msg = G::LoadTranslation('ID_CASE_REACTIVATED_SUCCESSFULLY', SYS_LANG, $data);
} catch (Exception $e) { } catch (Exception $e) {
$result->success = false; $result->success = false;
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
print G::json_encode( $result ); print G::json_encode($result);
} }
public function changeLogTab () public function changeLogTab()
{ {
try { try {
global $G_PUBLISH; global $G_PUBLISH;
@@ -603,169 +601,168 @@ class Ajax
//!dataInput //!dataInput
$idHistory = $_REQUEST["idHistory"]; $idHistory = $_REQUEST["idHistory"];
//!dataInput //!dataInput
//!dataSytem //!dataSytem
$idHistoryArray = explode( "_", $idHistory ); $idHistoryArray = explode("_", $idHistory);
$_REQUEST["PRO_UID"] = $idHistoryArray[0]; $_REQUEST["PRO_UID"] = $idHistoryArray[0];
$_REQUEST["APP_UID"] = $idHistoryArray[1]; $_REQUEST["APP_UID"] = $idHistoryArray[1];
$_REQUEST["TAS_UID"] = $idHistoryArray[2]; $_REQUEST["TAS_UID"] = $idHistoryArray[2];
$_REQUEST["DYN_UID"] = ""; $_REQUEST["DYN_UID"] = "";
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'view', 'cases/cases_DynaformHistory' ); $G_PUBLISH->AddContent('view', 'cases/cases_DynaformHistory');
?> ?>
<link rel="stylesheet" type="text/css" href="/css/classic.css" /> <link rel="stylesheet" type="text/css" href="/css/classic.css" />
<style type="text/css"> <style type="text/css">
html { html {
color: black !important; color: black !important;
} }
body { body {
color: black !important; color: black !important;
} }
</style> </style>
<script language="javascript"> <script language="javascript">
function ajaxPostRequest(url, callback_function, id){ function ajaxPostRequest(url, callback_function, id) {
var d = new Date(); var d = new Date();
var time = d.getTime(); var time = d.getTime();
url = url + '&nocachetime='+time; url = url + '&nocachetime=' + time;
var return_xml=false; var return_xml = false;
var http_request = false; var http_request = false;
if (window.XMLHttpRequest) { if (window.XMLHttpRequest) {
// Mozilla, Safari,... // Mozilla, Safari,...
http_request = new XMLHttpRequest(); http_request = new XMLHttpRequest();
if (http_request.overrideMimeType){ if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml'); http_request.overrideMimeType('text/xml');
} }
} }
elseif (window.ActiveXObject) { elseif (window.ActiveXObject) {
// IE // IE
try { try {
http_request = new ActiveXObject("Msxml2.XMLHTTP"); http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
}
}
}
if (!http_request) {
alert('This browser is not supported.');
return false;
}
http_request.onreadystatechange = function() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
if (return_xml) {
eval(callback_function + '(http_request.responseXML)');
}
else {
eval(callback_function + '(http_request.responseText, \'' + id + '\')');
}
}
else {
alert('Error found on request:(Code: ' + http_request.status + ')');
}
}
}
http_request.open('GET', url, true);
http_request.send(null);
} }
catch (e) {
try { function toggleTable(tablename) {
http_request = new ActiveXObject("Microsoft.XMLHTTP"); table = document.getElementById(tablename);
}
catch (e) { if (table.style.display == '') {
} table.style.display = 'none';
} else {
table.style.display = '';
}
} }
}
if (!http_request){ function noesFuncion(idIframe) {
alert('This browser is not supported.'); window.parent.tabIframeWidthFix2(idIframe);
return false;
}
http_request.onreadystatechange = function(){
if (http_request.readyState == 4){
if (http_request.status == 200){
if (return_xml){
eval(callback_function + '(http_request.responseXML)');
}
else{
eval(callback_function + '(http_request.responseText, \''+id+'\')');
}
} }
else {
alert('Error found on request:(Code: ' + http_request.status + ')'); function onResizeIframe(idIframe) {
window.onresize = noesFuncion(idIframe);
} }
}
}
http_request.open('GET', url, true);
http_request.send(null);
}
function toggleTable(tablename) { function showDynaformHistoryGetNomDynaform_RSP(response, id) {
table= document.getElementById(tablename); //!showDynaformHistoryGlobal
showDynaformHistoryGlobal.idDin = showDynaformHistoryGlobal.idDin;
showDynaformHistoryGlobal.idHistory = showDynaformHistoryGlobal.idHistory;
showDynaformHistoryGlobal.dynDate = showDynaformHistoryGlobal.dynDate;
if(table.style.display == ''){ //!dataSystem
table.style.display = 'none'; var idDin = showDynaformHistoryGlobal.idDin;
}else{ var idHistory = showDynaformHistoryGlobal.idHistory;
table.style.display = ''; var dynDate = showDynaformHistoryGlobal.dynDate;
}
}
function noesFuncion(idIframe) { //!windowParent
window.parent.tabIframeWidthFix2(idIframe); window.parent.historyGridListChangeLogGlobal.viewIdDin = idDin;
} window.parent.historyGridListChangeLogGlobal.viewIdHistory = idHistory;
window.parent.historyGridListChangeLogGlobal.viewDynaformName = response;
window.parent.historyGridListChangeLogGlobal.dynDate = dynDate;
function onResizeIframe(idIframe){ window.parent.Actions.tabFrame('dynaformViewFromHistory');
window.onresize = noesFuncion(idIframe); }
}
function showDynaformHistoryGetNomDynaform_RSP(response,id) { showDynaformHistoryGlobal = {};
//!showDynaformHistoryGlobal showDynaformHistoryGlobal.idDin = "";
showDynaformHistoryGlobal.idDin = showDynaformHistoryGlobal.idDin; showDynaformHistoryGlobal.idHistory = "";
showDynaformHistoryGlobal.idHistory = showDynaformHistoryGlobal.idHistory; showDynaformHistoryGlobal.dynDate = "";
showDynaformHistoryGlobal.dynDate = showDynaformHistoryGlobal.dynDate;
//!dataSystem function showDynaformHistory(idDin, idHistory, dynDate) {
var idDin = showDynaformHistoryGlobal.idDin; //!showDynaformHistoryGlobal
var idHistory = showDynaformHistoryGlobal.idHistory; showDynaformHistoryGlobal.idDin = showDynaformHistoryGlobal.idDin;
var dynDate = showDynaformHistoryGlobal.dynDate; showDynaformHistoryGlobal.idHistory = showDynaformHistoryGlobal.idHistory;
showDynaformHistoryGlobal.dynDate = showDynaformHistoryGlobal.dynDate;
//!windowParent //!dataSystem
window.parent.historyGridListChangeLogGlobal.viewIdDin = idDin; showDynaformHistoryGlobal.idDin = idDin;
window.parent.historyGridListChangeLogGlobal.viewIdHistory = idHistory; showDynaformHistoryGlobal.idHistory = idHistory;
window.parent.historyGridListChangeLogGlobal.viewDynaformName = response; showDynaformHistoryGlobal.dynDate = dynDate;
window.parent.historyGridListChangeLogGlobal.dynDate = dynDate;
window.parent.Actions.tabFrame('dynaformViewFromHistory'); var url = "caseHistory_Ajax.php?actionAjax=showDynaformHistoryGetNomDynaform_JXP&idDin=" + idDin + "&dynDate=" + dynDate;
} ajaxPostRequest(url, 'showDynaformHistoryGetNomDynaform_RSP');
}
showDynaformHistoryGlobal = {};
showDynaformHistoryGlobal.idDin = "";
showDynaformHistoryGlobal.idHistory = "";
showDynaformHistoryGlobal.dynDate = "";
function showDynaformHistory(idDin, idHistory, dynDate) {
//!showDynaformHistoryGlobal
showDynaformHistoryGlobal.idDin = showDynaformHistoryGlobal.idDin;
showDynaformHistoryGlobal.idHistory = showDynaformHistoryGlobal.idHistory;
showDynaformHistoryGlobal.dynDate = showDynaformHistoryGlobal.dynDate;
//!dataSystem
showDynaformHistoryGlobal.idDin = idDin;
showDynaformHistoryGlobal.idHistory = idHistory;
showDynaformHistoryGlobal.dynDate = dynDate;
var url = "caseHistory_Ajax.php?actionAjax=showDynaformHistoryGetNomDynaform_JXP&idDin="+idDin+"&dynDate="+dynDate;ajaxPostRequest(url, 'showDynaformHistoryGetNomDynaform_RSP');
}
</script> </script>
<?php <?php
G::RenderPage('publish', 'raw');
G::RenderPage( 'publish', 'raw' );
$result->success = true; $result->success = true;
$result->msg = G::LoadTranslation( 'ID_CASE_REACTIVATED_SUCCESSFULLY', SYS_LANG, "success" ); $result->msg = G::LoadTranslation('ID_CASE_REACTIVATED_SUCCESSFULLY', SYS_LANG, "success");
} catch (Exception $e) { } catch (Exception $e) {
$result->success = false; $result->success = false;
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
} }
public function dynaformViewFromHistory () public function dynaformViewFromHistory()
{ {
?> ?>
<link rel="stylesheet" type="text/css" href="/css/classic.css" /> <link rel="stylesheet" type="text/css" href="/css/classic.css" />
<script type="text/javascript"> <script type="text/javascript">
//!Code that simulated reload library javascript maborak //!Code that simulated reload library javascript maborak
var leimnud = {}; var leimnud = {};
leimnud.exec = ""; leimnud.exec = "";
leimnud.fix = {}; leimnud.fix = {};
leimnud.fix.memoryLeak = ""; leimnud.fix.memoryLeak = "";
leimnud.browser = {}; leimnud.browser = {};
leimnud.browser.isIphone = ""; leimnud.browser.isIphone = "";
leimnud.iphone = {}; leimnud.iphone = {};
leimnud.iphone.make = function () {}; leimnud.iphone.make = function() {
function ajax_function(ajax_server, funcion, parameters, method) };
{ function ajax_function(ajax_server, funcion, parameters, method)
} {
//! }
//!
</script> </script>
<?php <?php
@@ -775,37 +772,37 @@ class Ajax
$_POST["DYN_UID"] = $_REQUEST["DYN_UID"]; $_POST["DYN_UID"] = $_REQUEST["DYN_UID"];
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();
$FieldsHistory = unserialize( $_SESSION["HISTORY_DATA"] ); $FieldsHistory = unserialize($_SESSION["HISTORY_DATA"]);
$Fields["APP_DATA"] = $FieldsHistory[$_POST["HISTORY_ID"]]; //isset($FieldsHistory[$_POST["HISTORY_ID"]])? $FieldsHistory[$_POST["HISTORY_ID"]] : ""; $Fields["APP_DATA"] = $FieldsHistory[$_POST["HISTORY_ID"]]; //isset($FieldsHistory[$_POST["HISTORY_ID"]])? $FieldsHistory[$_POST["HISTORY_ID"]] : "";
$Fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["PREVIOUS_STEP_LABEL"] = ""; $Fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["PREVIOUS_STEP_LABEL"] = "";
$Fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["NEXT_STEP_LABEL"] = ""; $Fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["NEXT_STEP_LABEL"] = "";
$Fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["NEXT_STEP"] = "#"; $Fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["NEXT_STEP"] = "#";
$Fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["NEXT_ACTION"] = "return false;"; $Fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["NEXT_ACTION"] = "return false;";
$G_PUBLISH->AddContent( "dynaform", "xmlform", $_SESSION["PROCESS"] . "/" . $_POST["DYN_UID"], "", $Fields["APP_DATA"], "", "", "view" ); $G_PUBLISH->AddContent("dynaform", "xmlform", $_SESSION["PROCESS"] . "/" . $_POST["DYN_UID"], "", $Fields["APP_DATA"], "", "", "view");
?> ?>
<script type="text/javascript"> <script type="text/javascript">
<?php <?php
global $G_FORM; global $G_FORM;
?> ?>
function loadForm_<?php echo $G_FORM->id; ?>(parametro1) { function loadForm_<?php echo $G_FORM->id; ?>(parametro1) {
} }
</script> </script>
<?php <?php
G::RenderPage( "publish", "raw" ); G::RenderPage("publish", "raw");
?> ?>
<style type="text/css"> <style type="text/css">
html { html {
color: black !important; color: black !important;
} }
body { body {
color: black !important; color: black !important;
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
@@ -814,15 +811,15 @@ class Ajax
global $G_FORM; global $G_FORM;
?> ?>
function loadForm_<?php echo $G_FORM->id; ?>(parametro1) { function loadForm_<?php echo $G_FORM->id; ?>(parametro1) {
} }
</script> </script>
<?php <?php
} }
} }
$pluginRegistry =& PMPluginRegistry::getSingleton(); $pluginRegistry = & PMPluginRegistry::getSingleton();
if ($pluginRegistry->existsTrigger(PM_GET_CASES_AJAX_LISTENER)) { if ($pluginRegistry->existsTrigger(PM_GET_CASES_AJAX_LISTENER)) {
$ajax = $pluginRegistry->executeTriggers(PM_GET_CASES_AJAX_LISTENER, null); $ajax = $pluginRegistry->executeTriggers(PM_GET_CASES_AJAX_LISTENER, null);
} else { } else {
@@ -833,10 +830,11 @@ if (!($ajax instanceof Ajax)) {
$ajax = new Ajax(); $ajax = new Ajax();
} }
G::LoadClass( 'case' ); G::LoadClass('case');
$action = $_REQUEST['action']; $action = $_REQUEST['action'];
unset( $_REQUEST['action'] ); unset($_REQUEST['action']);
$ajax->$action($_REQUEST);
$ajax->$action( $_REQUEST );

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* processes/ajaxListener.php Ajax Listener for Cases rpc requests * processes/ajaxListener.php Ajax Listener for Cases rpc requests
* *
@@ -21,67 +22,64 @@
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
/** /**
* *
* @author Erik Amaru Ortiz <erik@colosa.com> * @author Erik Amaru Ortiz <erik@colosa.com>
* @date Jan 10th, 2010 * @date Jan 10th, 2010
*/ */
$action = $_REQUEST['action']; $action = $_REQUEST['action'];
unset( $_REQUEST['action'] ); unset($_REQUEST['action']);
$ajax = new Ajax(); $ajax = new Ajax();
$ajax->$action( $_REQUEST ); $ajax->$action($_REQUEST);
class Ajax class Ajax
{ {
function categoriesList () public function categoriesList()
{ {
require_once "classes/model/ProcessCategory.php"; require_once "classes/model/ProcessCategory.php";
$processCategory = new ProcessCategory(); $processCategory = new ProcessCategory();
$defaultOption = Array (); $defaultOption = Array();
$defaultOption[] = Array ('CATEGORY_UID' => '<reset>','CATEGORY_NAME' => G::LoadTranslation( 'ID_ALL' ) $defaultOption[] = Array('CATEGORY_UID' => '<reset>', 'CATEGORY_NAME' => G::LoadTranslation('ID_ALL'));
); $defaultOption[] = Array('CATEGORY_UID' => '', 'CATEGORY_NAME' => G::LoadTranslation('ID_PROCESS_NO_CATEGORY'));
$defaultOption[] = Array ('CATEGORY_UID' => '','CATEGORY_NAME' => G::LoadTranslation( 'ID_PROCESS_NO_CATEGORY' )
);
$response->rows = array_merge( $defaultOption, $processCategory->getAll( 'array' ) ); $response->rows = array_merge($defaultOption, $processCategory->getAll('array'));
echo G::json_encode( $response ); echo G::json_encode($response);
} }
function processCategories () public function processCategories()
{ {
require_once "classes/model/ProcessCategory.php"; require_once "classes/model/ProcessCategory.php";
$processCategory = new ProcessCategory(); $processCategory = new ProcessCategory();
$defaultOption = Array (); $defaultOption = Array();
$defaultOption[] = Array ('CATEGORY_UID' => '','CATEGORY_NAME' => G::LoadTranslation( 'ID_PROCESS_NO_CATEGORY' ) $defaultOption[] = Array('CATEGORY_UID' => '', 'CATEGORY_NAME' => G::LoadTranslation('ID_PROCESS_NO_CATEGORY'));
);
$response->rows = array_merge( $defaultOption, $processCategory->getAll( 'array' ) ); $response->rows = array_merge($defaultOption, $processCategory->getAll('array'));
echo G::json_encode( $response ); echo G::json_encode($response);
} }
function saveProcess () public function saveProcess()
{ {
try { try {
require_once 'classes/model/Task.php'; require_once 'classes/model/Task.php';
G::LoadClass( 'processMap' ); G::LoadClass('processMap');
$oProcessMap = new ProcessMap(); $oProcessMap = new ProcessMap();
if (! isset( $_POST['PRO_UID'] )) { if (!isset($_POST['PRO_UID'])) {
if (Process::existsByProTitle( $_POST['PRO_TITLE'] )) { if (Process::existsByProTitle($_POST['PRO_TITLE'])) {
$result = array ('success' => false,'msg' => 'Process Save Error','errors' => array ('PRO_TITLE' => G::LoadTranslation( 'ID_PROCESSTITLE_ALREADY_EXISTS', SYS_LANG, $_POST ) $result = array(
) 'success' => false,
'msg' => 'Process Save Error',
'errors' => array('PRO_TITLE' => G::LoadTranslation('ID_PROCESSTITLE_ALREADY_EXISTS', SYS_LANG, $_POST))
); );
print G::json_encode( $result ); print G::json_encode($result);
exit( 0 ); exit(0);
} }
$processData['USR_UID'] = $_SESSION['USER_LOGGED']; $processData['USR_UID'] = $_SESSION['USER_LOGGED'];
@@ -89,138 +87,135 @@ class Ajax
$processData['PRO_DESCRIPTION'] = $_POST['PRO_DESCRIPTION']; $processData['PRO_DESCRIPTION'] = $_POST['PRO_DESCRIPTION'];
$processData['PRO_CATEGORY'] = $_POST['PRO_CATEGORY']; $processData['PRO_CATEGORY'] = $_POST['PRO_CATEGORY'];
$sProUid = $oProcessMap->createProcess( $processData ); $sProUid = $oProcessMap->createProcess($processData);
//call plugins //call plugins
$oData['PRO_UID'] = $sProUid; $oData['PRO_UID'] = $sProUid;
$oData['PRO_TEMPLATE'] = (isset( $_POST['PRO_TEMPLATE'] ) && $_POST['PRO_TEMPLATE'] != '') ? $_POST['form']['PRO_TEMPLATE'] : ''; $oData['PRO_TEMPLATE'] = (isset($_POST['PRO_TEMPLATE']) && $_POST['PRO_TEMPLATE'] != '') ? $_POST['form']['PRO_TEMPLATE'] : '';
$oData['PROCESSMAP'] = $oProcessMap; $oData['PROCESSMAP'] = $oProcessMap;
$oPluginRegistry = & PMPluginRegistry::getSingleton(); $oPluginRegistry = & PMPluginRegistry::getSingleton();
$oPluginRegistry->executeTriggers( PM_NEW_PROCESS_SAVE, $oData ); $oPluginRegistry->executeTriggers(PM_NEW_PROCESS_SAVE, $oData);
} else { } else {
//$oProcessMap->updateProcess($_POST['form']); //$oProcessMap->updateProcess($_POST['form']);
$sProUid = $_POST['PRO_UID']; $sProUid = $_POST['PRO_UID'];
} }
//Save Calendar ID for this process //Save Calendar ID for this process
if (isset( $_POST['PRO_CALENDAR'] )) { if (isset($_POST['PRO_CALENDAR'])) {
G::LoadClass( "calendar" ); G::LoadClass("calendar");
$calendarObj = new Calendar(); $calendarObj = new Calendar();
$calendarObj->assignCalendarTo( $sProUid, $_POST['PRO_CALENDAR'], 'PROCESS' ); $calendarObj->assignCalendarTo($sProUid, $_POST['PRO_CALENDAR'], 'PROCESS');
} }
$result->success = true; $result->success = true;
$result->PRO_UID = $sProUid; $result->PRO_UID = $sProUid;
$result->msg = G::LoadTranslation( 'ID_CREATE_PROCESS_SUCCESS' ); $result->msg = G::LoadTranslation('ID_CREATE_PROCESS_SUCCESS');
} catch (Exception $e) { } catch (Exception $e) {
$result->success = false; $result->success = false;
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
print G::json_encode( $result ); print G::json_encode($result);
} }
function changeStatus () public function changeStatus()
{ {
$ids = explode( ',', $_REQUEST['UIDS'] ); $ids = explode(',', $_REQUEST['UIDS']);
G::LoadClass( 'processes' ); G::LoadClass('processes');
$oProcess = new Processes(); $oProcess = new Processes();
if (count( $ids ) > 0) { if (count($ids) > 0) {
foreach ($ids as $id) foreach ($ids as $id) {
$oProcess->changeStatus( $id ); $oProcess->changeStatus($id);
}
} }
} }
function changeDebugMode () public function changeDebugMode()
{ {
$ids = explode( ',', $_REQUEST['UIDS'] ); $ids = explode(',', $_REQUEST['UIDS']);
G::LoadClass( 'processes' ); G::LoadClass('processes');
$oProcess = new Processes(); $oProcess = new Processes();
if (count( $ids ) > 0) { if (count($ids) > 0) {
foreach ($ids as $id) foreach ($ids as $id) {
$oProcess->changeDebugMode( $id ); $oProcess->changeDebugMode($id);
}
} }
} }
function getUsers ($params) public function getUsers($params)
{ {
require_once 'classes/model/Users.php'; require_once 'classes/model/Users.php';
G::LoadClass( 'configuration' ); G::LoadClass('configuration');
$conf = new Configurations(); $conf = new Configurations();
$search = isset( $params['search'] ) ? $params['search'] : null; $search = isset($params['search']) ? $params['search'] : null;
$users = Users::getAll( $params['start'], $params['limit'], $search ); $users = Users::getAll($params['start'], $params['limit'], $search);
foreach ($users->data as $i => $user) { foreach ($users->data as $i => $user) {
$users->data[$i]['USER'] = $conf->getEnvSetting( 'format', Array ('userName' => $user['USR_USERNAME'],'firstName' => $user['USR_FIRSTNAME'],'lastName' => $user['USR_LASTNAME'] $users->data[$i]['USER'] = $conf->getEnvSetting('format', Array('userName' => $user['USR_USERNAME'], 'firstName' => $user['USR_FIRSTNAME'], 'lastName' => $user['USR_LASTNAME']));
) );
} }
print G::json_encode( $users ); print G::json_encode($users);
} }
function getGroups ($params) public function getGroups($params)
{ {
require_once 'classes/model/Groupwf.php'; require_once 'classes/model/Groupwf.php';
$search = isset( $params['search'] ) ? $params['search'] : null; $search = isset($params['search']) ? $params['search'] : null;
$groups = Groupwf::getAll( $params['start'], $params['limit'], $search ); $groups = Groupwf::getAll($params['start'], $params['limit'], $search);
print G::json_encode( $groups ); print G::json_encode($groups);
} }
function assignUsersTask ($param) public function assignUsersTask($param)
{ {
try { try {
require_once 'classes/model/TaskUser.php'; require_once 'classes/model/TaskUser.php';
require_once 'classes/model/Task.php'; require_once 'classes/model/Task.php';
$oTaskUser = new TaskUser(); $oTaskUser = new TaskUser();
$UIDS = explode( ',', $param['UIDS'] ); $UIDS = explode(',', $param['UIDS']);
$TU_TYPE = 1; $TU_TYPE = 1;
foreach ($UIDS as $UID) { foreach ($UIDS as $UID) {
if ($_POST['TU_RELATION'] == 1) if ($_POST['TU_RELATION'] == 1) {
$oTaskUser->create( array ('TAS_UID' => $param['TAS_UID'],'USR_UID' => $UID,'TU_TYPE' => $TU_TYPE,'TU_RELATION' => 1 $oTaskUser->create(array('TAS_UID' => $param['TAS_UID'], 'USR_UID' => $UID, 'TU_TYPE' => $TU_TYPE, 'TU_RELATION' => 1));
) ); } else {
else $oTaskUser->create(array('TAS_UID' => $param['TAS_UID'], 'USR_UID' => $UID, 'TU_TYPE' => $TU_TYPE, 'TU_RELATION' => 2));
$oTaskUser->create( array ('TAS_UID' => $param['TAS_UID'],'USR_UID' => $UID,'TU_TYPE' => $TU_TYPE,'TU_RELATION' => 2 }
) );
} }
$task = TaskPeer::retrieveByPk( $param['TAS_UID'] ); $task = TaskPeer::retrieveByPk($param['TAS_UID']);
$result->success = true; $result->success = true;
if (count( $UIDS ) > 1) if (count($UIDS) > 1) {
$result->msg = __( 'ID_ACTORS_ASSIGNED_SUCESSFULLY', SYS_LANG, Array (count( $UIDS ),$task->getTasTitle() $result->msg = __('ID_ACTORS_ASSIGNED_SUCESSFULLY', SYS_LANG, Array(count($UIDS), $task->getTasTitle()));
) ); } else {
else $result->msg = __('ID_ACTOR_ASSIGNED_SUCESSFULLY', SYS_LANG, Array('tas_title' => $task->getTasTitle()));
$result->msg = __( 'ID_ACTOR_ASSIGNED_SUCESSFULLY', SYS_LANG, Array ('tas_title' => $task->getTasTitle() }
) );
} catch (Exception $e) { } catch (Exception $e) {
$result->success = false; $result->success = false;
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
print G::json_encode( $result ); print G::json_encode($result);
} }
function removeUsersTask ($param) public function removeUsersTask($param)
{ {
try { try {
require_once 'classes/model/TaskUser.php'; require_once 'classes/model/TaskUser.php';
$oTaskUser = new TaskUser(); $oTaskUser = new TaskUser();
$USR_UIDS = explode( ',', $param['USR_UID'] ); $USR_UIDS = explode(',', $param['USR_UID']);
$TU_RELATIONS = explode( ',', $param['TU_RELATION'] ); $TU_RELATIONS = explode(',', $param['TU_RELATION']);
$TU_TYPE = 1; $TU_TYPE = 1;
foreach ($USR_UIDS as $i => $USR_UID) { foreach ($USR_UIDS as $i => $USR_UID) {
if ($TU_RELATIONS[$i] == 1) { if ($TU_RELATIONS[$i] == 1) {
$oTaskUser->remove( $param['TAS_UID'], $USR_UID, $TU_TYPE, 1 ); $oTaskUser->remove($param['TAS_UID'], $USR_UID, $TU_TYPE, 1);
} else { } else {
$oTaskUser->remove( $param['TAS_UID'], $USR_UID, $TU_TYPE, 2 ); $oTaskUser->remove($param['TAS_UID'], $USR_UID, $TU_TYPE, 2);
} }
} }
@@ -231,19 +226,19 @@ class Ajax
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
print G::json_encode( $result ); print G::json_encode($result);
} }
function getUsersTask ($param) public function getUsersTask($param)
{ {
require_once 'classes/model/TaskUser.php'; require_once 'classes/model/TaskUser.php';
G::LoadClass( 'configuration' ); G::LoadClass('configuration');
$usersTaskList = Array (); $usersTaskList = Array();
$task = new TaskUser(); $task = new TaskUser();
$conf = new Configurations(); $conf = new Configurations();
$TU_TYPE = 1; $TU_TYPE = 1;
$usersTask = $task->getUsersTask( $param['TAS_UID'], $TU_TYPE ); $usersTask = $task->getUsersTask($param['TAS_UID'], $TU_TYPE);
foreach ($usersTask->data as $userTask) { foreach ($usersTask->data as $userTask) {
$usersTaskListItem['TAS_UID'] = $userTask['TAS_UID']; $usersTaskListItem['TAS_UID'] = $userTask['TAS_UID'];
@@ -251,8 +246,9 @@ class Ajax
$usersTaskListItem['USR_USERNAME'] = $userTask['USR_USERNAME']; $usersTaskListItem['USR_USERNAME'] = $userTask['USR_USERNAME'];
$usersTaskListItem['USR_FIRSTNAME'] = $userTask['USR_FIRSTNAME']; $usersTaskListItem['USR_FIRSTNAME'] = $userTask['USR_FIRSTNAME'];
$usersTaskListItem['USR_LASTNAME'] = $userTask['USR_LASTNAME']; $usersTaskListItem['USR_LASTNAME'] = $userTask['USR_LASTNAME'];
} else } else {
$usersTaskListItem['NAME'] = $userTask['GRP_TITLE']; $usersTaskListItem['NAME'] = $userTask['GRP_TITLE'];
}
$usersTaskListItem['TU_RELATION'] = $userTask['TU_RELATION']; $usersTaskListItem['TU_RELATION'] = $userTask['TU_RELATION'];
$usersTaskListItem['USR_UID'] = $userTask['USR_UID']; $usersTaskListItem['USR_UID'] = $userTask['USR_UID'];
@@ -263,33 +259,33 @@ class Ajax
$result->data = $usersTaskList; $result->data = $usersTaskList;
$result->totalCount = $usersTask->totalCount; $result->totalCount = $usersTask->totalCount;
print G::json_encode( $result ); print G::json_encode($result);
} }
function getProcessDetail ($param) public function getProcessDetail($param)
{ {
require_once 'classes/model/Process.php'; require_once 'classes/model/Process.php';
$PRO_UID = $param['PRO_UID']; $PRO_UID = $param['PRO_UID'];
G::loadClass( 'tasks' ); G::loadClass('tasks');
$tasks = new Tasks(); $tasks = new Tasks();
$process = ProcessPeer::retrieveByPk( $PRO_UID ); $process = ProcessPeer::retrieveByPk($PRO_UID);
$tasksList = $tasks->getAllTasks( $PRO_UID ); $tasksList = $tasks->getAllTasks($PRO_UID);
$rootNode->id = $process->getProUid(); $rootNode->id = $process->getProUid();
$rootNode->type = 'process'; $rootNode->type = 'process';
$rootNode->typeLabel = G::LoadTranslation( 'ID_PROCESS' ); $rootNode->typeLabel = G::LoadTranslation('ID_PROCESS');
$rootNode->text = $process->getProTitle(); $rootNode->text = $process->getProTitle();
$rootNode->leaf = count( $tasksList ) > 0 ? false : true; $rootNode->leaf = count($tasksList) > 0 ? false : true;
$rootNode->iconCls = 'ss_sprite ss_application'; $rootNode->iconCls = 'ss_sprite ss_application';
$rootNode->expanded = true; $rootNode->expanded = true;
foreach ($tasksList as $task) { foreach ($tasksList as $task) {
$node = new stdClass(); $node = new stdClass();
$node->id = $task['TAS_UID']; $node->id = $task['TAS_UID'];
$node->type = 'task'; $node->type = 'task';
$node->typeLabel = G::LoadTranslation( 'ID_TASK' ); $node->typeLabel = G::LoadTranslation('ID_TASK');
$node->text = $task['TAS_TITLE']; $node->text = $task['TAS_TITLE'];
$node->iconCls = 'ss_sprite ss_layout'; $node->iconCls = 'ss_sprite ss_layout';
$node->leaf = true; $node->leaf = true;
@@ -297,23 +293,23 @@ class Ajax
} }
$treeDetail[] = $rootNode; $treeDetail[] = $rootNode;
print G::json_encode( $treeDetail ); print G::json_encode($treeDetail);
} }
function getProperties ($param) public function getProperties($param)
{ {
switch ($param['type']) { switch ($param['type']) {
case 'process': case 'process':
require_once 'classes/model/ProcessCategory.php'; require_once 'classes/model/ProcessCategory.php';
require_once 'classes/model/CalendarDefinition.php'; require_once 'classes/model/CalendarDefinition.php';
G::LoadClass( 'processMap' ); G::LoadClass('processMap');
$oProcessMap = new processMap( new DBConnection() ); $oProcessMap = new processMap(new DBConnection());
$process = $oProcessMap->editProcessNew( $param['UID'] ); $process = $oProcessMap->editProcessNew($param['UID']);
$category = ProcessCategoryPeer::retrieveByPk( $process['PRO_CATEGORY'] ); $category = ProcessCategoryPeer::retrieveByPk($process['PRO_CATEGORY']);
$categoryName = is_object( $category ) ? $category->getCategoryName() : ''; $categoryName = is_object($category) ? $category->getCategoryName() : '';
$calendar = CalendarDefinitionPeer::retrieveByPk( $process['PRO_CALENDAR'] ); $calendar = CalendarDefinitionPeer::retrieveByPk($process['PRO_CALENDAR']);
$calendarName = is_object( $calendar ) ? $calendar->getCalendarName() : ''; $calendarName = is_object($calendar) ? $calendar->getCalendarName() : '';
$properties['Title'] = $process['PRO_TITLE']; $properties['Title'] = $process['PRO_TITLE'];
$properties['Description'] = $process['PRO_DESCRIPTION']; $properties['Description'] = $process['PRO_DESCRIPTION'];
@@ -324,11 +320,10 @@ class Ajax
$result->sucess = true; $result->sucess = true;
$result->prop = $properties; $result->prop = $properties;
break; break;
case 'task': case 'task':
require_once 'classes/model/Task.php'; require_once 'classes/model/Task.php';
$task = new Task(); $task = new Task();
$taskData = $task->load( $param['UID'] ); $taskData = $task->load($param['UID']);
$properties['Title'] = $taskData['TAS_TITLE']; $properties['Title'] = $taskData['TAS_TITLE'];
$properties['Description'] = $taskData['TAS_DESCRIPTION']; $properties['Description'] = $taskData['TAS_DESCRIPTION'];
@@ -341,10 +336,10 @@ class Ajax
break; break;
} }
print G::json_encode( $result ); print G::json_encode($result);
} }
function saveProperties ($param) public function saveProperties($param)
{ {
try { try {
$result->sucess = true; $result->sucess = true;
@@ -354,7 +349,7 @@ class Ajax
case 'process': case 'process':
require_once 'classes/model/ProcessCategory.php'; require_once 'classes/model/ProcessCategory.php';
require_once 'classes/model/CalendarDefinition.php'; require_once 'classes/model/CalendarDefinition.php';
G::LoadClass( 'processMap' ); G::LoadClass('processMap');
$oProcessMap = new ProcessMap(); $oProcessMap = new ProcessMap();
$process['PRO_UID'] = $param['UID']; $process['PRO_UID'] = $param['UID'];
@@ -371,25 +366,24 @@ class Ajax
break; break;
case 'Category': case 'Category':
$fieldName = 'PRO_CATEGORY'; $fieldName = 'PRO_CATEGORY';
$category = ProcessCategory::loadByCategoryName( $param['value'] ); $category = ProcessCategory::loadByCategoryName($param['value']);
$param['value'] = $category[0]['CATEGORY_UID']; $param['value'] = $category[0]['CATEGORY_UID'];
break; break;
case 'Calendar': case 'Calendar':
$fieldName = 'PRO_CALENDAR'; $fieldName = 'PRO_CALENDAR';
$calendar = CalendarDefinition::loadByCalendarName( $param['value'] ); $calendar = CalendarDefinition::loadByCalendarName($param['value']);
G::LoadClass( "calendar" ); G::LoadClass("calendar");
$calendarObj = new Calendar(); $calendarObj = new Calendar();
$calendarObj->assignCalendarTo( $process['PRO_UID'], $calendar['CALENDAR_UID'], 'PROCESS' ); $calendarObj->assignCalendarTo($process['PRO_UID'], $calendar['CALENDAR_UID'], 'PROCESS');
break; break;
} }
if ($fieldName != 'PRO_CALENDAR') { if ($fieldName != 'PRO_CALENDAR') {
$process[$fieldName] = $param['value']; $process[$fieldName] = $param['value'];
$oProcessMap->updateProcess( $process ); $oProcessMap->updateProcess($process);
} }
break; break;
case 'task': case 'task':
require_once 'classes/model/Task.php'; require_once 'classes/model/Task.php';
$oTask = new Task(); $oTask = new Task();
@@ -407,12 +401,12 @@ class Ajax
break; break;
case 'Starting Task': case 'Starting Task':
$fieldName = 'TAS_START'; $fieldName = 'TAS_START';
$param['value'] = strtoupper( $param['value'] ); $param['value'] = strtoupper($param['value']);
break; break;
} }
$task[$fieldName] = $param['value']; $task[$fieldName] = $param['value'];
print_r( $task ); print_r($task);
$oTask->update( $task ); $oTask->update($task);
break; break;
} }
@@ -421,47 +415,43 @@ class Ajax
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
print G::json_encode( $result ); print G::json_encode($result);
} }
function getCategoriesList () public function getCategoriesList()
{ {
require_once "classes/model/ProcessCategory.php"; require_once "classes/model/ProcessCategory.php";
$processCategory = new ProcessCategory(); $processCategory = new ProcessCategory();
$defaultOption = Array (); $defaultOption = Array();
$defaultOption[] = Array ('CATEGORY_UID' => '','CATEGORY_NAME' => '' $defaultOption[] = Array('CATEGORY_UID' => '', 'CATEGORY_NAME' => '');
);
$response->rows = array_merge( $defaultOption, $processCategory->getAll( 'array' ) ); $response->rows = array_merge($defaultOption, $processCategory->getAll('array'));
print G::json_encode( $response ); print G::json_encode($response);
} }
function getCaledarList () public function getCaledarList()
{ {
G::LoadClass( 'calendar' ); G::LoadClass('calendar');
$calendar = new CalendarDefinition(); $calendar = new CalendarDefinition();
$calendarObj = $calendar->getCalendarList( true, true ); $calendarObj = $calendar->getCalendarList(true, true);
$calendarObj['array'][0] = Array ('CALENDAR_UID' => '','CALENDAR_NAME' => '' $calendarObj['array'][0] = Array('CALENDAR_UID' => '', 'CALENDAR_NAME' => '');
);
$response->rows = $calendarObj['array']; $response->rows = $calendarObj['array'];
print G::json_encode( $response ); print G::json_encode($response);
} }
function getPMVariables ($param) public function getPMVariables($param)
{ {
G::LoadClass( 'processMap' ); G::LoadClass('processMap');
$oProcessMap = new processMap( new DBConnection() ); $oProcessMap = new processMap(new DBConnection());
$response->rows = getDynaformsVars( $param['PRO_UID'] ); $response->rows = getDynaformsVars($param['PRO_UID']);
foreach ($response->rows as $i => $var) { foreach ($response->rows as $i => $var) {
$response->rows[$i]['sName'] = "@@{$var['sName']}"; $response->rows[$i]['sName'] = "@@{$var['sName']}";
} }
print G::json_encode( $response ); print G::json_encode($response);
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* tools/ajaxListener.php Ajax Listener for Cases rpc requests * tools/ajaxListener.php Ajax Listener for Cases rpc requests
* *
@@ -21,47 +22,45 @@
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
/** /**
* *
* @author Erik Amaru Ortiz <erik@colosa.com> * @author Erik Amaru Ortiz <erik@colosa.com>
* @date Jan 10th, 2010 * @date Jan 10th, 2010
*/ */
require "classes/model/Translation.php"; require "classes/model/Translation.php";
$action = $_REQUEST['action']; $action = $_REQUEST['action'];
unset( $_REQUEST['action'] ); unset($_REQUEST['action']);
$ajax = new Ajax(); $ajax = new Ajax();
$ajax->$action( $_REQUEST ); $ajax->$action($_REQUEST);
class Ajax class Ajax
{ {
function getList ($params) public function getList($params)
{ {
$search = isset( $params['search'] ) ? $params['search'] : null; $search = isset($params['search']) ? $params['search'] : null;
$params['dateFrom'] = str_replace( 'T00:00:00', '', $params['dateFrom'] ); $params['dateFrom'] = str_replace('T00:00:00', '', $params['dateFrom']);
$params['dateTo'] = str_replace( 'T00:00:00', '', $params['dateTo'] ); $params['dateTo'] = str_replace('T00:00:00', '', $params['dateTo']);
$result = Translation::getAll( 'en', $params['start'], $params['limit'], $search, $params['dateFrom'], $params['dateTo'] ); $result = Translation::getAll('en', $params['start'], $params['limit'], $search, $params['dateFrom'], $params['dateTo']);
//$result = Translation::getAll('en', $params['start'], $params['limit'], $search); //$result = Translation::getAll('en', $params['start'], $params['limit'], $search);
/*foreach($result->data as $i=>$row){ /* foreach($result->data as $i=>$row){
$result->data[$i]['TRN_VALUE'] = substr($row['TRN_VALUE'], 0, 15) . '...'; $result->data[$i]['TRN_VALUE'] = substr($row['TRN_VALUE'], 0, 15) . '...';
}*/ } */
echo G::json_encode( $result ); echo G::json_encode($result);
} }
function save () public function save()
{ {
try { try {
require_once ("classes/model/Translation.php"); require_once ("classes/model/Translation.php");
$id = $_POST['id']; $id = $_POST['id'];
$label = preg_replace( "[\n|\r|\n\r]", ' ', $_POST['label'] ); $label = preg_replace("[\n|\r|\n\r]", ' ', $_POST['label']);
$res = Translation::addTranslation( 'LABEL', $id, 'en', $label ); $res = Translation::addTranslation('LABEL', $id, 'en', $label);
if ($res['codError'] < 0) { if ($res['codError'] < 0) {
$result->success = false; $result->success = false;
$result->msg = $res['message']; $result->msg = $res['message'];
@@ -69,51 +68,48 @@ class Ajax
$result->success = true; $result->success = true;
$result->msg = 'Label ' . $id . ' saved Successfully!'; $result->msg = 'Label ' . $id . ' saved Successfully!';
} }
} catch (Exception $e) { } catch (Exception $e) {
$result->success = false; $result->success = false;
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
print G::json_encode( $result ); print G::json_encode($result);
} }
function delete () public function delete()
{ {
require_once ("classes/model/Translation.php"); require_once ("classes/model/Translation.php");
$ids = explode( ',', $_POST['IDS'] ); $ids = explode(',', $_POST['IDS']);
$category = 'LABEL'; $category = 'LABEL';
try { try {
foreach ($ids as $id) { foreach ($ids as $id) {
$tr = TranslationPeer::retrieveByPK( $category, $id, 'en' ); $tr = TranslationPeer::retrieveByPK($category, $id, 'en');
if ((is_object( $tr ) && get_class( $tr ) == 'Translation')) { if ((is_object($tr) && get_class($tr) == 'Translation')) {
$tr->delete(); $tr->delete();
} }
} }
$result->success = true; $result->success = true;
$result->msg = 'Deleted Successfully!'; $result->msg = 'Deleted Successfully!';
} catch (Exception $e) { } catch (Exception $e) {
$result->success = false; $result->success = false;
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
print G::json_encode( $result ); print G::json_encode($result);
} }
function rebuild () public function rebuild()
{ {
try { try {
require_once ("classes/model/Translation.php"); require_once ("classes/model/Translation.php");
$t = new Translation(); $t = new Translation();
$result = Translation::generateFileTranslation( 'en' ); $result = Translation::generateFileTranslation('en');
$result['success'] = true; $result['success'] = true;
} catch (Exception $e) { } catch (Exception $e) {
$result->success = false; $result->success = false;
$result->msg = $e->getMessage(); $result->msg = $e->getMessage();
} }
print G::json_encode( $result ); print G::json_encode($result);
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* triggers_WizardSave.php * triggers_WizardSave.php
* *
@@ -21,20 +22,19 @@
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) {
return $RBAC_Response; return $RBAC_Response;
} }
require_once ('classes/model/Triggers.php'); require_once ('classes/model/Triggers.php');
$oTrigger = new Triggers(); $oTrigger = new Triggers();
G::LoadClass( 'processMap' ); G::LoadClass('processMap');
$oProcessMap = new processMap( new DBConnection() ); $oProcessMap = new processMap(new DBConnection());
$aDataTriggers = $_POST; $aDataTriggers = $_POST;
$aInfoFunction = explode( ",", $aDataTriggers['ALLFUNCTION'] ); $aInfoFunction = explode(",", $aDataTriggers['ALLFUNCTION']);
$aInfoFunctionType = explode( ",", $aDataTriggers['ALLFUNCTION_TYPE'] ); $aInfoFunctionType = explode(",", $aDataTriggers['ALLFUNCTION_TYPE']);
$sPMfunction = " $sPMfunction = "
/*************************************************** /***************************************************
@@ -42,75 +42,73 @@ $sPMfunction = "
* Generated by ProcessMaker Trigger Wizard * Generated by ProcessMaker Trigger Wizard
* Library: " . $aDataTriggers['LIBRARY_NAME'] . " * Library: " . $aDataTriggers['LIBRARY_NAME'] . "
* Method: " . $aDataTriggers['PMFUNTION_LABEL'] . " * Method: " . $aDataTriggers['PMFUNTION_LABEL'] . "
* Date: " . date( "Y-m-d H:i:s" ) . " * Date: " . date("Y-m-d H:i:s") . "
* *
* ProcessMaker " . date( "Y" ) . " * ProcessMaker " . date("Y") . "
* *
****************************************************/ ****************************************************/
"; ";
$methodParamsFinal = array (); $methodParamsFinal = array();
//Generate params to send //Generate params to send
$i = 0; $i = 0;
foreach ($aInfoFunction as $k => $v) { foreach ($aInfoFunction as $k => $v) {
if ($v != '') { if ($v != '') {
$sOptionTrigger = trim( str_replace( "$", "", $v ) ); $sOptionTrigger = trim(str_replace("$", "", $v));
if (strstr( $sOptionTrigger, "=" )) { if (strstr($sOptionTrigger, "=")) {
$aOptionParameters = explode( "=", $sOptionTrigger ); $aOptionParameters = explode("=", $sOptionTrigger);
$sOptionTrigger = trim( $aOptionParameters[0] ); $sOptionTrigger = trim($aOptionParameters[0]);
} }
if ($aDataTriggers[$sOptionTrigger] != '') { if ($aDataTriggers[$sOptionTrigger] != '') {
if ((strstr( $aDataTriggers[$sOptionTrigger], "@@" ))) { if ((strstr($aDataTriggers[$sOptionTrigger], "@@"))) {
$option = trim( $aDataTriggers[$sOptionTrigger] ); $option = trim($aDataTriggers[$sOptionTrigger]);
} else { } else {
$aDataTriggers[$sOptionTrigger] = (strstr( $aDataTriggers[$sOptionTrigger], 'array' )) ? str_replace( "'", '"', $aDataTriggers[$sOptionTrigger] ) : str_replace( "'", "\'", $aDataTriggers[$sOptionTrigger] ); $aDataTriggers[$sOptionTrigger] = (strstr($aDataTriggers[$sOptionTrigger], 'array')) ? str_replace("'", '"', $aDataTriggers[$sOptionTrigger]) : str_replace("'", "\'", $aDataTriggers[$sOptionTrigger]);
switch(trim($aInfoFunctionType[$i])) { switch (trim($aInfoFunctionType[$i])) {
case 'boolean' : case 'boolean':
$option = $aDataTriggers[$sOptionTrigger]; $option = $aDataTriggers[$sOptionTrigger];
break; break;
case 'int' : case 'int':
$option = intval($aDataTriggers[$sOptionTrigger]); $option = intval($aDataTriggers[$sOptionTrigger]);
break; break;
case 'float' : case 'float':
case 'real' : case 'real':
case 'double' : case 'double':
$option = floatval($aDataTriggers[$sOptionTrigger]); $option = floatval($aDataTriggers[$sOptionTrigger]);
break; break;
default: default:
$option = (is_numeric( $aDataTriggers[$sOptionTrigger] ) || is_bool($aDataTriggers[$sOptionTrigger]) ) ? trim( $aDataTriggers[$sOptionTrigger] ) : (strstr( $aDataTriggers[$sOptionTrigger], "array" )) ? trim( $aDataTriggers[$sOptionTrigger] ) : "'" . trim( $aDataTriggers[$sOptionTrigger] ) . "'"; $option = (is_numeric($aDataTriggers[$sOptionTrigger]) || is_bool($aDataTriggers[$sOptionTrigger]) ) ? trim($aDataTriggers[$sOptionTrigger]) : (strstr($aDataTriggers[$sOptionTrigger], "array")) ? trim($aDataTriggers[$sOptionTrigger]) : "'" . trim($aDataTriggers[$sOptionTrigger]) . "'";
break; break;
} }
} }
} else { } else {
$option = "''"; $option = "''";
} }
$methodParamsFinal[] = $option; $methodParamsFinal[] = $option;
} }
$i++; $i++;
} }
//G::pr($methodParamsFinal);die; //G::pr($methodParamsFinal);die;
$sPMfunction .= (isset( $aDataTriggers['TRI_ANSWER'] ) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : ""; $sPMfunction .= (isset($aDataTriggers['TRI_ANSWER']) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : "";
$sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode( ",", $methodParamsFinal ) . ");"; $sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode(",", $methodParamsFinal) . ");";
//Create Trigger //Create Trigger
$aDataTriggers['TRI_WEBBOT'] = $sPMfunction; $aDataTriggers['TRI_WEBBOT'] = $sPMfunction;
$aDataTriggersParams = array (); $aDataTriggersParams = array();
$aDataTriggersParams['hash'] = md5( $sPMfunction ); $aDataTriggersParams['hash'] = md5($sPMfunction);
$aDataTriggersParams['params'] = $aDataTriggers; $aDataTriggersParams['params'] = $aDataTriggers;
$aDataTriggers['TRI_PARAM'] = serialize( $aDataTriggersParams ); $aDataTriggers['TRI_PARAM'] = serialize($aDataTriggersParams);
$oTrigger->create( $aDataTriggers ); $oTrigger->create($aDataTriggers);
//Update Info //Update Info
$aDataTriggers['TRI_UID'] = $oTrigger->getTriUid(); $aDataTriggers['TRI_UID'] = $oTrigger->getTriUid();
$oTrigger->update( $aDataTriggers ); $oTrigger->update($aDataTriggers);
//Update Trigger Array //Update Trigger Array
$oProcessMap->triggersList( $aDataTriggers['PRO_UID'] ); $oProcessMap->triggersList($aDataTriggers['PRO_UID']);

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* triggers_WizardUpdate.php * triggers_WizardUpdate.php
* *
@@ -21,101 +22,98 @@
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) {
return $RBAC_Response; return $RBAC_Response;
} }
if (! class_exists( 'Triggers' )) { if (!class_exists('Triggers')) {
require_once ('classes/model/Triggers.php'); require_once ('classes/model/Triggers.php');
} }
$oTrigger = new Triggers(); $oTrigger = new Triggers();
G::LoadClass( 'processMap' ); G::LoadClass('processMap');
$oProcessMap = new processMap( new DBConnection() ); $oProcessMap = new processMap(new DBConnection());
$aDataTriggers = $_POST; $aDataTriggers = $_POST;
$triUid = $_POST['TRI_UID']; $triUid = $_POST['TRI_UID'];
$aInfoFunction = explode( ",", $aDataTriggers['ALLFUNCTION'] ); $aInfoFunction = explode(",", $aDataTriggers['ALLFUNCTION']);
$aInfoFunctionType = explode( ",", $aDataTriggers['ALLFUNCTION_TYPE'] ); $aInfoFunctionType = explode(",", $aDataTriggers['ALLFUNCTION_TYPE']);
$sPMfunction = " $sPMfunction = "
/*************************************************** /***************************************************
* *
* Generated by ProcessMaker Trigger Wizard * Generated by ProcessMaker Trigger Wizard
* Library: " . $aDataTriggers['LIBRARY_NAME'] . " * Library: " . $aDataTriggers['LIBRARY_NAME'] . "
* Method: " . $aDataTriggers['PMFUNTION_LABEL'] . " * Method: " . $aDataTriggers['PMFUNTION_LABEL'] . "
* Date: " . date( "Y-m-d H:i:s" ) . " * Date: " . date("Y-m-d H:i:s") . "
* *
* ProcessMaker " . date( "Y" ) . " * ProcessMaker " . date("Y") . "
* *
****************************************************/ ****************************************************/
"; ";
$methodParamsFinal = array (); $methodParamsFinal = array();
//Generate params to send //Generate params to send
$i = 0; $i = 0;
foreach ($aInfoFunction as $k => $v) { foreach ($aInfoFunction as $k => $v) {
if ($v != '') { if ($v != '') {
$sOptionTrigger = trim( str_replace( "$", "", $v ) ); $sOptionTrigger = trim(str_replace("$", "", $v));
if (strstr( $sOptionTrigger, "=" )) { if (strstr($sOptionTrigger, "=")) {
$aOptionParameters = explode( "=", $sOptionTrigger ); $aOptionParameters = explode("=", $sOptionTrigger);
$sOptionTrigger = trim( $aOptionParameters[0] ); $sOptionTrigger = trim($aOptionParameters[0]);
} }
if ($aDataTriggers[$sOptionTrigger] != '') { if ($aDataTriggers[$sOptionTrigger] != '') {
if ((strstr( $aDataTriggers[$sOptionTrigger], "@@" ))) { if ((strstr($aDataTriggers[$sOptionTrigger], "@@"))) {
$option = $aDataTriggers[$sOptionTrigger]; $option = $aDataTriggers[$sOptionTrigger];
} else { } else {
$aDataTriggers[$sOptionTrigger] = (strstr( $aDataTriggers[$sOptionTrigger], 'array' )) ? str_replace( "'", '"', $aDataTriggers[$sOptionTrigger] ) : str_replace( "'", "\'", $aDataTriggers[$sOptionTrigger] ); $aDataTriggers[$sOptionTrigger] = (strstr($aDataTriggers[$sOptionTrigger], 'array')) ? str_replace("'", '"', $aDataTriggers[$sOptionTrigger]) : str_replace("'", "\'", $aDataTriggers[$sOptionTrigger]);
switch(trim($aInfoFunctionType[$i])) { switch (trim($aInfoFunctionType[$i])) {
case 'boolean' : case 'boolean':
$option = $aDataTriggers[$sOptionTrigger]; $option = $aDataTriggers[$sOptionTrigger];
break; break;
case 'int' : case 'int':
$option = intval($aDataTriggers[$sOptionTrigger]); $option = intval($aDataTriggers[$sOptionTrigger]);
break; break;
case 'float' : case 'float':
case 'real' : case 'real':
case 'double' : case 'double':
$option = floatval($aDataTriggers[$sOptionTrigger]); $option = floatval($aDataTriggers[$sOptionTrigger]);
break; break;
default: default:
$option = (is_numeric( $aDataTriggers[$sOptionTrigger] ) || is_bool($aDataTriggers[$sOptionTrigger]) ) ? trim( $aDataTriggers[$sOptionTrigger] ) : (strstr( $aDataTriggers[$sOptionTrigger], "array" )) ? trim( $aDataTriggers[$sOptionTrigger] ) : "'" . trim( $aDataTriggers[$sOptionTrigger] ) . "'"; $option = (is_numeric($aDataTriggers[$sOptionTrigger]) || is_bool($aDataTriggers[$sOptionTrigger]) ) ? trim($aDataTriggers[$sOptionTrigger]) : (strstr($aDataTriggers[$sOptionTrigger], "array")) ? trim($aDataTriggers[$sOptionTrigger]) : "'" . trim($aDataTriggers[$sOptionTrigger]) . "'";
break; break;
} }
} }
} else { } else {
$option = "' '"; $option = "' '";
} }
$methodParamsFinal[] = $option; $methodParamsFinal[] = $option;
} }
$i++; $i++;
} }
$sPMfunction .= (isset( $aDataTriggers['TRI_ANSWER'] ) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : ""; $sPMfunction .= (isset($aDataTriggers['TRI_ANSWER']) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : "";
$sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode( ",", $methodParamsFinal ) . ");"; $sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode(",", $methodParamsFinal) . ");";
//Create Trigger //Create Trigger
$aDataTriggers['TRI_WEBBOT'] = $sPMfunction; $aDataTriggers['TRI_WEBBOT'] = $sPMfunction;
$aDataTriggersParams = array (); $aDataTriggersParams = array();
$aDataTriggersParams['hash'] = md5( $sPMfunction ); $aDataTriggersParams['hash'] = md5($sPMfunction);
$aDataTriggersParams['params'] = $aDataTriggers; $aDataTriggersParams['params'] = $aDataTriggers;
$aDataTriggers['TRI_PARAM'] = serialize( $aDataTriggersParams ); $aDataTriggers['TRI_PARAM'] = serialize($aDataTriggersParams);
//$oTrigger->create ( $aDataTriggers ); //$oTrigger->create ( $aDataTriggers );
$aDataTriggerLoaded = $oTrigger->load( $triUid ); $aDataTriggerLoaded = $oTrigger->load($triUid);
//var_dump($aDataTriggerLoaded); //var_dump($aDataTriggerLoaded);
//die; //die;
//Update Info //Update Info
$aDataTriggers['TRI_UID'] = $oTrigger->getTriUid(); $aDataTriggers['TRI_UID'] = $oTrigger->getTriUid();
$oTrigger->update( $aDataTriggers ); $oTrigger->update($aDataTriggers);
//Update Trigger Array //Update Trigger Array
$oProcessMap->triggersList( $aDataTriggers['PRO_UID'] ); $oProcessMap->triggersList($aDataTriggers['PRO_UID']);