Merge branch 'master' of bitbucket.org:colosa/processmaker into PM-1279

This commit is contained in:
Freddy Daniel Rojas Valda
2015-01-20 13:53:48 -04:00
7 changed files with 179 additions and 60 deletions

View File

@@ -927,7 +927,7 @@ class wsBase
} else {
/*----------------------------------********---------------------------------*/
$aSetup = System::getEmailConfiguration();
/*----------------------------------********---------------------------------*/
/*----------------------------------********---------------------------------*/
}
/*----------------------------------********---------------------------------*/
@@ -2093,6 +2093,7 @@ class wsBase
* @param string $userId
* @param string $caseId
* @param string $delIndex
* @param bool $bExecuteTriggersBeforeAssignment
* @return $result will return an object
*/
public function derivateCase ($userId, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false)
@@ -2187,6 +2188,8 @@ class wsBase
$aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 1, 'BEFORE' );
if (count( $aTriggers ) > 0) {
$varTriggers = $varTriggers . "<br /><b>-= Before Assignment =-</b><br />";
$oPMScript = new PMScript();
foreach ($aTriggers as $aTrigger) {
@@ -2218,7 +2221,8 @@ class wsBase
$oPMScript->setScript( $aTrigger['TRI_WEBBOT'] );
$oPMScript->execute();
$varTriggers .= "<br/><b>-= Before Assignment =-</b><br/>" . nl2br( htmlentities( $aTrigger['TRI_WEBBOT'], ENT_QUOTES ) ) . "<br/>";
$trigger = TriggersPeer::retrieveByPk($aTrigger["TRI_UID"]);
$varTriggers = $varTriggers . "&nbsp;- " . nl2br(htmlentities($trigger->getTriTitle(), ENT_QUOTES)) . "<br />";
//$appFields = $oCase->loadCase( $caseId );
$appFields['APP_DATA'] = $oPMScript->aFields;
@@ -2283,51 +2287,6 @@ class wsBase
}
}
//Execute triggers before derivation BEFORE_ASSIGNMENT
$aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 1, 'BEFORE' );
if (count( $aTriggers ) > 0) {
$varTriggers .= "<b>-= Before Derivation =-</b><br/>";
$oPMScript = new PMScript();
foreach ($aTriggers as $aTrigger) {
//Set variables
$params = new stdClass();
$params->appData = $appFields["APP_DATA"];
if ($this->stored_system_variables) {
$params->option = "STORED SESSION";
$params->SID = $this->wsSessionId;
}
$appFields["APP_DATA"] = array_merge( $appFields["APP_DATA"], G::getSystemConstants( $params ) );
//PMScript
$oPMScript->setFields( $appFields['APP_DATA'] );
$bExecute = true;
if ($aTrigger['ST_CONDITION'] !== '') {
$oPMScript->setScript( $aTrigger['ST_CONDITION'] );
$bExecute = $oPMScript->evaluate();
}
if ($bExecute) {
$oPMScript->setScript( $aTrigger['TRI_WEBBOT'] );
$oPMScript->execute();
$oTrigger = TriggersPeer::retrieveByPk( $aTrigger['TRI_UID'] );
$varTriggers .= "&nbsp;- " . nl2br( htmlentities( $oTrigger->getTriTitle(), ENT_QUOTES ) ) . "<br/>";
$appFields['APP_DATA'] = $oPMScript->aFields;
unset($appFields['APP_STATUS']);
unset($appFields['APP_PROC_STATUS']);
unset($appFields['APP_PROC_CODE']);
unset($appFields['APP_PIN']);
$oCase->updateCase( $caseId, $appFields );
}
}
}
$oDerivation = new Derivation();
$derive = $oDerivation->prepareInformation( $aData );

View File

