/**
  * tdClass
  *
  * @param  string $values
  * @param  string $owner 
  *
  * @return $value
  */
 function tdClass($values, $owner)
 {
     $value = G::replaceDataField($this->condition, $owner->values);
     $value = @eval('return (' . $value . ');');
     $row = $values['row__'];
     $style = $row % 2 == 0 ? $this->classNameAlt : $this->className;
     return $value ? $style : '';
 }
 public function render($value, $owner = null)
 {
     $url = G::replaceDataField($this->file, $owner->values);
     if ($this->home === "methods") {
         $url = G::encryptlink(SYS_URI . $url);
     }
     if ($this->home === "public_html") {
         $url = '/' . $url;
     }
     return '<img src="' . htmlentities($url, ENT_QUOTES, 'utf-8') . '" ' . ($this->style ? 'style="' . $this->style . '"' : '') . ' alt ="' . htmlentities($value, ENT_QUOTES, 'utf-8') . '"/>';
 }
示例#3
0
 /**
  * Function renderField
  * @author David S. Callizaya S. <*****@*****.**>
  * @access public
  * @parameter string row
  * @parameter string r
  * @parameter string result
  * @return string
  */
 function renderField($row, $r, $result)
 {
     global $G_DATE_FORMAT;
     //BEGIN: Special content: __sqlEdit__,__sqlDelete__
     $result['sqlDelete__'] = "pagedTable.event='Delete';pagedTable_DoIt=true;if (pagedTable.onDeleteField) pagedTable_DoIt=eval(pagedTable.onDeleteField);if (pagedTable_DoIt) document.getElementById('pagedTable').outerHTML=ajax_function('{$this->ajaxServer}','delete','field='+encodeURIComponent('" . $this->fieldDataList . "'));if (pagedTable.afterDeleteField) return eval(pagedTable.afterDeleteField); else return false;";
     $result['sqlEdit__'] = "pagedTable.event='Update';pagedTable.field=encodeURIComponent('" . $this->fieldDataList . "');pagedTable.updateField(pagedTable.field);return false;";
     $result['pagedTableField__'] = "'" . $this->fieldDataList . "'";
     $result['row__'] = $row;
     //END: Special content.
     //Merge $result with $xmlForm values (for default valuesSettings)
     $result = array_merge($this->xmlForm->values, $result);
     switch (true) {
         case $this->style[$r]['data'] != '':
             $value = isset($result[$this->style[$r]['data']]) ? $result[$this->style[$r]['data']] : '';
             break;
         default:
             $value = $this->fields[$r]['Label'];
     }
     switch ($this->fields[$r]['Type']) {
         case 'date':
             /*Accept dates like 20070515 without - or / to separate its parts*/
             if (strlen($value) <= 10 && strlen($value) > 4) {
                 $value = str_replace('/', '-', $value);
                 if (strpos($value, '-') === FALSE) {
                     $value = substr($value, 0, 4) . '-' . substr($value, 4, 2) . '-' . substr($value, 6, 2);
                 }
             }
     }
     $this->tpl->newBlock("field");
     $this->tpl->assign('width', $this->style[$r]['colWidth']);
     $this->tpl->assign('widthPercent', $this->style[$r]['colWidth'] * 100 / $this->totalWidth . '%');
     $this->tpl->assign('className', isset($this->style[$r]['colClassName']) && $this->style[$r]['colClassName'] ? $this->style[$r]['colClassName'] : $this->tdClass);
     $this->tpl->assign('style', $this->tdStyle);
     if (isset($this->style[$r]['align'])) {
         $this->tpl->assign("align", $this->style[$r]['align']);
     }
     if (isset($this->style[$r]['colAlign'])) {
         $this->tpl->assign("align", $this->style[$r]['colAlign']);
     }
     /**
      * BEGIN : Reeplace of @@, @%,... in field's attributes like onclick, link,
      *         ...
      */
     if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->onclick)) {
         $this->xmlForm->fields[$this->fields[$r]['Name']]->onclick = G::replaceDataField($this->style[$r]['onclick'], $result);
     }
     if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->link)) {
         $this->xmlForm->fields[$this->fields[$r]['Name']]->link = G::replaceDataField($this->style[$r]['link'], $result);
     }
     if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->value)) {
         $this->xmlForm->fields[$this->fields[$r]['Name']]->value = G::replaceDataField($this->style[$r]['value'], $result);
     }
     /**
      * BREAK : Reeplace of @@, @%,...
      */
     /**
      * Rendering of the field
      */
     $this->xmlForm->setDefaultValues();
     $this->xmlForm->setValues($result);
     $this->xmlForm->fields[$this->fields[$r]['Name']]->mode = 'view';
     if (array_search('rendergrid', get_class_methods(get_class($this->xmlForm->fields[$this->fields[$r]['Name']]))) !== FALSE || array_search('renderGrid', get_class_methods(get_class($this->xmlForm->fields[$this->fields[$r]['Name']]))) !== FALSE) {
         $htmlField = $this->xmlForm->fields[$this->fields[$r]['Name']]->renderGrid(array($value), $this->xmlForm);
         $this->tpl->assign("value", $htmlField[0]);
     } else {
     }
     /**
      * CONTINUE : Reeplace of @@, @%,...
      */
     if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->onclick)) {
         $this->xmlForm->fields[$this->fields[$r]['Name']]->onclick = $this->style[$r]['onclick'];
     }
     if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->link)) {
         $this->xmlForm->fields[$this->fields[$r]['Name']]->link = $this->style[$r]['link'];
     }
     if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->value)) {
         $this->xmlForm->fields[$this->fields[$r]['Name']]->value = $this->style[$r]['value'];
     }
     /**
      * END : Reeplace of @@, @%,...
      */
     return $this->fields[$r]['Type'];
 }
示例#4
0
 public function registerLabel($id, $label)
 {
     return 1;
     $dbc = new DBConnection();
     $ses = new DBSession($dbc);
     $ses->Execute(G::replaceDataField('REPLACE INTO `TRANSLATION` (`TRN_CATEGORY`, `TRN_ID`, `TRN_LANG`, `TRN_VALUE`) VALUES
     ("LABEL", @@ID, "' . SYS_LANG . '", @@LABEL);', array('ID' => $id, 'LABEL' => $label !== null ? $label : '')));
 }
 */
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
    return $RBAC_Response;
    //G::genericForceLogin( 'WF_MYINFO' , 'login/noViewPage', $urlLogin = '******' );
}
G::LoadInclude('ajax');
G::LoadClass('dynaform');
G::LoadClass('xmlDb');
$dbc = new DBConnection();
$ses = new DBSession($dbc);
//$dynaform = new dynaform( $dbc );
if ($_POST['form']['DYN_UID'] === '') {
    unset($_POST['form']['DYN_UID']);
}
$Fields = $_POST['form'];
if (!isset($Fields['DYN_UID'])) {
    return;
}
$file = G::decrypt($Fields['A'], URL_KEY);
$Fields['DYN_FILENAME'] = strcasecmp(substr($file, -5), '_tmp0') == 0 ? substr($file, 0, strlen($file) - 5) : $file;
$_SESSION['CURRENT_DYNAFORM'] = $Fields;
//$dynaform->Save( $Fields );
$dbc2 = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
$ses2 = new DBSession($dbc2);
if (!isset($Fields['ENABLETEMPLATE'])) {
    $Fields['ENABLETEMPLATE'] = "0";
}
$ses2->execute(G::replaceDataField("UPDATE . SET WIDTH = @@WIDTH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields));
$ses2->execute(G::replaceDataField("UPDATE . SET ENABLETEMPLATE = @@ENABLETEMPLATE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields));
$ses2->execute(G::replaceDataField("UPDATE . SET MODE = @@MODE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields));
示例#6
0
 public function jsonr(&$json)
 {
     foreach ($json as $key => &$value) {
         $sw1 = is_array($value);
         $sw2 = is_object($value);
         if ($sw1 || $sw2) {
             $this->jsonr($value);
         }
         if (!$sw1 && !$sw2) {
             //read event
             $fn = $this->onPropertyRead;
             if (function_exists($fn)) {
                 $fn($json, $key, $value);
             }
             //set properties from trigger
             $prefixs = array("@@", "@#", "@%", "@?", "@$", "@=");
             if (is_string($value) && in_array(substr($value, 0, 2), $prefixs)) {
                 $triggerValue = substr($value, 2);
                 if (isset($this->fields["APP_DATA"][$triggerValue])) {
                     $json->{$key} = $this->fields["APP_DATA"][$triggerValue];
                 }
             }
             //set properties from 'formInstance' variable
             if (isset($this->fields["APP_DATA"]["formInstance"])) {
                 $formInstance = $this->fields["APP_DATA"]["formInstance"];
                 if (!is_array($formInstance)) {
                     $formInstance = array($formInstance);
                 }
                 $nfi = count($formInstance);
                 for ($ifi = 0; $ifi < $nfi; $ifi++) {
                     $fi = $formInstance[$ifi];
                     if (is_object($fi) && isset($fi->id) && $key === "id" && $json->{$key} === $fi->id) {
                         foreach ($fi as $keyfi => $valuefi) {
                             if (isset($json->{$keyfi})) {
                                 $json->{$keyfi} = $valuefi;
                             }
                         }
                     }
                 }
             }
             //query & options
             if ($key === "type" && ($value === "text" || $value === "textarea" || $value === "dropdown" || $value === "suggest" || $value === "checkbox" || $value === "radio" || $value === "datetime" || $value === "hidden")) {
                 if (!isset($json->data)) {
                     $json->data = array(
                         "value" => "",
                         "label" => ""
                     );
                 }
                 if (!isset($json->dbConnection))
                     $json->dbConnection = "none";
                 if (!isset($json->sql))
                     $json->sql = "";
                 if (!isset($json->options))
                     $json->options = array();
                 if (!isset($json->optionsSql))
                     $json->optionsSql = array();
                 else {
                     //convert stdClass to array
                     if (is_array($json->options)) {
                         $option = array();
                         foreach ($json->options as $valueOptions) {
                             array_push($option, array(
                                 "value" => $valueOptions->value,
                                 "label" => isset($valueOptions->label) ? $valueOptions->label : ""
                             ));
                         }
                         $json->options = $option;
                     }
                 }
                 if ($json->dbConnection !== "" && $json->dbConnection !== "none" && $json->sql !== "") {
                     $cnn = Propel::getConnection($json->dbConnection);
                     $stmt = $cnn->createStatement();
                     try {
                         $rs = $stmt->executeQuery(G::replaceDataField($json->sql, array()), \ResultSet::FETCHMODE_NUM);
                         while ($rs->next()) {
                             $row = $rs->getRow();
                             $option = array(
                                 "label" => isset($row[1]) ? $row[1] : $row[0],
                                 "value" => $row[0]
                             );
                             array_push($json->optionsSql, $option);
                         }
                     } catch (Exception $e) {
                         
                     }
                 }
                 if (isset($json->options[0])) {
                     $json->data = $json->options[0];
                     $no = count($json->options);
                     for ($io = 0; $io < $no; $io++) {
                         if ((is_array($json->options[$io]) ? $json->options[$io]["value"] : $json->options[$io]->value) === $json->defaultValue) {
                             $json->data = $json->options[$io];
                         }
                     }
                 }
             }
             //data
             if ($key === "type" && ($value === "text" || $value === "textarea" || $value === "suggest" || $value === "dropdown" || $value === "checkbox" || $value === "radio" || $value === "datetime" || $value === "hidden")) {
                 $json->data = array(
                     "value" => isset($this->fields["APP_DATA"][$json->name]) ? $this->fields["APP_DATA"][$json->name] : (is_array($json->data) ? $json->data["value"] : $json->data->value),
                     "label" => isset($this->fields["APP_DATA"][$json->name . "_label"]) ? $this->fields["APP_DATA"][$json->name . "_label"] : (is_array($json->data) ? $json->data["label"] : $json->data->label)
                 );
                 if ($json->data["label"] === "") {
                     $json->data["label"] = $json->data["value"];
                 }
                 //synchronize var_label
                 if (isset($this->fields["APP_DATA"]["__VAR_CHANGED__"]) &&
                         in_array($json->name, explode(",", $this->fields["APP_DATA"]["__VAR_CHANGED__"]))) {
                     $json->data["label"] = $json->data["value"];
                     foreach ($json->options as $io) {
                         if ($json->data["value"] === $io->value) {
                             $json->data["label"] = $io->label;
                         }
                     }
                     foreach ($json->optionsSql as $io) {
                         if ($json->data["value"] === $io["value"]) {
                             $json->data["label"] = $io["label"];
                         }
                     }
                     $_SESSION["TRIGGER_DEBUG"]["DATA"][] = Array(
                         "key" => $json->name . "_label",
                         "value" => $json->data["label"]
                     );
                 }
             }
             if ($key === "type" && ($value === "checkbox")) {
                 $json->data = array(
                     "value" => isset($this->fields["APP_DATA"][$json->name]) ? $this->fields["APP_DATA"][$json->name] : array(),
                     "label" => isset($this->fields["APP_DATA"][$json->name . "_label"]) ? $this->fields["APP_DATA"][$json->name . "_label"] : "[]"
                 );
             }
             if ($key === "type" && ($value === "file") && isset($this->fields["APP_DATA"]["APPLICATION"])) {
                 $oCriteria = new Criteria("workflow");
                 $oCriteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID);
                 $oCriteria->addSelectColumn(AppDocumentPeer::DOC_VERSION);
                 $oCriteria->add(AppDocumentPeer::APP_UID, $this->fields["APP_DATA"]["APPLICATION"]);
                 $oCriteria->add(AppDocumentPeer::APP_DOC_FIELDNAME, $json->name);
                 $rs = AppDocumentPeer::doSelectRS($oCriteria);
                 $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                 $links = array();
                 while ($rs->next()) {
                     $row = $rs->getRow();
                     array_push($links, "../cases/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"]);
                 }
                 $json->data = array(
                     "value" => $links,
                     "label" => isset($this->fields["APP_DATA"][$json->name . "_label"]) ? $this->fields["APP_DATA"][$json->name . "_label"] : "[]"
                 );
             }
             //grid
             if ($key === "type" && ($value === "grid")) {
                 if (isset($this->fields["APP_DATA"][$json->name])) {
                     //rows
                     $rows = $this->fields["APP_DATA"][$json->name];
                     foreach ($rows as $keyRow => $row) {
                         //cells
                         $cells = array();
                         foreach ($json->columns as $column) {
                             //data
                             if ($column->type === "text" || $column->type === "textarea" || $column->type === "dropdown" || $column->type === "suggest" || $column->type === "datetime" || $column->type === "checkbox" || $column->type === "file" || $column->type === "link" || $column->type === "hidden") {
                                 array_push($cells, array(
                                     "value" => isset($row[$column->name]) ? $row[$column->name] : "",
                                     "label" => isset($row[$column->name . "_label"]) ? $row[$column->name . "_label"] : (isset($row[$column->name]) ? $row[$column->name] : "")
                                 ));
                             }
                         }
                         $rows[$keyRow] = $cells;
                     }
                     $json->rows = count($rows);
                     $json->data = $rows;
                 }
                 //todo compatibility 'columnWidth'
                 foreach ($json->columns as $column) {
                     if (!isset($column->columnWidth)) {
                         $json->layout = "static";
                         $column->columnWidth = "";
                     }
                 }
             }
             //languages
             if ($this->lang === null && $key === "language" && isset($json->language)) {
                 $this->lang = $json->language;
             }
             if ($this->langs !== null) {
                 if (($key === "label" || $key === "title" || $key === "hint" || $key === "placeholder" || $key === "validateMessage" || $key === "alternateText" || $key === "comment" || $key === "alt") && isset($this->langs->{$this->lang})) {
                     $langs = $this->langs->{$this->lang}->Labels;
                     foreach ($langs as $langsValue) {
                         if (is_object($json) && $json->{$key} === $langsValue->msgid) {
                             $json->{$key} = $langsValue->msgstr;
                         }
                         if (is_array($json) && $json[$key] === $langsValue->msgid) {
                             $json[$key] = $langsValue->msgstr;
                         }
                     }
                 }
             }
         }
     }
 }
示例#7
0
    public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = "")

    {

        try {

            $applicationData = $this->loadCase($sApplicationUID);

            $aFields["APP_NUMBER"] = $applicationData["APP_NUMBER"];



            if (!class_exists('System')) {

                G::LoadClass('system');

            }

            $aConfiguration = System::getEmailConfiguration();



            $msgError = "";

            if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {

                $msgError = "The default configuration wasn't defined";

                $aConfiguration['MESS_ENGINE'] = '';

            }



            //Send derivation notification - Start

            $oTask = new Task();

            $aTaskInfo = $oTask->load($sCurrentTask);



            if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') {

                return false;

            }



            $sFrom = G::buildFrom($aConfiguration, $sFrom);



            if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') {

                $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields);

            } else {

                $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION');

            }



            //erik: new behaviour for messages

            G::loadClass('configuration');

            $oConf = new Configurations;

            $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', '');

            $conf = $oConf->aConfig;



            $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP;

            $swtplDefault = 0;

            $sBody = null;



            if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) &&

                    isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) &&

                    $conf["TAS_DEF_MESSAGE_TYPE"] == "template" &&

                    $conf["TAS_DEF_MESSAGE_TEMPLATE"] != ""

            ) {

                if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") {

                    $swtplDefault = 1;

                }



                $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"];



                if (!file_exists($fileTemplate)) {

                    throw (new Exception("Template file \"$fileTemplate\" does not exist."));

                }



                $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $aFields, false);

            } else {

                $sBody = nl2br(G::replaceDataGridField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields, false));

            }



            G::LoadClass("tasks");

            G::LoadClass("groups");

            G::LoadClass("spool");



            $task = new Tasks();

            $group = new Groups();

            $oUser = new Users();



            foreach ($aTasks as $aTask) {

                $sTo = null;

                $sCc = null;



                switch ($aTask["TAS_ASSIGN_TYPE"]) {

                    case "SELF_SERVICE":

                        if ($swtplDefault == 1) {

                            G::verifyPath($pathEmail, true); //Create if it does not exist

                            $fileTemplate = $pathEmail . G::LoadTranslation('ID_UNASSIGNED_MESSAGE');



                            if ((!file_exists($fileTemplate)) && file_exists(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'))) {

                                @copy(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'), $fileTemplate);

                            }



                            $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields);

                        }



                        if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) {

                            $arrayTaskUser = array();



                            $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1);



                            foreach ($arrayAux1 as $arrayGroup) {

                                $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]);



                                foreach ($arrayAux2 as $arrayUser) {

                                    $arrayTaskUser[] = $arrayUser["USR_UID"];

                                }

                            }



                            $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1);



                            foreach ($arrayAux1 as $arrayUser) {

                                $arrayTaskUser[] = $arrayUser["USR_UID"];

                            }



                            $criteria = new Criteria("workflow");



                            $criteria->addSelectColumn(UsersPeer::USR_UID);

                            $criteria->addSelectColumn(UsersPeer::USR_USERNAME);

                            $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);

                            $criteria->addSelectColumn(UsersPeer::USR_LASTNAME);

                            $criteria->addSelectColumn(UsersPeer::USR_EMAIL);

                            $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN);

                            $rsCriteria = UsersPeer::doSelectRs($criteria);

                            $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);



                            $to = null;

                            $cc = null;

                            $sw = 1;



                            while ($rsCriteria->next()) {

                                $row = $rsCriteria->getRow();



                                $toAux = (

                                        (($row["USR_FIRSTNAME"] != "") || ($row["USR_LASTNAME"] != "")) ?

                                                $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : ""

                                        ) . "<" . $row["USR_EMAIL"] . ">";



                                if ($sw == 1) {

                                    $to = $toAux;

                                    $sw = 0;

                                } else {

                                    $cc = $cc . (($cc != null) ? "," : null) . $toAux;

                                }

                            }



                            $sTo = $to;

                            $sCc = $cc;

                        }

                        break;

                    default:

                        if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) {

                            $aUser = $oUser->load($aTask["USR_UID"]);



                            $sTo = (

                                    (($aUser["USR_FIRSTNAME"] != "") || ($aUser["USR_LASTNAME"] != "")) ?

                                            $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : ""

                                    ) . "<" . $aUser["USR_EMAIL"] . ">";

                        }

                        break;

                }



                if ($sTo != null) {

                    $oSpool = new spoolRun();



                    $oSpool->setConfig($aConfiguration);

                    $oSpool->create(array(

                        "msg_uid" => "",

                        "app_uid" => $sApplicationUID,

                        "del_index" => $iDelegation,

                        "app_msg_type" => "DERIVATION",

                        "app_msg_subject" => $sSubject,

                        "app_msg_from" => $sFrom,

                        "app_msg_to" => $sTo,

                        "app_msg_body" => $sBody,

                        "app_msg_cc" => $sCc,

                        "app_msg_bcc" => "",

                        "app_msg_attach" => "",

                        "app_msg_template" => "",

                        "app_msg_status" => "pending",

                        "app_msg_error" => $msgError

                    ));



                    if ($msgError == '') {

                        if (($aConfiguration["MESS_BACKGROUND"] == "") ||

                                ($aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1")

                        ) {

                            $oSpool->sendMail();

                        }

                    }

                }

            }

            //Send derivation notification - End

        } catch (Exception $oException) {

            throw $oException;

        }

    }
