public function cancelCase($sApplicationUID, $iIndex, $user_logged) { $this->getExecuteTriggerProcess($sApplicationUID, 'CANCELED'); $oApplication = new Application(); $aFields = $oApplication->load($sApplicationUID); $appStatusCurrent = $aFields['APP_STATUS']; $oCriteria = new Criteria('workflow'); $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); if (AppDelegationPeer::doCount($oCriteria) == 1) { $aFields['APP_STATUS'] = 'CANCELLED'; $oApplication->update($aFields); G::LoadClass('reportTables'); require_once 'classes/model/AdditionalTables.php'; $oReportTables = new ReportTables(); $addtionalTables = new additionalTables(); $oReportTables->updateTables($aFields['PRO_UID'], $aFields['APP_UID'], $aFields['APP_NUMBER'], $aFields['APP_DATA']); $addtionalTables->updateReportTables($aFields['PRO_UID'], $aFields['APP_UID'], $aFields['APP_NUMBER'], $aFields['APP_DATA'], $aFields['APP_STATUS']); } $this->CloseCurrentDelegation($sApplicationUID, $iIndex); $oAppDel = new AppDelegation(); $oAppDel->Load($sApplicationUID, $iIndex); $aAppDel = $oAppDel->toArray(BasePeer::TYPE_FIELDNAME); $this->closeAppThread($sApplicationUID, $aAppDel['DEL_THREAD']); $delay = new AppDelay(); $array['PRO_UID'] = $aFields['PRO_UID']; $array['APP_UID'] = $sApplicationUID; $c = new Criteria('workflow'); $c->clearSelectColumns(); $c->addSelectColumn(AppThreadPeer::APP_THREAD_INDEX); $c->add(AppThreadPeer::APP_UID, $sApplicationUID); $c->add(AppThreadPeer::DEL_INDEX, $iIndex); $oDataset = AppThreadPeer::doSelectRS($c); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aRow = $oDataset->getRow(); $array['APP_THREAD_INDEX'] = $aRow['APP_THREAD_INDEX']; $array['APP_DEL_INDEX'] = $iIndex; $array['APP_TYPE'] = 'CANCEL'; $c = new Criteria('workflow'); $c->clearSelectColumns(); $c->addSelectColumn(ApplicationPeer::APP_STATUS); $c->add(ApplicationPeer::APP_UID, $sApplicationUID); $oDataset = ApplicationPeer::doSelectRS($c); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aRow1 = $oDataset->getRow(); $array['APP_STATUS'] = $aRow1['APP_STATUS']; $array['APP_DELEGATION_USER'] = $user_logged; $array['APP_ENABLE_ACTION_USER'] = $user_logged; $array['APP_ENABLE_ACTION_DATE'] = date('Y-m-d H:i:s'); $delay->create($array); //Before cancel a case verify if is a child case $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(SubApplicationPeer::APP_UID, $sApplicationUID); $oCriteria2->add(SubApplicationPeer::SA_STATUS, 'ACTIVE'); if (SubApplicationPeer::doCount($oCriteria2) > 0) { G::LoadClass('derivation'); $oDerivation = new Derivation(); $oDerivation->verifyIsCaseChild($sApplicationUID, $iIndex); } //update searchindex if ($this->appSolr != null) { $this->appSolr->updateApplicationSearchIndex($sApplicationUID); } /*----------------------------------********---------------------------------*/ }
/** * Export PM tables * * @author : Erik Amaru Ortiz <*****@*****.**> */ public function export($httpData) { require_once 'classes/model/AdditionalTables.php'; $at = new AdditionalTables(); $tablesToExport = G::json_decode(stripslashes($httpData->rows)); try { G::LoadCLass('net'); $net = new NET(G::getIpAddress()); G::LoadClass("system"); $META = " \n-----== ProcessMaker Open Source Private Tables ==-----\n" . " @Ver: 1.0 Oct-2009\n" . " @Processmaker version: " . System::getVersion() . "\n" . " -------------------------------------------------------\n" . " @Export Date: " . date("l jS \\of F Y h:i:s A") . "\n" . " @Server address: " . getenv('SERVER_NAME') . " (" . getenv('SERVER_ADDR') . ")\n" . " @Client address: " . $net->hostname . "\n" . " @Workspace: " . SYS_SYS . "\n" . " @Export trace back:\n\n"; $EXPORT_TRACEBACK = array(); $c = 0; foreach ($tablesToExport as $table) { $tableRecord = $at->load($table->ADD_TAB_UID); $tableData = $at->getAllData($table->ADD_TAB_UID, null, null, false); $table->ADD_TAB_NAME = $tableRecord['ADD_TAB_NAME']; $rows = $tableData['rows']; $count = $tableData['count']; array_push($EXPORT_TRACEBACK, array('uid' => $table->ADD_TAB_UID, 'name' => $table->ADD_TAB_NAME, 'num_regs' => $tableData['count'], 'schema' => $table->_SCHEMA ? 'yes' : 'no', 'data' => $table->_DATA ? 'yes' : 'no')); } $sTrace = "TABLE UID TABLE NAME\tREGS\tSCHEMA\tDATA\n"; foreach ($EXPORT_TRACEBACK as $row) { $sTrace .= "{$row['uid']}\t{$row['name']}\t\t{$row['num_regs']}\t{$row['schema']}\t{$row['data']}\n"; } $META .= $sTrace; ///////////////EXPORT PROCESS $PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP; $filenameOnly = strtolower('SYS-' . SYS_SYS . "_" . date("Y-m-d") . '_' . date("Hi") . ".pmt"); $filename = $PUBLIC_ROOT_PATH . $filenameOnly; $fp = fopen($filename, "wb"); $bytesSaved = 0; $bufferType = '@META'; $fsData = sprintf("%09d", strlen($META)); $fsbufferType = sprintf("%09d", strlen($bufferType)); $bytesSaved += fwrite($fp, $fsbufferType); //writing the size of $oData $bytesSaved += fwrite($fp, $bufferType); //writing the $oData $bytesSaved += fwrite($fp, $fsData); //writing the size of $oData $bytesSaved += fwrite($fp, $META); //writing the $oData foreach ($tablesToExport as $table) { if ($table->_SCHEMA) { $oAdditionalTables = new AdditionalTables(); $aData = $oAdditionalTables->load($table->ADD_TAB_UID, true); $bufferType = '@SCHEMA'; $SDATA = serialize($aData); $fsUid = sprintf("%09d", strlen($table->ADD_TAB_UID)); $fsData = sprintf("%09d", strlen($SDATA)); $fsbufferType = sprintf("%09d", strlen($bufferType)); $bytesSaved += fwrite($fp, $fsbufferType); //writing the size of $oData $bytesSaved += fwrite($fp, $bufferType); //writing the $oData $bytesSaved += fwrite($fp, $fsUid); //writing the size of xml file $bytesSaved += fwrite($fp, $table->ADD_TAB_UID); //writing the xmlfile $bytesSaved += fwrite($fp, $fsData); //writing the size of xml file $bytesSaved += fwrite($fp, $SDATA); //writing the xmlfile } if ($table->_DATA) { //export data $oAdditionalTables = new additionalTables(); $tableData = $oAdditionalTables->getAllData($table->ADD_TAB_UID, null, null, false); $SDATA = serialize($tableData['rows']); $bufferType = '@DATA'; $fsbufferType = sprintf("%09d", strlen($bufferType)); $fsTableName = sprintf("%09d", strlen($table->ADD_TAB_NAME)); $fsData = sprintf("%09d", strlen($SDATA)); $bytesSaved += fwrite($fp, $fsbufferType); //writing type size $bytesSaved += fwrite($fp, $bufferType); //writing type $bytesSaved += fwrite($fp, $fsTableName); //writing the size of xml file $bytesSaved += fwrite($fp, $table->ADD_TAB_NAME); //writing the xmlfile $bytesSaved += fwrite($fp, $fsData); //writing the size of xml file $bytesSaved += fwrite($fp, $SDATA); //writing the xmlfile } } fclose($fp); $filenameLink = "pmTables/streamExported?f={$filenameOnly}"; $size = round($bytesSaved / 1024, 2) . " Kb"; $meta = "<pre>" . $META . "</pre>"; $filename = $filenameOnly; $link = $filenameLink; $result->success = true; $result->filename = $filenameOnly; $result->link = $link; $result->message = "Generated file: {$filenameOnly}, size: {$size}"; } catch (Exception $e) { $result->success = false; $result->message = $e->getMessage(); } return $result; }
public function updateCase($sAppUid, $Fields = array()) { try { $aApplicationFields = $Fields['APP_DATA']; $Fields['APP_UID'] = $sAppUid; $Fields['APP_UPDATE_DATE'] = 'now'; $Fields['APP_DATA'] = serialize($Fields['APP_DATA']); /* $oApp = new Application; $appFields = $oApp->load($sAppUid); */ $oApp = ApplicationPeer::retrieveByPk($sAppUid); $appFields = $oApp->toArray(BasePeer::TYPE_FIELDNAME); if (isset($Fields['APP_TITLE'])) { $appFields['APP_TITLE'] = $Fields['APP_TITLE']; } if (isset($Fields['APP_DESCRIPTION'])) { $appFields['APP_DESCRIPTION'] = $Fields['APP_DESCRIPTION']; } $newValues = $this->newRefreshCaseTitleAndDescription($sAppUid, $appFields, $aApplicationFields); //Start: Save History --By JHL if (isset($Fields['CURRENT_DYNAFORM'])) { //only when that variable is set.. from Save $FieldsBefore = $this->loadCase($sAppUid); $FieldsDifference = $this->arrayRecursiveDiff($FieldsBefore['APP_DATA'], $aApplicationFields); $fieldsOnBoth = array_intersect_assoc($FieldsBefore['APP_DATA'], $aApplicationFields); //Add fields that weren't in previous version foreach ($aApplicationFields as $key => $value) { if (!isset($fieldsOnBoth[$key])) { $FieldsDifference[$key] = $value; } } if (is_array($FieldsDifference) && count($FieldsDifference) > 0) { //There are changes $appHistory = new AppHistory(); $aFieldsHistory = $Fields; $aFieldsHistory['APP_DATA'] = serialize($FieldsDifference); $appHistory->insertHistory($aFieldsHistory); } } //End Save History //we are removing the app_title and app_description from this array, //because they already be updated in newRefreshCaseTitleAndDescription function if (isset($Fields['APP_TITLE'])) { unset($Fields['APP_TITLE']); } if (isset($Fields['APP_DESCRIPTION'])) { unset($Fields['APP_DESCRIPTION']); } $oApp->update($Fields); $DEL_INDEX = isset($Fields['DEL_INDEX']) ? $Fields['DEL_INDEX'] : ''; $TAS_UID = isset($Fields['TAS_UID']) ? $Fields['TAS_UID'] : ''; G::LoadClass('reportTables'); require_once 'classes/model/AdditionalTables.php'; $oReportTables = new ReportTables(); $addtionalTables = new additionalTables(); $oReportTables->updateTables($appFields['PRO_UID'], $sAppUid, $Fields['APP_NUMBER'], $aApplicationFields); $addtionalTables->updateReportTables($appFields['PRO_UID'], $sAppUid, $Fields['APP_NUMBER'], $aApplicationFields); //now update the priority in appdelegation table, using the defined variable in task if (trim($DEL_INDEX) != '' && trim($TAS_UID) != '') { //optimized code to avoid load task content row. $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(TaskPeer::TAS_PRIORITY_VARIABLE); $c->add(TaskPeer::TAS_UID, $TAS_UID); $rs = TaskPeer::doSelectRS($c); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->next(); $row = $rs->getRow(); $VAR_PRI = substr($row['TAS_PRIORITY_VARIABLE'], 2); //end optimized code. $x = unserialize($Fields['APP_DATA']); if (isset($x[$VAR_PRI])) { if (trim($x[$VAR_PRI]) != '') { $oDel = new AppDelegation(); $array = array(); $array['APP_UID'] = $sAppUid; $array['DEL_INDEX'] = $DEL_INDEX; $array['TAS_UID'] = $TAS_UID; $array['DEL_PRIORITY'] = isset($x[$VAR_PRI]) ? $x[$VAR_PRI] >= 1 && $x[$VAR_PRI] <= 5 ? $x[$VAR_PRI] : '3' : '3'; $oDel->update($array); } } } //Update Solr Index if ($this->appSolr != null) { $this->appSolr->updateApplicationSearchIndex($sAppUid); } return $Fields; } catch (exception $e) { throw $e; } }