@@ -353,6 +353,158 @@ class Dynaform extends BaseDynaform
$attributes = array ('XMLNODE_NAME_OLD' => '','XMLNODE_NAME' => 'SUBMIT','TYPE' => 'submit'
);
$fieldXML->Save( $attributes, $labels, $options );
//update content if version is 2
if ($this->getDynVersion() === 2) {
$items = array();
$variables = array();
$res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
while ($res->next()) {
//variables
$arrayData = array(
"var_name" => $res->get('Field'),
"var_label" => $res->get('Field'),
"var_field_type" => "string",
"var_field_size" => 10,
"var_null" => 1,
"var_dbconnection" => "none",
"var_sql" => "",
"var_options_control" => "",
"var_default" => "",
"var_accepted_values" => Array()
);
$objVariable = new \ProcessMaker\BusinessModel\Variable();
try {
$objVariable->existsName($this->getProUid(), $res->get('Field'));
$variable = $objVariable->create($this->getProUid(), $arrayData);
} catch (\Exception $e) {
$data = $objVariable->getVariables($this->getProUid());
foreach ($data as $datavariable) {
if ($datavariable["var_name"] === $res->get('Field')) {
$variable = $datavariable;
break;
}
}
}
array_push($variables, $variable);
//data type
$type = "text";
$dataType = explode('(', $res->get('Type'));
error_log(print_r($dataType, true));
switch ($dataType[0]) {
case 'bigint':
$type = 'text';
$dataType = 'integer';
break;
case 'int':
$type = 'text';
$dataType = 'integer';
break;
case 'smallint':
$type = 'text';
$dataType = 'integer';
break;
case 'tinyint':
$type = 'text';
$dataType = 'integer';
break;
case 'decimal':
$type = 'text';
$dataType = 'float';
break;
case 'double':
$type = 'text';
$dataType = 'float';
break;
case 'float':
$type = 'text';
$dataType = 'float';
break;
case 'datetime':
$type = 'datetime';
$dataType = 'datetime';
break;
case 'date':
$type = 'datetime';
$dataType = 'datetime';
break;
case 'time':
$type = 'datetime';
$dataType = 'datetime';
break;
case 'char':
$type = 'text';
$dataType = 'string';
break;
case 'varchar':
$type = 'text';
$dataType = 'string';
break;
case 'mediumtext':
$type = 'textarea';
$dataType = 'string';
break;
default:
$type = "text";
$dataType = 'string';
break;
}
array_push($items, array(
array(
"type" => $type,
"dataType" => $dataType, //$res->get('Type'),
"id" => $res->get('Field'),
"name" => $res->get('Field'),
"label" => $res->get('Field'),
"hint" => "",
"required" => false,
"defaultValue" => "",
"dependentFields" => array(),
"textTransform" => "none",
"validate" => "any",
"mask" => "",
"maxLength" => 1000,
"formula" => "",
"mode" => "parent",
"var_uid" => $variable["var_uid"],
"var_name" => $variable["var_name"],
"colSpan" => 12
)
));
}
//submit button
array_push($items, array(
array(
"type" => "submit",
"id" => "FormDesigner-" . \ProcessMaker\Util\Common::generateUID(),
"name" => "submit",
"label" => "submit",
"colSpan" => 12
)
));
$json = array(
"name" => $this->getDynTitle(),
"description" => $this->getDynDescription(),
"items" => array(
array(
"type" => "form",
"id" => $this->getDynUid(),
"name" => $this->getDynTitle(),
"description" => $this->getDynDescription(),
"mode" => "edit",
"script" => "",
"items" => $items,
"variables" => $variables
)
)
);
$aData = $this->Load($this->getDynUid());
$aData["DYN_CONTENT"] = G::json_encode($json);
$this->update($aData);
}
}
/**

View File

@@ -187,14 +187,12 @@ class StepSupervisor extends BaseStepSupervisor
$oCriteria->add( StepSupervisorPeer::STEP_POSITION, $iPosition, '>' );
$oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
var_dump( StepSupervisorPeer::doCount( $oCriteria ) );
while ($aRow = $oDataset->getRow()) {
var_dump( $aRow );
echo "\n";
while ($oDataset->next()) {
$aRow = $oDataset->getRow();
$this->update( array ('STEP_UID' => $aRow['STEP_UID'],'PRO_UID' => $aRow['PRO_UID'],'STEP_TYPE_OBJ' => $aRow['STEP_TYPE_OBJ'],'STEP_UID_OBJ' => $aRow['STEP_UID_OBJ'],'STEP_POSITION' => $aRow['STEP_POSITION'] - 1
) );
$oDataset->next();
}
} catch (Exception $oException) {
throw $Exception;
@@ -243,7 +241,7 @@ class StepSupervisor extends BaseStepSupervisor
$oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, 'DYNAFORM' );
$oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
while($oDataset->next()) {
while ($oDataset->next()) {
$res[] = $oDataset->getRow();
}
return $res;

View File

@@ -385,6 +385,8 @@ if ($actionAjax == 'dynaformChangeLogViewHistory') {
G::LoadClass('pmDynaform');
$a = new pmDynaform($_GET['DYN_UID'], $Fields['APP_DATA']);
if ($a->isResponsive()) {
$a->app_data["PROCESS"] = $_SESSION['PROCESS'];
$a->app_data["SYS_SYS"] = SYS_SYS;
$a->printView((!isset($_SESSION["PM_RUN_OUTSIDE_MAIN_APP"])) ? "true" : "false", $_SESSION['APPLICATION']);
} else {
$G_PUBLISH->AddContent('dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_POST['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view');

View File

@@ -544,6 +544,16 @@ class DynaForm
$this->throwExceptionIfNotExistsDynaForm($dynaFormUidCopyImport, $processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID"));
//Copy/Import
//Copy content if version is 2
if ($arrayData["DYN_VERSION"] === 2) {
$dynaFormOld = new \Dynaform();
$arrayDynaFormData = $dynaFormOld->Load($dynaFormUidCopyImport);
$arrayData["DYN_CONTENT"] = $arrayDynaFormData["DYN_CONTENT"];
}
//Create
$arrayData = $this->create($processUid, $arrayData);

View File

@@ -855,7 +855,7 @@ class ProcessSupervisor
try {
$oDynaformSupervidor = \StepSupervisorPeer::retrieveByPK($sPudUID);
if (!is_null($oDynaformSupervidor)) {
$oProcessMap = new \processMap(new \DBConnection());
$oProcessMap = new \processMap();
$oProcessMap->removeSupervisorStep( $oDynaformSupervidor->getStepUid(), $sProcessUID, 'DYNAFORM', $oDynaformSupervidor->getStepUidObj(), $oDynaformSupervidor->getStepPosition() );
} else {
throw new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST"));
@@ -877,7 +877,7 @@ class ProcessSupervisor
try {
$oInputDocumentSupervidor = \StepSupervisorPeer::retrieveByPK($sPuiUID);
if (!is_null($oInputDocumentSupervidor)) {
$oProcessMap = new \processMap(new \DBConnection());
$oProcessMap = new \processMap();
$oProcessMap->removeSupervisorStep( $oInputDocumentSupervidor->getStepUid(), $sProcessUID, 'INPUT_DOCUMENT', $oInputDocumentSupervidor->getStepUidObj(), $oInputDocumentSupervidor->getStepPosition() );
} else {
throw new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST"));

View File

@@ -219,7 +219,7 @@ class ProcessSupervisors extends Api
*
* @status 201
*/
public function doPostProcessSupervisorDynaform($prjUid, $dyn_uid, $pud_position=null)
public function doPostProcessSupervisorDynaform($prjUid, $dyn_uid, $pud_position = null)
{
try {
$supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
@@ -242,7 +242,7 @@ class ProcessSupervisors extends Api
*
* @status 201
*/
public function doPostProcessSupervisorInputDocument($prjUid, $inp_doc_uid, $pui_position=null)
public function doPostProcessSupervisorInputDocument($prjUid, $inp_doc_uid, $pui_position = null)
{
try {
$supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
@@ -286,7 +286,6 @@ class ProcessSupervisors extends Api
try {
$supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
$supervisor->removeDynaformSupervisor($prjUid, $pudUid);
ob_end_clean();
} catch (\Exception $e) {
//response
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
@@ -305,7 +304,6 @@ class ProcessSupervisors extends Api
try {
$supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
$supervisor->removeInputDocumentSupervisor($prjUid, $puiUid);
ob_end_clean();
} catch (\Exception $e) {
//response
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());