示例#8
0
 function createAppEvents($PRO_UID, $APP_UID, $DEL_INDEX, $TAS_UID)
 {
     $aRows = array();
     $aEventsRows = $this->getBy($PRO_UID, array('TAS_UID' => $TAS_UID));
     if ($aEventsRows !== false) {
         $aRows = array_merge($aRows, $aEventsRows);
     }
     $aEventsRows = $this->getBy($PRO_UID, array('EVN_TAS_UID_FROM' => $TAS_UID));
     if ($aEventsRows !== false) {
         $aRows = array_merge($aRows, $aEventsRows);
     }
     foreach ($aRows as $aData) {
         // if the events has a condition
         if (trim($aData['EVN_CONDITIONS']) != '') {
             G::LoadClass('case');
             $oCase = new Cases();
             $aFields = $oCase->loadCase($APP_UID);
             $Fields = $aFields['APP_DATA'];
             $conditionContents = trim($aData['EVN_CONDITIONS']);
             //$sContent    = G::unhtmlentities($sContent);
             $iAux = 0;
             $iOcurrences = preg_match_all('/\\@(?:([\\>])([a-zA-Z\\_]\\w*)|([a-zA-Z\\_][\\w\\-\\>\\:]*)\\(((?:[^\\\\\\)]*(?:[\\\\][\\w\\W])?)*)\\))((?:\\s*\\[[\'"]?\\w+[\'"]?\\])+)?/', $conditionContents, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
             if ($iOcurrences) {
                 for ($i = 0; $i < $iOcurrences; $i++) {
                     preg_match_all('/@>' . $aMatch[2][$i][0] . '([\\w\\W]*)' . '@<' . $aMatch[2][$i][0] . '/', $conditionContents, $aMatch2, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
                     $sGridName = $aMatch[2][$i][0];
                     $sStringToRepeat = $aMatch2[1][0][0];
                     if (isset($Fields[$sGridName])) {
                         if (is_array($Fields[$sGridName])) {
                             $sAux = '';
                             foreach ($Fields[$sGridName] as $aRow) {
                                 $sAux .= G::replaceDataField($sStringToRepeat, $aRow);
                             }
                         }
                     }
                     $conditionContents = str_replace('@>' . $sGridName . $sStringToRepeat . '@<' . $sGridName, $sAux, $conditionContents);
                 }
             }
             $sCondition = G::replaceDataField($conditionContents, $Fields);
             $evalConditionResult = false;
             $sCond = 'try{ $evalConditionResult=(' . $sCondition . ')? true: false; } catch(Exception $e){$evalConditionResult=false;}';
             @eval($sCond);
             if (!$evalConditionResult) {
                 continue;
             }
         }
         $appEventData['APP_UID'] = $APP_UID;
         $appEventData['DEL_INDEX'] = $DEL_INDEX;
         $appEventData['EVN_UID'] = $aData['EVN_UID'];
         $appEventData['APP_EVN_ACTION_DATE'] = $this->toCalculateTime($aData);
         $appEventData['APP_EVN_ATTEMPTS'] = 3;
         $appEventData['APP_EVN_LAST_EXECUTION_DATE'] = null;
         $appEventData['APP_EVN_STATUS'] = 'OPEN';
         $oAppEvent = new AppEvent();
         $oAppEvent->create($appEventData);
     }
 }
 /**
  * Function render
  *
  * @author The Answer
  * @access public
  * @param eter string value
  * @param eter string owner
  * @return string
  */
 public function render($value = null, $owner = null)
 {
     //$optionName = $owner->values['USR_UID'];
     $optionName = $value;
     $onclick = $this->onclick ? ' onclick="' . G::replaceDataField($this->onclick, $owner->values) . '" ' : '';
     $html = '<input class="FormCheck" id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . '][' . $optionName . ']" type=\'checkbox\' value="' . $value . '"' . $onclick . '> <span class="FormCheck"></span></input>';
     return $html;
 }
 /**
  * Catch Message-Events for the Cases
  *
  * @param bool $frontEnd Flag to represent progress bar
  *
  * @return void
  */
 public function catchMessageEvent($frontEnd = false)
 {
     try {
         \G::LoadClass("wsBase");
         //Set variables
         $ws = new \wsBase();
         $case = new \Cases();
         $common = new \ProcessMaker\Util\Common();
         $common->setFrontEnd($frontEnd);
         //Get data
         $totalMessageEvent = 0;
         $counterStartMessageEvent = 0;
         $counterIntermediateCatchMessageEvent = 0;
         $counter = 0;
         $flagFirstTime = false;
         $common->frontEndShow("START");
         do {
             $flagNextRecords = false;
             $arrayMessageApplicationUnread = $this->getMessageApplications(array("messageApplicationStatus" => "UNREAD"), null, null, 0, 1000);
             if (!$flagFirstTime) {
                 $totalMessageEvent = $arrayMessageApplicationUnread["total"];
                 $flagFirstTime = true;
             }
             foreach ($arrayMessageApplicationUnread["data"] as $value) {
                 if ($counter + 1 > $totalMessageEvent) {
                     $flagNextRecords = false;
                     break;
                 }
                 $arrayMessageApplicationData = $value;
                 $processUid = $arrayMessageApplicationData["PRJ_UID"];
                 $taskUid = $arrayMessageApplicationData["TAS_UID"];
                 $messageApplicationUid = $arrayMessageApplicationData["MSGAPP_UID"];
                 $messageApplicationCorrelation = $arrayMessageApplicationData["MSGAPP_CORRELATION"];
                 $messageEventDefinitionUserUid = $arrayMessageApplicationData["MSGED_USR_UID"];
                 $messageEventDefinitionCorrelation = $arrayMessageApplicationData["MSGED_CORRELATION"];
                 $arrayVariable = $this->mergeVariables($arrayMessageApplicationData["MSGED_VARIABLES"], $arrayMessageApplicationData["MSGAPP_VARIABLES"]);
                 $flagCatched = false;
                 switch ($arrayMessageApplicationData["EVN_TYPE"]) {
                     case "START":
                         if ($messageEventDefinitionCorrelation == $messageApplicationCorrelation && $messageEventDefinitionUserUid != "") {
                             //Start and derivate new Case
                             $result = $ws->newCase($processUid, $messageEventDefinitionUserUid, $taskUid, $arrayVariable);
                             $arrayResult = json_decode(json_encode($result), true);
                             if ($arrayResult["status_code"] == 0) {
                                 $applicationUid = $arrayResult["caseId"];
                                 $result = $ws->derivateCase($messageEventDefinitionUserUid, $applicationUid, 1);
                                 $flagCatched = true;
                                 //Counter
                                 $counterStartMessageEvent++;
                             }
                         }
                         break;
                     case "INTERMEDIATE":
                         $criteria = new \Criteria("workflow");
                         $criteria->addSelectColumn(\AppDelegationPeer::APP_UID);
                         $criteria->addSelectColumn(\AppDelegationPeer::DEL_INDEX);
                         $criteria->addSelectColumn(\AppDelegationPeer::USR_UID);
                         $criteria->add(\AppDelegationPeer::PRO_UID, $processUid, \Criteria::EQUAL);
                         $criteria->add(\AppDelegationPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
                         $criteria->add(\AppDelegationPeer::DEL_THREAD_STATUS, "OPEN", \Criteria::EQUAL);
                         $criteria->add(\AppDelegationPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL);
                         $rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
                         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
                         while ($rsCriteria->next()) {
                             $row = $rsCriteria->getRow();
                             $applicationUid = $row["APP_UID"];
                             $delIndex = $row["DEL_INDEX"];
                             $userUid = $row["USR_UID"];
                             $arrayApplicationData = $case->loadCase($applicationUid);
                             if (\G::replaceDataField($messageEventDefinitionCorrelation, $arrayApplicationData["APP_DATA"]) == $messageApplicationCorrelation) {
                                 //"Unpause" and derivate Case
                                 $arrayApplicationData["APP_DATA"] = array_merge($arrayApplicationData["APP_DATA"], $arrayVariable);
                                 $arrayResult = $case->updateCase($applicationUid, $arrayApplicationData);
                                 $result = $ws->derivateCase($userUid, $applicationUid, $delIndex);
                                 $flagCatched = true;
                             }
                         }
                         //Counter
                         if ($flagCatched) {
                             $counterIntermediateCatchMessageEvent++;
                         }
                         break;
                 }
                 //Message-Application catch
                 if ($flagCatched) {
                     $result = $this->update($messageApplicationUid, array("MSGAPP_STATUS" => "READ"));
                 }
                 $counter++;
                 //Progress bar
                 $common->frontEndShow("BAR", "Message-Events (unread): " . $counter . "/" . $totalMessageEvent . " " . $common->progressBar($totalMessageEvent, $counter));
                 $flagNextRecords = true;
             }
         } while ($flagNextRecords);
         $common->frontEndShow("TEXT", "Total Message-Events unread: " . $totalMessageEvent);
         $common->frontEndShow("TEXT", "Total cases started: " . $counterStartMessageEvent);
         $common->frontEndShow("TEXT", "Total cases continued: " . $counterIntermediateCatchMessageEvent);
         $common->frontEndShow("TEXT", "Total Message-Events pending: " . ($totalMessageEvent - ($counterStartMessageEvent + $counterIntermediateCatchMessageEvent)));
         $common->frontEndShow("END");
     } catch (\Exception $e) {
         throw $e;
     }
 }
示例#11
0
 private function getValuesDependentFields($json)
 {
     if (!isset($this->record["DYN_CONTENT"])) {
         return array();
     }
     $data = array();
     if (isset($json->dbConnection) && isset($json->sql)) {
         $salida = array();
         preg_match_all('/\\@(?:([\\@\\%\\#\\=\\!Qq])([a-zA-Z\\_]\\w*)|([a-zA-Z\\_][\\w\\-\\>\\:]*)\\(((?:[^\\\\\\)]*?)*)\\))/', $json->sql, $salida, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
         $variables = isset($salida[2]) ? $salida[2] : array();
         foreach ($variables as $key => $value) {
             $jsonSearch = $this->jsonsf(G::json_decode($this->record["DYN_CONTENT"]), $value[0], $json->variable === "" ? "id" : "variable");
             $a = $this->getValuesDependentFields($jsonSearch);
             foreach ($a as $i => $v) {
                 $data[$i] = $v;
             }
         }
         if ($json->dbConnection !== "" && $json->dbConnection !== "none" && $json->sql !== "") {
             $cnn = Propel::getConnection($json->dbConnection);
             $stmt = $cnn->createStatement();
             try {
                 $a = G::replaceDataField($json->sql, $data);
                 $rs = $stmt->executeQuery($a, \ResultSet::FETCHMODE_NUM);
                 $rs->next();
                 $row = $rs->getRow();
                 if (isset($row[0]) && $json->type !== "suggest") {
                     $data[$json->variable === "" ? $json->id : $json->variable] = $row[0];
                 }
             } catch (Exception $e) {
             }
         }
     }
     if (isset($json->options) && isset($json->options[0])) {
         $data[$json->variable === "" ? $json->id : $json->variable] = $json->options[0]->value;
     }
     if (isset($json->placeholder) && $json->placeholder !== "") {
         $data[$json->variable === "" ? $json->id : $json->variable] = "";
     }
     if (isset($json->defaultValue) && $json->defaultValue !== "") {
         $data[$json->variable === "" ? $json->id : $json->variable] = $json->defaultValue;
     }
     return $data;
 }
 /**
  * Function renderField
  *
  * @author David S. Callizaya S. <*****@*****.**>
  * @access public
  * @param eter string row
  * @param eter string r
  * @param eter string result
  * @return string
  */
 public function renderField($row, $r, $result)
 {
     global $G_DATE_FORMAT;
     //to do: special content??
     //$result['row__']            = $row;   //Special content:
     $styleData = $this->style[$r];
     $fielDataName = $styleData['data'];
     $fieldClassName = isset($styleData['colClassName']) && $styleData['colClassName'] ? $styleData['colClassName'] : $this->tdClass;
     if ($fielDataName != '') {
         $value = isset($result[$fielDataName]) ? $result[$fielDataName] : '';
     } else {
         $value = $this->fields[$r]['Label'];
     }
     $this->tpl->newBlock("field");
     $this->tpl->assign('width', $this->style[$r]['colWidth']);
     $classAttr = trim($fieldClassName) != '' ? " class=\"{$fieldClassName}\"" : '';
     $this->tpl->assign('classAttr', $classAttr);
     //to do: style is needed or not?
     //$this->tpl->assign('style', $this->tdStyle);
     $alignAttr = isset($this->style[$r]['align']) && strlen($this->style[$r]['align'] > 0) ? " align=\"" . $this->style[$r]['align'] . "\"" : '';
     $this->tpl->assign("alignAttr", $alignAttr);
     $fieldName = $this->fields[$r]['Name'];
     $fieldClass = get_class($this->xmlForm->fields[$fieldName]);
     /**
      * * BEGIN : Reeplace of @@, @%,...
      * in field's attributes like onclick, link,
      */
     if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->link)) {
         $this->xmlForm->fields[$this->fields[$r]['Name']]->link = G::replaceDataField($this->style[$r]['link'], $result);
     }
     if (isset($this->xmlForm->fields[$fieldName]->value)) {
         $this->xmlForm->fields[$fieldName]->value = G::replaceDataField($styleData['value'], $result);
     }
     /**
      * * END : Reeplace of @@, @%,...
      */
     /**
      * * Rendering of the field
      */
     $this->xmlForm->fields[$fieldName]->mode = 'view';
     $this->xmlForm->setDefaultValues();
     $this->xmlForm->setValues($result);
     //var_dump($fieldName, $fieldClass );echo '<br /><br />';
     if (array_search('renderTable', get_class_methods($fieldClass)) !== false) {
         $htmlField = $this->xmlForm->fields[$fieldName]->renderTable($value, $this->xmlForm, true);
         if (is_object($value)) {
             $value = '';
         }
         // checking if the value variable is a html field, a html tag content can't contain &nbsp; as white spaces
         $testValue = preg_match("/<a ?.*>(.*)<\\/a>/i", $htmlField, $value);
         $this->tpl->assign("value", $htmlField);
         if ($testValue > 0 && (isset($value[1]) && strlen(trim($value[1])) == 0)) {
             if (trim($value[0]) == '') {
                 $this->tpl->assign("value", "&nbsp;");
             }
             // $this->tpl->assign( "value" , (preg_match('^[[:space:]]^', $value) && (substr($fieldName,0,3)!="PRO"))? str_ireplace(" ","&nbsp;",$htmlField):$htmlField );
         } else {
             $this->tpl->assign("value", $htmlField);
         }
         /* $testValue = preg_match( "/<\/?\w+((\s+(\w|\w[\w-]*\w)(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>/i", $value, $matches );  */
         //      if (empty($matches)){
         //        $this->tpl->assign( "value" , (preg_match('^[[:space:]]^', $value) && (substr($fieldName,0,3)!="PRO"))? str_ireplace(" ","&nbsp;",$htmlField):$htmlField );
         //      } else {
         //        $this->tpl->assign( "value" , $htmlField );
         //      }
     }
     return $this->fields[$r]['Type'];
 }
示例#13
0
 public function sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom = "")
 {
     try {
         if (!class_exists('System')) {
             G::LoadClass('system');
         }
         $aConfiguration = System::getEmailConfiguration();
         if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {
             return false;
         }
         $oUser = new Users();
         $aUser = $oUser->load($usrUid);
         $authorName = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
         G::LoadClass('case');
         $oCase = new Cases();
         $aFields = $oCase->loadCase($appUid);
         $configNoteNotification['subject'] = G::LoadTranslation('ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION') . " @#APP_TITLE ";
         $configNoteNotification['body'] = G::LoadTranslation('ID_CASE') . ": @#APP_TITLE<br />" . G::LoadTranslation('ID_AUTHOR') . ": {$authorName}<br /><br />{$noteContent}";
         $sFrom = G::buildFrom($aConfiguration, $sFrom);
         $sSubject = G::replaceDataField($configNoteNotification['subject'], $aFields);
         $sBody = nl2br(G::replaceDataField($configNoteNotification['body'], $aFields));
         G::LoadClass('spool');
         $oUser = new Users();
         $recipientsArray = explode(",", $noteRecipients);
         foreach ($recipientsArray as $recipientUid) {
             $aUser = $oUser->load($recipientUid);
             $sTo = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
             $oSpool = new spoolRun();
             $oSpool->setConfig($aConfiguration);
             $oSpool->create(array('msg_uid' => '', 'app_uid' => $appUid, 'del_index' => 0, 'app_msg_type' => 'DERIVATION', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $sTo, 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending'));
             if ($aConfiguration['MESS_BACKGROUND'] == '' || $aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1') {
                 $oSpool->sendMail();
             }
         }
         //Send derivation notification - End
     } catch (Exception $oException) {
         throw $oException;
     }
 }
示例#14
0
 public function evaluateVariable()
 {
     $process = new Process();
     if (!$process->isBpmnProcess($_SESSION['PROCESS'])) {
         return;
     }
     require_once PATH_CORE . 'controllers/pmTablesProxy.php';
     $pmTablesProxy = new pmTablesProxy();
     $variableModule = new ProcessMaker\BusinessModel\Variable();
     $searchTypes = array('checkgroup', 'dropdown', 'suggest');
     $processVariables = $pmTablesProxy->getDynaformVariables($_SESSION['PROCESS'], $searchTypes, false);
     $variables = $this->affected_fields;
     $variables = array_unique($variables);
     $newFields = array();
     $arrayValues = array();
     $arrayLabels = array();
     if (is_array($variables) && is_array($processVariables)) {
         foreach ($variables as $var) {
             if (strpos($var, '_label') === false) {
                 if (in_array($var, $processVariables)) {
                     if (isset($this->aFields[$var]) && is_array($this->aFields[$var][1])) {
                         $varLabel = $var . '_label';
                         $arrayValue = $this->aFields[$var];
                         if (is_array($arrayValue) && sizeof($arrayValue)) {
                             foreach ($arrayValue as $val) {
                                 if (is_array($val)) {
                                     $val = array_values($val);
                                     $arrayValues[] = $val[0];
                                     $arrayLabels[] = $val[1];
                                 }
                             }
                             if (sizeof($arrayLabels)) {
                                 $varInfo = $variableModule->getVariableTypeByName($_SESSION['PROCESS'], $var);
                                 if (is_array($varInfo) && sizeof($varInfo)) {
                                     $varType = $varInfo['VAR_FIELD_TYPE'];
                                     switch ($varType) {
                                         case 'array':
                                             $arrayLabels = '["' . implode('","', $arrayLabels) . '"]';
                                             $newFields[$var] = $arrayValues;
                                             $newFields[$varLabel] = $arrayLabels;
                                             break;
                                         case 'string':
                                             $newFields[$var] = $arrayValues[0];
                                             $newFields[$varLabel] = $arrayLabels[0];
                                             break;
                                     }
                                     $this->affected_fields[] = $varLabel;
                                     $this->aFields = array_merge($this->aFields, $newFields);
                                     unset($newFields);
                                     unset($arrayValues);
                                     unset($arrayLabels);
                                 }
                             }
                         }
                     }
                     if (isset($this->aFields[$var]) && is_string($this->aFields[$var])) {
                         $varInfo = $variableModule->getVariableTypeByName($_SESSION['PROCESS'], $var);
                         $options = G::json_decode($varInfo["VAR_ACCEPTED_VALUES"]);
                         $no = count($options);
                         for ($io = 0; $io < $no; $io++) {
                             if ($options[$io]->value === $this->aFields[$var]) {
                                 $this->aFields[$var . "_label"] = $options[$io]->label;
                             }
                         }
                         if ($varInfo["VAR_DBCONNECTION"] !== "" && $varInfo["VAR_DBCONNECTION"] !== "none" && $varInfo["VAR_SQL"] !== "") {
                             try {
                                 $cnn = Propel::getConnection($varInfo["VAR_DBCONNECTION"]);
                                 $stmt = $cnn->createStatement();
                                 $sql = G::replaceDataField($varInfo["VAR_SQL"], $this->aFields);
                                 $rs = $stmt->executeQuery($sql, \ResultSet::FETCHMODE_NUM);
                                 while ($rs->next()) {
                                     $row = $rs->getRow();
                                     if ($row[0] === $this->aFields[$var]) {
                                         $this->aFields[$var . "_label"] = isset($row[1]) ? $row[1] : $row[0];
                                     }
                                 }
                             } catch (Exception $e) {
                             }
                         }
                     }
                 }
             }
         }
     }
 }
示例#15
0
 /**
  * Start/Continue case by Timer-Event
  *
  * @param string $datetime Datetime (yyyy-mm-dd hh:ii:ss)
  * @param bool   $frontEnd Flag to represent the terminal front-end
  *
  * return void
  */
 public function startContinueCaseByTimerEvent($datetime, $frontEnd = false)
 {
     try {
         \G::LoadClass("wsBase");
         //Set variables
         $ws = new \wsBase();
         $case = new \Cases();
         $common = new \ProcessMaker\Util\Common();
         $common->setFrontEnd($frontEnd);
         list($year, $month, $day, $hour, $minute) = $this->getYearMonthDayHourMinuteSecondByDatetime($datetime);
         $date = "{$year}-{$month}-{$day}";
         $dateIni = "{$year}-{$month}-{$day} 00:00:00";
         $dateEnd = "{$year}-{$month}-{$day} 23:59:59";
         //Start Timer-Event (start new case) ///////////////////////////////////////////////////////////////////////
         $common->frontEndShow("START");
         $this->log("START-NEW-CASES", "Date \"{$datetime}\": Start new cases");
         //Query
         $criteria = $this->getTimerEventCriteria();
         $criteria->addSelectColumn(\BpmnEventPeer::EVN_NAME);
         $criteria->addSelectColumn(\ElementTaskRelationPeer::TAS_UID);
         $arrayCondition = array();
         $arrayCondition[] = array(\TimerEventPeer::PRJ_UID, \ProcessPeer::PRO_UID, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteria->add(\ProcessPeer::PRO_STATUS, "ACTIVE", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\TimerEventPeer::PRJ_UID, \ElementTaskRelationPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\TimerEventPeer::EVN_UID, \ElementTaskRelationPeer::ELEMENT_UID, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteria->add(\ElementTaskRelationPeer::ELEMENT_TYPE, "bpmnEvent", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\ElementTaskRelationPeer::PRJ_UID, \TaskPeer::PRO_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\ElementTaskRelationPeer::TAS_UID, \TaskPeer::TAS_UID, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteria->add(\TaskPeer::TAS_TYPE, "START-TIMER-EVENT", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\TimerEventPeer::PRJ_UID, \BpmnEventPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\TimerEventPeer::EVN_UID, \BpmnEventPeer::EVN_UID, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteria->add(\BpmnEventPeer::EVN_TYPE, "START", \Criteria::EQUAL);
         $criteria->add(\BpmnEventPeer::EVN_MARKER, "TIMER", \Criteria::EQUAL);
         $criteria->add(\TimerEventPeer::TMREVN_OPTION, array("HOURLY", "DAILY", "MONTHLY", "EVERY", "ONE-DATE-TIME"), \Criteria::IN);
         $criteria->add(\TimerEventPeer::TMREVN_STATUS, "ACTIVE", \Criteria::EQUAL);
         $criteria->add($criteria->getNewCriterion(\TimerEventPeer::TMREVN_NEXT_RUN_DATE, $dateIni, \Criteria::GREATER_EQUAL)->addAnd($criteria->getNewCriterion(\TimerEventPeer::TMREVN_NEXT_RUN_DATE, $dateEnd, \Criteria::LESS_EQUAL))->addOr($criteria->getNewCriterion(\TimerEventPeer::TMREVN_NEXT_RUN_DATE, $dateIni, \Criteria::LESS_THAN)));
         $criteria->add($criteria->getNewCriterion(\TimerEventPeer::TMREVN_END_DATE, $date, \Criteria::GREATER_EQUAL)->addOr($criteria->getNewCriterion(\TimerEventPeer::TMREVN_END_DATE, null, \Criteria::EQUAL)));
         $rsCriteria = \TimerEventPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $flagRecord = false;
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $row["TMREVN_CONFIGURATION_DATA"] = unserialize($row["TMREVN_CONFIGURATION_DATA"]);
             //Set variables
             $arrayTimerEventData = $row;
             $bpmnEventName = $row["EVN_NAME"];
             $taskUid = $row["TAS_UID"];
             //Create the new case
             $timerEventNextRunDate = $arrayTimerEventData["TMREVN_NEXT_RUN_DATE"];
             $timerEventNextRunDateNew = "";
             $flagCase = false;
             if (strtotime($timerEventNextRunDate) < strtotime($dateIni)) {
                 $timerEventNextRunDateNew = $this->getNextRunDateByDataAndDatetime($arrayTimerEventData, $datetime);
                 //Generate new date for old TMREVN_NEXT_RUN_DATE
                 $flagCase = true;
                 //Create the old case
             } else {
                 list(, , , $hourCase, $minuteCase) = $this->getYearMonthDayHourMinuteSecondByDatetime($timerEventNextRunDate);
                 if ((int) ($hour . $minute) <= (int) ($hourCase . $minuteCase)) {
                     $flagCase = $hourCase == $hour && $minuteCase == $minute;
                 } else {
                     $timerEventNextRunDateNew = $this->getNextRunDateByDataAndDatetime($arrayTimerEventData, $datetime);
                     //Generate new date for old TMREVN_NEXT_RUN_DATE
                     $flagCase = true;
                     //Create the old case
                 }
             }
             if ($flagCase) {
                 if ($flagRecord) {
                     $common->frontEndShow("TEXT", "");
                 }
                 if ($bpmnEventName != "") {
                     $common->frontEndShow("TEXT", "> Name Timer-Event: {$bpmnEventName}");
                 }
                 $common->frontEndShow("TEXT", "> Creating the new case...");
                 //Start new case
                 $result = $ws->newCase($arrayTimerEventData["PRJ_UID"], "", $taskUid, array());
                 $arrayResult = json_decode(json_encode($result), true);
                 if ($arrayResult["status_code"] == 0) {
                     $applicationUid = $arrayResult["caseId"];
                     $applicationNumber = $arrayResult["caseNumber"];
                     $common->frontEndShow("TEXT", "    - OK case #{$applicationNumber} was created");
                     $common->frontEndShow("TEXT", "> Routing the case #{$applicationNumber}...");
                     $this->log("CREATED-NEW-CASE", "Case #{$applicationNumber} created, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                     //Derivate new case
                     $result = $ws->derivateCase("", $applicationUid, 1);
                     $arrayResult = json_decode(json_encode($result), true);
                     if ($arrayResult["status_code"] == 0) {
                         $common->frontEndShow("TEXT", "    - OK");
                         $this->log("ROUTED-NEW-CASE", "Case #{$applicationNumber} routed, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                     } else {
                         $common->frontEndShow("TEXT", "    - Failed: " . $arrayResult["message"]);
                         $this->log("ROUTED-NEW-CASE", "Failed: " . $arrayResult["message"] . ", Case: #{$applicationNumber}, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                     }
                 } else {
                     $common->frontEndShow("TEXT", "    - Failed: " . $arrayResult["message"]);
                     $this->log("CREATED-NEW-CASE", "Failed: " . $arrayResult["message"] . ", PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                 }
                 //Update Timer-Event
                 $arrayData = array();
                 switch ($arrayTimerEventData["TMREVN_OPTION"]) {
                     case "HOURLY":
                     case "DAILY":
                     case "MONTHLY":
                     case "EVERY":
                         if ($timerEventNextRunDateNew == "") {
                             $timerEventNextRunDateNew = $this->getNextRunDateByDataAndDatetime($arrayTimerEventData, $timerEventNextRunDate, false);
                         }
                         if ($arrayTimerEventData["TMREVN_OPTION"] != "EVERY" && $arrayTimerEventData["TMREVN_END_DATE"] . "" != "" && strtotime($timerEventNextRunDateNew) > strtotime($arrayTimerEventData["TMREVN_END_DATE"] . " 23:59:59")) {
                             $arrayData["TMREVN_STATUS"] = "PROCESSED";
                         } else {
                             $arrayData["TMREVN_NEXT_RUN_DATE"] = $timerEventNextRunDateNew;
                         }
                         break;
                     case "ONE-DATE-TIME":
                         $arrayData["TMREVN_STATUS"] = "PROCESSED";
                         break;
                 }
                 $arrayData["TMREVN_LAST_RUN_DATE"] = $timerEventNextRunDate;
                 $arrayData["TMREVN_LAST_EXECUTION_DATE"] = date("Y-m-d H:i:s");
                 $result = $this->singleUpdate($arrayTimerEventData["TMREVN_UID"], $arrayData);
                 $flagRecord = true;
             }
         }
         if (!$flagRecord) {
             $common->frontEndShow("TEXT", "Not exists any record to start a new case, on date \"{$datetime}\"");
             $this->log("NO-RECORDS", "Not exists any record to start a new case");
         }
         $common->frontEndShow("END");
         $this->log("END-NEW-CASES", "Date \"{$datetime}\": End new cases");
         //Intermediate Catch Timer-Event (continue the case) ///////////////////////////////////////////////////////
         $this->log("START-CONTINUE-CASES", "Date \"{$datetime}\": Start continue the cases");
         //Query
         $criteriaMain = $this->getTimerEventCriteria();
         $criteriaMain->addSelectColumn(\AppDelegationPeer::APP_UID);
         $criteriaMain->addSelectColumn(\AppDelegationPeer::DEL_INDEX);
         $criteriaMain->addSelectColumn(\AppDelegationPeer::DEL_DELEGATE_DATE);
         $criteriaMain->addSelectColumn(\BpmnEventPeer::EVN_NAME);
         $arrayCondition = array();
         $arrayCondition[] = array(\AppDelegationPeer::PRO_UID, \ProcessPeer::PRO_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\ProcessPeer::PRO_STATUS, "ACTIVE", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\AppDelegationPeer::APP_UID, \ApplicationPeer::APP_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\ApplicationPeer::APP_STATUS, "DRAFT", \Criteria::NOT_EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\AppDelegationPeer::PRO_UID, \TaskPeer::PRO_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\AppDelegationPeer::TAS_UID, \TaskPeer::TAS_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\TaskPeer::TAS_TYPE, "INTERMEDIATE-CATCH-TIMER-EVENT", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\TaskPeer::PRO_UID, \ElementTaskRelationPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\TaskPeer::TAS_UID, \ElementTaskRelationPeer::TAS_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\ElementTaskRelationPeer::ELEMENT_TYPE, "bpmnEvent", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\ElementTaskRelationPeer::PRJ_UID, \TimerEventPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\ElementTaskRelationPeer::ELEMENT_UID, \TimerEventPeer::EVN_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $arrayCondition = array();
         $arrayCondition[] = array(\TimerEventPeer::PRJ_UID, \BpmnEventPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\TimerEventPeer::EVN_UID, \BpmnEventPeer::EVN_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\BpmnEventPeer::EVN_TYPE, "INTERMEDIATE", \Criteria::EQUAL);
         $criteriaMain->add(\BpmnEventPeer::EVN_MARKER, "TIMER", \Criteria::EQUAL);
         $criteriaMain->add(\TimerEventPeer::TMREVN_OPTION, array("WAIT-FOR", "WAIT-UNTIL-SPECIFIED-DATE-TIME"), \Criteria::IN);
         $criteriaMain->add(\TimerEventPeer::TMREVN_STATUS, "ACTIVE", \Criteria::EQUAL);
         $criteriaMain->add(\AppDelegationPeer::DEL_THREAD_STATUS, "OPEN", \Criteria::EQUAL);
         $criteriaMain->add(\AppDelegationPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL);
         //Number records total
         $criteriaCount = clone $criteriaMain;
         $criteriaCount->clearSelectColumns();
         $criteriaCount->addSelectColumn("COUNT(" . \AppDelegationPeer::APP_UID . ") AS NUM_REC");
         $rsCriteriaCount = \AppDelegationPeer::doSelectRS($criteriaCount);
         $rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $result = $rsCriteriaCount->next();
         $row = $rsCriteriaCount->getRow();
         $numRecTotal = $row["NUM_REC"];
         //Query
         $total = $numRecTotal;
         $counter = 0;
         $start = 0;
         $limit = 1000;
         $flagRecord = false;
         do {
             $flagNextRecord = false;
             $criteria = clone $criteriaMain;
             $criteria->setOffset($start);
             $criteria->setLimit($limit);
             $rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
             $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             while ($rsCriteria->next()) {
                 if ($counter + 1 > $total) {
                     $flagNextRecord = false;
                     break;
                 }
                 $row = $rsCriteria->getRow();
                 $row["TMREVN_CONFIGURATION_DATA"] = unserialize($row["TMREVN_CONFIGURATION_DATA"]);
                 //Set variables
                 $arrayTimerEventData = $row;
                 $arrayApplicationData = $case->loadCase($row["APP_UID"]);
                 $applicationUid = $row["APP_UID"];
                 $applicationNumber = $arrayApplicationData["APP_NUMBER"];
                 $delIndex = $row["DEL_INDEX"];
                 $delDelegateDate = $row["DEL_DELEGATE_DATE"];
                 $bpmnEventName = $row["EVN_NAME"];
                 //Continue the case
                 $continueCaseDate = $delDelegateDate;
                 switch ($arrayTimerEventData["TMREVN_OPTION"]) {
                     case "WAIT-FOR":
                         if ($arrayTimerEventData["TMREVN_DAY"] . "" != "") {
                             $continueCaseDate = date("Y-m-d H:i:s", strtotime("{$continueCaseDate} +" . (int) $arrayTimerEventData["TMREVN_DAY"] . " days"));
                         }
                         if ($arrayTimerEventData["TMREVN_HOUR"] . "" != "") {
                             $continueCaseDate = date("Y-m-d H:i:s", strtotime("{$continueCaseDate} +" . (int) $arrayTimerEventData["TMREVN_HOUR"] . " hours"));
                         }
                         if ($arrayTimerEventData["TMREVN_MINUTE"] . "" != "") {
                             $continueCaseDate = date("Y-m-d H:i:s", strtotime("{$continueCaseDate} +" . (int) $arrayTimerEventData["TMREVN_MINUTE"] . " minutes"));
                         }
                         break;
                     case "WAIT-UNTIL-SPECIFIED-DATE-TIME":
                         $continueCaseDate = \G::replaceDataField($arrayTimerEventData["TMREVN_CONFIGURATION_DATA"], $arrayApplicationData["APP_DATA"]);
                         break;
                 }
                 $arrayContinueCaseDateData = $this->getYearMonthDayHourMinuteSecondByDatetime($continueCaseDate);
                 if (!empty($arrayContinueCaseDateData)) {
                     $flagCase = false;
                     if (strtotime($continueCaseDate) < strtotime($dateIni)) {
                         $flagCase = true;
                         //Continue the old case
                     } else {
                         $yearCase = $arrayContinueCaseDateData[0];
                         $monthCase = $arrayContinueCaseDateData[1];
                         $dayCase = $arrayContinueCaseDateData[2];
                         $hourCase = $arrayContinueCaseDateData[3];
                         $minuteCase = $arrayContinueCaseDateData[4];
                         if ("{$yearCase}-{$monthCase}-{$dayCase}" == "{$year}-{$month}-{$day}") {
                             if ((int) ($hour . $minute) <= (int) ($hourCase . $minuteCase)) {
                                 $flagCase = $hourCase == $hour && $minuteCase == $minute;
                             } else {
                                 $flagCase = true;
                                 //Continue the old case
                             }
                         }
                     }
                     if ($flagCase) {
                         if ($flagRecord) {
                             $common->frontEndShow("TEXT", "");
                         }
                         if ($bpmnEventName != "") {
                             $common->frontEndShow("TEXT", "> Name Timer-Event: {$bpmnEventName}");
                         }
                         $common->frontEndShow("TEXT", "> Continue the case #{$applicationNumber}");
                         $common->frontEndShow("TEXT", "> Routing the case #{$applicationNumber}...");
                         //Continue the case
                         //Derivate case
                         $result = $ws->derivateCase("", $applicationUid, $delIndex);
                         $arrayResult = json_decode(json_encode($result), true);
                         if ($arrayResult["status_code"] == 0) {
                             $common->frontEndShow("TEXT", "    - OK");
                             $this->log("CONTINUED-CASE", "Case #{$applicationNumber} continued, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                         } else {
                             $common->frontEndShow("TEXT", "    - Failed: " . $arrayResult["message"]);
                             $this->log("CONTINUED-CASE", "Failed: " . $arrayResult["message"] . ", Case: #{$applicationNumber}, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                         }
                         $flagRecord = true;
                     }
                 } else {
                     $this->log("INVALID-CONTINUE-DATE", "Continue date: {$continueCaseDate}, Case: #{$applicationNumber}, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                 }
                 $counter++;
                 $flagNextRecord = true;
             }
             $start = $start + $limit;
         } while ($flagNextRecord);
         if (!$flagRecord) {
             $common->frontEndShow("TEXT", "Not exists any record to continue a case, on date \"{$datetime}\"");
             $this->log("NO-RECORDS", "Not exists any record to continue a case");
         }
         $common->frontEndShow("END");
         $this->log("END-CONTINUE-CASES", "Date \"{$datetime}\": End continue the cases");
     } catch (\Exception $e) {
         throw $e;
     }
 }
示例#16
0
 public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = "")
 {
     try {
         $applicationData = $this->loadCase($sApplicationUID);
         $aFields["APP_NUMBER"] = $applicationData["APP_NUMBER"];
         $oConfiguration = new Configuration();
         $sDelimiter = DBAdapter::getStringDelimiter();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails');
         $oCriteria->add(ConfigurationPeer::OBJ_UID, '');
         $oCriteria->add(ConfigurationPeer::PRO_UID, '');
         $oCriteria->add(ConfigurationPeer::USR_UID, '');
         $oCriteria->add(ConfigurationPeer::APP_UID, '');
         if (ConfigurationPeer::doCount($oCriteria) == 0) {
             $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => ''));
             $aConfiguration = array();
         } else {
             $aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
             if ($aConfiguration['CFG_VALUE'] != '') {
                 $aConfiguration = unserialize($aConfiguration["CFG_VALUE"]);
                 $passwd = $aConfiguration["MESS_PASSWORD"];
                 $passwdDec = G::decrypt($passwd, "EMAILENCRYPT");
                 $auxPass = explode('hash:', $passwdDec);
                 if (count($auxPass) > 1) {
                     if (count($auxPass) == 2) {
                         $passwd = $auxPass[1];
                     } else {
                         array_shift($auxPass);
                         $passwd = implode('', $auxPass);
                     }
                 }
                 $aConfiguration["MESS_PASSWORD"] = $passwd;
             } else {
                 $aConfiguration = array();
             }
         }
         if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {
             return false;
         }
         //Send derivation notification - Start
         $oTask = new Task();
         $aTaskInfo = $oTask->load($sCurrentTask);
         if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') {
             return false;
         }
         if ($sFrom == '') {
             $sFrom = '"ProcessMaker"';
         }
         $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $sFrom, $match);
         if (!$hasEmailFrom || strpos($sFrom, $aConfiguration['MESS_ACCOUNT']) === false) {
             if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') {
                 $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>';
             } else {
                 if ($aConfiguration['MESS_ENGINE'] == 'MAIL') {
                     $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>';
                 } else {
                     if ($aConfiguration['MESS_SERVER'] != '') {
                         if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) {
                             $sFrom .= ' <info@' . $sAux . '>';
                         } else {
                             $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>';
                         }
                     } else {
                         $sFrom .= ' <*****@*****.**>';
                     }
                 }
             }
         }
         if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') {
             $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields);
         } else {
             $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION');
         }
         //erik: new behaviour for messages
         G::loadClass('configuration');
         $oConf = new Configurations();
         $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', '');
         $conf = $oConf->aConfig;
         $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP;
         $swtplDefault = 0;
         $sBody = null;
         if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) && isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) && $conf["TAS_DEF_MESSAGE_TYPE"] == "template" && $conf["TAS_DEF_MESSAGE_TEMPLATE"] != "") {
             if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") {
                 $swtplDefault = 1;
             }
             $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"];
             if (!file_exists($fileTemplate)) {
                 throw new Exception("Template file \"{$fileTemplate}\" does not exist.");
             }
             $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $aFields);
         } else {
             $sBody = nl2br(G::replaceDataGridField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields));
         }
         G::LoadClass("tasks");
         G::LoadClass("groups");
         G::LoadClass("spool");
         $task = new Tasks();
         $group = new Groups();
         $oUser = new Users();
         foreach ($aTasks as $aTask) {
             $sTo = null;
             $sCc = null;
             switch ($aTask["TAS_ASSIGN_TYPE"]) {
                 case "SELF_SERVICE":
                     if ($swtplDefault == 1) {
                         G::verifyPath($pathEmail, true);
                         //Create if it does not exist
                         $fileTemplate = $pathEmail . "unassignedMessage.html";
                         if (!file_exists($fileTemplate)) {
                             @copy(PATH_TPL . "mails" . PATH_SEP . "unassignedMessage.html", $fileTemplate);
                         }
                         $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields);
                     }
                     if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) {
                         $arrayTaskUser = array();
                         $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1);
                         foreach ($arrayAux1 as $arrayGroup) {
                             $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]);
                             foreach ($arrayAux2 as $arrayUser) {
                                 $arrayTaskUser[] = $arrayUser["USR_UID"];
                             }
                         }
                         $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1);
                         foreach ($arrayAux1 as $arrayUser) {
                             $arrayTaskUser[] = $arrayUser["USR_UID"];
                         }
                         $criteria = new Criteria("workflow");
                         $criteria->addSelectColumn(UsersPeer::USR_UID);
                         $criteria->addSelectColumn(UsersPeer::USR_USERNAME);
                         $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
                         $criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
                         $criteria->addSelectColumn(UsersPeer::USR_EMAIL);
                         $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN);
                         $rsCriteria = UsersPeer::doSelectRs($criteria);
                         $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                         $to = null;
                         $cc = null;
                         $sw = 1;
                         while ($rsCriteria->next()) {
                             $row = $rsCriteria->getRow();
                             $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">";
                             if ($sw == 1) {
                                 $to = $toAux;
                                 $sw = 0;
                             } else {
                                 $cc = $cc . ($cc != null ? "," : null) . $toAux;
                             }
                         }
                         $sTo = $to;
                         $sCc = $cc;
                     }
                     break;
                 default:
                     if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) {
                         $aUser = $oUser->load($aTask["USR_UID"]);
                         $sTo = ($aUser["USR_FIRSTNAME"] != "" || $aUser["USR_LASTNAME"] != "" ? $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : "") . "<" . $aUser["USR_EMAIL"] . ">";
                     }
                     break;
             }
             if ($sTo != null) {
                 $oSpool = new spoolRun();
                 if ($aConfiguration['MESS_RAUTH'] == false || is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false') {
                     $aConfiguration['MESS_RAUTH'] = 0;
                 } else {
                     $aConfiguration['MESS_RAUTH'] = 1;
                 }
                 $oSpool->setConfig(array("MESS_ENGINE" => $aConfiguration["MESS_ENGINE"], "MESS_SERVER" => $aConfiguration["MESS_SERVER"], "MESS_PORT" => $aConfiguration["MESS_PORT"], "MESS_ACCOUNT" => $aConfiguration["MESS_ACCOUNT"], "MESS_PASSWORD" => $aConfiguration["MESS_PASSWORD"], "SMTPAuth" => $aConfiguration["MESS_RAUTH"] == "1" ? true : false, "SMTPSecure" => isset($aConfiguration["SMTPSecure"]) ? $aConfiguration["SMTPSecure"] : ""));
                 $oSpool->create(array("msg_uid" => "", "app_uid" => $sApplicationUID, "del_index" => $iDelegation, "app_msg_type" => "DERIVATION", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $sTo, "app_msg_body" => $sBody, "app_msg_cc" => $sCc, "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending"));
                 if ($aConfiguration["MESS_BACKGROUND"] == "" || $aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1") {
                     $oSpool->sendMail();
                 }
             }
         }
         //Send derivation notification - End
     } catch (Exception $oException) {
         throw $oException;
     }
 }
