diff --git a/workflow/engine/classes/class.consolidatedCases.php b/workflow/engine/classes/class.consolidatedCases.php
new file mode 100644
index 000000000..b298e1e34
--- /dev/null
+++ b/workflow/engine/classes/class.consolidatedCases.php
@@ -0,0 +1,287 @@
+addSelectColumn(ReportTablePeer::REP_TAB_UID);
+ $criteria->add(ReportTablePeer::REP_TAB_NAME, $tableName);
+
+ $rsCriteria = ReportTablePeer::doSelectRS($criteria);
+
+ $rptUid = null;
+
+ if ($rsCriteria->next()) {
+ $row = $rsCriteria->getRow();
+
+ $rptUid = $row[0];
+ }
+
+ $rpts = new ReportTables();
+
+ if ($rptUid != null) {
+ $rpts->deleteReportTable($rptUid);
+ }
+
+ $sRepTabUid = "";
+ break;
+ case 2:
+ //Delete table
+ $rpts = new ReportTables();
+ $rpts->dropTable($tableName, "wf");
+
+ $sRepTabUid = "";
+ break;
+ }
+
+ $criteria = new Criteria();
+ $criteria->addSelectColumn(ReportTablePeer::REP_TAB_UID);
+ //$criteria->add(ReportTablePeer::PRO_UID, $sProUid);
+ $criteria->add(ReportTablePeer::REP_TAB_NAME, $tableName);
+
+ $result = ReportTablePeer::doSelectRS($criteria);
+ $result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ if ($result->next()) {
+ $dataRes = $result->getRow();
+
+ if ($dataRes["REP_TAB_UID"] != $sRepTabUid) {
+ return 1;
+ }
+ } else {
+ //check if table $tableName exists
+ $con = Propel::getConnection("workflow");
+ $stmt = $con->createStatement();
+
+ $sql="SHOW TABLES";
+ $rs1 = $stmt->executeQuery($sql, ResultSet::FETCHMODE_NUM);
+ $rs1->next();
+ while ( is_array($row = $rs1->getRow() )) {
+ if ( $row[0] == $tableName ) {
+ return 2;
+ }
+ $rs1->next();
+ }
+ }
+
+ if ($isBPMN) {
+ $_POST['form']['PRO_UID'] = $sProUid;
+ $_POST['form']['REP_TAB_UID'] = $sRepTabUid;
+ $_POST['form']['REP_TAB_NAME'] = $tableName;
+ $_POST['form']['REP_TAB_TYPE'] = "NORMAL";
+ $_POST['form']['REP_TAB_GRID'] = '';
+ $_POST['form']['REP_TAB_CONNECTION'] = 'wf';
+ $_POST['form']['REP_TAB_CREATE_DATE'] = date("Y-m-d H:i:s");
+ $_POST['form']['REP_TAB_STATUS'] = 'ACTIVE';
+ $_POST['form']['REP_TAB_TITLE'] = $title;
+ } else {
+ $_POST['form']['PRO_UID'] = $sProUid;
+ $_POST['form']['REP_TAB_UID'] = $sRepTabUid;
+ $_POST['form']['REP_TAB_NAME'] = $tableName;
+ $_POST['form']['REP_TAB_TYPE'] = "GRID";
+ $_POST['form']['REP_TAB_GRID'] = $sProUid . "-" . $sDynUid;
+ $_POST['form']['REP_TAB_CONNECTION'] = 'wf';
+ $_POST['form']['REP_TAB_CREATE_DATE'] = date("Y-m-d H:i:s");
+ $_POST['form']['REP_TAB_STATUS'] = 'ACTIVE';
+ $_POST['form']['REP_TAB_TITLE'] = $title;
+ }
+
+ $_POST['form']['FIELDS'] = array();
+
+ G::LoadClass("reportTables");
+
+ $oReportTable = new ReportTable();
+ //if (!isset($_POST['form']['REP_TAB_CONNECTION'])) {
+ // $_POST['form']['REP_TAB_CONNECTION'] = 'report';
+ //}
+ if ($_POST['form']['REP_TAB_UID'] != "") {
+ $aReportTable = $oReportTable->load($_POST['form']['REP_TAB_UID']);
+ $sOldTableName = $aReportTable['REP_TAB_NAME'];
+ $sOldConnection = $aReportTable['REP_TAB_CONNECTION'];
+ } else {
+
+ $sOldTableName = $_POST['form']['REP_TAB_NAME'];
+ $sOldConnection = $_POST['form']['REP_TAB_CONNECTION'];
+ $_POST['form']['REP_TAB_TYPE'] = 'NORMAL';
+ $oReportTable->create($_POST['form']);
+ $_POST['form']['REP_TAB_UID'] = $oReportTable->getRepTabUid();
+ }
+
+ $_POST['form']['REP_TAB_TYPE'] = 'NORMAL';
+ $oReportTable->update($_POST['form']);
+
+ $oReportVar = new ReportVar();
+ $oReportTables = new ReportTables();
+ $oReportTables->deleteAllReportVars($_POST['form']['REP_TAB_UID']);
+
+ $aFields = array();
+
+ if ($isBPMN) {
+ G::LoadClass("pmDynaform");
+ $pmDyna = new pmDynaform(array());
+ $pmDyna->fields["CURRENT_DYNAFORM"] = $sDynUid;
+ $dataDyna = $pmDyna->getDynaform();
+ $json = G::json_decode($dataDyna["DYN_CONTENT"]);
+ $fieldsDyna = $json->items[0]->items;
+ foreach ($fieldsDyna as $value) {
+ $_POST['form']['FIELDS'][] = $value[0]->name . '-' . $value[0]->type;
+ }
+ } else {
+ $aAux = explode('-', $_POST['form']['REP_TAB_GRID']);
+ global $G_FORM;
+
+ require_once "classes/class.formBatchRouting.php";
+
+ $G_FORM = new FormBatchRouting($_POST["form"]["PRO_UID"] . PATH_SEP . $aAux[1], PATH_DYNAFORM, SYS_LANG, false);
+ $aAux = $G_FORM->getVars(false);
+
+ foreach ($aAux as $aField) {
+ $_POST['form']['FIELDS'][] = $aField['sName'] . '-' . $aField['sType'];
+ }
+ }
+
+ $aFieldsClases = array();
+ $i = 1;
+ $aFieldsClases[$i]['FLD_NAME'] = 'APP_UID';
+ $aFieldsClases[$i]['FLD_NULL'] = 'off';
+ $aFieldsClases[$i]['FLD_KEY'] = 'on';
+ $aFieldsClases[$i]['FLD_AUTO_INCREMENT'] = 'off';
+ $aFieldsClases[$i]['FLD_DESCRIPTION'] = '';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'VARCHAR' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = 32;
+ $i++;
+ $aFieldsClases[$i]['FLD_NAME'] = 'APP_NUMBER';
+ $aFieldsClases[$i]['FLD_NULL'] = 'off';
+ $aFieldsClases[$i]['FLD_KEY'] = 'on';
+ $aFieldsClases[$i]['FLD_AUTO_INCREMENT'] = 'off';
+ $aFieldsClases[$i]['FLD_DESCRIPTION'] = '';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'VARCHAR' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = 255;
+
+ foreach ($_POST['form']['FIELDS'] as $sField) {
+ $aField = explode('-', $sField);
+ $i++;
+ $aFieldsClases[$i]['FLD_NAME'] = $aField[0];
+ $aFieldsClases[$i]['FLD_NULL'] = 'off';
+ $aFieldsClases[$i]['FLD_KEY'] = 'off';
+ $aFieldsClases[$i]['FLD_AUTO_INCREMENT'] = 'off';
+ $aFieldsClases[$i]['FLD_DESCRIPTION'] = '';
+
+ switch ($aField[1]) {
+ case 'currency':
+ case 'percentage':
+ $sType = 'number';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'FLOAT' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = 255;
+ break;
+ case 'text':
+ case 'password':
+ case 'dropdown':
+ case 'yesno':
+ case 'checkbox':
+ case 'radiogroup':
+ case 'hidden':
+ case "link":
+ $sType = 'char';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'VARCHAR' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = 255;
+ break;
+ case 'textarea':
+ $sType = 'text';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'TEXT' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = '';
+ break;
+ case 'date':
+ $sType = 'date';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'DATE' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = '';
+ break;
+ default:
+ $sType = 'char';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'VARCHAR' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = 255;
+ break;
+ }
+
+ $oReportVar->create(array('REP_TAB_UID' => $_POST['form']['REP_TAB_UID'],
+ 'PRO_UID' => $_POST['form']['PRO_UID'],
+ 'REP_VAR_NAME' => $aField[0],
+ 'REP_VAR_TYPE' => $sType));
+ $aFields[] = array('sFieldName' => $aField[0], 'sType' => $sType);
+ }
+
+ $_POST['form']['REP_TAB_TYPE'] = "NORMAL";
+ $oReportTables->dropTable($sOldTableName, $sOldConnection);
+ $oReportTables->createTable($_POST['form']['REP_TAB_NAME'], $_POST['form']['REP_TAB_CONNECTION'], $_POST['form']['REP_TAB_TYPE'], $aFields);
+ $oReportTables->populateTable($_POST['form']['REP_TAB_NAME'], $_POST['form']['REP_TAB_CONNECTION'], $_POST['form']['REP_TAB_TYPE'], $aFields, $_POST['form']['PRO_UID'], '');
+
+ $sRepTabUid = $_POST['form']['REP_TAB_UID'];
+
+ //clases
+ } else {
+ $oReportTables = new ReportTables();
+ if ($sRepTabUid != "") {
+ $oReportTables->deleteReportTable($sRepTabUid);
+ }
+ $sRepTabUid = "";
+ }
+
+ require_once ("classes/model/CaseConsolidatedPeer.php");
+ require_once ("classes/model/CaseConsolidated.php");
+
+ $oCaseConsolidated = CaseConsolidatedPeer::retrieveByPK($sTasUid);
+
+ if (!(is_object($oCaseConsolidated)) || get_class($oCaseConsolidated) != 'CaseConsolidated') {
+ $oCaseConsolidated = new CaseConsolidated();
+ $oCaseConsolidated->setTasUid($sTasUid);
+ }
+
+ if ($sStatus == '1') {
+ $oCaseConsolidated->setConStatus('ACTIVE');
+ } else {
+ $oCaseConsolidated->setConStatus('INACTIVE');
+ }
+
+ $oCaseConsolidated->setDynUid($sDynUid);
+ $oCaseConsolidated->setRepTabUid($sRepTabUid);
+ $oCaseConsolidated->save();
+
+ $sClassName = $tableName;//'__' . $sTasUid;
+
+ if ($sStatus == '1') {
+ //$oAdditionalTables->createPropelClasses($sTableName, $sClassName, $aFields, $sAddTabUid)
+ //require_once 'classes/model/AdditionalTables.php';
+ //$oAdditionalTables = new AdditionalTables();
+ $oAdditionalTables = new AdditionalTables();//AdditionalTablesConsolidated
+
+ $oAdditionalTables->createPropelClasses($tableName, $sClassName, $aFieldsClases, $sTasUid);
+ } else {
+ $sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
+ @unlink($sPath . $sClassName . '.php');
+ @unlink($sPath . $sClassName . 'Peer.php');
+ @unlink($sPath . PATH_SEP . 'map' . PATH_SEP . $sClassName . 'MapBuilder.php');
+ @unlink($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $sClassName . '.php');
+ @unlink($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $sClassName . 'Peer.php');
+ }
+
+
+ }
+}
diff --git a/workflow/engine/classes/class.formBatchRouting.php b/workflow/engine/classes/class.formBatchRouting.php
new file mode 100644
index 000000000..938ea0dfa
--- /dev/null
+++ b/workflow/engine/classes/class.formBatchRouting.php
@@ -0,0 +1,21 @@
+ $sValue) {
+ $aFields[] = array ("sName" => $sName, "sType" => "system");
+ }
+ }
+ foreach ($this->fields as $k => $v) {
+ if (($v->type != "title") && ($v->type != "subtitle") && ($v->type != "file") && ($v->type != "button") && ($v->type != "reset") && ($v->type != "submit") && ($v->type != "listbox") && ($v->type != "checkgroup") && ($v->type != "grid") && ($v->type != "javascript")) {
+ $aFields[] = array ('sName' => trim( $k ),'sType' => trim( $v->type ));
+ }
+ }
+ return $aFields;
+ }
+}
+
diff --git a/workflow/engine/classes/class.library.php b/workflow/engine/classes/class.library.php
new file mode 100644
index 000000000..d280fa1b6
--- /dev/null
+++ b/workflow/engine/classes/class.library.php
@@ -0,0 +1,43 @@
+createStatement();
+
+ //Number of records active
+ $criteria = new Criteria("workflow");
+
+ //SELECT
+ $criteria->addSelectColumn(CaseConsolidatedPeer::CON_STATUS);
+ //FROM
+ //WHERE
+ $criteria->add(CaseConsolidatedPeer::CON_STATUS, "ACTIVE");
+
+ $activeNumRec = CaseConsolidatedPeer::doCount($criteria);
+
+ //Number of records
+ $numRec = 0;
+
+ $sql = "SELECT COUNT(APP_CACHE_VIEW.TAS_UID) AS NUMREC
+ FROM CASE_CONSOLIDATED
+ LEFT JOIN APP_CACHE_VIEW ON (CASE_CONSOLIDATED.TAS_UID = APP_CACHE_VIEW.TAS_UID)
+ WHERE APP_CACHE_VIEW.USR_UID = '$userUid' AND
+ APP_CACHE_VIEW.DEL_THREAD_STATUS = 'OPEN' AND
+ APP_CACHE_VIEW.APP_STATUS = 'TO_DO'";
+
+ $rsSql = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
+
+ while ($rsSql->next()) {
+ $row = $rsSql->getRow();
+
+ $numRec = $row["NUMREC"];
+ }
+
+ $numRec = ($activeNumRec > 0)? $numRec : 0;
+
+ return $numRec;
+ }
+}
+
diff --git a/workflow/engine/classes/class.pmDynaform.php b/workflow/engine/classes/class.pmDynaform.php
index 9134dd233..0cca427e3 100644
--- a/workflow/engine/classes/class.pmDynaform.php
+++ b/workflow/engine/classes/class.pmDynaform.php
@@ -19,8 +19,10 @@ class pmDynaform
public function __construct($fields)
{
$this->fields = $fields;
- $this->getDynaform();
- $this->getCredentials();
+ if (count($fields) && count($fields['APP_DATA'])) {
+ $this->getDynaform();
+ $this->getCredentials();
+ }
if (isset($this->fields["APP_UID"])) {
//current
$cases = new \ProcessMaker\BusinessModel\Cases();
diff --git a/workflow/engine/classes/model/CaseConsolidated.php b/workflow/engine/classes/model/CaseConsolidated.php
new file mode 100644
index 000000000..972127612
--- /dev/null
+++ b/workflow/engine/classes/model/CaseConsolidated.php
@@ -0,0 +1,19 @@
+dbMap !== null);
+ }
+
+ /**
+ * Gets the databasemap this map builder built.
+ *
+ * @return the databasemap
+ */
+ public function getDatabaseMap()
+ {
+ return $this->dbMap;
+ }
+
+ /**
+ * The doBuild() method builds the DatabaseMap
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function doBuild()
+ {
+ $this->dbMap = Propel::getDatabaseMap('workflow');
+
+ $tMap = $this->dbMap->addTable('CASE_CONSOLIDATED');
+ $tMap->setPhpName('CaseConsolidated');
+
+ $tMap->setUseIdGenerator(false);
+
+ $tMap->addPrimaryKey('TAS_UID', 'TasUid', 'string', CreoleTypes::VARCHAR, true, 32);
+
+ $tMap->addColumn('DYN_UID', 'DynUid', 'string', CreoleTypes::VARCHAR, true, 32);
+
+ $tMap->addColumn('REP_TAB_UID', 'RepTabUid', 'string', CreoleTypes::VARCHAR, true, 32);
+
+ $tMap->addColumn('CON_STATUS', 'ConStatus', 'string', CreoleTypes::VARCHAR, true, 20);
+
+ } // doBuild()
+
+} // CaseConsolidatedMapBuilder
diff --git a/workflow/engine/classes/model/om/BaseCaseConsolidated.php b/workflow/engine/classes/model/om/BaseCaseConsolidated.php
new file mode 100644
index 000000000..b0f0ba1c2
--- /dev/null
+++ b/workflow/engine/classes/model/om/BaseCaseConsolidated.php
@@ -0,0 +1,684 @@
+tas_uid;
+ }
+
+ /**
+ * Get the [dyn_uid] column value.
+ *
+ * @return string
+ */
+ public function getDynUid()
+ {
+
+ return $this->dyn_uid;
+ }
+
+ /**
+ * Get the [rep_tab_uid] column value.
+ *
+ * @return string
+ */
+ public function getRepTabUid()
+ {
+
+ return $this->rep_tab_uid;
+ }
+
+ /**
+ * Get the [con_status] column value.
+ *
+ * @return string
+ */
+ public function getConStatus()
+ {
+
+ return $this->con_status;
+ }
+
+ /**
+ * Set the value of [tas_uid] column.
+ *
+ * @param string $v new value
+ * @return void
+ */
+ public function setTasUid($v)
+ {
+
+ // Since the native PHP type for this column is string,
+ // we will cast the input to a string (if it is not).
+ if ($v !== null && !is_string($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->tas_uid !== $v || $v === '') {
+ $this->tas_uid = $v;
+ $this->modifiedColumns[] = CaseConsolidatedPeer::TAS_UID;
+ }
+
+ } // setTasUid()
+
+ /**
+ * Set the value of [dyn_uid] column.
+ *
+ * @param string $v new value
+ * @return void
+ */
+ public function setDynUid($v)
+ {
+
+ // Since the native PHP type for this column is string,
+ // we will cast the input to a string (if it is not).
+ if ($v !== null && !is_string($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->dyn_uid !== $v || $v === '') {
+ $this->dyn_uid = $v;
+ $this->modifiedColumns[] = CaseConsolidatedPeer::DYN_UID;
+ }
+
+ } // setDynUid()
+
+ /**
+ * Set the value of [rep_tab_uid] column.
+ *
+ * @param string $v new value
+ * @return void
+ */
+ public function setRepTabUid($v)
+ {
+
+ // Since the native PHP type for this column is string,
+ // we will cast the input to a string (if it is not).
+ if ($v !== null && !is_string($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->rep_tab_uid !== $v || $v === '') {
+ $this->rep_tab_uid = $v;
+ $this->modifiedColumns[] = CaseConsolidatedPeer::REP_TAB_UID;
+ }
+
+ } // setRepTabUid()
+
+ /**
+ * Set the value of [con_status] column.
+ *
+ * @param string $v new value
+ * @return void
+ */
+ public function setConStatus($v)
+ {
+
+ // Since the native PHP type for this column is string,
+ // we will cast the input to a string (if it is not).
+ if ($v !== null && !is_string($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->con_status !== $v || $v === 'ACTIVE') {
+ $this->con_status = $v;
+ $this->modifiedColumns[] = CaseConsolidatedPeer::CON_STATUS;
+ }
+
+ } // setConStatus()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (1-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
+ * @param int $startcol 1-based offset column which indicates which restultset column to start with.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate(ResultSet $rs, $startcol = 1)
+ {
+ try {
+
+ $this->tas_uid = $rs->getString($startcol + 0);
+
+ $this->dyn_uid = $rs->getString($startcol + 1);
+
+ $this->rep_tab_uid = $rs->getString($startcol + 2);
+
+ $this->con_status = $rs->getString($startcol + 3);
+
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ // FIXME - using NUM_COLUMNS may be clearer.
+ return $startcol + 4; // 4 = CaseConsolidatedPeer::NUM_COLUMNS - CaseConsolidatedPeer::NUM_LAZY_LOAD_COLUMNS).
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating CaseConsolidated object", $e);
+ }
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param Connection $con
+ * @return void
+ * @throws PropelException
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete($con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CaseConsolidatedPeer::DATABASE_NAME);
+ }
+
+ try {
+ $con->begin();
+ CaseConsolidatedPeer::doDelete($this, $con);
+ $this->setDeleted(true);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+ }
+
+ /**
+ * Stores the object in the database. If the object is new,
+ * it inserts it; otherwise an update is performed. This method
+ * wraps the doSave() worker method in a transaction.
+ *
+ * @param Connection $con
+ * @return int The number of rows affected by this insert/update
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save($con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CaseConsolidatedPeer::DATABASE_NAME);
+ }
+
+ try {
+ $con->begin();
+ $affectedRows = $this->doSave($con);
+ $con->commit();
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+ }
+
+ /**
+ * Stores the object in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param Connection $con
+ * @return int The number of rows affected by this insert/update and any referring
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave($con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+
+ // If this object has been modified, then save it to the database.
+ if ($this->isModified()) {
+ if ($this->isNew()) {
+ $pk = CaseConsolidatedPeer::doInsert($this, $con);
+ $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
+ // should always be true here (even though technically
+ // BasePeer::doInsert() can insert multiple rows).
+
+ $this->setNew(false);
+ } else {
+ $affectedRows += CaseConsolidatedPeer::doUpdate($this, $con);
+ }
+ $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
+ }
+
+ $this->alreadyInSave = false;
+ }
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+ return true;
+ } else {
+ $this->validationFailures = $res;
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass;
+ array of ValidationFailed objects otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ if (($retval = CaseConsolidatedPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TYPE_PHPNAME,
+ * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CaseConsolidatedPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ return $this->getByPosition($pos);
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch($pos) {
+ case 0:
+ return $this->getTasUid();
+ break;
+ case 1:
+ return $this->getDynUid();
+ break;
+ case 2:
+ return $this->getRepTabUid();
+ break;
+ case 3:
+ return $this->getConStatus();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType One of the class type constants TYPE_PHPNAME,
+ * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
+ * @return an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CaseConsolidatedPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getTasUid(),
+ $keys[1] => $this->getDynUid(),
+ $keys[2] => $this->getRepTabUid(),
+ $keys[3] => $this->getConStatus(),
+ );
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TYPE_PHPNAME,
+ * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CaseConsolidatedPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch($pos) {
+ case 0:
+ $this->setTasUid($value);
+ break;
+ case 1:
+ $this->setDynUid($value);
+ break;
+ case 2:
+ $this->setRepTabUid($value);
+ break;
+ case 3:
+ $this->setConStatus($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
+ * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CaseConsolidatedPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) {
+ $this->setTasUid($arr[$keys[0]]);
+ }
+
+ if (array_key_exists($keys[1], $arr)) {
+ $this->setDynUid($arr[$keys[1]]);
+ }
+
+ if (array_key_exists($keys[2], $arr)) {
+ $this->setRepTabUid($arr[$keys[2]]);
+ }
+
+ if (array_key_exists($keys[3], $arr)) {
+ $this->setConStatus($arr[$keys[3]]);
+ }
+
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CaseConsolidatedPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CaseConsolidatedPeer::TAS_UID)) {
+ $criteria->add(CaseConsolidatedPeer::TAS_UID, $this->tas_uid);
+ }
+
+ if ($this->isColumnModified(CaseConsolidatedPeer::DYN_UID)) {
+ $criteria->add(CaseConsolidatedPeer::DYN_UID, $this->dyn_uid);
+ }
+
+ if ($this->isColumnModified(CaseConsolidatedPeer::REP_TAB_UID)) {
+ $criteria->add(CaseConsolidatedPeer::REP_TAB_UID, $this->rep_tab_uid);
+ }
+
+ if ($this->isColumnModified(CaseConsolidatedPeer::CON_STATUS)) {
+ $criteria->add(CaseConsolidatedPeer::CON_STATUS, $this->con_status);
+ }
+
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CaseConsolidatedPeer::DATABASE_NAME);
+
+ $criteria->add(CaseConsolidatedPeer::TAS_UID, $this->tas_uid);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return string
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getTasUid();
+ }
+
+ /**
+ * Generic method to set the primary key (tas_uid column).
+ *
+ * @param string $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setTasUid($key);
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of CaseConsolidated (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false)
+ {
+
+ $copyObj->setDynUid($this->dyn_uid);
+
+ $copyObj->setRepTabUid($this->rep_tab_uid);
+
+ $copyObj->setConStatus($this->con_status);
+
+
+ $copyObj->setNew(true);
+
+ $copyObj->setTasUid(''); // this is a pkey column, so set to default value
+
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return CaseConsolidated Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CaseConsolidatedPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CaseConsolidatedPeer();
+ }
+ return self::$peer;
+ }
+}
+
diff --git a/workflow/engine/classes/model/om/BaseCaseConsolidatedPeer.php b/workflow/engine/classes/model/om/BaseCaseConsolidatedPeer.php
new file mode 100644
index 000000000..5c280d57a
--- /dev/null
+++ b/workflow/engine/classes/model/om/BaseCaseConsolidatedPeer.php
@@ -0,0 +1,582 @@
+ array ('TasUid', 'DynUid', 'RepTabUid', 'ConStatus', ),
+ BasePeer::TYPE_COLNAME => array (CaseConsolidatedPeer::TAS_UID, CaseConsolidatedPeer::DYN_UID, CaseConsolidatedPeer::REP_TAB_UID, CaseConsolidatedPeer::CON_STATUS, ),
+ BasePeer::TYPE_FIELDNAME => array ('TAS_UID', 'DYN_UID', 'REP_TAB_UID', 'CON_STATUS', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ private static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('TasUid' => 0, 'DynUid' => 1, 'RepTabUid' => 2, 'ConStatus' => 3, ),
+ BasePeer::TYPE_COLNAME => array (CaseConsolidatedPeer::TAS_UID => 0, CaseConsolidatedPeer::DYN_UID => 1, CaseConsolidatedPeer::REP_TAB_UID => 2, CaseConsolidatedPeer::CON_STATUS => 3, ),
+ BasePeer::TYPE_FIELDNAME => array ('TAS_UID' => 0, 'DYN_UID' => 1, 'REP_TAB_UID' => 2, 'CON_STATUS' => 3, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * @return MapBuilder the map builder for this peer
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getMapBuilder()
+ {
+ include_once 'classes/model/map/CaseConsolidatedMapBuilder.php';
+ return BasePeer::getMapBuilder('classes.model.map.CaseConsolidatedMapBuilder');
+ }
+ /**
+ * Gets a map (hash) of PHP names to DB column names.
+ *
+ * @return array The PHP to DB name map for this peer
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
+ */
+ public static function getPhpNameMap()
+ {
+ if (self::$phpNameMap === null) {
+ $map = CaseConsolidatedPeer::getTableMap();
+ $columns = $map->getColumns();
+ $nameMap = array();
+ foreach ($columns as $column) {
+ $nameMap[$column->getPhpName()] = $column->getColumnName();
+ }
+ self::$phpNameMap = $nameMap;
+ }
+ return self::$phpNameMap;
+ }
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants TYPE_PHPNAME,
+ * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ */
+ static public function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = self::getFieldNames($toType);
+ $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
+ }
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants TYPE_PHPNAME,
+ * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
+ * @return array A list of field names
+ */
+
+ static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, self::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
+ }
+ return self::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CaseConsolidatedPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CaseConsolidatedPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param criteria object containing the columns to add.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria)
+ {
+
+ $criteria->addSelectColumn(CaseConsolidatedPeer::TAS_UID);
+
+ $criteria->addSelectColumn(CaseConsolidatedPeer::DYN_UID);
+
+ $criteria->addSelectColumn(CaseConsolidatedPeer::REP_TAB_UID);
+
+ $criteria->addSelectColumn(CaseConsolidatedPeer::CON_STATUS);
+
+ }
+
+ const COUNT = 'COUNT(CASE_CONSOLIDATED.TAS_UID)';
+ const COUNT_DISTINCT = 'COUNT(DISTINCT CASE_CONSOLIDATED.TAS_UID)';
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
+ * @param Connection $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, $con = null)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // clear out anything that might confuse the ORDER BY clause
+ $criteria->clearSelectColumns()->clearOrderByColumns();
+ if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->addSelectColumn(CaseConsolidatedPeer::COUNT_DISTINCT);
+ } else {
+ $criteria->addSelectColumn(CaseConsolidatedPeer::COUNT);
+ }
+
+ // just in case we're grouping: add those columns to the select statement
+ foreach ($criteria->getGroupByColumns() as $column) {
+ $criteria->addSelectColumn($column);
+ }
+
+ $rs = CaseConsolidatedPeer::doSelectRS($criteria, $con);
+ if ($rs->next()) {
+ return $rs->getInt(1);
+ } else {
+ // no rows returned; we infer that means 0 matches.
+ return 0;
+ }
+ }
+ /**
+ * Method to select one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param Connection $con
+ * @return CaseConsolidated
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CaseConsolidatedPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+ return null;
+ }
+ /**
+ * Method to do selects.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param Connection $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, $con = null)
+ {
+ return CaseConsolidatedPeer::populateObjects(CaseConsolidatedPeer::doSelectRS($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect()
+ * method to get a ResultSet.
+ *
+ * Use this method directly if you want to just get the resultset
+ * (instead of an array of objects).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param Connection $con the connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return ResultSet The resultset object with numerically-indexed fields.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectRS(Criteria $criteria, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ if (!$criteria->getSelectColumns()) {
+ $criteria = clone $criteria;
+ CaseConsolidatedPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ // BasePeer returns a Creole ResultSet, set to return
+ // rows indexed numerically.
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(ResultSet $rs)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CaseConsolidatedPeer::getOMClass();
+ $cls = Propel::import($cls);
+ // populate the object(s)
+ while ($rs->next()) {
+
+ $obj = new $cls();
+ $obj->hydrate($rs);
+ $results[] = $obj;
+
+ }
+ return $results;
+ }
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ * This uses a dot-path notation which is tranalted into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass()
+ {
+ return CaseConsolidatedPeer::CLASS_DEFAULT;
+ }
+
+ /**
+ * Method perform an INSERT on the database, given a CaseConsolidated or Criteria object.
+ *
+ * @param mixed $values Criteria or CaseConsolidated object containing data that is used to create the INSERT statement.
+ * @param Connection $con the connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from CaseConsolidated object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->begin();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Method perform an UPDATE on the database, given a CaseConsolidated or Criteria object.
+ *
+ * @param mixed $values Criteria or CaseConsolidated object containing data create the UPDATE statement.
+ * @param Connection $con The connection to use (specify Connection exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ $selectCriteria = new Criteria(self::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CaseConsolidatedPeer::TAS_UID);
+ $selectCriteria->add(CaseConsolidatedPeer::TAS_UID, $criteria->remove(CaseConsolidatedPeer::TAS_UID), $comparison);
+
+ } else {
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Method to DELETE all rows from the CASE_CONSOLIDATED table.
+ *
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll($con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->begin();
+ $affectedRows += BasePeer::doDeleteAll(CaseConsolidatedPeer::TABLE_NAME, $con);
+ $con->commit();
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+ }
+
+ /**
+ * Method perform a DELETE on the database, given a CaseConsolidated or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CaseConsolidated object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param Connection $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CaseConsolidatedPeer::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } elseif ($values instanceof CaseConsolidated) {
+
+ $criteria = $values->buildPkeyCriteria();
+ } else {
+ // it must be the primary key
+ $criteria = new Criteria(self::DATABASE_NAME);
+ $criteria->add(CaseConsolidatedPeer::TAS_UID, (array) $values, Criteria::IN);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->begin();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ $con->commit();
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given CaseConsolidated object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param CaseConsolidated $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate(CaseConsolidated $obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CaseConsolidatedPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CaseConsolidatedPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->containsColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CaseConsolidatedPeer::DATABASE_NAME, CaseConsolidatedPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param mixed $pk the primary key.
+ * @param Connection $con the connection to use
+ * @return CaseConsolidated
+ */
+ public static function retrieveByPK($pk, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ $criteria = new Criteria(CaseConsolidatedPeer::DATABASE_NAME);
+
+ $criteria->add(CaseConsolidatedPeer::TAS_UID, $pk);
+
+
+ $v = CaseConsolidatedPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param Connection $con the connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria();
+ $criteria->add(CaseConsolidatedPeer::TAS_UID, $pks, Criteria::IN);
+ $objs = CaseConsolidatedPeer::doSelect($criteria, $con);
+ }
+ return $objs;
+ }
+}
+
+
+// static code to register the map builder for this Peer with the main Propel class
+if (Propel::isInit()) {
+ // the MapBuilder classes register themselves with Propel during initialization
+ // so we need to load them here.
+ try {
+ BaseCaseConsolidatedPeer::getMapBuilder();
+ } catch (Exception $e) {
+ Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
+ }
+} else {
+ // even if Propel is not yet initialized, the map builder class can be registered
+ // now and then it will be loaded when Propel initializes.
+ require_once 'classes/model/map/CaseConsolidatedMapBuilder.php';
+ Propel::registerMapBuilder('classes.model.map.CaseConsolidatedMapBuilder');
+}
+
diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml
index f3d2be41d..0d5c81aa2 100755
--- a/workflow/engine/config/schema.xml
+++ b/workflow/engine/config/schema.xml
@@ -1930,6 +1930,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql
index df9bb5e43..80fc185e2 100755
--- a/workflow/engine/data/mysql/schema.sql
+++ b/workflow/engine/data/mysql/schema.sql
@@ -880,6 +880,21 @@ CREATE TABLE `CASE_TRACKER_OBJECT`
KEY `indexCaseTrackerObject`(`PRO_UID`, `CTO_UID_OBJ`)
)ENGINE=InnoDB DEFAULT CHARSET='utf8';
#-----------------------------------------------------------------------------
+#-- CASE_CONSOLIDATED
+#-----------------------------------------------------------------------------
+
+DROP TABLE IF EXISTS `CASE_CONSOLIDATED`;
+
+
+CREATE TABLE `CASE_CONSOLIDATED`
+(
+ `TAS_UID` VARCHAR(32) default '' NOT NULL,
+ `DYN_UID` VARCHAR(32) default '' NOT NULL,
+ `REP_TAB_UID` VARCHAR(32) default '' NOT NULL,
+ `CON_STATUS` VARCHAR(20) default 'ACTIVE' NOT NULL,
+ PRIMARY KEY (`TAS_UID`)
+)ENGINE=InnoDB DEFAULT CHARSET='utf8';
+#-----------------------------------------------------------------------------
#-- STAGE
#-----------------------------------------------------------------------------
diff --git a/workflow/engine/menus/cases.php b/workflow/engine/menus/cases.php
index 28abdb5c7..2a22e0e1b 100755
--- a/workflow/engine/menus/cases.php
+++ b/workflow/engine/menus/cases.php
@@ -29,6 +29,10 @@ $G_TMP_MENU->AddIdRawOption('FOLDERS', '', G::LoadTranslation('ID_CASES_MENU_FOL
$G_TMP_MENU->AddIdRawOption('CASES_START_CASE', 'casesStartPage?action=startCase',
G::LoadTranslation('ID_NEW_CASE'), '');
+/*----------------------------------********---------------------------------*/
+$G_TMP_MENU->AddIdRawOption('CASE_CONSOLIDATED_1', 'casesConsolidatedListExtJs?action=consolidated', 'Batch Routing', '');
+/*----------------------------------********---------------------------------*/
+
$G_TMP_MENU->AddIdRawOption('CASES_INBOX', 'casesListExtJs?action=todo', G::LoadTranslation('ID_INBOX'),
'icon-cases-inbox.png');
$G_TMP_MENU->AddIdRawOption('CASES_DRAFT', 'casesListExtJs?action=draft', G::LoadTranslation('ID_DRAFT'),
diff --git a/workflow/engine/methods/cases/caseConsolidated.php b/workflow/engine/methods/cases/caseConsolidated.php
new file mode 100644
index 000000000..fb11661fd
--- /dev/null
+++ b/workflow/engine/methods/cases/caseConsolidated.php
@@ -0,0 +1,277 @@
+addSelectColumn(ReportTablePeer::REP_TAB_UID);
+ $criteria->add(ReportTablePeer::REP_TAB_NAME, $tableName);
+
+ $rsCriteria = ReportTablePeer::doSelectRS($criteria);
+
+ $rptUid = null;
+
+ if ($rsCriteria->next()) {
+ $row = $rsCriteria->getRow();
+
+ $rptUid = $row[0];
+ }
+
+ $rpts = new ReportTables();
+
+ if ($rptUid != null) {
+ $rpts->deleteReportTable($rptUid);
+ }
+
+ $sRepTabUid = "";
+ break;
+ case 2:
+ //Delete table
+ $rpts = new ReportTables();
+ $rpts->dropTable($tableName, "wf");
+
+ $sRepTabUid = "";
+ break;
+ }
+
+ $criteria = new Criteria();
+ $criteria->addSelectColumn(ReportTablePeer::REP_TAB_UID);
+ //$criteria->add(ReportTablePeer::PRO_UID, $sProUid);
+ $criteria->add(ReportTablePeer::REP_TAB_NAME, $tableName);
+
+ $result = ReportTablePeer::doSelectRS($criteria);
+ $result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+
+ if ($result->next()) {
+ $dataRes = $result->getRow();
+
+ if ($dataRes["REP_TAB_UID"] != $sRepTabUid) {
+ return 1;
+ }
+ } else {
+ //check if table $tableName exists
+ $con = Propel::getConnection("workflow");
+ $stmt = $con->createStatement();
+
+ $sql="SHOW TABLES";
+ $rs1 = $stmt->executeQuery($sql, ResultSet::FETCHMODE_NUM);
+ $rs1->next();
+ while ( is_array($row = $rs1->getRow() )) {
+ if ( $row[0] == $tableName ) {
+ return 2;
+ }
+ $rs1->next();
+ }
+ }
+
+ if ($isBPMN) {
+ $_POST['form']['PRO_UID'] = $sProUid;
+ $_POST['form']['REP_TAB_UID'] = $sRepTabUid;
+ $_POST['form']['REP_TAB_NAME'] = $tableName;
+ $_POST['form']['REP_TAB_TYPE'] = "NORMAL";
+ $_POST['form']['REP_TAB_GRID'] = '';
+ $_POST['form']['REP_TAB_CONNECTION'] = 'wf';
+ $_POST['form']['REP_TAB_CREATE_DATE'] = date("Y-m-d H:i:s");
+ $_POST['form']['REP_TAB_STATUS'] = 'ACTIVE';
+ $_POST['form']['REP_TAB_TITLE'] = $title;
+ } else {
+ $_POST['form']['PRO_UID'] = $sProUid;
+ $_POST['form']['REP_TAB_UID'] = $sRepTabUid;
+ $_POST['form']['REP_TAB_NAME'] = $tableName;
+ $_POST['form']['REP_TAB_TYPE'] = "GRID";
+ $_POST['form']['REP_TAB_GRID'] = $sProUid . "-" . $sDynUid;
+ $_POST['form']['REP_TAB_CONNECTION'] = 'wf';
+ $_POST['form']['REP_TAB_CREATE_DATE'] = date("Y-m-d H:i:s");
+ $_POST['form']['REP_TAB_STATUS'] = 'ACTIVE';
+ $_POST['form']['REP_TAB_TITLE'] = $title;
+ }
+
+ $_POST['form']['FIELDS'] = array();
+
+ G::LoadClass("reportTables");
+
+ $oReportTable = new ReportTable();
+ //if (!isset($_POST['form']['REP_TAB_CONNECTION'])) {
+ // $_POST['form']['REP_TAB_CONNECTION'] = 'report';
+ //}
+ if ($_POST['form']['REP_TAB_UID'] != "") {
+ $aReportTable = $oReportTable->load($_POST['form']['REP_TAB_UID']);
+ $sOldTableName = $aReportTable['REP_TAB_NAME'];
+ $sOldConnection = $aReportTable['REP_TAB_CONNECTION'];
+ } else {
+ $sOldTableName = $_POST['form']['REP_TAB_NAME'];
+ $sOldConnection = $_POST['form']['REP_TAB_CONNECTION'];
+ $_POST['form']['REP_TAB_TYPE'] = 'NORMAL';
+ $oReportTable->create($_POST['form']);
+ $_POST['form']['REP_TAB_UID'] = $oReportTable->getRepTabUid();
+ }
+
+ $_POST['form']['REP_TAB_TYPE'] = 'NORMAL';
+ $oReportTable->update($_POST['form']);
+
+ $oReportVar = new ReportVar();
+ $oReportTables = new ReportTables();
+ $oReportTables->deleteAllReportVars($_POST['form']['REP_TAB_UID']);
+
+ $aFields = array();
+
+ if ($isBPMN) {
+ G::LoadClass("pmDynaform");
+
+ $pmDyna = new pmDynaform(array());
+ $pmDyna->fields["CURRENT_DYNAFORM"] = $sDynUid;
+ $dataDyna = $pmDyna->getDynaform();
+ $json = G::json_decode($dataDyna["DYN_CONTENT"]);
+ $data = $pmDyna->jsonr($json);
+ G::pr($data); die;
+ } else {
+ $aAux = explode('-', $_POST['form']['REP_TAB_GRID']);
+ global $G_FORM;
+
+ require_once "classes/class.formBatchRouting.php";
+
+ $G_FORM = new FormBatchRouting($_POST["form"]["PRO_UID"] . PATH_SEP . $aAux[1], PATH_DYNAFORM, SYS_LANG, false);
+ $aAux = $G_FORM->getVars(false);
+
+ foreach ($aAux as $aField) {
+ $_POST['form']['FIELDS'][] = $aField['sName'] . '-' . $aField['sType'];
+ }
+ }
+
+ $aFieldsClases = array();
+ $i = 1;
+ $aFieldsClases[$i]['FLD_NAME'] = 'APP_UID';
+ $aFieldsClases[$i]['FLD_NULL'] = 'off';
+ $aFieldsClases[$i]['FLD_KEY'] = 'on';
+ $aFieldsClases[$i]['FLD_AUTO_INCREMENT'] = 'off';
+ $aFieldsClases[$i]['FLD_DESCRIPTION'] = '';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'VARCHAR' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = 32;
+ $i++;
+ $aFieldsClases[$i]['FLD_NAME'] = 'APP_NUMBER';
+ $aFieldsClases[$i]['FLD_NULL'] = 'off';
+ $aFieldsClases[$i]['FLD_KEY'] = 'on';
+ $aFieldsClases[$i]['FLD_AUTO_INCREMENT'] = 'off';
+ $aFieldsClases[$i]['FLD_DESCRIPTION'] = '';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'VARCHAR' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = 255;
+
+ foreach ($_POST['form']['FIELDS'] as $sField) {
+ $aField = explode('-', $sField);
+ $i++;
+ $aFieldsClases[$i]['FLD_NAME'] = $aField[0];
+ $aFieldsClases[$i]['FLD_NULL'] = 'off';
+ $aFieldsClases[$i]['FLD_KEY'] = 'off';
+ $aFieldsClases[$i]['FLD_AUTO_INCREMENT'] = 'off';
+ $aFieldsClases[$i]['FLD_DESCRIPTION'] = '';
+
+ switch ($aField[1]) {
+ case 'currency':
+ case 'percentage':
+ $sType = 'number';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'FLOAT' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = 255;
+ break;
+ case 'text':
+ case 'password':
+ case 'dropdown':
+ case 'yesno':
+ case 'checkbox':
+ case 'radiogroup':
+ case 'hidden':
+ case "link":
+ $sType = 'char';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'VARCHAR' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = 255;
+ break;
+ case 'textarea':
+ $sType = 'text';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'TEXT' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = '';
+ break;
+ case 'date':
+ $sType = 'date';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'DATE' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = '';
+ break;
+ default:
+ $sType = 'char';
+ $aFieldsClases[$i]['FLD_TYPE'] = 'VARCHAR' ;
+ $aFieldsClases[$i]['FLD_SIZE'] = 255;
+ break;
+ }
+
+ $oReportVar->create(array('REP_TAB_UID' => $_POST['form']['REP_TAB_UID'],
+ 'PRO_UID' => $_POST['form']['PRO_UID'],
+ 'REP_VAR_NAME' => $aField[0],
+ 'REP_VAR_TYPE' => $sType));
+ $aFields[] = array('sFieldName' => $aField[0], 'sType' => $sType);
+ }
+
+ $_POST['form']['REP_TAB_TYPE'] = "NORMAL";
+ $oReportTables->dropTable($sOldTableName, $sOldConnection);
+ $oReportTables->createTable($_POST['form']['REP_TAB_NAME'], $_POST['form']['REP_TAB_CONNECTION'], $_POST['form']['REP_TAB_TYPE'], $aFields);
+ $oReportTables->populateTable($_POST['form']['REP_TAB_NAME'], $_POST['form']['REP_TAB_CONNECTION'], $_POST['form']['REP_TAB_TYPE'], $aFields, $_POST['form']['PRO_UID'], '');
+
+ $sRepTabUid = $_POST['form']['REP_TAB_UID'];
+
+ //clases
+} else {
+ $oReportTables = new ReportTables();
+ if ($sRepTabUid != "") {
+ $oReportTables->deleteReportTable($sRepTabUid);
+ }
+ $sRepTabUid = "";
+}
+
+require_once ("classes/model/CaseConsolidatedPeer.php");
+require_once ("classes/model/CaseConsolidated.php");
+
+$oCaseConsolidated = CaseConsolidatedPeer::retrieveByPK($sTasUid);
+
+if (!(is_object($oCaseConsolidated)) || get_class($oCaseConsolidated) != 'CaseConsolidated') {
+ $oCaseConsolidated = new CaseConsolidated();
+ $oCaseConsolidated->setTasUid($sTasUid);
+}
+
+if ($sStatus == '1') {
+ $oCaseConsolidated->setConStatus('ACTIVE');
+} else {
+ $oCaseConsolidated->setConStatus('INACTIVE');
+}
+
+$oCaseConsolidated->setDynUid($sDynUid);
+$oCaseConsolidated->setRepTabUid($sRepTabUid);
+$oCaseConsolidated->save();
+
+$sClassName = $tableName;//'__' . $sTasUid;
+
+if ($sStatus == '1') {
+ //$oAdditionalTables->createPropelClasses($sTableName, $sClassName, $aFields, $sAddTabUid)
+ //require_once 'classes/model/AdditionalTables.php';
+ //$oAdditionalTables = new AdditionalTables();
+ $oAdditionalTables = new AdditionalTables();//AdditionalTablesConsolidated
+
+ $oAdditionalTables->createPropelClasses($tableName, $sClassName, $aFieldsClases, $sTasUid);
+} else {
+ $sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
+ @unlink($sPath . $sClassName . '.php');
+ @unlink($sPath . $sClassName . 'Peer.php');
+ @unlink($sPath . PATH_SEP . 'map' . PATH_SEP . $sClassName . 'MapBuilder.php');
+ @unlink($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $sClassName . '.php');
+ @unlink($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $sClassName . 'Peer.php');
+}
diff --git a/workflow/engine/methods/cases/casesConsolidatedListExtJs.php b/workflow/engine/methods/cases/casesConsolidatedListExtJs.php
new file mode 100644
index 000000000..9ce405b42
--- /dev/null
+++ b/workflow/engine/methods/cases/casesConsolidatedListExtJs.php
@@ -0,0 +1,335 @@
+addSelectColumn(CaseConsolidatedPeer::CON_STATUS);
+$oCriteria->add(CaseConsolidatedPeer::CON_STATUS, "ACTIVE");
+$activeNumRows = CaseConsolidatedPeer::doCount($oCriteria);
+
+G::LoadClass ("BasePeer");
+G::LoadClass ("configuration");
+G::loadClass("pmFunctions");
+
+$headPublisher = &headPublisher::getSingleton();
+
+//cambiar esto por PROPEL //CASE_CONSOLIDATED TASK
+$usrUid = $_SESSION["USER_LOGGED"];
+
+$oCriteria = new Criteria("workflow");
+$oCriteria->addSelectColumn("*");
+$oCriteria->addSelectColumn(CaseConsolidatedPeer::TAS_UID);
+$oCriteria->addJoin(CaseConsolidatedPeer::TAS_UID,ContentPeer::CON_ID, Criteria::LEFT_JOIN);
+$oCriteria->addJoin(CaseConsolidatedPeer::TAS_UID,TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
+$oCriteria->addAnd(ContentPeer::CON_CATEGORY, "TAS_TITLE");
+$oCriteria->addAnd(ContentPeer::CON_LANG, "en");
+
+$params = array(); //This will be filled with the parameters
+$sql = BasePeer::createSelectSql($oCriteria, $params);
+
+$oDataset = CaseConsolidatedPeer::doSelectRS($oCriteria);
+$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+//$oDataset->next();
+while ($oDataset->next()) {
+ $aRow = $oDataset->getRow();
+ //$aTaskConsolidated [] = $aRow;
+}
+
+$query = "SELECT *
+ FROM CASE_CONSOLIDATED LEFT JOIN CONTENT ON
+ (CASE_CONSOLIDATED.TAS_UID = CONTENT.CON_ID) LEFT JOIN TASK ON (CASE_CONSOLIDATED.TAS_UID = TASK.TAS_UID)
+ WHERE CONTENT.CON_CATEGORY='TAS_TITLE' AND CONTENT.CON_LANG='en'";
+$aTaskConsolidated = executeQuery($query);
+
+$conf = new Configurations();
+
+try {
+ $confCasesList = $conf->getConfiguration("casesList", $action);
+ $generalConfCasesList = $conf->getConfiguration("ENVIRONMENT_SETTINGS", "");
+} catch (Exception $e) {
+ $confCasesList = array();
+ $generalConfCasesList = array();
+}
+
+$config = getAdditionalFields($action, $confCasesList);
+
+if (isset($generalConfCasesList["casesListRowNumber"]) && !empty($generalConfCasesList["casesListRowNumber"])) {
+ $pageSize = intval($generalConfCasesList["casesListRowNumber"]);
+} else {
+ $pageSize = intval($config["rowsperpage"]);
+}
+
+$arrayTabItem = array();
+$aAllData = array();
+//$aQTY = array();
+$i = 0;
+
+//SQL
+$cnn = Propel::getConnection("workflow");
+$stmt = $cnn->createStatement();
+
+//foreach ($aTaskConsolidated as $value)
+//{
+$i++;
+
+$sql = "SELECT COUNT(APP_CACHE_VIEW.TAS_UID) AS NUMREC,
+ APP_CACHE_VIEW.PRO_UID,
+ (SELECT CON.CON_VALUE
+ FROM CONTENT AS CON
+ WHERE CON.CON_ID = APP_CACHE_VIEW.PRO_UID AND CON.CON_CATEGORY = 'PRO_TITLE' AND CON.CON_LANG = '" . SYS_LANG . "'
+ ) AS PROCESS_TITLE,
+ APP_CACHE_VIEW.TAS_UID,
+ CONTASK.CON_VALUE AS TASK_TITLE,
+ CASE_CONSOLIDATED.DYN_UID
+ FROM CASE_CONSOLIDATED
+ LEFT JOIN CONTENT AS CONTASK ON (CASE_CONSOLIDATED.TAS_UID = CONTASK.CON_ID AND CONTASK.CON_CATEGORY = 'TAS_TITLE' AND CONTASK.CON_LANG = '" . SYS_LANG . "')
+ LEFT JOIN APP_CACHE_VIEW ON (CASE_CONSOLIDATED.TAS_UID = APP_CACHE_VIEW.TAS_UID)
+ WHERE APP_CACHE_VIEW.USR_UID = '$usrUid' AND
+ APP_CACHE_VIEW.DEL_THREAD_STATUS = 'OPEN' AND
+ APP_CACHE_VIEW.APP_STATUS = 'TO_DO'
+ GROUP BY APP_CACHE_VIEW.TAS_UID";
+
+$rsSql = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
+
+while ($rsSql->next()) {
+ $row = $rsSql->getRow();
+
+ $processUid = $row["PRO_UID"];
+ $proTitle = $row["PROCESS_TITLE"];
+ $taskUid = $row["TAS_UID"];
+ $taskTitle = $row["TASK_TITLE"];
+ $dynaformUid = $row["DYN_UID"];
+
+ $tabTitle = $taskTitle . " (" . (($activeNumRows > 0)? $row["NUMREC"] : 0) . ")";
+
+ $grdTitle = htmlentities($proTitle . " / " . $tabTitle, ENT_QUOTES, "UTF-8");
+ $tabTitle = htmlentities(substr($proTitle, 0, 25) . ((strlen($proTitle) > 25)? "..." : null) . " / " . $tabTitle, ENT_QUOTES, "UTF-8");
+
+ $arrayTabItem[] = "
+ {
+ title: \"$tabTitle\",
+ listeners: {
+ activate: function ()
+ {
+ generateGrid(\"$processUid\", \"$taskUid\", \"$dynaformUid\");
+ }
+ }
+ }";
+}
+
+if (count($arrayTabItem) > 0) {
+ $urlProxy = '/api/1.0/' . SYS_SYS . '/consolidated/';
+ $clientId = 'x-pm-local-client';
+ $client = getClientCredentials($clientId);
+ $authCode = getAuthorizationCode($client);
+ $debug = false; //System::isDebugMode();
+
+ $loader = Maveriks\Util\ClassLoader::getInstance();
+ $loader->add(PATH_TRUNK . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2");
+
+ $request = array(
+ 'grant_type' => 'authorization_code',
+ 'code' => $authCode
+ );
+ $server = array(
+ 'REQUEST_METHOD' => 'POST'
+ );
+ $headers = array(
+ "PHP_AUTH_USER" => $client['CLIENT_ID'],
+ "PHP_AUTH_PW" => $client['CLIENT_SECRET'],
+ "Content-Type" => "multipart/form-data;",
+ "Authorization" => "Basic " . base64_encode($client['CLIENT_ID'] . ":" . $client['CLIENT_SECRET'])
+ );
+
+ $request = new \OAuth2\Request(array(), $request, array(), array(), array(), $server, null, $headers);
+ $oauthServer = new \ProcessMaker\Services\OAuth2\Server();
+ $response = $oauthServer->postToken($request, true);
+
+ $clientToken = $response->getParameters();
+ $clientToken["client_id"] = $client['CLIENT_ID'];
+ $clientToken["client_secret"] = $client['CLIENT_SECRET'];
+
+
+ $items = "[" . implode(",", $arrayTabItem) ."]";
+
+ $userUid = (isset($_SESSION["USER_LOGGED"]) && $_SESSION["USER_LOGGED"] != "")? $_SESSION["USER_LOGGED"] : null;
+ $processes = getProcessArray($action, $userUid);
+
+ $headPublisher->assign("pageSize", $pageSize); //Sending the page size
+ $headPublisher->assign("action", $action); //Sending the fields to get from proxy
+ $headPublisher->assign("Items", $items);
+ $headPublisher->assign("processValues", $processes); //Sending the columns to display in grid
+ $headPublisher->assign("varSkin", SYS_SKIN); //Sending the current Skin
+ $headPublisher->assign("FORMATS", $conf->getFormats());
+ $headPublisher->assign("urlProxy", $urlProxy);
+ $headPublisher->assign('credentials', $clientToken );
+
+ $headPublisher->addExtJsScript("app/main", true);
+ $headPublisher->addExtJsScript("cases/casesListConsolidated", false); //Adding a JavaScript file .js
+ $headPublisher->addContent("cases/casesListConsolidated"); //Adding a HTML file .html
+
+ G::RenderPage("publish", "extJs");
+} else {
+ echo "" . G::LoadTranslation("ID_NO_RECORDS_FOUND") . "";
+}
+
+
+
+function getProcessArray($action, $userUid)
+{
+ $processes = array();
+ $processes[] = array("", G::LoadTranslation("ID_ALL_PROCESS"));
+
+ switch ($action) {
+ case "simple_search":
+ case "search":
+ //In search action, the query to obtain all process is too slow, so we need to query directly to
+ //process and content tables, and for that reason we need the current language in AppCacheView.
+ G::loadClass("configuration");
+ $oConf = new Configurations;
+ $oConf->loadConfig($x, "APP_CACHE_VIEW_ENGINE", "", "", "", "");
+ $appCacheViewEngine = $oConf->aConfig;
+ $lang = isset($appCacheViewEngine["LANG"])? $appCacheViewEngine["LANG"] : "en";
+
+ $cProcess = new Criteria("workflow");
+ $cProcess->clearSelectColumns();
+ $cProcess->addSelectColumn(ProcessPeer::PRO_UID);
+ $cProcess->addSelectColumn(ContentPeer::CON_VALUE);
+
+ $del = DBAdapter::getStringDelimiter();
+
+ $conds = array();
+ $conds[] = array(ProcessPeer::PRO_UID, ContentPeer::CON_ID);
+ $conds[] = array(ContentPeer::CON_CATEGORY, $del . "PRO_TITLE" . $del);
+ $conds[] = array(ContentPeer::CON_LANG, $del . $lang . $del);
+ $cProcess->addJoinMC($conds, Criteria::LEFT_JOIN);
+ $cProcess->add(ProcessPeer::PRO_STATUS, "ACTIVE");
+ $oDataset = ProcessPeer::doSelectRS($cProcess);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $processes[] = array($aRow["PRO_UID"], $aRow["CON_VALUE"]);
+ $oDataset->next();
+ }
+
+ return ($processes);
+ break;
+ case "consolidated":
+ default:
+ $oAppCache = new AppCacheView();
+ $cProcess = $oAppCache->getToDoListCriteria($userUid); //fast enough
+ break;
+ }
+
+ $cProcess->clearSelectColumns();
+ $cProcess->setDistinct();
+ $cProcess->addSelectColumn(AppCacheViewPeer::PRO_UID);
+ $cProcess->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE);
+ $oDataset = AppCacheViewPeer::doSelectRS($cProcess);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+
+ while ($aRow = $oDataset->getRow()) {
+ $processes[] = array($aRow["PRO_UID"], $aRow["APP_PRO_TITLE"]);
+ $oDataset->next();
+ }
+
+ return ($processes);
+}
+
+function getConsolidated()
+{
+ $caseColumns = array ();
+ $caseColumns[] = array("header" =>"#", "dataIndex" => "APP_NUMBER", "width" => 45, "align" => "center");
+ $caseColumns[] = array("header" =>"Case", "dataIndex" => "APP_TITLE", "width" => 150);
+ $caseColumns[] = array("header" =>"UserUid", "dataIndex" => "USR_UID", "width" => 50, "hidden" => true, "hideable" => false);
+ $caseColumns[] = array("header" =>"PreUsrUid", "dataIndex" => "PREVIOUS_USR_UID", "width" => 50, "hidden" => true, "hideable" => false);
+ $caseColumns[] = array("header" =>"Task", "dataIndex" => "APP_TAS_TITLE", "width" => 120);
+ $caseColumns[] = array("header" =>"Process", "dataIndex" => "APP_PRO_TITLE", "width" => 120);
+ $caseColumns[] = array("header" =>"Sent by", "dataIndex" => "APP_DEL_PREVIOUS_USER", "width" => 90);
+ $caseColumns[] = array("header" =>"Due Date", "dataIndex" => "DEL_TASK_DUE_DATE", "width" => 110);
+ $caseColumns[] = array("header" =>"Last Modify", "dataIndex" => "APP_UPDATE_DATE", "width" => 110);
+ $caseColumns[] = array("header" =>"Priority", "dataIndex" => "DEL_PRIORITY", "width" => 50);
+
+ $caseReaderFields = array();
+ $caseReaderFields[] = array("name" => "APP_UID");
+ $caseReaderFields[] = array("name" => "USR_UID");
+ $caseReaderFields[] = array("name" => "PREVIOUS_USR_UID");
+ $caseReaderFields[] = array("name" => "DEL_INDEX");
+ $caseReaderFields[] = array("name" => "APP_NUMBER");
+ $caseReaderFields[] = array("name" => "APP_TITLE");
+ $caseReaderFields[] = array("name" => "APP_PRO_TITLE");
+ $caseReaderFields[] = array("name" => "APP_TAS_TITLE");
+ $caseReaderFields[] = array("name" => "APP_DEL_PREVIOUS_USER");
+ $caseReaderFields[] = array("name" => "DEL_TASK_DUE_DATE");
+ $caseReaderFields[] = array("name" => "APP_UPDATE_DATE");
+ $caseReaderFields[] = array("name" => "DEL_PRIORITY");
+ $caseReaderFields[] = array("name" => "APP_FINISH_DATE");
+ $caseReaderFields[] = array("name" => "APP_CURRENT_USER");
+ $caseReaderFields[] = array("name" => "APP_STATUS");
+
+ return (array("caseColumns" => $caseColumns, "caseReaderFields" => $caseReaderFields, "rowsperpage" => 20, "dateformat" => "M d, Y"));
+}
+
+function getAdditionalFields($action, $confCasesList)
+{
+ $caseColumns = array();
+ $caseReaderFields = array();
+
+ if (!empty($confCasesList) && !empty($confCasesList["second"]["data"])) {
+ foreach ($confCasesList["second"]["data"] as $fieldData) {
+ if ($fieldData["fieldType"] != "key") {
+ $label = $fieldData["label"];
+ $caseColumns[] = array("header" => $label, "dataIndex" => $fieldData["name"], "width" => $fieldData["width"], "align" => $fieldData["align"]);
+ $caseReaderFields[] = array("name" => $fieldData["name"]);
+ }
+ }
+ return (array("caseColumns" => $caseColumns, "caseReaderFields" => $caseReaderFields, "rowsperpage" => $confCasesList["rowsperpage"], "dateformat" => $confCasesList["dateformat"]));
+ } else {
+ switch ($action) {
+ case "consolidated":
+ default:
+ $action = "consolidated";
+ $config = getConsolidated();
+ break;
+ }
+ return ($config);
+ }
+}
+
+function getClientCredentials($clientId)
+{
+ $oauthQuery = new ProcessMaker\Services\OAuth2\PmPdo(getDsn());
+ return $oauthQuery->getClientDetails($clientId);
+}
+
+function getDsn()
+{
+ list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, '');
+ $port = empty($port) ? '' : ";port=$port";
+ $dsn = DB_ADAPTER.':host='.$host.';dbname='.DB_NAME.$port;
+
+ return array('dsn' => $dsn, 'username' => DB_USER, 'password' => DB_PASS);
+}
+
+
+function getAuthorizationCode($client)
+{
+ \ProcessMaker\Services\OAuth2\Server::setDatabaseSource(getDsn());
+ \ProcessMaker\Services\OAuth2\Server::setPmClientId($client['CLIENT_ID']);
+
+ $oauthServer = new \ProcessMaker\Services\OAuth2\Server();
+ $userId = $_SESSION['USER_LOGGED'];
+ $authorize = true;
+ $_GET = array_merge($_GET, array(
+ 'response_type' => 'code',
+ 'client_id' => $client['CLIENT_ID'],
+ 'scope' => implode(' ', $oauthServer->getScope())
+ ));
+
+ $response = $oauthServer->postAuthorize($authorize, $userId, true);
+ $code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=')+5, 40);
+
+ return $code;
+}
\ No newline at end of file
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Consolidated.php b/workflow/engine/src/ProcessMaker/BusinessModel/Consolidated.php
new file mode 100644
index 000000000..7a1a90bdb
--- /dev/null
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/Consolidated.php
@@ -0,0 +1,981 @@
+
+ * @copyright Colosa - Bolivia
+ */
+class Consolidated
+{
+ /**
+ * Get Consolidated
+ *
+ * @access public
+ * @param string $tas_uid, Task Uid
+ * @return array
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ */
+ public function get ($tas_uid)
+ {
+ $criteria = new Criteria();
+ $criteria->addSelectColumn(CaseConsolidatedPeer::DYN_UID);
+ $criteria->addSelectColumn(\ReportTablePeer::REP_TAB_NAME);
+ $criteria->addSelectColumn(ContentPeer::CON_VALUE);
+ $criteria->addSelectColumn(CaseConsolidatedPeer::CON_STATUS);
+
+ $criteria->addJoin( CaseConsolidatedPeer::REP_TAB_UID, ReportTablePeer::REP_TAB_UID, Criteria::LEFT_JOIN );
+ $criteria->addJoin( CaseConsolidatedPeer::REP_TAB_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
+ $criteria->add( ContentPeer::CON_CATEGORY, "REP_TAB_TITLE");
+ $criteria->add( ContentPeer::CON_LANG, SYS_LANG);
+
+ $criteria->add( CaseConsolidatedPeer::TAS_UID, $tas_uid, Criteria::EQUAL );
+ $criteria->add( CaseConsolidatedPeer::CON_STATUS, 'ACTIVE', Criteria::EQUAL );
+
+ $dataset = CaseConsolidatedPeer::doSelectRS($criteria);
+ $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ if ($dataset->next()) {
+ $response = $dataset->getRow();
+ } else {
+ $response = array(
+ 'REP_TAB_NAME' => '__' . $tas_uid,
+ 'CON_VALUE' => '__' . $tas_uid,
+ );
+ }
+ return array_change_key_case($response, CASE_LOWER);;
+ }
+
+ /**
+ * Put Data Generate
+ *
+ * @access public
+ * @param string $app_uid, Process Uid
+ * @param string $app_number, Task Uid
+ * @param string $del_index, Task Uid
+ * @param string $usr_uid, Task Uid
+ * @return string
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ */
+ public function postDerivate ($app_uid, $app_number, $del_index, $usr_uid)
+ {
+ G::LoadClass("library");
+ G::LoadClass("wsBase");
+ G::LoadClass("case");
+
+ $ws = new \wsBase();
+ $oCase = new \Cases();
+
+ if (!isset($Fields["DEL_INIT_DATE"])) {
+ $oCase->setDelInitDate($app_uid, $del_index);
+ $aFields = $oCase->loadCase($app_uid, $del_index);
+ }
+
+ $res = $ws->derivateCase($usr_uid, $app_uid, $del_index, true);
+ $messageDerivateCase = null;
+
+ if (is_array($res)) {
+ $messageDerivateCase = "";
+
+ if (count($res["routing"]) > 0) {
+ foreach ($res["routing"] as $k => $field) {
+ $messageDerivateCase = $messageDerivateCase . "- " . $res["routing"][$k]->taskName . " - " . $res["routing"][$k]->userName;
+ }
+ } else {
+ $messageDerivateCase = explode("-", $res["message"]);
+ $messageDerivateCase = "
- " . $messageDerivateCase[0];
+ }
+
+ $messageDerivateCase = $messageDerivateCase . "
";
+ }
+
+ $response = array();
+
+ $response["casesNumRec"] = \Library::getCasesNumRec($usr_uid);
+
+ if (is_array($res)) {
+ $response ["message"] = "" . G::LoadTranslation("ID_CASE") . " " . $app_number . " Summary of Derivations:
" . $messageDerivateCase;
+ } else {
+ $response ["message"] = G::LoadTranslation("ID_CASE") . " " . $app_number . " " . $res->message;
+ }
+ return $response;
+ }
+
+
+ /**
+ * Put Data Generate
+ *
+ * @access public
+ * @param string $pro_uid, Process Uid
+ * @param string $tas_uid, Task Uid
+ * @param string $dyn_uid, Dynaform Uid
+ * @return string
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ */
+ public function putDataGrid ($pro_uid, $tas_uid, $dyn_uid, $usr_uid, $data)
+ {
+ $option = (isset($data["option"]))? $data["option"] : null;
+ $response = array();
+ switch ($option) {
+ case "ALL":
+ $dataUpdate = $data["dataUpdate"];
+ $status = 1;
+ try {
+ $array = explode("(sep1 /)", $dataUpdate);
+ for ($i = 0; $i <= count($array) - 1; $i++) {
+ $arrayAux = explode("(sep2 /)", $array[$i]);
+ $data = array(
+ 'APP_UID' => $arrayAux[0],
+ $arrayAux[1] => $arrayAux[2]
+ );
+ self::consolidatedUpdate($dyn_uid, $data, $usr_uid);
+ }
+ $response["status"] = "OK";
+ } catch (\Exception $e) {
+ $response["message"] = $e->getMessage();
+ $status = 0;
+ }
+ if ($status == 0) {
+ $response["status"] = "ERROR";
+ }
+ break;
+ default:
+ $dynUid = $dyn_uid;
+ $data = $data['data'];
+
+ $status = 1;
+
+ try {
+ self::consolidatedUpdate($dynUid, $data, $usr_uid);
+ $response["status"] = "OK";
+ $response["success"] = true;
+ } catch (\Exception $e) {
+ $response["message"] = $e->getMessage();
+ $status = 0;
+ }
+
+ if ($status == 0) {
+ $response["status"] = "ERROR";
+ $response["success"] = false;
+ }
+ break;
+ }
+ return $response;
+ }
+ /**
+ * Get Data Generate
+ *
+ * @access public
+ * @param string $pro_uid, Process Uid
+ * @param string $tas_uid, Task Uid
+ * @param string $dyn_uid, Dynaform Uid
+ * @return string
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ */
+ public function getDataGrid ($pro_uid, $tas_uid, $dyn_uid, $usr_uid, $start = '', $limit = '', $search = '')
+ {
+ $start = !empty($start) ? $start : "0";
+ $limit = !empty($limit) ? $limit : "20";
+ $search = !empty($search) ? $search : "";
+
+ $callback = isset($_REQUEST["callback"])? $_REQUEST["callback"] : "stcCallback1001";
+ $dir = isset($_REQUEST["dir"])? $_REQUEST["dir"] : "DESC";
+ $sort = isset($_REQUEST["sort"])? $_REQUEST["sort"] : "";
+ $filter = isset($_REQUEST["filter"])? $_REQUEST["filter"] : "";
+ $user = isset($_REQUEST["user"])? $_REQUEST["user"] : "";
+ $status = isset($_REQUEST["status"])? strtoupper($_REQUEST["status"]) : "";
+ $action = isset($_GET["action"])? $_GET["action"] : (isset($_REQUEST["action"])? $_REQUEST["action"] : "todo");
+ $type = isset($_GET["type"])? $_GET["type"] : (isset($_REQUEST["type"])? $_REQUEST["type"] : "extjs");
+ $user = isset($_REQUEST["user"])? $_REQUEST["user"] : "";
+ $dateFrom = isset($_REQUEST["dateFrom"])? substr($_REQUEST["dateFrom"], 0, 10) : "";
+ $dateTo = isset($_REQUEST["dateTo"])? substr($_REQUEST["dateTo"], 0, 10) : "";
+
+ $rowUid = isset($_REQUEST["rowUid"])? $_REQUEST["rowUid"] : "";
+ $dropdownList = isset($_REQUEST ["dropList"])? G::json_decode($_REQUEST ["dropList"]) : array();
+
+ try {
+ G::LoadClass("pmFunctions");
+ G::LoadClass("BasePeer");
+ G::LoadClass("configuration");
+ G::LoadClass("case");
+ G::LoadClass("reportTables");
+
+ $response = array();
+ $searchFields = array();
+ //
+ $query = "SELECT REP_TAB_UID
+ FROM CASE_CONSOLIDATED
+ WHERE TAS_UID = '" . $tas_uid . "'";
+ $caseConsolidated = executeQuery($query);
+
+ $tableUid = null;
+ $tableName = null;
+
+ foreach ($caseConsolidated as $item) {
+ $criteria = new Criteria();
+ $criteria->addSelectColumn(ReportTablePeer::REP_TAB_NAME);
+ $criteria->add(ReportTablePeer::REP_TAB_UID,$item["REP_TAB_UID"]);
+
+ $result = ReportTablePeer::doSelectRS($criteria);
+ $result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+
+ if ($result->next()) {
+ $row = $result->getRow();
+
+ $tableUid = $item["REP_TAB_UID"];
+ $tableName = $row["REP_TAB_NAME"];
+ } else {
+ throw (new Exception("Not found the report table"));
+ }
+ }
+
+ $className = $tableName;
+
+ if (!class_exists($className)) {
+ require_once (PATH_DB . SYS_SYS . PATH_SEP . "classes" . PATH_SEP . $className . ".php");
+ }
+
+ $oCriteria = new Criteria("workflow");
+
+ $oCriteria->addSelectColumn("*");
+ $oCriteria->addSelectColumn($tableName . ".APP_UID");
+
+ $oCriteria->addJoin($tableName . ".APP_UID", AppCacheViewPeer::APP_UID, Criteria::LEFT_JOIN);
+
+ $oCriteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN");
+ $oCriteria->add(AppCacheViewPeer::TAS_UID, $tas_uid);
+ $oCriteria->add(AppCacheViewPeer::USR_UID, $usr_uid);
+ $oCriteria->add(AppCacheViewPeer::APP_STATUS, "TO_DO");
+
+ if ($search != "") {
+ $filename = $pro_uid . PATH_SEP . $dyn_uid . ".xml";
+
+ if (!class_exists('Smarty')) {
+ require_once(PATH_THIRDPARTY . 'smarty' . PATH_SEP . 'libs' . PATH_SEP . 'Smarty.class.php');
+ }
+ $G_FORM = new \xmlform();
+ $G_FORM->home = PATH_DYNAFORM;
+ $G_FORM->parseFile($filename, SYS_LANG, true);
+
+ foreach ($G_FORM->fields as $key => $val) {
+ switch ($val->type) {
+ case "text":
+ case "textarea":
+ case "currency":
+ case "percentage":
+ $searchFields[] = $val->name;
+ $dataType[] = $val->type;
+ break;
+ }
+ }
+
+ $oNewCriteria = new Criteria("workflow");
+ $oTmpCriteria = null;
+ $sw = 0;
+
+ foreach ($searchFields as $index => $value) {
+ $value = strtoupper($value);
+ eval("\$field = " . $tableName . "Peer::" . $value . ";");
+
+ if ($sw == 0) {
+ if ($dataType[$index] == 'currency' || $dataType[$index] == 'percentage') {
+ if ( is_numeric($search) || is_float($search) ) {
+ $oTmpCriteria = $oNewCriteria->getNewCriterion($field, $search);
+ }
+ } else {
+ $oTmpCriteria = $oNewCriteria->getNewCriterion($field, "%" . $search . "%", Criteria::LIKE);
+ }
+ } else {
+ if ($dataType[$index] == 'currency' || $dataType[$index] == 'percentage') {
+ if ( is_numeric($search) || is_float($search) ) {
+ $oTmpCriteria = $oNewCriteria->getNewCriterion($field, $search)->addOr($oTmpCriteria);
+ }
+ } else {
+ $oTmpCriteria = $oNewCriteria->getNewCriterion($field, "%" . $search . "%", Criteria::LIKE)->addOr($oTmpCriteria);
+ }
+ }
+
+ $sw = 1;
+ }
+
+ if ($oTmpCriteria != null) {
+ $oCriteria->add(
+ $oCriteria->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE)->addOr($oTmpCriteria)
+ );
+ } else {
+ $oCriteria->add($oCriteria->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE));
+ }
+ }
+
+ if ($sort != "") {
+ $reportTable = new ReportTables();
+ $arrayReportTableVar = $reportTable->getTableVars($tableUid);
+
+ if (in_array($sort, $arrayReportTableVar)) {
+ $sort = strtoupper($sort);
+ eval("\$field = " . $tableName . "Peer::" . $sort . ";");
+ } else {
+ eval("\$field = AppCacheViewPeer::" . $sort . ";");
+ }
+
+ if ($dir == "ASC") {
+ $oCriteria->addAscendingOrderByColumn($field);
+ } else {
+ $oCriteria->addDescendingOrderByColumn($field);
+ }
+ } else {
+ $oCriteria->addDescendingOrderByColumn(AppCacheViewPeer::APP_NUMBER);
+ }
+
+ //pagination pagination attributes
+ $oCriteria->setLimit($limit);
+ $oCriteria->setOffset($start);
+ //end of pagination attributes
+
+ $oDataset = AppCacheViewPeer::doSelectRS($oCriteria);
+ //eval('$oDataset = '.$className.'Peer::doSelectRS($oCriteria);');
+
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ //$oDataset->next();
+
+ $aTaskConsolidated = array();
+
+ while ($oDataset->next()) {
+ $aRow = $oDataset->getRow();
+
+ foreach ($aRow as $datakey => $dataField) {
+ foreach ($dropdownList as $tmpField) {
+ if ($tmpField == $datakey) {
+ $appUid = $aRow["APP_UID"];
+ $fieldVal = $aRow[$tmpField];
+ $aRow[$tmpField] = self::getDropdownLabel($appUid, $pro_uid, $dyn_uid, $tmpField, $fieldVal);
+ }
+ }
+ }
+
+ $aTaskConsolidated[] = $aRow;
+ }
+
+ foreach ($aTaskConsolidated as $key => $val) {
+ foreach ($val as $iKey => $iVal) {
+ if (self::checkValidDate($iVal)) {
+ $val[$iKey] = str_replace("-", "/", $val[$iKey]);
+ }
+ }
+ $response["data"][] = $val;
+ }
+
+ $query = "SELECT COUNT(APP_CACHE_VIEW.TAS_UID) AS QTY
+ FROM CASE_CONSOLIDATED
+ LEFT JOIN CONTENT ON (CASE_CONSOLIDATED.TAS_UID = CONTENT.CON_ID)
+ LEFT JOIN APP_CACHE_VIEW ON (CASE_CONSOLIDATED.TAS_UID = APP_CACHE_VIEW.TAS_UID)
+ LEFT JOIN TASK ON (CASE_CONSOLIDATED.TAS_UID = TASK.TAS_UID)
+ WHERE CONTENT.CON_CATEGORY = 'TAS_TITLE' AND
+ CONTENT.CON_LANG = 'en' AND
+ APP_CACHE_VIEW.DEL_THREAD_STATUS = 'OPEN' AND
+ USR_UID = '" . $usr_uid . "' AND
+ APP_CACHE_VIEW.TAS_UID = '" . $tas_uid . "'";
+ $count = executeQuery($query);
+
+ $totalCount = 0;
+ foreach ($count as $item) {
+ $totalCount = $totalCount + $item["QTY"];
+ }
+
+ $response["totalCount"] = $totalCount;
+ echo G::json_encode($response);
+ } catch (Exception $e) {
+ $msg = array("error" => $e->getMessage());
+ echo G::json_encode($msg);
+ }
+ }
+
+ /**
+ * Get Data Generate
+ *
+ * @access public
+ * @param string $pro_uid, Process Uid
+ * @param string $tas_uid, Task Uid
+ * @param string $dyn_uid, Dynaform Uid
+ * @return string
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ */
+ public function getDataGenerate($pro_uid, $tas_uid, $dyn_uid)
+ {
+ G::LoadClass ('case');
+ G::LoadClass ('pmFunctions');
+ G::LoadClass ("configuration");
+ $hasTextArea = false;
+
+ $conf = new \Configurations();
+ $generalConfCasesList = $conf->getConfiguration("ENVIRONMENT_SETTINGS", "");
+ if (isset($generalConfCasesList["casesListDateFormat"]) && !empty($generalConfCasesList["casesListDateFormat"])) {
+ $dateFormat = $generalConfCasesList["casesListDateFormat"];
+ } else {
+ $dateFormat = "Y/m/d";
+ }
+
+ $oDyna = new \Dynaform();
+ $dataTask = $oDyna->load($dyn_uid);
+ if ($dataTask['DYN_VERSION'] > 0) {
+ G::LoadClass("pmDynaform");
+ $pmDyna = new \pmDynaform(array('APP_DATA' => array()));
+ $pmDyna->fields["CURRENT_DYNAFORM"] = $dyn_uid;
+ $json = G::json_decode($dataTask["DYN_CONTENT"]);
+ $pmDyna->jsonr($json);
+ $fieldsDyna = $json->items[0]->items;
+
+ $xmlfrm = new \stdclass();
+ $xmlfrm->fields = array();
+ foreach ($fieldsDyna as $key => $value) {
+ //$temp = $value[0];
+ $temp = new \stdclass();
+ $temp->type = $value[0]->type;
+ $temp->label = $value[0]->label;
+ $temp->name = $value[0]->name;
+ $temp->required = $value[0]->required;
+ $temp->mode = $value[0]->mode;
+
+ $temp->storeData = '[';
+ foreach ($value[0]->options as $valueOption) {
+ $temp->storeData .= '{"value":"' . $valueOption['value'] . '", "text":"' . $valueOption['value'] . '"},';
+ }
+ $temp->storeData = substr($temp->storeData,0,-1);
+ $temp->storeData .= ']';
+
+ $temp->readOnly = ($value[0]->mode == 'view') ? "0" : "1";
+ $temp->colWidth = 200;
+ $xmlfrm->fields[] = $temp;
+ }
+ } else {
+ $filename = $pro_uid . PATH_SEP . $dyn_uid . ".xml";
+ if (!class_exists('Smarty')) {
+ require_once(PATH_THIRDPARTY . 'smarty' . PATH_SEP . 'libs' . PATH_SEP . 'Smarty.class.php');
+ }
+ $xmlfrm = new \XmlForm();
+ $xmlfrm->home = PATH_DYNAFORM;
+ $xmlfrm->parseFile($filename, SYS_LANG, true);
+ }
+
+ $caseColumns = array();
+ $caseReaderFields = array();
+
+ $dropList = array();
+ $comboBoxYesNoList = array();
+
+ $caseColumns[] = array("header" => "APP_UID", "dataIndex" => "APP_UID", "width" => 100, "hidden" => true, "hideable" => false);
+ $caseColumns[] = array("header" => "#", "dataIndex" => "APP_NUMBER", "width" => 40, "sortable" => true);
+ $caseColumns[] = array("header" => G::LoadTranslation("ID_TITLE"), "dataIndex" => "APP_TITLE", "width" => 180, "renderer" => "renderTitle", "sortable" => true);
+ $caseColumns[] = array("header" => G::LoadTranslation("ID_SUMMARY"), "width" => 60, "renderer" => "renderSummary", "align" => "center");
+ $caseColumns[] = array("header" => "DEL_INDEX", "dataIndex" => "DEL_INDEX", "width" => 100, "hidden" => true, "hideable" => false);
+
+ $caseReaderFields[] = array("name" => "APP_UID");
+ $caseReaderFields[] = array("name" => "APP_NUMBER");
+ $caseReaderFields[] = array("name" => "APP_TITLE");
+ $caseReaderFields[] = array("name" => "DEL_INDEX");
+
+ //$caseColumns[] = array("header" => "FLAG", "dataIndex" => "FLAG", "width" => 55, "xtype"=>"checkcolumn");
+ //$caseReaderFields[] = array("name" => "FLAG", "type"=>"bool");
+
+ foreach ($xmlfrm->fields as $index => $value) {
+ $field = $value;
+
+ $editor = null;
+ $renderer = null;
+
+ $readOnly = (isset($field->readOnly))? $field->readOnly : null;
+ $required = (isset($field->required))? $field->required : null;
+ $validate = (isset($field->validate))? strtolower($field->validate) : null;
+
+ $fieldReadOnly = ($readOnly . "" == "1")? "readOnly: true," : null;
+ $fieldRequired = ($required . "" == "1")? "allowBlank: false," : null;
+ $fieldValidate = ($validate == "alpha" || $validate == "alphanum" || $validate == "email" || $validate == "int" || $validate == "real")? "vtype: \"$validate\"," : null;
+
+ $fieldLabel = (($fieldRequired != null)? "* ": null) . $field->label;
+ $fieldDisabled = ($field->mode != "edit")? "true" : "false";
+
+ switch ($field->type) {
+ case "dropdown":
+ $dropList[] = $field->name;
+ $align = "left";
+ $editor = "* new Ext.form.ComboBox({
+ id: \"cbo" . $field->name . "_" . $pro_uid . "\",
+
+ valueField: 'value',
+ displayField: 'text',
+
+ /*store: comboStore,*/
+ store: new Ext.data.JsonStore({
+ data: " . htmlspecialchars_decode($field->storeData) . ",
+ fields: [{name: 'value'},
+ {name: 'text'}
+ ]
+ }),
+
+
+ queryMode: 'local',
+ editable: false,
+ disabled: $fieldDisabled,
+ lazyRender: false,
+
+ $fieldReadOnly
+ $fieldRequired
+ $fieldValidate
+ cls: \"\"
+ }) *";
+ $editor = eregi_replace("[\n|\r|\n\r]", ' ', $editor);
+ $width = $field->colWidth;
+
+ $caseColumns[] = array("xtype" => "combocolumn", "gridId" => "gridId", "header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => "true", "clicksToEdit" => "1");
+ $caseReaderFields[] = array("name" => $field->name);
+ break;
+ case "date":
+ //minValue: '01/01/06',
+ //disabledDays: [0, 6],
+ //disabledDaysText: 'Plants are not available on the weekends'
+
+ $align = "center";
+ $size = 100;
+
+ if (isset($field->size)) {
+ $size = $field->size * 10;
+ }
+
+ $width = $size;
+
+ $editor = "* new Ext.form.DateField({
+ format: \"$dateFormat\",
+
+ $fieldReadOnly
+ $fieldRequired
+ $fieldValidate
+ cls: \"\"
+ }) *";
+
+ //$renderer = "* formatDate *";
+ $renderer = "* function (value){
+ return Ext.isDate(value)? value.dateFormat('{$dateFormat}') : value;
+ } *";
+
+ if ($field->mode != "edit") {
+ $editor = null;
+ }
+
+ $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "editor" => $editor, "renderer" => $renderer, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
+ $caseReaderFields[] = array("name" => $field->name, "type" => "date");
+ break;
+ case "currency":
+ //align: 'right',
+ //renderer: 'usMoney',
+ //allowBlank: false,
+ //allowNegative: false,
+ $align = 'right';
+ $size = 100;
+
+ if (isset($field->size)) {
+ $size = $field->size * 10;
+ }
+
+ $width = $size;
+
+ $editor = "* new Ext.form.NumberField({
+ maxValue: 1000000,
+ allowDecimals: true,
+ allowNegative: true,
+
+ $fieldReadOnly
+ $fieldRequired
+ $fieldValidate
+ cls: \"\"
+ }) *";
+
+ if ($field->mode != "edit") {
+ $editor = null;
+ }
+
+ $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
+ $caseReaderFields[] = array("name" => $field->name);
+ break;
+ case "percentage":
+ $align = 'right';
+ $size = 100;
+
+ if (isset($field->size)) {
+ $size = $field->size * 10;
+ }
+
+ $width = $size;
+
+ $editor = "* new Ext.form.NumberField({
+ maxValue: 100,
+ allowDecimals: true,
+
+ $fieldReadOnly
+ $fieldRequired
+ $fieldValidate
+ cls: \"\"
+ }) *";
+
+ $renderer = "* function (value){
+ return (value + ' %');
+ } *";
+
+ if ($field->mode != "edit") {
+ $editor = null;
+ }
+
+ $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "renderer" => $renderer, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
+ $caseReaderFields[] = array("name" => $field->name);
+ break;
+ case "textarea":
+ $align = 'left';
+ $size = 200;
+
+ if (isset($field->size)) {
+ $size = $field->size * 15;
+ }
+
+ $width = $size;
+
+ $editor = "* new Ext.form.TextArea({
+ growMin: 60,
+ growMax: 1000,
+ grow: true,
+ autoHeight: true,
+ disabled: $fieldDisabled,
+ enterIsSpecial: false,
+ preventScrollbars: false,
+
+ $fieldReadOnly
+ $fieldRequired
+ $fieldValidate
+ cls: \"\"
+ }) *";
+
+ $renderer = "* function (value) { return (value); } *";
+
+ $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "renderer" => $renderer, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
+ $caseReaderFields[] = array("name" => $field->name);
+
+ $hasTextArea = true;
+ break;
+ case "link":
+ $align = 'center';
+ $size = 100;
+
+ if (isset($field->size)) {
+ $size = $field->size * 10;
+ }
+
+ $width = $size;
+ $editor = null;
+
+ $renderer = "* function (value)
+ {
+ return linkRenderer(value);
+ } *";
+
+ $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "renderer" => $renderer, "frame" => true, "hidden" => false, "hideable" => false, "clicksToEdit" => 1, "sortable" => true);
+ $caseReaderFields[] = array("name" => $field->name);
+ break;
+ case "hidden":
+ $align = 'left';
+ $size = 100;
+
+ if (isset($field->size)) {
+ $size = $field->size * 10;
+ }
+
+ $width = $size;
+
+ $editor = "* new Ext.form.TextField({ allowBlank: false }) *";
+
+ $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)$width, "align" => $align, "editor" => $editor, "frame" => "true", "hidden" => "true", "hideable" => false, "clicksToEdit" => "1");
+ $caseReaderFields[] = array("name" => $field->name);
+ break;
+ case "yesno":
+ $align = "right";
+ $size = 100;
+
+ if (isset($field->size)) {
+ $size = $field->size * 10;
+ }
+
+ $width = $size;
+ $dropList[] = $field->name;
+ $comboBoxYesNoList[] = $field->name;
+
+ $editor="* new Ext.form.ComboBox({
+ id: \"cbo" . $field->name . "_" . $pro_uid . "\",
+
+ valueField: 'value',
+ displayField: 'text',
+
+ store: new Ext.data.ArrayStore({
+ storeId: \"store" . $field->name . "_" . $pro_uid . "\",
+ fields: ['value', 'text'],
+ data: [[1, 'YES'],
+ [0, 'NO']
+ ]
+ }),
+
+ typeAhead: true,
+
+ triggerAction: 'all',
+ mode: 'local',
+ editable: false,
+ disabled : $fieldDisabled,
+ lazyRender: true,
+
+ $fieldReadOnly
+ $fieldRequired
+ $fieldValidate
+ cls: \"\"
+ }) *";
+
+ /*
+ $renderer = "* function(value) {
+ idx = this.editor.store.find(this.editor.valueField, value);
+ if (currentFieldEdited == '{$field->name}') {
+ if (rec = this.editor.store.getAt(idx)) {
+ rowLabels['{$field->name}'] = rec.get(this.editor.displayField);
+ return rec.get(this.editor.displayField);
+ }
+ else {
+ return value;
+ }
+ }
+ else {
+ if (typeof(currentFieldEdited) == 'undefined') {
+ return value;
+ }
+ else {
+ return (rowLabels['{$field->name}']);
+ }
+ }
+ } *";
+ */
+
+ //$caseColumns[] = array('header' => $fieldLabel, 'dataIndex' => $field->name, 'width' => (int)$width, 'align' => $align, 'editor' => $editor, 'renderer' => $renderer, 'frame' => 'true', 'clicksToEdit' => '1');
+ $caseColumns[] = array("xtype" => "combocolumn", "gridId" => "gridId", "header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => "true", "clicksToEdit" => "1");
+ $caseReaderFields[] = array("name" => $field->name);
+ break;
+ case "text":
+ default:
+ $align = "left";
+ $size = 100;
+
+ if (isset($field->size)) {
+ $size = $field->size * 10;
+ }
+
+ $width = $size;
+ $editor = "* new Ext.form.TextField({ $fieldReadOnly $fieldRequired $fieldValidate cls: \"\"}) *";
+
+ if ($field->mode != "edit") {
+ $editor = null;
+ }
+
+ $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
+ $caseReaderFields[] = array("name" => $field->name);
+ }
+ }
+
+ @unlink(PATH_C . "ws" . PATH_SEP . SYS_SYS . PATH_SEP . "xmlform" . PATH_SEP . $pro_uid . PATH_SEP . $dyn_uid . "." . SYS_LANG);
+
+
+
+ $array ['columnModel'] = $caseColumns;
+ $array ['readerFields'] = $caseReaderFields;
+ $array ["dropList"] = $dropList;
+ $array ["comboBoxYesNoList"] = $comboBoxYesNoList;
+ $array ['hasTextArea'] = $hasTextArea;
+
+ $temp = G::json_encode($array);
+
+ //$temp = str_replace("***","'",$temp);
+ $temp = str_replace('"*','', $temp);
+ $temp = str_replace('*"','', $temp);
+ $temp = str_replace('\t','', $temp);
+ $temp = str_replace('\n','', $temp);
+ $temp = str_replace('\/','/', $temp);
+ $temp = str_replace('\"','"', $temp);
+ $temp = str_replace('"checkcolumn"','\'checkcolumn\'',$temp);
+
+ print $temp;
+ die();
+ }
+
+
+ /**
+ * Get Dropdown Label
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ */
+ public function getDropdownLabel($appUid, $pro_uid, $dyn_uid, $fieldName, $fieldVal)
+ {
+ $oCase = new Cases();
+ $filename = $pro_uid . PATH_SEP . $dyn_uid . ".xml";
+
+ $G_FORM = new xmlform();
+ $G_FORM->home = PATH_DYNAFORM;
+ $G_FORM->parseFile($filename, SYS_LANG, true);
+
+ $aFields = $oCase->loadCase($appUid);
+
+ $arrayTmp = array();
+ $array = array();
+ $sqlQuery = null;
+
+ foreach ($G_FORM->fields as $key => $val) {
+ if ($fieldName == $val->name) {
+ if ($G_FORM->fields[$key]->sql != "") {
+ $sqlQuery = G::replaceDataField($G_FORM->fields[$key]->sql, $aFields ["APP_DATA"]);
+ }
+ if ((is_array($val->options)) && (!empty($val->options))) {
+ foreach ($val->options as $key1 => $val1) {
+ $array[] = array("id" => $key1, "value" => $val1);
+ }
+ }
+ if ($val->type == "yesno") {
+ $array[] = array("id" => 1, "value" => strtoupper(G::LoadTranslation("ID_YES")));
+ $array[] = array("id" => 0, "value" => strtoupper(G::LoadTranslation("ID_NO")));
+ }
+ }
+ }
+
+ if ($sqlQuery != null) {
+ $aResult = executeQuery($sqlQuery);
+ if ($aResult == false) {
+ $aResult = array();
+ }
+ } else {
+ $aResult = array();
+ }
+
+ foreach ($aResult as $field) {
+ $i = 0;
+ foreach ($field as $key => $value) {
+ if ($i == 0) {
+ $arrayTmp["id"] = $value;
+ if (count($field) == 1) {
+ $arrayTmp["value"] = $value;
+ }
+ }
+
+ if ($i == 1) {
+ $arrayTmp["value"] = $value;
+ }
+ $i++;
+ }
+ $array[] = $arrayTmp;
+ }
+
+ foreach ($array as $newKey => $newValue) {
+ if ($newValue["id"] == $fieldVal) {
+ return $newValue["value"];
+ }
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Check Valid Date
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ */
+ public function checkValidDate($field)
+ {
+ if (($timestamp = strtotime($field)) === false || is_double($field) || is_float($field) || is_bool($field) || is_int($field)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * consolidatedUpdate
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ */
+ function consolidatedUpdate($dynaformUid, $dataUpdate, $usr_uid)
+ {
+ G::LoadClass("case");
+ G::LoadClass("pmFunctions");
+
+ $delIndex = 1;
+ $oCase = new \Cases();
+
+ $array = array();
+ $array["form"] = $dataUpdate;
+
+ $appUid = $array["form"]["APP_UID"];
+
+ $fields = $oCase->loadCase($appUid);
+
+ if (!isset($fields["DEL_INIT_DATE"])) {
+ $oCase->setDelInitDate($appUid, $delIndex);
+ //$aFields = $oCase->loadCase($appUid, $delIndex);
+ $fields = $oCase->loadCase($appUid, $delIndex);
+ }
+
+ $auxAppDataApplication = $fields["APP_DATA"]["APPLICATION"];
+ $auxAppDataProcess = $fields["APP_DATA"]["PROCESS"];
+ $auxAppDataTask = $fields["APP_DATA"]["TASK"];
+ $auxAppDataIndex = $fields["APP_DATA"]["INDEX"];
+
+ foreach ($array["form"] as $key => $value) {
+ $array["form"][$key] = (string)$array["form"][$key];
+ }
+ $_POST['form'] = $array["form"];
+ if (!class_exists('Smarty')) {
+ require_once(PATH_THIRDPARTY . 'smarty' . PATH_SEP . 'libs' . PATH_SEP . 'Smarty.class.php');
+ }
+ $oForm = new \Form( $auxAppDataProcess . "/" . $dynaformUid , PATH_DYNAFORM );
+ $oForm->validatePost();
+ $array["form"] = $_POST['form'];
+
+ $fields["APP_DATA"] = array_merge($fields["APP_DATA"], G::getSystemConstants());
+ $fields["APP_DATA"] = array_merge($fields["APP_DATA"], $array["form"]);
+
+ $fields["APP_DATA"]["APPLICATION"] = $auxAppDataApplication;
+ $fields["APP_DATA"]["PROCESS"] = $auxAppDataProcess;
+ $fields["APP_DATA"]["TASK"] = $auxAppDataTask;
+ $fields["APP_DATA"]["INDEX"] = $auxAppDataIndex;
+
+ $aData = array();
+ $aData["APP_NUMBER"] = $fields["APP_NUMBER"];
+ $aData["APP_PROC_STATUS"] = $fields["APP_PROC_STATUS"];
+ $aData["APP_DATA"] = $fields["APP_DATA"];
+ $aData["DEL_INDEX"] = $delIndex;
+ $aData["TAS_UID"] = $fields["APP_DATA"]["TASK"];
+ $aData["CURRENT_DYNAFORM"] = $dynaformUid;
+ $aData["USER_UID"] = $usr_uid;
+ $aData["APP_STATUS"] = $fields["APP_STATUS"];
+ $aData["PRO_UID"] = $fields["APP_DATA"]["PROCESS"];
+
+ $oCase->updateCase($appUid, $aData);
+ }
+}
\ No newline at end of file
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Task.php b/workflow/engine/src/ProcessMaker/BusinessModel/Task.php
index 800fadaf0..4425dab2b 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/Task.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/Task.php
@@ -383,6 +383,23 @@ class Task
}
$result = $task->update($arrayProperty);
+ if (!empty($arrayProperty['CONSOLIDATE_DATA'])) {
+ G::LoadClass("consolidatedCases");
+ $consolidated = new \ConsolidatedCases();
+ $dataConso = array(
+ 'tas_uid' => $arrayProperty['TAS_UID'],
+ 'dyn_uid' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_dynaform'],
+ 'status' => true,
+ 'pro_uid' => $arrayProperty['PRO_UID'],
+ 'rep_uid' => '',
+ 'table_name' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_table'],
+ 'title' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_title'],
+ 'overwrite' => true,
+ 'isBPMN' => true
+ );
+ $consolidated->cochalo($dataConso);
+
+ }
$arrayResult["status"] = "OK";
if ($result == 3) {
diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Consolidated.php b/workflow/engine/src/ProcessMaker/Services/Api/Consolidated.php
new file mode 100644
index 000000000..35705c86f
--- /dev/null
+++ b/workflow/engine/src/ProcessMaker/Services/Api/Consolidated.php
@@ -0,0 +1,156 @@
+
+ * @copyright Colosa - Bolivia
+ *
+ * @protected
+ */
+class Consolidated extends Api
+{
+ /**
+ * Get Consolidated
+ *
+ * @return array
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ *
+ * @url GET /:tas_uid
+ */
+ public function doGet($tas_uid)
+ {
+ try {
+ $consolidated = new \ProcessMaker\BusinessModel\Consolidated();
+ return $consolidated->get($tas_uid);
+ } catch (\Exception $e) {
+ throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
+ }
+ }
+
+ /**
+ * Post Consolidated
+ *
+ * @param array $request_data
+ * @return array
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ *
+ */
+ public function doPost($request_data)
+ {
+ try {
+ $consolidated = new \ProcessMaker\BusinessModel\Consolidated();
+ return $consolidated->post($request_data);
+ } catch (\Exception $e) {
+ throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
+ }
+ }
+
+ /**
+ * Get for Generate Consolidated
+ *
+ * @param string $pro_uid {@min 1} {@max 32}
+ * @param string $tas_uid {@min 1} {@max 32}
+ * @param string $dyn_uid {@min 1} {@max 32}
+ * @return string
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ *
+ * @url GET /generate/:pro_uid/:tas_uid/:dyn_uid
+ */
+ public function doGetGenerateConsolidated($pro_uid, $tas_uid, $dyn_uid)
+ {
+ try {
+ $consolidated = new \ProcessMaker\BusinessModel\Consolidated();
+ return $consolidated->getDataGenerate($pro_uid, $tas_uid, $dyn_uid);
+ } catch (\Exception $e) {
+ throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
+ }
+ }
+
+ /**
+ * Get Cases Consolidated
+ *
+ * @param string $tas_uid {@min 1} {@max 32}
+ * @param string $dyn_uid {@min 1} {@max 32}
+ * @param string $pro_uid {@min 1} {@max 32}
+ * @param string $start {@from path}
+ * @param string $limit {@from path}
+ * @param string $search {@from path}
+ * @return array
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ *
+ * @url GET /cases/:tas_uid/:dyn_uid/:pro_uid
+ */
+ public function doGetCasesConsolidated($tas_uid, $dyn_uid, $pro_uid, $start = '', $limit = '', $search = '')
+ {
+ try {
+ $usr_uid = $this->getUserId();
+ $consolidated = new \ProcessMaker\BusinessModel\Consolidated();
+ $consolidated->getDataGrid($tas_uid, $dyn_uid, $pro_uid, $usr_uid, $start, $limit, $search);
+ } catch (\Exception $e) {
+ throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
+ }
+ }
+
+ /**
+ * Get Cases Consolidated
+ *
+ * @param string $tas_uid {@min 1} {@max 32}
+ * @param string $dyn_uid {@min 1} {@max 32}
+ * @param string $pro_uid {@min 1} {@max 32}
+ * @param array $request_data
+ * @return array
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ *
+ * @url PUT /cases/:tas_uid/:dyn_uid/:pro_uid
+ */
+ public function doPutCasesConsolidated($tas_uid, $dyn_uid, $pro_uid, $request_data)
+ {
+ try {
+ $usr_uid = $this->getUserId();
+ $consolidated = new \ProcessMaker\BusinessModel\Consolidated();
+ return $consolidated->putDataGrid($tas_uid, $dyn_uid, $pro_uid, $usr_uid, $request_data);
+ } catch (\Exception $e) {
+ throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
+ }
+ }
+
+ /**
+ * Post Derivate
+ *
+ * @param string $app_uid {@min 1} {@max 32}
+ * @param string $app_number
+ * @param string $del_index
+ * @return array
+ *
+ * @author Brayan Pereyra (Cochalo)
+ * @copyright Colosa - Bolivia
+ *
+ * @url POST /derivate/:app_uid/:app_number/:del_index
+ */
+ public function doPostDerivate($app_uid, $app_number, $del_index)
+ {
+ try {
+ $usr_uid = $this->getUserId();
+ $consolidated = new \ProcessMaker\BusinessModel\Consolidated();
+ return $consolidated->postDerivate($app_uid, $app_number, $del_index, $usr_uid);
+ } catch (\Exception $e) {
+ throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
+ }
+ }
+}
diff --git a/workflow/engine/src/ProcessMaker/Services/api.ini b/workflow/engine/src/ProcessMaker/Services/api.ini
index c907e69fc..ac846471a 100644
--- a/workflow/engine/src/ProcessMaker/Services/api.ini
+++ b/workflow/engine/src/ProcessMaker/Services/api.ini
@@ -99,4 +99,7 @@ debug = 1
email = "ProcessMaker\Services\Api\EmailServer"
[alias: light]
- light = "ProcessMaker\Services\Api\Light"
\ No newline at end of file
+ light = "ProcessMaker\Services\Api\Light"
+
+[alias: consolidated]
+ list = "ProcessMaker\Services\Api\Consolidated"
diff --git a/workflow/engine/templates/cases/casesListConsolidated.html b/workflow/engine/templates/cases/casesListConsolidated.html
new file mode 100644
index 000000000..7f3366ec5
--- /dev/null
+++ b/workflow/engine/templates/cases/casesListConsolidated.html
@@ -0,0 +1,3 @@
+
+
+
diff --git a/workflow/engine/templates/cases/casesListConsolidated.js b/workflow/engine/templates/cases/casesListConsolidated.js
new file mode 100644
index 000000000..d8f8332b9
--- /dev/null
+++ b/workflow/engine/templates/cases/casesListConsolidated.js
@@ -0,0 +1,1093 @@
+var grdNumRows = 0; //
+var grdRowLabel = []; //
+
+
+
+
+
+Ext.ns("Ext.ux.renderer", "Ext.ux.grid");
+
+Ext.ux.grid.ComboColumn = Ext.extend(Ext.grid.Column, {
+ //@cfg {String} gridId
+ //The id of the grid this column is in. This is required to be able to refresh the view once the combo store has loaded
+
+ gridId: undefined,
+
+ constructor: function (cfg) {
+ Ext.ux.grid.ComboColumn.superclass.constructor.call(this, cfg);
+
+ //Detect if there is an editor and if it at least extends a combobox, otherwise just treat it as a normal column and render the value itself
+ this.renderer = (this.editor && this.editor.triggerAction)? Ext.ux.renderer.ComboBoxRenderer(this.editor, this.gridId) : function (value) { return value; };
+ }
+});
+
+Ext.grid.Column.types["combocolumn"] = Ext.ux.grid.ComboColumn;
+
+//A renderer that makes a editorgrid panel render the correct value
+Ext.ux.renderer.ComboBoxRenderer = function(combo, gridId) {
+ //Get the displayfield from the store or return the value itself if the record cannot be found
+
+ //var str = combo.getId().substring(3); //
+ //var i = str.lastIndexOf("_"); //
+ //var fieldName = str.substring(0, i); //
+ //var processUID = str.substring(i + 1); //
+ var comboBoxField = combo.getId().substring(3); //
+ var str = ""; //
+
+ var getValueComboBox = function (value) {
+ var idx = combo.store.find(combo.valueField, value);
+ var rec = combo.store.getAt(idx);
+ if (rec) {
+ //return rec.get(combo.displayField);
+ if (grdNumRows > 1 || grdNumRows == 0) {
+ return rec.get(combo.displayField);
+ } else {
+ str = rec.get(combo.displayField);
+ grdRowLabel[comboBoxField] = str;
+ return str;
+ }
+ }
+
+ //return value;
+ if (grdNumRows > 1 || grdNumRows == 0) {
+ return value;
+ } else {
+ if (value) {
+ grdRowLabel[comboBoxField] = value;
+ } else {
+ value = grdRowLabel[comboBoxField];
+ }
+
+ return value;
+ }
+ }
+
+ return function (value) {
+ //If we are trying to load the displayField from a store that is not loaded, add a single listener to the combo store's load event to refresh the grid view
+
+ if (combo.store.getCount() == 0 && gridId) {
+ combo.store.on(
+ "load",
+ function () {
+ var grid = Ext.getCmp(gridId);
+ if (grid) {
+ grid.getView().refresh();
+ }
+ },
+ {
+ single: true
+ }
+ );
+
+ //return value;
+ if (grdNumRows > 1 || grdNumRows == 0) {
+ return value;
+ } else {
+ if (typeof(grdRowLabel[comboBoxField]) == "undefined") {
+ grdRowLabel[comboBoxField] = value;
+ return grdRowLabel[comboBoxField];
+ } else {
+ return grdRowLabel[comboBoxField];
+ }
+ }
+ }
+
+ //return getValueComboBox(value);
+ str = getValueComboBox(value); //
+ if (grdNumRows > 1 || grdNumRows == 0) {
+ return str;
+ } else {
+ return grdRowLabel[comboBoxField];
+ }
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Ext.QuickTips.init();
+
+Ext.namespace("Ext.ux");
+
+/*
+Ext.ux.comboBoxRenderer = function(combo) {
+ return function(value) {
+ var idx = combo.store.find(combo.valueField, value);
+ var rec = combo.store.getAt(idx);
+ return rec.get(combo.displayField);
+ };
+};
+*/
+
+//
+//screen.width, screen.height
+var browserWidth = 0;
+var browserHeight = 0;
+
+//The more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
+if (typeof window.innerWidth != "undefined") {
+ browserWidth = window.innerWidth;
+ browserHeight = window.innerHeight;
+}
+else {
+ //IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
+ if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" &&
+ document.documentElement.clientWidth != 0) {
+ browserWidth = document.documentElement.clientWidth;
+ browserHeight = document.documentElement.clientHeight;
+ } else {
+ if (typeof document.documentElement != "undefined" && typeof document.documentElement.offsetHeight != "undefined") {
+ //windows
+ browserWidth = document.documentElement.offsetWidth;
+ browserHeight = document.documentElement.offsetHeight;
+ } else {
+ //Older versions of IE
+ browserWidth = document.getElementsByTagName("body")[0].clientWidth;
+ browserHeight = document.getElementsByTagName("body")[0].clientHeight;
+ }
+ }
+}
+//
+
+/*
+var gridHeight;
+if (window.innerHeight){
+ gridHeight = window.innerHeight - 30;
+}else {
+ gridHeight = 350;
+}
+*/
+
+new Ext.KeyMap(document, {
+ key: Ext.EventObject.F5,
+ fn: function(keycode, e) {
+ if (!e.ctrlKey) {
+ if (Ext.isIE) {
+ // IE6 doesn't allow cancellation of the F5 key, so trick it into
+ // thinking some other key was pressed (backspace in this case)
+ e.browserEvent.keyCode = 8;
+ }
+ e.stopEvent();
+ //document.location = document.location;
+ //Ext.getCmp('storeConsolidatedGrid').reload();
+ storeConsolidated.reload();
+ } else {
+ Ext.Msg.alert(_("ID_REFRESH_LABEL"), _("ID_REFRESH_MESSAGE"));
+ }
+ }
+});
+
+//var comboStore = new Ext.data.JsonStore({
+// proxy: new Ext.data.HttpProxy({
+// url: "proxyDataCombobox"
+// }),
+// root: "records",
+// fields: [{name: "value"},
+// {name: "id"}
+// ]
+//});
+
+//var gridId = Ext.id();
+var gridId = "editorGridPanelMain";
+var storeAux;
+
+//Global variables
+var storeConsolidated;
+var toolbarconsolidated;
+//var tb;
+var consolidatedGrid;
+var grid;
+var textJump;
+var readerCasesList;
+var writerCasesList;
+var proxyCasesList ;
+var htmlMessage;
+//var currentFieldEdited;
+
+//var rowLabels = [];
+
+var smodel;
+
+function openCase(){
+ var rowModel = consolidatedGrid.getSelectionModel().getSelected();
+ if(rowModel){
+ var appUid = rowModel.data.APP_UID;
+ var delIndex = rowModel.data.DEL_INDEX;
+ var caseTitle = (rowModel.data.APP_TITLE) ? rowModel.data.APP_TITLE : rowModel.data.APP_UID;
+
+ Ext.Msg.show({
+ msg: _("ID_OPEN_CASE") + " " + caseTitle,
+ width:300,
+ wait:true,
+ waitConfig: {
+ interval:200
+ }
+ });
+ params = '';
+ switch(action){
+ case 'consolidated':
+ default:
+ params += 'APP_UID=' + appUid;
+ params += '&DEL_INDEX=' + delIndex;
+ requestFile = '../../'+varSkin+'/cases/open';
+ break;
+ }
+ params += '&action=' + 'todo';
+ redirect(requestFile + '?' + params);
+
+ } else {
+ msgBox(_("ID_INFORMATION"), _("ID_SELECT_ONE_AT_LEAST"));
+ }
+}
+
+function jumpToCase(appNumber){
+ Ext.MessageBox.show({ msg: _('ID_PROCESSING'), wait:true,waitConfig: {interval:200} });
+ Ext.Ajax.request({
+ url: 'cases_Ajax',
+ success: function(response) {
+ var res = Ext.decode(response.responseText);
+ if (res.exists === true) {
+ params = 'APP_NUMBER=' + appNumber;
+ params += '&action=jump';
+ requestFile = '../cases/open';
+ redirect(requestFile + '?' + params);
+ } else {
+ Ext.MessageBox.hide();
+ var message = new Array();
+ message['CASE_NUMBER'] = appNumber;
+ msgBox(_('ID_INPUT_ERROR'), _('ID_CASE_DOES_NOT_EXIST_JS', appNumber), 'error');
+ }
+ },
+ params: {action:'previusJump', appNumber: appNumber}
+ });
+}
+
+function pauseCase(date){
+ rowModel = consolidatedGrid.getSelectionModel().getSelected();
+ unpauseDate = date.format('Y-m-d');
+
+ Ext.Msg.confirm(
+ _("ID_CONFIRM"),
+ _("ID_PAUSE_CASE_TO_DATE") + " " + date.format("M j, Y"),
+ function(btn, text){
+ if ( btn == 'yes' ) {
+ Ext.MessageBox.show({
+ msg: _("ID_PROCESSING"),
+ wait:true,
+ waitConfig: {
+ interval:200
+ }
+ });
+ Ext.Ajax.request({
+ url: '../cases/cases_Ajax',
+ success: function(response) {
+ parent.updateCasesView();
+ parent.updateCasesTree();
+ Ext.MessageBox.hide();
+ },
+ params: {
+ action:'pauseCase',
+ unpausedate:unpauseDate,
+ APP_UID:rowModel.data.APP_UID,
+ DEL_INDEX: rowModel.data.DEL_INDEX
+ }
+ });
+ }
+ }
+ );
+}
+
+function redirect(href){
+ window.location.href = href;
+}
+
+function strReplace(strs, strr, str)
+{
+ var expresion = eval("/" + strs + "/gi");
+ return (str.replace(expresion, strr));
+}
+
+function toolTipTab(str, show)
+{
+ document.getElementById("toolTipTab").innerHTML = str;
+ document.getElementById("toolTipTab").style.left = "3px"; //x
+ document.getElementById("toolTipTab").style.top = "27px"; //y
+ document.getElementById("toolTipTab").style.display = (show == 1)? "inline" : "none";
+}
+
+var pnlMain;
+
+Ext.apply(Ext.form.VTypes,{
+ "int": function (value, field)
+ {
+ return /^\d*$/.test(value);
+ },
+ intText: "This field should only contain numbers",
+ intMask: /[\d]/,
+
+ real: function (value, field)
+ {
+ return /^\d*\.?\d*$/.test(value);
+ },
+ realText: "This field should only contain numbers and the point",
+ realMask: /[\d\.]/
+});
+
+Ext.onReady(function () {
+ pnlMain = new Ext.Panel({
+ title : '',
+ renderTo : 'cases-grid',
+ //autoHeight : true,
+ //height : 300,
+ layout : 'fit',
+ layoutConfig : {
+ align : 'stretch'
+ }
+ });
+
+ //pnlMain = new Ext.Panel({
+ // id: "pnlMain",
+ //
+ // region: "center",
+ // margins: {top:3, right:3, bottom:3, left:3},
+ // //bodyStyle: "padding: 25px 25px 25px 25px;", //propiedades ...
+ // border: false
+ //});
+
+ //LOAD ALL PANELS
+ //var viewport = new Ext.Viewport({
+ // layout:"fit",
+ // items:[pnlMain]
+ //});
+
+ parent._action = action;
+
+ optionMenuOpen = new Ext.Action({
+ text: _("ID_OPEN_CASE"),
+ iconCls: 'ICON_CASES_OPEN',
+ handler: openCase
+ });
+
+ optionMenuPause = new Ext.Action({
+ text: _("ID_PAUSE_CASE"),
+ iconCls: 'ICON_CASES_PAUSED',
+ menu: new Ext.menu.DateMenu({
+ //vtype: 'daterange',
+ handler: function(dp, date){
+ pauseCase(date);
+ }
+ })
+
+ });
+
+ var buttonProcess = new Ext.Action({
+ text: "Derivate",
+ //iconCls: 'ICON_CASES_PAUSED',
+ handler : function (){
+ htmlMessage = "";
+ var selectedRow = Ext.getCmp(gridId).getSelectionModel().getSelections();
+ var maxLenght = selectedRow.length;
+ for (var i in selectedRow) {
+ if (selectedRow[i].data) {
+ //alert (derivateRequestAjax(selectedRow[i].data["company"]));
+ ajaxDerivationRequest(selectedRow[i].data["APP_UID"], selectedRow[i].data["DEL_INDEX"], maxLenght, selectedRow[i].data["APP_NUMBER"]);
+ }
+ }
+ }
+ });
+ switch(action){
+ case 'consolidated':
+ menuItems = [buttonProcess, optionMenuOpen];
+ break;
+ default:
+ menuItems = [];
+ break;
+ }
+
+ var tabs = new Ext.TabPanel({
+ autoWidth: true,
+ enableTabScroll: true,
+ activeTab: 0,
+ //resizeTabs: true,
+ style: {
+ //height: "1.55em"
+ height: "1.65em"
+ //,
+ //border: "5px solid blue"
+ },
+ defaults:{
+ autoScroll: true
+ },
+ items: eval(Items),
+ plugins: new Ext.ux.TabCloseMenu()
+ });
+
+ smodel = new Ext.grid.CheckboxSelectionModel({
+ listeners:{
+ selectionchange: function(sm){
+ var count_rows = sm.getCount();
+ switch(count_rows){
+ case 0:
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ });
+
+ var textSearch = new Ext.form.TextField ({
+ allowBlank: true,
+ ctCls:'pm_search_text_field',
+ width: 150,
+ emptyText: _("ID_EMPTY_SEARCH"),
+ listeners: {
+ specialkey: function(f,e){
+ if (e.getKey() == e.ENTER) {
+ doSearch();
+ }
+ }
+ }
+ });
+
+ var btnSearch = new Ext.Button ({
+ text: _("ID_SEARCH"),
+ handler: doSearch
+ });
+
+ function doSearch(){
+ searchText = textSearch.getValue();
+ storeConsolidated.setBaseParam( 'search', searchText);
+ storeConsolidated.load({
+ params:{
+ start : 0 ,
+ limit : 20
+ }
+ });
+ }
+
+ var resetSearchButton = {
+ text:'X',
+ ctCls:'pm_search_x_button',
+ handler: function(){
+ textSearch.setValue('');
+ doSearch();
+ }
+ };
+
+ textJump = {
+ xtype: 'numberfield',
+ id : 'textJump',
+ allowBlank: true,
+ width: 50,
+ emptyText: _("ID_CASESLIST_APP_UID"),
+ listeners: {
+ specialkey: function(f,e){
+ if (e.getKey() == e.ENTER) {
+ // defining an id and using the Ext.getCmp method improves the accesibility of Ext components
+ caseNumber = parseFloat(Ext.util.Format.trim(Ext.getCmp('textJump').getValue()));
+ if (caseNumber) {
+ jumpToCase(caseNumber);
+ } else {
+ msgBox('Input Error', 'You have set a invalid Application Number', 'error');
+ }
+ }
+ }
+ }
+ };
+
+ var btnJump = new Ext.Button ({
+ text: _("ID_OPT_JUMP"),
+ handler: function(){
+ var caseNumber = parseFloat(Ext.util.Format.trim(Ext.getCmp('textJump').getValue()));
+ if (caseNumber) {
+ jumpToCase(caseNumber);
+ } else {
+ msgBox('Input Error', 'You have set a invalid Application Number', 'error');
+ }
+ }
+ });
+
+ function enableDisableMenuOption(){
+ var rl = Ext.getCmp(gridId).store.getModifiedRecords();
+ //alert ('-'+rl+'-');
+ var rows = consolidatedGrid.getSelectionModel().getSelections();
+ if (rl.toString()!='') {
+ //alert(rl);
+ optionMenuOpen.setDisabled(true);
+ optionMenuPause.setDisabled(true);
+ buttonProcess.setDisabled(true);
+ return;
+ }
+ switch(action){
+ case 'consolidated':
+ if (rows.length == 0) {
+ optionMenuOpen.setDisabled(true);
+ optionMenuPause.setDisabled(true);
+ buttonProcess.setDisabled(true);
+ } else if( rows.length == 1 ) {
+ optionMenuOpen.setDisabled(false);
+ optionMenuPause.setDisabled(false);
+ buttonProcess.setDisabled(false);
+ } else {
+ optionMenuOpen.setDisabled(true);
+ optionMenuPause.setDisabled(true);
+ buttonProcess.setDisabled(false);
+ }
+ break;
+ }
+
+ }
+
+ toolbarconsolidated = [
+ {
+ xtype: "button",
+ text: _("ID_ACTIONS"),
+ menu: menuItems,
+ listeners: {
+ menushow: enableDisableMenuOption
+ }
+ },
+ "->",
+ {
+ xtype: "checkbox",
+ id: "chk_allColumn",
+ name: "chk_allColumn",
+ boxLabel: "Apply changes to all rows"
+ },
+ "",
+ "-",
+ textSearch,
+ resetSearchButton,
+ btnSearch,
+ "-",
+ textJump,
+ "",
+ btnJump
+ ];
+
+ //tb = new Ext.Toolbar({
+ // height: 33,
+ // items: toolbarconsolidated
+ //});
+
+ var viewport = new Ext.Viewport({
+ layout: "fit",
+ autoScroll: true,
+
+ //items:[tabs, {id:"myDiv", border:false}]
+ items: [tabs]
+ });
+
+ //routine to hide the debug panel if it is open
+ if (parent.PANEL_EAST_OPEN) {
+ parent.PANEL_EAST_OPEN = false;
+ var debugPanel = parent.Ext.getCmp('debugPanel');
+ debugPanel.hide();
+ debugPanel.ownerCt.doLayout();
+ }
+
+ _nodeId = '';
+ switch(action){
+ case 'consolidated':
+ _nodeId = "ID_CASES_CONSOLIDATED";
+ break;
+ }
+
+ if (_nodeId != '') {
+ treePanel1 = parent.Ext.getCmp('tree-panel');
+ if (treePanel1) {
+ node = treePanel1.getNodeById(_nodeId);
+ }
+ if (node) {
+ node.select();
+ }
+ }
+
+ //parent.updateCasesView();
+ parent.updateCasesTree();
+
+ function inArray(arr, obj) {
+ for (var i=0; i';
+ return ("" + val + "");
+}
+
+function renderSummary (val, p, r) {
+ var summaryIcon = '';
+ return summaryIcon;
+ };
+
+
+function generateGrid(proUid, tasUid, dynUid)
+{
+ var pager = 20; //pageSize
+ var pagei = 0; //start
+
+ Ext.Ajax.request({
+ url: urlProxy + 'generate/' + proUid + '/' + tasUid + '/' + dynUid,
+ //url: '../pmConsolidatedCL/proxyGenerateGrid',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Bearer ' + credentials.access_token
+ },
+ success: function(response) {
+ //Obtenemos el column model y los reader fields de proxyGenerateGrid
+ //console.log(response.responseText);
+ var dataResponse = Ext.util.JSON.decode(response.responseText);
+ var viewConfigObject;
+ var textArea = dataResponse.hasTextArea;
+
+ if (textArea == false) {
+ viewConfigObject = { //forceFit: true
+ };
+ } else {
+ viewConfigObject = {
+ //forceFit:true,
+ enableRowBody:true,
+ showPreview:true,
+ getRowClass : function(record, rowIndex, p, store){
+ if (this.showPreview) {
+ p.body = '
';
+ return 'x-grid3-row-expanded';
+ }
+ return 'x-grid3-row-collapsed';
+ }
+ };
+ }
+ storeConsolidated = new Ext.data.Store({
+ id: "storeConsolidatedGrid",
+ remoteSort: true,
+ //definimos un proxy como un objeto de la clase HttpProxy
+ proxy: new Ext.data.HttpProxy({
+ method: 'GET',
+ url: urlProxy + 'cases/' + proUid + '/' + tasUid + '/' + dynUid,
+ api: {
+ read: {
+ method: 'GET',
+ url: urlProxy + 'cases/' + proUid + '/' + tasUid + '/' + dynUid
+ },
+ update: {
+ method: 'PUT',
+ url: urlProxy + 'cases/' + proUid + '/' + tasUid + '/' + dynUid
+ }
+ },
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Bearer ' + credentials.access_token
+ }
+ }),
+ //el data reader obtiene los reader fields de la consulta en ajax
+ reader: new Ext.data.JsonReader({
+ fields: dataResponse.readerFields,
+ totalProperty: "totalCount",
+ //successProperty: "success",
+ idProperty: "APP_UID",
+ root: "data",
+ messageProperty: "message"
+ }),
+
+ //el data writer es un objeto generico pero q permitira a futuro el escribir los datos al servidor mediante el proxy
+ writer: new Ext.data.JsonWriter({
+ encode: false,
+ writeAllFields: false
+ }), //<-- plug a DataWriter into the store just as you would a Reader
+ autoSave: true, //<-- false would delay executing create, update, destroy requests until specifically told to do so with some [save] buton.
+
+ //el ordenamiento para los campos posiblemente este tenga q ser el tercer dato obtenido del proxy dado q los listados son muy cambiantes de tarea en tarea
+ //sortInfo:{
+ // field: 'APP_CACHE_VIEW.APP_NUMBER',
+ // direction: "DESC"
+ //}
+
+ //,
+ listeners: { //
+ beforeload:function (store, options) { //
+ grdNumRows = 0; //
+ }, //
+
+ load:function (store, records, options) { //
+ grdNumRows = store.getCount(); //
+
+ consolidatedGrid.setDisabled(false);
+ } //
+ } //
+ });
+
+ //carga de datos del data store via un request en Ajax
+ //storeConsolidated.load();
+ //ejemplo de un load con parametros para un data store
+ //storeConsolidated.load({params:{start: 0 , limit: pageSize, action: 'todo'}});
+ //definicion del column model basados en la respuesta del servidor
+ //shorthand alias
+ //var fm = Ext.form;
+ var xColumns = dataResponse.columnModel;
+ xColumns.unshift(smodel);
+
+ var cm = new Ext.grid.ColumnModel(xColumns);
+ cm.config[2].renderer = renderTitle; //Case Number
+ cm.config[3].renderer = renderTitle; //Case Title
+ cm.config[4].renderer = renderSummary;//Case Summary
+
+ //generacion del grid basados en los atributos definidos con anterioridad
+ /*
+ storeConsolidated.setBaseParam("limit", pager);
+ storeConsolidated.setBaseParam("start", pagei);
+ storeConsolidated.setBaseParam('tasUid', tasUid);
+ storeConsolidated.setBaseParam('dynUid', dynUid);
+ storeConsolidated.setBaseParam('proUid', proUid);
+ storeConsolidated.setBaseParam('dropList', Ext.util.JSON.encode(dataResponse.dropList));
+ */
+ storeConsolidated.load();
+
+ consolidatedGrid = new Ext.grid.EditorGridPanel({
+ id: gridId,
+ region: "center",
+
+ store: storeConsolidated,
+ cm: cm,
+ sm: smodel,
+ //autoHeight: true,
+
+ //height: pnlMain.getSize().height - pnlMain.getFrameHeight(), //
+ width: pnlMain.getSize().width, //
+ height: browserHeight - 35, //
+
+ layout: 'fit',
+ //plugins: filters,
+ viewConfig: viewConfigObject,
+
+ listeners: {
+ beforeedit: function (e) {
+ var selRow = Ext.getCmp(gridId).getSelectionModel().getSelected();
+
+ var swDropdown = 0;
+ for (var i = 0; i <= dataResponse.dropList.length - 1 && swDropdown == 0; i++) {
+ if (dataResponse.dropList[i] == e.field) {
+ swDropdown = 1;
+ }
+ }
+
+ var swYesNo = 0;
+ for (var i = 0; i <= dataResponse.comboBoxYesNoList.length - 1 && swYesNo == 0; i++) {
+ if (dataResponse.comboBoxYesNoList[i] == e.field) {
+ swYesNo = 1;
+ }
+ }
+
+ //Saving the row previous values in order to fix the change label bug
+ //Este bug se reproduce: cuando se cambia un dropdown y luego de otro row por ej un text se cambia su valor, el text del dropdown se copiaba a la fila del text actual en su dropdown, y asi
+ //if (typeof(rowLabels["APP_UID"]) == "undefined" || selRow.data["APP_UID"] != rowLabels["APP_UID"]){
+ // for (var key in selRow.data) {
+ // rowLabels[key] = selRow.data[key];
+ // }
+ //}
+
+ //if (typeof(rowLabels["APP_UID"]) == "undefined"){
+ // for (var key in selRow.data) {
+ // rowLabels[key] = selRow.data[key];
+ // }
+ //}
+ //else {
+ // if(selRow.data["APP_UID"] != rowLabels["APP_UID"]) {
+ // for (var key in selRow.data) {
+ // rowLabels[key] = selRow.data[key];
+ // }
+ // }
+ // //else {
+ // //
+ // //}
+ //}
+
+ if (swDropdown == 1 && swYesNo == 0) {
+ //comboStore.setBaseParam('appUid', selRow.data['APP_UID']);
+ //comboStore.setBaseParam('dynUid', dynUid);
+ //comboStore.setBaseParam('proUid', proUid);
+ //comboStore.setBaseParam('fieldName', e.field);
+ //currentFieldEdited = e.field;
+ //comboStore.load();
+
+ }
+ },
+
+ afteredit: function (e) {
+ //var store = consolidatedGrid.getStore();
+
+ if (Ext.getCmp("chk_allColumn").checked) {
+ Ext.Msg.show({
+ title: "",
+ msg: "The modification will be applied to all rows in your selection.",
+ buttons: Ext.Msg.YESNO,
+ fn: function (btn) {
+ if (btn == "yes") {
+ //storeConsolidated.each(function (record) {
+ // record.set(e.field, e.value);
+ //});
+
+ consolidatedGrid.setDisabled(true);
+
+ var dataUpdate = "";
+ var strValue = "";
+ var sw = 0;
+
+ if (e.value instanceof Date) {
+ var mAux = e.value.getMonth() + 1;
+ var dAux = e.value.getDate();
+ var hAux = e.value.getHours();
+ var iAux = e.value.getMinutes();
+ var sAux = e.value.getSeconds();
+
+ strValue = e.value.getFullYear() + "-" + ((mAux <= 9)? "0" : "") + mAux + "-" + ((dAux <= 9)? "0" : "") + dAux;
+ strValue = strValue + " " + ((hAux <= 9)? "0" + ((hAux == 0)? "0" : hAux) : hAux) + ":" + ((iAux <= 9)? "0" + ((iAux == 0)? "0" : iAux) : iAux) + ":" + ((sAux <= 9)? "0" + ((sAux == 0)? "0" : sAux) : sAux);
+ } else {
+ strValue = strReplace("\"", "\\\"", e.value + "");
+ }
+
+ storeConsolidated.each(function (record) {
+ dataUpdate = dataUpdate + ((sw == 1)? "(sep1 /)": "") + record.data["APP_UID"] + "(sep2 /)" + e.field + "(sep2 /)" + strValue;
+ sw = 1;
+ });
+
+ ///////
+ Ext.Ajax.request({
+ url: "consolidatedUpdateAjax",
+ method: 'PUT',
+ url: urlProxy + 'cases/' + proUid + '/' + tasUid + '/' + dynUid,
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Bearer ' + credentials.access_token
+ },
+ jsonData: {
+ "option": "ALL",
+ "dynaformUid": dynUid,
+ "dataUpdate": dataUpdate
+ },
+ success: function (response, opts) {
+ var dataResponse = eval("(" + response.responseText + ")"); //json
+
+ if (dataResponse.status && dataResponse.status == "OK") {
+ if (typeof(storeConsolidated.lastOptions.params) != "undefined") {
+ pagei = storeConsolidated.lastOptions.params.start;
+ }
+
+ storeConsolidated.setBaseParam("start", pagei);
+ storeConsolidated.load();
+ } else {
+ //
+ }
+ }
+ });
+ }
+ },
+ //animEl: "elId",
+ icon: Ext.MessageBox.QUESTION
+ });
+ }
+ },
+
+ mouseover: function (e, cell) {
+ var rowIndex = consolidatedGrid.getView().findRowIndex(cell);
+ if (!(rowIndex === false)) {
+ var record = consolidatedGrid.store.getAt(rowIndex);
+ var msg = record.get('APP_TITLE');
+ Ext.QuickTips.register({
+ text: msg,
+ target: e.target
+ });
+ } else {
+ Ext.QuickTips.unregister(e.target);
+ }
+ },
+
+ mouseout: function (e, cell) {
+ Ext.QuickTips.unregister(e.target);
+ }
+ },
+
+ //tbar: tb,
+
+ tbar: new Ext.Toolbar({
+ height: 33,
+ items: toolbarconsolidated
+ }),
+
+ bbar: new Ext.PagingToolbar({
+ pageSize: pager,
+ store: storeConsolidated,
+ displayInfo: true,
+ displayMsg: _("ID_DISPLAY_ITEMS"),
+ emptyMsg: _("ID_DISPLAY_EMPTY")
+ })
+ });
+
+ //remocion de todos los elementos del panel principal donde se carga el grid
+ //Ext.ComponentMgr.get("myId").body.update("");
+ //pnlMain.removeAll(false);
+ pnlMain.removeAll();
+ //adicion del grid definido con anterioridad
+ pnlMain.add(consolidatedGrid);
+ //recarga de los elementos del grid, para su visualizacion.
+ pnlMain.doLayout();
+ },
+
+ //en caso de fallo ejecutar la siguiente funcion.
+ failure: function(){
+ alert("Failure...");
+ }
+ });
+}
+
+function ajaxDerivationRequest(appUid, delIndex, maxLenght, appNumber){
+ Ext.Ajax.request({
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Bearer ' + credentials.access_token
+ },
+ url: urlProxy + 'derivate/' + appUid + '/' + appNumber + '/' + delIndex,
+ success: function(response) {
+ var dataResponse;
+ var fullResponseText = response.responseText;
+
+ if (fullResponseText.charAt(0) != "<") {
+ dataResponse = Ext.util.JSON.decode(response.responseText);
+ } else {
+ dataResponse = Ext.util.JSON.decode("{message:\"Case Derivated\"}");
+ storeConsolidated.reload();
+ }
+
+ htmlMessage = htmlMessage + dataResponse.message + "
";
+ var tmpIndex = htmlMessage.split("
");
+ index = tmpIndex.length - 1;
+
+ if (index == maxLenght) {
+ Ext.MessageBox.show({
+ title: "Derivation Result",
+ msg: htmlMessage,
+ buttons: Ext.MessageBox.OK,
+
+ fn: function (btn, text, opt) {
+ //if (btn == "ok") {}
+ if (maxLenght == storeConsolidated.getCount()) {
+ window.location.reload();
+ }
+
+ if (fullResponseText.charAt(0) != "<") {
+ parent.document.getElementById("batchRoutingCasesNumRec").innerHTML = parseInt(dataResponse.casesNumRec);
+ }
+
+ storeConsolidated.reload();
+ }
+ });
+ }
+ //if an exception die trigger happens
+ },
+
+ failure: function() {
+ index = tmpIndex.length - 1;
+ htmlMessage = htmlMessage + "failed: " + appUid;
+
+ if (index == maxLenght) {
+ Ext.Msg.show({
+ title: "Derivation Result",
+ msg: htmlMessage
+ });
+ storeConsolidated.reload();
+ }
+ }
+ });
+}
+
+function linkRenderer(value)
+{
+ return "" + value + "";
+}
+