示例#17
0
 if ($oForm->fields[$sField]->pmconnection != '' && $oForm->fields[$sField]->pmfield != '') {
     if (isset($oForm->fields[$oForm->fields[$sField]->pmconnection])) {
         require_once PATH_CORE . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'AdditionalTables.php';
         $oAdditionalTables = new AdditionalTables();
         try {
             $aData = $oAdditionalTables->load($oForm->fields[$oForm->fields[$sField]->pmconnection]->pmtable, true);
         } catch (Exception $oError) {
             $aData = array('FIELDS' => array());
         }
         $aKeys = array();
         $aAux = explode('|', $oForm->fields[$oForm->fields[$sField]->pmconnection]->keys);
         $i = 0;
         $aValues = array();
         foreach ($aData['FIELDS'] as $aField) {
             if ($aField['FLD_KEY'] == '1') {
                 $aKeys[$aField['FLD_NAME']] = isset($aAux[$i]) ? G::replaceDataField($aAux[$i], $Fields['APP_DATA']) : '';
                 $i++;
             }
             if ($aField['FLD_NAME'] == $oForm->fields[$sField]->pmfield) {
                 $aValues[$aField['FLD_NAME']] = $Fields['APP_DATA'][$sField];
             } else {
                 $aValues[$aField['FLD_NAME']] = '';
             }
         }
         try {
             $aRow = $oAdditionalTables->getDataTable($oForm->fields[$oForm->fields[$sField]->pmconnection]->pmtable, $aKeys);
         } catch (Exception $oError) {
             $aRow = false;
         }
         if ($aRow) {
             foreach ($aValues as $sKey => $sValue) {
示例#18
0
/**
 *
 * @method
 *
 * Generates an Output Document
 *
 * @name PMFGenerateOutputDocument
 * @label PMF Generate Output Document
 *
 * @param string(32) | $outputID | Output ID | Output Document ID
 * @return none | $none | None | None
 *
 */
function PMFGenerateOutputDocument($outputID, $sApplication = null, $index = null, $sUserLogged = null)
{
    $g = new G();
    $g->sessionVarSave();
    if ($sApplication) {
        $_SESSION["APPLICATION"] = $sApplication;
    } else {
        $sApplication = $_SESSION["APPLICATION"];
    }
    if ($index) {
        $_SESSION["INDEX"] = $index;
    } else {
        $index = $_SESSION["INDEX"];
    }
    if ($sUserLogged) {
        $_SESSION["USER_LOGGED"] = $sUserLogged;
    } else {
        $sUserLogged = $_SESSION["USER_LOGGED"];
    }
    G::LoadClass('case');
    $oCase = new Cases();
    $oCase->thisIsTheCurrentUser($sApplication, $index, $sUserLogged, '', 'casesListExtJs');
    //require_once 'classes/model/OutputDocument.php';
    $oOutputDocument = new OutputDocument();
    $aOD = $oOutputDocument->load($outputID);
    $Fields = $oCase->loadCase($sApplication);
    //The $_GET['UID'] variable is used when a process executes.
    //$_GET['UID']=($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID'];
    //$sUID = ($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID'];
    $sFilename = preg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
    require_once 'classes/model/AppFolder.php';
    require_once 'classes/model/AppDocument.php';
    //Get the Custom Folder ID (create if necessary)
    $oFolder = new AppFolder();
    //$aOD['OUT_DOC_DESTINATION_PATH'] = ($aOD['OUT_DOC_DESTINATION_PATH']=='')?PATH_DOCUMENT
    //      . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs'. PATH_SEP:$aOD['OUT_DOC_DESTINATION_PATH'];
    $folderId = $oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH'], $sApplication);
    //Tags
    $fileTags = $oFolder->parseTags($aOD['OUT_DOC_TAGS'], $sApplication);
    //Get last Document Version and apply versioning if is enabled
    $oAppDocument = new AppDocument();
    $lastDocVersion = $oAppDocument->getLastDocVersion($outputID, $sApplication);
    $oCriteria = new Criteria('workflow');
    $oCriteria->add(AppDocumentPeer::APP_UID, $sApplication);
    //$oCriteria->add(AppDocumentPeer::DEL_INDEX,    $index);
    $oCriteria->add(AppDocumentPeer::DOC_UID, $outputID);
    $oCriteria->add(AppDocumentPeer::DOC_VERSION, $lastDocVersion);
    $oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT');
    $oDataset = AppDocumentPeer::doSelectRS($oCriteria);
    $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
    $oDataset->next();
    if ($aOD['OUT_DOC_VERSIONING'] && $lastDocVersion != 0) {
        //Create new Version of current output
        $lastDocVersion++;
        if ($aRow = $oDataset->getRow()) {
            $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion + 1, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags);
            $oAppDocument = new AppDocument();
            $oAppDocument->create($aFields);
            $sDocUID = $aRow['APP_DOC_UID'];
        }
    } else {
        ////No versioning so Update a current Output or Create new if no exist
        if ($aRow = $oDataset->getRow()) {
            //Update
            $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags);
            $oAppDocument = new AppDocument();
            $oAppDocument->update($aFields);
            $sDocUID = $aRow['APP_DOC_UID'];
        } else {
            //we are creating the appdocument row
            //create
            if ($lastDocVersion == 0) {
                $lastDocVersion++;
            }
            $aFields = array('APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags);
            $oAppDocument = new AppDocument();
            $aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create($aFields);
        }
    }
    $sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion;
    $pathOutput = PATH_DOCUMENT . G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP;
    //G::pr($sFilename);die;
    G::mk_dir($pathOutput);
    $aProperties = array();
    if (!isset($aOD['OUT_DOC_MEDIA'])) {
        $aOD['OUT_DOC_MEDIA'] = 'Letter';
    }
    if (!isset($aOD['OUT_DOC_LEFT_MARGIN'])) {
        $aOD['OUT_DOC_LEFT_MARGIN'] = '15';
    }
    if (!isset($aOD['OUT_DOC_RIGHT_MARGIN'])) {
        $aOD['OUT_DOC_RIGHT_MARGIN'] = '15';
    }
    if (!isset($aOD['OUT_DOC_TOP_MARGIN'])) {
        $aOD['OUT_DOC_TOP_MARGIN'] = '15';
    }
    if (!isset($aOD['OUT_DOC_BOTTOM_MARGIN'])) {
        $aOD['OUT_DOC_BOTTOM_MARGIN'] = '15';
    }
    $aProperties['media'] = $aOD['OUT_DOC_MEDIA'];
    $aProperties['margins'] = array('left' => $aOD['OUT_DOC_LEFT_MARGIN'], 'right' => $aOD['OUT_DOC_RIGHT_MARGIN'], 'top' => $aOD['OUT_DOC_TOP_MARGIN'], 'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']);
    if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) {
        $aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR'];
    }
    $oOutputDocument->generate($outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (bool) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties);
    //Plugin Hook PM_UPLOAD_DOCUMENT for upload document
    //G::LoadClass('plugin');
    $oPluginRegistry =& PMPluginRegistry::getSingleton();
    if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) {
        $triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT);
        $aFields['APP_DOC_PLUGIN'] = $triggerDetail->sNamespace;
        $oAppDocument1 = new AppDocument();
        $oAppDocument1->update($aFields);
        $sPathName = PATH_DOCUMENT . G::getPathFromUID($sApplication) . PATH_SEP;
        $oData['APP_UID'] = $sApplication;
        $oData['ATTACHMENT_FOLDER'] = true;
        switch ($aOD['OUT_DOC_GENERATE']) {
            case "BOTH":
                $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion());
                $documentData->sFileType = "PDF";
                $documentData->bUseOutputFolder = true;
                $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
                if ($uploadReturn) {
                    //Only delete if the file was saved correctly
                    unlink($pathOutput . $sFilename . '.pdf');
                }
                $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion());
                $documentData->sFileType = "DOC";
                $documentData->bUseOutputFolder = true;
                $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
                if ($uploadReturn) {
                    //Only delete if the file was saved correctly
                    unlink($pathOutput . $sFilename . '.doc');
                }
                break;
            case "PDF":
                $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion());
                $documentData->sFileType = "PDF";
                $documentData->bUseOutputFolder = true;
                $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
                if ($uploadReturn) {
                    //Only delete if the file was saved correctly
                    unlink($pathOutput . $sFilename . '.pdf');
                }
                break;
            case "DOC":
                $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion());
                $documentData->sFileType = "DOC";
                $documentData->bUseOutputFolder = true;
                $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
                if ($uploadReturn) {
                    //Only delete if the file was saved correctly
                    unlink($pathOutput . $sFilename . '.doc');
                }
                break;
        }
    }
    $g->sessionVarRestore();
}
示例#19
0
    /**
     * 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;
    }
示例#20
0
    /**
     * Create Message-Application for the Case
     *
     * @param string $applicationUid       Unique id of Case
     * @param string $projectUid           Unique id of Project
     * @param string $eventUidThrow        Unique id of Event (throw)
     * @param array  $arrayApplicationData Case data
     *
     * return bool Return true if been created, false otherwise
     */
    public function create($applicationUid, $projectUid, $eventUidThrow, array $arrayApplicationData)
    {
        try {
            $flagCreate = true;

            //Set data
            //Message-Event-Relation - Get unique id of Event (catch)
            $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();

            $arrayMessageEventRelationData = $messageEventRelation->getMessageEventRelationWhere(
                array(
                    \MessageEventRelationPeer::PRJ_UID       => $projectUid,
                    \MessageEventRelationPeer::EVN_UID_THROW => $eventUidThrow
                ),
                true
            );

            if (!is_null($arrayMessageEventRelationData)) {
                $eventUidCatch = $arrayMessageEventRelationData["EVN_UID_CATCH"];
            } else {
                $flagCreate = false;
            }

            //Message-Application - Get data ($eventUidThrow)
            $messageEventDefinition = new \ProcessMaker\BusinessModel\MessageEventDefinition();

            if ($messageEventDefinition->existsEvent($projectUid, $eventUidThrow)) {
                $arrayMessageEventDefinitionData = $messageEventDefinition->getMessageEventDefinitionByEvent($projectUid, $eventUidThrow, true);

                $arrayMessageApplicationVariables = $arrayMessageEventDefinitionData["MSGED_VARIABLES"];
                $messageApplicationCorrelation = \G::replaceDataField($arrayMessageEventDefinitionData["MSGED_CORRELATION"], $arrayApplicationData["APP_DATA"]);

                foreach ($arrayMessageApplicationVariables as $key => $value) {
                    $arrayMessageApplicationVariables[$key] = \G::replaceDataField($value, $arrayApplicationData["APP_DATA"]);
                }
            } else {
                $flagCreate = false;
            }

            if (!$flagCreate) {
                //Return
                return false;
            }

            //Create
            $cnn = \Propel::getConnection("workflow");

            try {
                $messageApplication = new \MessageApplication();

                $messageApplicationUid = \ProcessMaker\Util\Common::generateUID();

                $messageApplication->setMsgappUid($messageApplicationUid);
                $messageApplication->setAppUid($applicationUid);
                $messageApplication->setPrjUid($projectUid);
                $messageApplication->setEvnUidThrow($eventUidThrow);
                $messageApplication->setEvnUidCatch($eventUidCatch);
                $messageApplication->setMsgappVariables(serialize($arrayMessageApplicationVariables));
                $messageApplication->setMsgappCorrelation($messageApplicationCorrelation);
                $messageApplication->setMsgappThrowDate("now");

                if ($messageApplication->validate()) {
                    $cnn->begin();

                    $result = $messageApplication->save();

                    $cnn->commit();

                    //Return
                    return true;
                } else {
                    $msg = "";

                    foreach ($messageApplication->getValidationFailures() as $validationFailure) {
                        $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
                    }

                    throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
                }
            } catch (\Exception $e) {
                $cnn->rollback();

                throw $e;
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }
示例#21
0
 public function sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom = "")
 {
     try {
         require_once 'classes/model/Configuration.php';
         $oConfiguration = new Configuration();
         $sDelimiter = DBAdapter::getStringDelimiter();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails');
         $oCriteria->add(ConfigurationPeer::OBJ_UID, '');
         $oCriteria->add(ConfigurationPeer::PRO_UID, '');
         $oCriteria->add(ConfigurationPeer::USR_UID, '');
         $oCriteria->add(ConfigurationPeer::APP_UID, '');
         if (ConfigurationPeer::doCount($oCriteria) == 0) {
             $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => ''));
             $aConfiguration = array();
         } else {
             $aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
             if ($aConfiguration['CFG_VALUE'] != '') {
                 $aConfiguration = unserialize($aConfiguration['CFG_VALUE']);
                 $passwd = $aConfiguration['MESS_PASSWORD'];
                 $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT');
                 $auxPass = explode('hash:', $passwdDec);
                 if (count($auxPass) > 1) {
                     if (count($auxPass) == 2) {
                         $passwd = $auxPass[1];
                     } else {
                         array_shift($auxPass);
                         $passwd = implode('', $auxPass);
                     }
                 }
                 $aConfiguration['MESS_PASSWORD'] = $passwd;
             } else {
                 $aConfiguration = array();
             }
         }
         if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {
             return false;
         }
         $oUser = new Users();
         $aUser = $oUser->load($usrUid);
         $authorName = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
         G::LoadClass('case');
         $oCase = new Cases();
         $aFields = $oCase->loadCase($appUid);
         $configNoteNotification['subject'] = G::LoadTranslation('ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION') . " @#APP_TITLE ";
         $configNoteNotification['body'] = G::LoadTranslation('ID_CASE') . ": @#APP_TITLE<br />" . G::LoadTranslation('ID_AUTHOR') . ": {$authorName}<br /><br />{$noteContent}";
         /*
         if ($sFrom == '') {
             $sFrom = '"ProcessMaker"';
         }
         */
         if (isset($aConfiguration['MESS_FROM_NAME']) && $aConfiguration['MESS_FROM_NAME'] != '') {
             $sFrom = $aConfiguration['MESS_FROM_NAME'];
         }
         $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $sFrom, $match);
         if (!$hasEmailFrom || strpos($sFrom, $aConfiguration['MESS_ACCOUNT']) === false) {
             if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') {
                 $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>';
             } else {
                 if ($aConfiguration['MESS_ENGINE'] == 'MAIL') {
                     $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>';
                 } else {
                     if ($aConfiguration['MESS_SERVER'] != '') {
                         if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) {
                             $sFrom .= ' <info@' . $sAux . '>';
                         } else {
                             $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>';
                         }
                     } else {
                         $sFrom .= ' <*****@*****.**>';
                     }
                 }
             }
         }
         $sSubject = G::replaceDataField($configNoteNotification['subject'], $aFields);
         $sBody = nl2br(G::replaceDataField($configNoteNotification['body'], $aFields));
         G::LoadClass('spool');
         $oUser = new Users();
         $recipientsArray = explode(",", $noteRecipients);
         foreach ($recipientsArray as $recipientUid) {
             $aUser = $oUser->load($recipientUid);
             $sTo = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
             $oSpool = new spoolRun();
             if ($aConfiguration['MESS_RAUTH'] == false || is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false') {
                 $aConfiguration['MESS_RAUTH'] = 0;
             } else {
                 $aConfiguration['MESS_RAUTH'] = 1;
             }
             $oSpool->setConfig(array('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'], 'MESS_SERVER' => $aConfiguration['MESS_SERVER'], 'MESS_PORT' => $aConfiguration['MESS_PORT'], 'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'], 'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false, 'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : ''));
             $oSpool->create(array('msg_uid' => '', 'app_uid' => $appUid, 'del_index' => 0, 'app_msg_type' => 'DERIVATION', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $sTo, 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending'));
             if ($aConfiguration['MESS_BACKGROUND'] == '' || $aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1') {
                 $oSpool->sendMail();
             }
         }
         //Send derivation notification - End
     } catch (Exception $oException) {
         throw $oException;
     }
 }
示例#22
0
try {
    if (isset($_GET["inputEnconde64"])) {
        $_GET['input'] = base64_decode($_GET['input']);
    }
    $sData = base64_decode(str_rot13($_GET['hash']));
    list($SQL, $DB_UID) = explode('@|', $sData);
    // Remplace values for dependent fields
    $aDependentFieldsKeys = explode("|", base64_decode(str_rot13($_GET['dependentFieldsKeys'])));
    $aDependentFieldsValue = explode("|", $_GET['dependentFieldsValue']);
    if ($aDependentFieldsKeys) {
        $aDependentFields = array();
        foreach ($aDependentFieldsKeys as $nKey => $sFieldVar) {
            $sKeyDepFields = substr($sFieldVar, 2);
            $aDependentFields[$sKeyDepFields] = $aDependentFieldsValue[$nKey];
        }
        $SQL = G::replaceDataField($SQL, $aDependentFields);
    }
    // Parsed SQL Structure
    G::LoadClass('phpSqlParser');
    $parser = new PHPSQLParser($SQL);
    $searchType = $_GET["searchType"];
    // Verif parsed array
    // print_r($parser->parsed);
    $SQL = queryModified($parser->parsed, $_GET['input'], $searchType);
    $aRows = array();
    try {
        $con = Propel::getConnection($DB_UID);
        $con->begin();
        $rs = $con->executeQuery($SQL);
        $con->commit();
        while ($rs->next()) {
示例#23
0
 public function appTitleByTaskCaseLabelUpdate($taskUid, $lang, $cron = 0)
 {
     $taskDefTitle = null;
     $criteria = new Criteria("workflow");
     $criteria->addSelectColumn(ContentPeer::CON_VALUE);
     $criteria->add(ContentPeer::CON_CATEGORY, "TAS_DEF_TITLE");
     $criteria->add(ContentPeer::CON_ID, $taskUid);
     $criteria->add(ContentPeer::CON_LANG, $lang);
     $rsCriteria = ContentPeer::doSelectRS($criteria);
     $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     while ($rsCriteria->next()) {
         $row = $rsCriteria->getRow();
         $taskDefTitle = $row["CON_VALUE"];
     }
     //Get cases
     $criteriaAPPCV = new Criteria("workflow");
     $criteriaAPPCV->setDistinct();
     $criteriaAPPCV->addSelectColumn(AppCacheViewPeer::APP_UID);
     $criteriaAPPCV->add(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN");
     $criteriaAPPCV->add(AppCacheViewPeer::TAS_UID, $taskUid);
     $rsCriteriaAPPCV = AppCacheViewPeer::doSelectRS($criteriaAPPCV);
     $rsCriteriaAPPCV->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     while ($rsCriteriaAPPCV->next()) {
         if ($cron == 1) {
             $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
             $arrayCron["processcTimeStart"] = time();
             @file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
         }
         $row = $rsCriteriaAPPCV->getRow();
         $appcvAppUid = $row["APP_UID"];
         //Current task?
         $criteria = new Criteria("workflow");
         $criteria->addSelectColumn(AppCacheViewPeer::APP_UID);
         $criteria->add(AppCacheViewPeer::APP_UID, $appcvAppUid);
         $criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN");
         $criteria->add(AppCacheViewPeer::TAS_UID, $taskUid);
         $rsCriteria = AppCacheViewPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         if ($rsCriteria->next()) {
             $appTitle = $taskDefTitle;
             $app = new Application();
             $arrayAppField = $app->Load($appcvAppUid);
             $appTitle = !empty($appTitle) ? $appTitle : "#" . $arrayAppField["APP_NUMBER"];
             $appTitleNew = G::replaceDataField($appTitle, unserialize($arrayAppField["APP_DATA"]));
             if (isset($arrayAppField["APP_TITLE"]) && $arrayAppField["APP_TITLE"] != $appTitleNew) {
                 //Updating the value in content, where...
                 $criteria1 = new Criteria("workflow");
                 $criteria1->add(ContentPeer::CON_CATEGORY, "APP_TITLE");
                 $criteria1->add(ContentPeer::CON_ID, $appcvAppUid);
                 $criteria1->add(ContentPeer::CON_LANG, $lang);
                 //Update set
                 $criteria2 = new Criteria("workflow");
                 $criteria2->add(ContentPeer::CON_VALUE, $appTitleNew);
                 BasePeer::doUpdate($criteria1, $criteria2, Propel::getConnection("workflow"));
             }
         }
     }
 }
示例#24
0
 /**
  * replaceFields
  *
  * @param array $Fields
  * @param string $content default value string empty
  *
  * @return none
  */
 function replaceFields($Fields = array(), $content = "")
 {
     return G::replaceDataField($content, $Fields);
 }
示例#25
0
 /**
  * Function that validates the values retrieved in an Array:
  * ex $_POST['form']
  *
  * @author David S. Callizaya S. <*****@*****.**>
  * @access public
  * @param array $newValues
  * @return array
  */
 public function validateArray($newValues)
 {
     $values = array();
     foreach ($this->fields as $k => $v) {
         if ($v->type != 'submit') {
             if ($v->type != 'file') {
                 if (array_key_exists($k, $newValues)) {
                     switch ($v->type) {
                         case 'radiogroup':
                             $values[$k] = $newValues[$k];
                             $values[$k . "_label"] = $newValues[$k . "_label"] = $v->options[$newValues[$k]];
                             break;
                         case 'suggest':
                             $values[$k] = $newValues[$k];
                             $values[$k . "_label"] = $newValues[$k . "_label"];
                             break;
                         case 'checkgroup':
                         case 'listbox':
                             if (is_array($newValues[$k])) {
                                 $values[$k] = $values[$k . "_label"] = null;
                                 foreach ($newValues[$k] as $i => $value) {
                                     //if $value is empty continue with the next loop, because this is a not selected/checked item
                                     //if (trim( $value ) == '') {
                                     //    continue;
                                     //}
                                     $values[$k] .= ($i != 0 ? "|" : null) . $value;
                                     if (isset($v->options[$value])) {
                                         $values[$k . "_label"] .= ($i != 0 ? "|" : null) . $v->options[$value];
                                     } else {
                                         // if hasn't options try execute a sql sentence
                                         $query = G::replaceDataField($this->fields[$k]->sql, $newValues);
                                         if ($query != '') {
                                             // execute just if a query was set, it should be not empty
                                             //we do the query to the external connection and we've got the label
                                             $con = Propel::getConnection($this->fields[$k]->sqlConnection != "" ? $this->fields[$k]->sqlConnection : "workflow");
                                             //use default connection workflow if connection is not defined. Same as Dynaforms
                                             $stmt = $con->prepareStatement($query);
                                             $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
                                             while ($rs->next()) {
                                                 list($rowId, $rowContent) = array_values($rs->getRow());
                                                 //This to be sure that the array is numeric. Some cases when is DBArray result it returns an associative. By JHL
                                                 if ($value == $rowId) {
                                                     $values[$k . "_label"] .= ($i != 0 ? "|" : null) . $rowContent;
                                                     break;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 $newValues[$k . "_label"] = isset($values[$k . "_label"]) ? $values[$k . "_label"] : null;
                             } else {
                                 $values[$k] = $newValues[$k];
                                 $values[$k . "_label"] = isset($newValues[$k . "_label"]) ? $newValues[$k . "_label"] : null;
                             }
                             break;
                         case 'dropdown':
                             $values[$k] = $newValues[$k];
                             if (isset($v->options[$newValues[$k]])) {
                                 $values[$k . "_label"] = $newValues[$k . "_label"] = $v->options[$newValues[$k]];
                             } else {
                                 $query = G::replaceDataField($this->fields[$k]->sql, $newValues);
                                 // execute just if a query was set, it should be not empty
                                 if (trim($query) == '') {
                                     continue;
                                     //if it is  empty string skip it
                                 }
                                 //we do the query to the external connection and we've got the label
                                 $con = Propel::getConnection($this->fields[$k]->sqlConnection != "" ? $this->fields[$k]->sqlConnection : "workflow");
                                 $stmt = $con->prepareStatement($query);
                                 $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
                                 while ($rs->next()) {
                                     list($rowId, $rowContent) = $rs->getRow();
                                     if ($newValues[$k] == $rowId) {
                                         $values[$k . "_label"] = $rowContent;
                                         break;
                                     }
                                 }
                             }
                             break;
                         case "link":
                             $values[$k] = $newValues[$k];
                             $values[$k . "_label"] = $newValues[$k . "_label"];
                             break;
                         case 'grid':
                             foreach ($newValues[$k] as $j => $item) {
                                 if (is_array($item)) {
                                     $values[$k][$j] = $this->fields[$k]->maskValue($newValues[$k][$j], $this);
                                     foreach ($item as $kk => $vv) {
                                         if (isset($this->fields[$k]->fields[$kk])) {
                                             if ($this->fields[$k]->fields[$kk]->type != "file") {
                                                 switch ($this->fields[$k]->fields[$kk]->type) {
                                                     case "dropdown":
                                                         //We need to know which fields are dropdowns
                                                         $values[$k][$j] = $newValues[$k][$j];
                                                         if ($this->fields[$k]->validateValue($newValues[$k][$j], $this)) {
                                                             //If the dropdown has otions
                                                             if (isset($this->fields[$k]->fields[$kk]->options[$vv])) {
                                                                 $values[$k][$j][$kk . "_label"] = $newValues[$k][$j][$kk . "_label"] = $this->fields[$k]->fields[$kk]->options[$vv];
                                                             } else {
                                                                 //If hasn't options try execute a sql sentence
                                                                 $query = G::replaceDataField($this->fields[$k]->fields[$kk]->sql, $values[$k][$j]);
                                                                 $con = Propel::getConnection(!empty($this->fields[$k]->fields[$kk]->sqlConnection) ? $this->fields[$k]->fields[$kk]->sqlConnection : "workflow");
                                                                 $stmt = $con->prepareStatement($query);
                                                                 //Execute just if a query was set, it should be not empty
                                                                 if (trim($query) == "") {
                                                                     //if it is  empty string skip it
                                                                     continue;
                                                                 }
                                                                 $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
                                                                 while ($rs->next()) {
                                                                     //From the query executed we only need certain elements
                                                                     //note added by krlos pacha carlos[at]colosa[dot]com
                                                                     //the following line has the correct values because the query return an associative array. Related 7945 bug
                                                                     list($rowId, $rowContent) = explode(",", implode(",", $rs->getRow()));
                                                                     if ($vv == $rowId) {
                                                                         $values[$k][$j][$kk . "_label"] = $newValues[$k][$j][$kk . "_label"] = $rowContent;
                                                                         break;
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                         break;
                                                     case "link":
                                                         $values[$k][$j] = $newValues[$k][$j];
                                                         $values[$k][$j][$kk . "_label"] = $newValues[$k][$j][$kk . "_label"];
                                                         break;
                                                     case 'date':
                                                         $values[$k][$j][$kk] = $this->fields[$k]->fields[$kk]->maskDateValue($newValues[$k][$j][$kk], $this->fields[$k]->fields[$kk]);
                                                         break;
                                                     default:
                                                         //If there are no dropdowns previously setted and the evaluated field is not a dropdown
                                                         //only then rewritte the $values
                                                         $values[$k][$j] = $this->fields[$k]->maskValue($newValues[$k][$j], $this);
                                                         break;
                                                 }
                                             } else {
                                                 if (isset($_FILES["form"]["name"][$k][$j][$kk])) {
                                                     $values[$k][$j][$kk] = $_FILES["form"]["name"][$k][$j][$kk];
                                                 }
                                                 if (isset($this->fields[$k]->fields[$kk]->input) && !empty($this->fields[$k]->fields[$kk]->input)) {
                                                     //$_POST["INPUTS"][$k][$j][$kk] = $this->fields[$k]->fields[$kk]->input;
                                                     $_POST["INPUTS"][$k][$kk] = $this->fields[$k]->fields[$kk]->input;
                                                 }
                                             }
                                         }
                                     }
                                 } else {
                                     $values[$k][$j] = $this->fields[$k]->maskValue($newValues[$k][$j], $this);
                                 }
                             }
                             break;
                         case 'date':
                             $values[$k] = $this->fields[$k]->maskDateValue($newValues[$k], $this->fields[$k]);
                             break;
                         default:
                             if ($this->fields[$k]->validateValue($newValues[$k], $this)) {
                                 $values[$k] = $this->fields[$k]->maskValue($newValues[$k], $this);
                             }
                     }
                 } else {
                     switch ($v->type) {
                         case "checkgroup":
                         case "listbox":
                             //This value is added when the user does not mark any checkbox
                             $values[$k] = "__NULL__";
                             break;
                     }
                 }
             } else {
                 if (isset($_FILES["form"]["name"][$k])) {
                     $values[$k] = $_FILES["form"]["name"][$k];
                 }
                 if (isset($v->input) && !empty($v->input)) {
                     $_POST["INPUTS"][$k] = $v->input;
                 }
             }
         }
     }
     foreach ($newValues as $k => $v) {
         if (strpos($k, 'SYS_GRID_AGGREGATE_') !== false) {
             $values[$k] = $v;
         }
     }
     return $values;
 }
示例#26
0
    /**
     *
     * @param string $fileTags
     * @param string(32) $sessionID Application ID
     * @return string
     */
    public function parseTags ($fileTags, $sessionID = "")
    {

        if ($sessionID == "") {
            $sessionID = $_SESSION['APPLICATION'];
            //Get current Application Fields
        }

        $oApplication = new Application();
        $appFields = $oApplication->Load( $sessionID );
        $fileTagsParsed = G::replaceDataField( $fileTags, $appFields );
        $fileTagsParsed = G::replaceDataField( $fileTags, unserialize( $appFields['APP_DATA'] ) );
        return $fileTagsParsed;
    }
    public function sendActionsByEmail($data)
    {
        try {
            // Validations
            try {
                if (!is_object($data)) {
                    throw new Exception('The parameter $data is null.');
                }
                if (!isset($data->TAS_UID)) {
                    throw new Exception('The parameter $data->TAS_UID is null.');
                }

                if (!isset($data->APP_UID)) {
                    throw new Exception('The parameter $data->APP_UID is null.');
                }

                if (!isset($data->DEL_INDEX)) {
                    throw new Exception('The parameter $data->DEL_INDEX is null.');
                }

                if (!isset($data->USR_UID)) {
                    throw new Exception('The parameter $data->USR_UID is null.');
                }

                if ($data->TAS_UID == '') {
                    throw new Exception('The parameter $data->TAS_UID is empty.');
                }

                if ($data->APP_UID == '') {
                    throw new Exception('The parameter $data->APP_UID is empty.');
                }

                if ($data->DEL_INDEX == '') {
                    throw new Exception('The parameter $data->DEL_INDEX is empty.');
                }

                if ($data->USR_UID == '') {
                    throw new Exception('The parameter $data->USR_UID is empty.');
                }
            } catch(Exception $e) {
                echo $e->getMessage().' Please contact to your system administrator.';
                die;
            }

            G::LoadClass('pmFunctions');

            $emailSetup = getEmailConfiguration();

            if (!empty($emailSetup)) {
                require_once 'classes/model/AbeConfiguration.php';
                G::LoadClass('case');

                $cases = new Cases();
                $caseFields = $cases->loadCase($data->APP_UID);
                $criteria = new Criteria();
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_UID);
                $criteria->addSelectColumn(AbeConfigurationPeer::PRO_UID);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_TYPE);
                $criteria->addSelectColumn(AbeConfigurationPeer::TAS_UID);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_TEMPLATE);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_DYN_TYPE);
                $criteria->addSelectColumn(AbeConfigurationPeer::DYN_UID);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_EMAIL_FIELD);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_ACTION_FIELD);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_SUBJECT_FIELD);
                $criteria->addSelectColumn(DynaformPeer::DYN_CONTENT);
                $criteria->addJoin( AbeConfigurationPeer::DYN_UID, DynaformPeer::DYN_UID, Criteria::LEFT_JOIN );
                $criteria->add(AbeConfigurationPeer::PRO_UID, $caseFields['PRO_UID']);
                $criteria->add(AbeConfigurationPeer::TAS_UID, $data->TAS_UID);
                $result = AbeConfigurationPeer::doSelectRS($criteria);
                $result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                $result->next();
                if ($configuration = $result->getRow()) {
                    $configuration['ABE_EMAIL_FIELD'] = str_replace('@@', '', $configuration['ABE_EMAIL_FIELD']);
                    if ($configuration['ABE_EMAIL_FIELD'] != '' && isset($caseFields['APP_DATA'][$configuration['ABE_EMAIL_FIELD']])) {
                        $email = trim($caseFields['APP_DATA'][$configuration['ABE_EMAIL_FIELD']]);
                    } else {
                        require_once 'classes/model/Users.php';

                        $userInstance = new Users();
                        $userInfo     = $userInstance->getAllInformation($data->USR_UID);
                        $email        = $userInfo['mail'];
                    }

                    if ($email != '') {
                        $subject = G::replaceDataField( $configuration['ABE_SUBJECT_FIELD'], $caseFields['APP_DATA'] );
                        if($subject == ''){
                            $subject = $caseFields['APP_TITLE'];
                        }

                        // Create
                        require_once 'classes/model/AbeRequests.php';

                        $abeRequest = array();
                        $abeRequest['ABE_REQ_UID']      = '';
                        $abeRequest['ABE_UID']          = $configuration['ABE_UID'];
                        $abeRequest['APP_UID']          = $data->APP_UID;
                        $abeRequest['DEL_INDEX']        = $data->DEL_INDEX;
                        $abeRequest['ABE_REQ_SENT_TO']  = $email;
                        $abeRequest['ABE_REQ_SUBJECT']  = $subject;
                        $abeRequest['ABE_REQ_BODY']     = '';
                        $abeRequest['ABE_REQ_ANSWERED'] = 0;
                        $abeRequest['ABE_REQ_STATUS']   = 'PENDING';

                        try {
                            $abeRequestsInstance = new AbeRequests();
                            $abeRequest['ABE_REQ_UID'] = $abeRequestsInstance->createOrUpdate($abeRequest);
                        } catch (Exception $error) {
                            throw $error;
                        }

                        if ($configuration['ABE_TYPE'] != '') {
                            // Email
                            $_SESSION['CURRENT_DYN_UID'] = $configuration['DYN_UID'];

                            $scriptCode = '';
//                            foreach ($dynaform->fields as $fieldName => $field) {
//                                if ($field->type == 'submit') {
//                                    unset($dynaform->fields[$fieldName]);
//                                }
//                            }

                            $__ABE__ = '';
                            $link = (G::is_https() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/ActionsByEmail';

                            switch ($configuration['ABE_TYPE']) {
                                case 'LINK':
                                    // $__ABE__ .= $dynaform->render(PATH_FEATURES . 'actionsByEmail/xmlform.html', $scriptCode) . '<br />';
                                    $__ABE__ .= '<a href="' . $link . 'DataForm?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&DYN_UID=' . G::encrypt($configuration['DYN_UID'], URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Please complete this form</a>';
                                    break;
                                // coment
                                case 'FIELD':
                                        $variableService = new \ProcessMaker\Services\Api\Project\Variable();
                                        $variables = $variableService->doGetVariables($caseFields['PRO_UID']);
                                        $field = new stdClass();
                                        $field->label = 'Test';
                                        $field->type = 'dropdown';
                                        $field->options = array();
                                        $actionField = str_replace('@@', '', $configuration['ABE_ACTION_FIELD']);
                                        $dynaform = $configuration['DYN_UID'];
                                        $variables = G::json_decode($configuration['DYN_CONTENT'], true);
                                        if(isset($variables['items'][0]['items'])){
                                            $fields = $variables['items'][0]['items'];
                                            foreach ($fields as $key => $value) {
                                                foreach($value as $var){ G::pr($var);
                                                    if(isset($var['variable'])){
                                                        if ($var['variable'] == $actionField) {
                                                             $field->label = $var['label'];
                                                             $field->type  = $var['type'];
                                                             $values = $var['options'];
                                                             foreach ($values as $val){
                                                               $field->options[$val['value']] = $val['value'];
                                                             }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        G::LoadClass('pmDynaform');
                                        $obj = new pmDynaform($configuration['DYN_UID']);
                                        $configuration['CURRENT_DYNAFORM'] = $configuration['DYN_UID'];
                                        $file = $obj->printPmDynaformAbe($configuration);
                                        $__ABE__ .= $file;
                                        $__ABE__ .= '<strong>' . $field->label . '</strong><br /><table align="left" border="0"><tr>';
                                        switch ($field->type) {
                                            case 'dropdown':
                                            case 'radiogroup':
                                                $index = 1;
                                                $__ABE__.='<br /><td><table align="left" cellpadding="2"><tr>';
                                                foreach ($field->options as $optValue => $optName) {
                                                    $__ABE__ .= '<td align="center"><a style="text-decoration: none; color: #000; background-color: #E5E5E5; ';
                                                    $__ABE__ .= 'filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#EFEFEF, endColorstr=#BCBCBC); ';
                                                    $__ABE__ .= 'background-image: -webkit-gradient(linear, left top, left bottom, from(#EFEFEF), #BCBCBC); ';
                                                    $__ABE__ .= 'background-image: -webkit-linear-gradient(top, #EFEFEF, #BCBCBC); ';
                                                    $__ABE__ .= 'background-image: -moz-linear-gradient(top, #EFEFEF, #BCBCBC); background-image: -ms-linear-gradient(top, #EFEFEF, #BCBCBC); ';
                                                    $__ABE__ .= 'background-image: -o-linear-gradient(top, #EFEFEF, #BCBCBC); border: 1px solid #AAAAAA; ';
                                                    $__ABE__ .= 'border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); ';
                                                    $__ABE__ .= 'font-family: Arial,serif; font-size: 9pt; font-weight: 400; line-height: 14px; margin: 2px 0; padding: 2px 7px; ';
                                                    $__ABE__ .= 'text-decoration: none; text-transform: capitalize;" href="' .urldecode(urlencode($link)). '?ACTION='.G::encrypt('processABE', URL_KEY).'&APP_UID=';
                                                    $__ABE__ .= G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY);
                                                    $__ABE__ .= '&FIELD=' . G::encrypt($actionField, URL_KEY) . '&VALUE=' . G::encrypt($optValue, URL_KEY);
                                                    $__ABE__ .= '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank" >' . $optName;
                                                    $__ABE__ .= '</a></td>' . (($index % 5 == 0) ? '</tr><tr>' : '  ');
                                                    $index++;
                                                }

                                                $__ABE__.='</tr></table></td>';
                                                break;
                                            case 'yesno':
                                                $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . urlencode(G::encrypt($data->APP_UID, URL_KEY)) . '&DEL_INDEX=' . urlencode(G::encrypt($data->DEL_INDEX, URL_KEY)). '&FIELD=' . urlencode(G::encrypt($actionField, URL_KEY)) . '&VALUE=' . urlencode(G::encrypt(1, URL_KEY)) . '&ABER=' . urlencode(G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY)) . '" target="_blank">' . G::LoadTranslation('ID_YES_VALUE') . '</a></td>';
                                                $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . urlencode(G::encrypt($data->APP_UID, URL_KEY)) . '&DEL_INDEX=' . urlencode(G::encrypt($data->DEL_INDEX, URL_KEY)) . '&FIELD=' . urlencode(G::encrypt($actionField, URL_KEY)) . '&VALUE=' . urlencode(G::encrypt(0, URL_KEY)) . '&ABER=' . urlencode(G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY)) . '" target="_blank">' . G::LoadTranslation('ID_NO_VALUE') . '</a></td>';
                                                break;
                                            case 'checkbox':
                                                $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&FIELD=' . G::encrypt($actionField, URL_KEY) . '&VALUE=' . G::encrypt($field->value, URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Check</a></td>';
                                                $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&FIELD=' . G::encrypt($actionField, URL_KEY) . '&VALUE=' . G::encrypt($field->value, URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Uncheck</a></td>';
                                                break;
                                        }
                                        $__ABE__ .= '</tr></table>';
                                    break;
                            }

                            $__ABE__ = preg_replace('/\<img src=\"\/js\/maborak\/core\/images\/(.+?)\>/', '' , $__ABE__);
                            $__ABE__ = preg_replace('/\<input\b[^>]*\/>/', '' , $__ABE__);
                            $__ABE__ = preg_replace('/<select\b[^>]*>(.*?)<\/select>/is', "", $__ABE__);
                            $__ABE__ = preg_replace('/align=\"center\"/', '' , $__ABE__);
                            $__ABE__ = preg_replace('/class="tableGrid_view" /', 'class="tableGrid_view" width="100%" ', $__ABE__);
                            $caseFields['APP_DATA']['__ABE__'] = $__ABE__;

                            G::LoadClass("Users");

                            $user = new Users();
                            $userDetails = $user->loadDetails($data->PREVIOUS_USR_UID);
                            $emailFrom = $userDetails["USR_EMAIL"];

                            G::LoadClass('wsBase');

                            $wsBaseInstance = new wsBase();
                            $result = $wsBaseInstance->sendMessage($data->APP_UID,
                                                                   $emailFrom,
                                                                   $email,
                                                                   '',
                                                                   '',
                                                                   $subject,
                                                                   $configuration['ABE_TEMPLATE'],
                                                                   $caseFields['APP_DATA'],
                                                                   '');
                            $abeRequest['ABE_REQ_STATUS'] = ($result->status_code == 0 ? 'SENT' : 'ERROR');

                            $body = '';
                            $messageSent = executeQuery('SELECT `APP_MSG_BODY` FROM `APP_MESSAGE` ORDER BY `APP_MSG_SEND_DATE` DESC LIMIT 1');

                            if (!empty($messageSent) && is_array($messageSent)) {
                                $body = $messageSent[1]['APP_MSG_BODY'];
                            }

                            $abeRequest['ABE_REQ_BODY'] = $body;

                            // Update 
                            try {
                                $abeRequestsInstance = new AbeRequests();
                                $abeRequestsInstance->createOrUpdate($abeRequest);
                            } catch (Exception $error) {
                                throw $error;
                            }
                        }
                    }
                }
            }
        } catch (Exception $error) {
            throw $error;
        }
    }
示例#28
0
 /**
  * Get data of Cases OutputDocument
  *
  * @param string $applicationUid
  * @param string $outputDocumentUid
  * @param string $userUid
  *
  * return object Return an object with data of an OutputDocument
  */
 public function addCasesOutputDocument($applicationUid, $outputDocumentUid, $userUid)
 {
     try {
         $sApplication = $applicationUid;
         $index = \AppDelegation::getCurrentIndex($applicationUid);
         $sUserLogged = $userUid;
         $outputID = $outputDocumentUid;
         $g = new \G();
         $g->sessionVarSave();
         \G::LoadClass( 'case' );
         $oCase = new \Cases();
         $oCase->thisIsTheCurrentUser( $sApplication, $index, $sUserLogged, '', 'casesListExtJs' );
         //require_once 'classes/model/OutputDocument.php';
         $oOutputDocument = new \OutputDocument();
         $aOD = $oOutputDocument->load( $outputID );
         $Fields = $oCase->loadCase( $sApplication );
         $sFilename = preg_replace( '[^A-Za-z0-9_]', '_', \G::replaceDataField( $aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'] ) );
         require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppFolder.php");
         require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.php");
         //Get the Custom Folder ID (create if necessary)
         $oFolder = new \AppFolder();
         $folderId = $oFolder->createFromPath( $aOD['OUT_DOC_DESTINATION_PATH'], $sApplication );
         //Tags
         $fileTags = $oFolder->parseTags( $aOD['OUT_DOC_TAGS'], $sApplication );
         //Get last Document Version and apply versioning if is enabled
         $oAppDocument = new \AppDocument();
         $lastDocVersion = $oAppDocument->getLastDocVersion( $outputID, $sApplication );
         $oCriteria = new \Criteria( 'workflow' );
         $oCriteria->add( \AppDocumentPeer::APP_UID, $sApplication );
         $oCriteria->add( \AppDocumentPeer::DOC_UID, $outputID );
         $oCriteria->add( \AppDocumentPeer::DOC_VERSION, $lastDocVersion );
         $oCriteria->add( \AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT' );
         $oDataset = \AppDocumentPeer::doSelectRS( $oCriteria );
         $oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
         $oDataset->next();
         if (($aOD['OUT_DOC_VERSIONING']) && ($lastDocVersion != 0)) {
             //Create new Version of current output
             $lastDocVersion ++;
             if ($aRow = $oDataset->getRow()) {
                 $aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion + 1,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags);
                 $oAppDocument = new \AppDocument();
                 $oAppDocument->create( $aFields );
                 $sDocUID = $aRow['APP_DOC_UID'];
             }
         } else {
             ////No versioning so Update a current Output or Create new if no exist
             if ($aRow = $oDataset->getRow()) {
                 //Update
                 $aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags
                 );
                 $oAppDocument = new \AppDocument();
                 $oAppDocument->update( $aFields );
                 $sDocUID = $aRow['APP_DOC_UID'];
             } else {
                 //we are creating the appdocument row
                 //create
                 if ($lastDocVersion == 0) {
                     $lastDocVersion ++;
                 }
                 $aFields = array ('APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags
                 );
                 $oAppDocument = new \AppDocument();
                 $aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create( $aFields );
             }
         }
         $sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion;
         $pathOutput = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die;
         \G::mk_dir( $pathOutput );
         $aProperties = array ();
         if (! isset( $aOD['OUT_DOC_MEDIA'] )) {
             $aOD['OUT_DOC_MEDIA'] = 'Letter';
         }
         if (! isset( $aOD['OUT_DOC_LEFT_MARGIN'] )) {
             $aOD['OUT_DOC_LEFT_MARGIN'] = '15';
         }
         if (! isset( $aOD['OUT_DOC_RIGHT_MARGIN'] )) {
             $aOD['OUT_DOC_RIGHT_MARGIN'] = '15';
         }
         if (! isset( $aOD['OUT_DOC_TOP_MARGIN'] )) {
             $aOD['OUT_DOC_TOP_MARGIN'] = '15';
         }
         if (! isset( $aOD['OUT_DOC_BOTTOM_MARGIN'] )) {
             $aOD['OUT_DOC_BOTTOM_MARGIN'] = '15';
         }
         $aProperties['media'] = $aOD['OUT_DOC_MEDIA'];
         $aProperties['margins'] = array ('left' => $aOD['OUT_DOC_LEFT_MARGIN'],'right' => $aOD['OUT_DOC_RIGHT_MARGIN'],'top' => $aOD['OUT_DOC_TOP_MARGIN'],'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']
         );
         if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) {
             $aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR'];
         }
         $this->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties , $applicationUid);
         //Plugin Hook PM_UPLOAD_DOCUMENT for upload document
         //G::LoadClass('plugin');
         $oPluginRegistry = & \PMPluginRegistry::getSingleton();
         if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) {
             $triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
             $aFields['APP_DOC_PLUGIN'] = $triggerDetail->sNamespace;
             $oAppDocument1 = new \AppDocument();
             $oAppDocument1->update( $aFields );
             $sPathName = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP;
             $oData['APP_UID'] = $sApplication;
             $oData['ATTACHMENT_FOLDER'] = true;
             switch ($aOD['OUT_DOC_GENERATE']) {
                 case "BOTH":
                     $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() );
                     $documentData->sFileType = "PDF";
                     $documentData->bUseOutputFolder = true;
                     $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
                     if ($uploadReturn) {
                         //Only delete if the file was saved correctly
                         unlink( $pathOutput . $sFilename . '.pdf' );
                     }
                     $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() );
                     $documentData->sFileType = "DOC";
                     $documentData->bUseOutputFolder = true;
                     $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
                     if ($uploadReturn) {
                         //Only delete if the file was saved correctly
                         unlink( $pathOutput . $sFilename . '.doc' );
                     }
                     break;
                 case "PDF":
                     $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() );
                     $documentData->sFileType = "PDF";
                     $documentData->bUseOutputFolder = true;
                     $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
                     if ($uploadReturn) {
                         //Only delete if the file was saved correctly
                         unlink( $pathOutput . $sFilename . '.pdf' );
                     }
                     break;
                 case "DOC":
                     $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() );
                     $documentData->sFileType = "DOC";
                     $documentData->bUseOutputFolder = true;
                     $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
                     if ($uploadReturn) {
                         //Only delete if the file was saved correctly
                         unlink( $pathOutput . $sFilename . '.doc' );
                     }
                     break;
             }
         }
         $g->sessionVarRestore();
         $oAppDocument = \AppDocumentPeer::retrieveByPK( $aFields['APP_DOC_UID'], $lastDocVersion);
         if ($oAppDocument->getAppDocStatus() == 'DELETED') {
             $oAppDocument->setAppDocStatus('ACTIVE');
             $oAppDocument->save();
         }
         $response = $this->getCasesOutputDocument($applicationUid, $userUid, $aFields['APP_DOC_UID']);
         return $response;
     } catch (\Exception $e) {
         throw $e;
     }
 }
示例#29
0
 } else {
     $aOD['__DYNAFORM_OPTIONS']['PREVIOUS_STEP'] = $aPreviousStep['PAGE'];
     $aOD['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = G::loadTranslation("ID_PREVIOUS_STEP");
 }
 $aOD['__DYNAFORM_OPTIONS']['NEXT_STEP'] = $aNextStep['PAGE'];
 $aOD['__DYNAFORM_OPTIONS']['NEXT_STEP_LABEL'] = G::loadTranslation("ID_NEXT_STEP");
 switch ($_GET['ACTION']) {
     case 'GENERATE':
         //START: If there is a Break Step registered from Plugin Similar as a Trigger debug
         $oPluginRegistry =& PMPluginRegistry::getSingleton();
         if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT_BEFORE)) {
             //If a Plugin has registered a Break Page Evaluator
             $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT_BEFORE, array('USR_UID' => $_SESSION['USER_LOGGED']));
         }
         //END: If there is a Break Step registered from Plugin
         $sFilenameOriginal = $sFilename = preg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
         require_once 'classes/model/AppFolder.php';
         require_once 'classes/model/AppDocument.php';
         //Get the Custom Folder ID (create if necessary)
         $oFolder = new AppFolder();
         $folderId = $oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH']);
         //Tags
         $fileTags = $oFolder->parseTags($aOD['OUT_DOC_TAGS']);
         //Get last Document Version and apply versioning if is enabled
         $oAppDocument = new AppDocument();
         $lastDocVersion = $oAppDocument->getLastDocVersion($_GET['UID'], $_SESSION['APPLICATION']);
         //if(($aOD['OUT_DOC_VERSIONING'])||($lastDocVersion==0)){
         //  $lastDocVersion++;
         //}
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(AppDocumentPeer::APP_UID, $_SESSION['APPLICATION']);
示例#30
0
 /**
  * Function that validates the values retrieved in an Array:
  *   ex $_POST['form']
  * @author David S. Callizaya S. <*****@*****.**>
  * @access public
  * @param array $newValues
  * @return array
  */
 function validateArray($newValues)
 {
     $values = array();
     foreach ($this->fields as $k => $v) {
         if ($v->type != 'submit') {
             if ($v->type != 'file') {
                 if (array_key_exists($k, $newValues)) {
                     switch ($v->type) {
                         case 'radiogroup':
                             $values[$k] = $newValues[$k];
                             $values["{$k}_label"] = $newValues["{$k}_label"] = $v->options[$newValues[$k]];
                             break;
                         case 'suggest':
                             $values[$k] = $newValues[$k];
                             $values["{$k}_label"] = $newValues["{$k}_label"];
                             break;
                         case 'checkgroup':
                         case 'listbox':
                             if (is_array($newValues[$k])) {
                                 $values[$k] = $values["{$k}_label"] = '';
                                 foreach ($newValues[$k] as $i => $value) {
                                     //if $value is empty continue with the next loop, because this is a not selected/checked item
                                     if (trim($value) == '') {
                                         continue;
                                     }
                                     $values[$k] .= ($i != 0 ? '|' : '') . $value;
                                     if (isset($v->options[$value])) {
                                         $values["{$k}_label"] .= ($i != 0 ? '|' : '') . $v->options[$value];
                                     } else {
                                         // if hasn't options try execute a sql sentence
                                         $query = G::replaceDataField($this->fields[$k]->sql, $newValues);
                                         if ($query != '') {
                                             // execute just if a query was set, it should be not empty
                                             //we do the query to the external connection and we've got the label
                                             $con = Propel::getConnection($this->fields[$k]->sqlConnection != "" ? $this->fields[$k]->sqlConnection : "workflow");
                                             //use default connection workflow if connection is not defined. Same as Dynaforms
                                             $stmt = $con->prepareStatement($query);
                                             $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
                                             while ($rs->next()) {
                                                 list($rowId, $rowContent) = array_values($rs->getRow());
                                                 //This to be sure that the array is numeric. Some cases when is DBArray result it returns an associative. By JHL
                                                 if ($value == $rowId) {
                                                     $values["{$k}_label"] .= ($i != 0 ? '|' : '') . $rowContent;
                                                     break;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 $newValues["{$k}_label"] = isset($values["{$k}_label"]) ? $values["{$k}_label"] : '';
                             } else {
                                 $values[$k] = $newValues[$k];
                                 $values["{$k}_label"] = isset($newValues["{$k}_label"]) ? $newValues["{$k}_label"] : '';
                             }
                             break;
                         case 'dropdown':
                             $values[$k] = $newValues[$k];
                             if (isset($v->options[$newValues[$k]])) {
                                 $values["{$k}_label"] = $newValues["{$k}_label"] = $v->options[$newValues[$k]];
                             } else {
                                 $query = G::replaceDataField($this->fields[$k]->sql, $newValues);
                                 // execute just if a query was set, it should be not empty
                                 if (trim($query) == '') {
                                     continue;
                                     //if it is  empty string skip it
                                 }
                                 //we do the query to the external connection and we've got the label
                                 $con = Propel::getConnection($this->fields[$k]->sqlConnection != "" ? $this->fields[$k]->sqlConnection : "workflow");
                                 $stmt = $con->prepareStatement($query);
                                 $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
                                 while ($rs->next()) {
                                     list($rowId, $rowContent) = $rs->getRow();
                                     if ($newValues[$k] == $rowId) {
                                         $values["{$k}_label"] = $rowContent;
                                         break;
                                     }
                                 }
                             }
                             break;
                         case 'grid':
                             foreach ($newValues[$k] as $j => $item) {
                                 if (is_array($item)) {
                                     $i = 0;
                                     $values[$k][$j] = $this->fields[$k]->maskValue($newValues[$k][$j], $this);
                                     foreach ($item as $kk => $vv) {
                                         //we need to know which fields are dropdowns
                                         if ($this->fields[$k]->fields[$kk]->type == 'dropdown') {
                                             $values[$k][$j] = $newValues[$k][$j];
                                             if ($this->fields[$k]->validateValue($newValues[$k][$j], $this)) {
                                                 // if the dropdown has otions
                                                 if (isset($this->fields[$k]->fields[$kk]->options[$vv])) {
                                                     $values[$k][$j]["{$kk}_label"] = $newValues[$k][$j][$kk . '_label'] = $this->fields[$k]->fields[$kk]->options[$vv];
                                                 } else {
                                                     // if hasn't options try execute a sql sentence
                                                     $query = G::replaceDataField($this->fields[$k]->fields[$kk]->sql, $values[$k][$j]);
                                                     $con = Propel::getConnection($this->fields[$k]->fields[$kk]->sqlConnection != "" ? $this->fields[$k]->fields[$kk]->sqlConnection : "workflow");
                                                     $stmt = $con->prepareStatement($query);
                                                     // execute just if a query was set, it should be not empty
                                                     if (trim($query) == '') {
                                                         continue;
                                                         //if it is  empty string skip it
                                                     }
                                                     $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
                                                     while ($rs->next()) {
                                                         // from the query executed we only need certain elements
                                                         // note added by krlos pacha carlos[at]colosa[dot]com
                                                         // the following line has the correct values because the query return an associative array. Related 7945 bug
                                                         list($rowId, $rowContent) = explode(',', implode(',', $rs->getRow()));
                                                         if ($vv == $rowId) {
                                                             $values[$k][$j]["{$kk}_label"] = $newValues[$k][$j][$kk . '_label'] = $rowContent;
                                                             break;
                                                         }
                                                     }
                                                     //end $rw->next() while
                                                 }
                                             }
                                         } else {
                                             // if there are no dropdowns previously setted and the evaluated field is not a dropdown
                                             // only then rewritte the $values
                                             $values[$k][$j] = $this->fields[$k]->maskValue($newValues[$k][$j], $this);
                                         }
                                         $i++;
                                     }
                                 } else {
                                     $values[$k][$j] = $this->fields[$k]->maskValue($newValues[$k][$j], $this);
                                 }
                             }
                             break;
                         default:
                             if ($this->fields[$k]->validateValue($newValues[$k], $this)) {
                                 $values[$k] = $this->fields[$k]->maskValue($newValues[$k], $this);
                             }
                     }
                 }
             } else {
                 if (isset($_FILES['form']['name'][$k])) {
                     $values[$k] = $_FILES['form']['name'][$k];
                 }
                 /**
                  * FIXED for multiple inputs documents related to file type field
                  * By Erik Amaru Ortiz <*****@*****.**>
                  * Nov 24th, 2009
                  */
                 if (isset($v->input) && $v->input != '') {
                     $_POST['INPUTS'][$k] = $v->input;
                 }
                 /**/
             }
         }
     }
     foreach ($newValues as $k => $v) {
         if (strpos($k, 'SYS_GRID_AGGREGATE_') !== false) {
             $values[$k] = $v;
         }
     }
     return $values;
 }