Merged in mcuiza/processmaker/PM-31 (pull request #2209)
PM-31 - Refactor output document
This commit is contained in:
@@ -373,11 +373,11 @@ class XmlForm_Field_hours extends XmlForm_Field_SimpleText
|
||||
* @param eter boolean $bSystemVars
|
||||
* @return array
|
||||
*/
|
||||
function getDynaformsVars ($sProcessUID, $bSystemVars = true, $bIncMulSelFields = 0)
|
||||
function getDynaformsVars ($sProcessUID, $typeVars = 'all', $bIncMulSelFields = 0)
|
||||
{
|
||||
$aFields = array ();
|
||||
$aFieldsNames = array ();
|
||||
if ($bSystemVars) {
|
||||
if ($typeVars == 'system' || $typeVars == 'all') {
|
||||
$aAux = G::getSystemConstants();
|
||||
foreach ($aAux as $sName => $sValue) {
|
||||
$aFields[] = array ('sName' => $sName,'sType' => 'system','sLabel' => G::LoadTranslation('ID_TINY_SYSTEM_VARIABLES'));
|
||||
@@ -401,21 +401,54 @@ function getDynaformsVars ($sProcessUID, $bSystemVars = true, $bIncMulSelFields
|
||||
$oDataset->next();
|
||||
$row = $oDataset->getRow();
|
||||
if (isset($row["PRJ_UID"])) {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_UID);
|
||||
$oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_NAME);
|
||||
$oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_FIELD_TYPE);
|
||||
$oCriteria->add(ProcessVariablesPeer::PRJ_UID, $sProcessUID);
|
||||
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
while ($oDataset->next()) {
|
||||
$row = $oDataset->getRow();
|
||||
array_push($aFields, array(
|
||||
"sName" => $row["VAR_NAME"],
|
||||
"sType" => $row["VAR_FIELD_TYPE"],
|
||||
"sLabel" => $row["VAR_NAME"] . " [" . $row["VAR_FIELD_TYPE"] . "]"
|
||||
));
|
||||
if($typeVars == 'process' || $typeVars == 'all') {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_UID);
|
||||
$oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_NAME);
|
||||
$oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_FIELD_TYPE);
|
||||
$oCriteria->add(ProcessVariablesPeer::PRJ_UID, $sProcessUID);
|
||||
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
while ($oDataset->next()) {
|
||||
$row = $oDataset->getRow();
|
||||
array_push($aFields, array(
|
||||
"sName" => $row["VAR_NAME"],
|
||||
"sType" => $row["VAR_FIELD_TYPE"],
|
||||
"sLabel" => $row["VAR_FIELD_TYPE"]
|
||||
));
|
||||
}
|
||||
}
|
||||
if($typeVars == 'grid' || $typeVars == 'all') {
|
||||
$oC = new Criteria( 'workflow' );
|
||||
$oC->addSelectColumn( DynaformPeer::DYN_CONTENT );
|
||||
$oC->add( DynaformPeer::PRO_UID, $sProcessUID );
|
||||
$oC->add( DynaformPeer::DYN_TYPE, 'xmlform' );
|
||||
$oData = DynaformPeer::doSelectRS( $oC );
|
||||
$oData->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oData->next();
|
||||
while ($aRowd = $oData->getRow()) {
|
||||
$dynaform = G::json_decode($aRowd['DYN_CONTENT'],true);
|
||||
if(is_array($dynaform) && sizeof($dynaform)) {
|
||||
$items = $dynaform['items'][0]['items'];
|
||||
foreach($items as $key => $val){
|
||||
if($val[0]['type'] == 'grid'){
|
||||
if(sizeof($val[0]['columns'])) {
|
||||
$columns = $val[0]['columns'];
|
||||
foreach($columns as $column) {
|
||||
array_push($aFields, array(
|
||||
"sName" => $column['name'],
|
||||
"sType" => $column['type'],
|
||||
"sLabel" => $column['type']
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$oData->next();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
|
||||
@@ -1,19 +1,35 @@
|
||||
var setVariablePickerJS = function(){
|
||||
if (document.getElementById('_Var_Form_').addEventListener) // W3C DOM
|
||||
document.getElementById('_Var_Form_').addEventListener('dblclick', function(){
|
||||
if (this.getAttribute('displayOption')=='event'){
|
||||
e.insertFormVar(this.value.substring(2), this.value.substring(2), 'dyn' );
|
||||
if(this.value.substring(0,5) == 'gridt') {
|
||||
try {
|
||||
updateEditorContent(this.value.substring(5));
|
||||
} catch(err) {
|
||||
closePluginPopup();
|
||||
}
|
||||
} else {
|
||||
insertFormVar(document.getElementById('selectedField').value, this.value);
|
||||
if (this.getAttribute('displayOption')=='event'){
|
||||
e.insertFormVar(this.value.substring(2), this.value.substring(2), 'dyn' );
|
||||
} else {
|
||||
insertFormVar(document.getElementById('selectedField').value, this.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
else if (document.getElementById('selectedField').attachEvent) { // IE DOM
|
||||
var element = document.getElementById('_Var_Form_');
|
||||
element.attachEvent("ondblclick", function(){
|
||||
if (element.displayOption=='event'){
|
||||
e.insertFormVar(element.value.substring(2), element.value.substring(2), 'dyn' );
|
||||
} else {
|
||||
insertFormVar(document.getElementById('selectedField').value, element.value);
|
||||
if(element.value.substring(0,5) == 'gridt') {
|
||||
try {
|
||||
updateEditorContent(element.value.substring(5));
|
||||
} catch(err) {
|
||||
closePluginPopup();
|
||||
}
|
||||
} else {
|
||||
if (element.displayOption=='event'){
|
||||
e.insertFormVar(element.value.substring(2), element.value.substring(2), 'dyn' );
|
||||
} else {
|
||||
insertFormVar(document.getElementById('selectedField').value, element.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -99,7 +115,12 @@ var setVariablePickerJS = function(){
|
||||
});
|
||||
|
||||
leimnud.event.add(document.getElementById('_Var_Form_'), 'change', function(event) {
|
||||
document.getElementById('selectedVariableLabel').textContent = document.getElementById('_Var_Form_').value
|
||||
var selectElement = document.getElementById('_Var_Form_');
|
||||
if(selectElement.value.substring(0,5) == 'gridt') {
|
||||
document.getElementById('selectedVariableLabel').textContent = selectElement.options[selectElement.selectedIndex].text;
|
||||
} else {
|
||||
document.getElementById('selectedVariableLabel').textContent = selectElement.value
|
||||
}
|
||||
});
|
||||
|
||||
leimnud.event.add(document.getElementById('search'), 'keypress', function(e) {
|
||||
@@ -130,6 +151,7 @@ var setVariablePickerJS = function(){
|
||||
var list = getVariableList(document.getElementById('search').value, document.getElementById('process').value, document.getElementById('type_variables').value);
|
||||
var combo = document.getElementById("_Var_Form_");
|
||||
var option = document.createElement('option');
|
||||
var isBpmn = document.getElementById('isBpmn').value;
|
||||
|
||||
for(i=(combo.length-1); i>=0; i--)
|
||||
{
|
||||
@@ -140,8 +162,15 @@ var setVariablePickerJS = function(){
|
||||
if(list.length>0){
|
||||
for(i=0; i<list.length; i++)
|
||||
{
|
||||
var optionValue = prefix+list[i].sName;
|
||||
if(isBpmn) {
|
||||
if(list[i].sLabel.toLowerCase() == 'grid') {
|
||||
var gridValue = 'gridt<table border=1 cellspacing=0><tr><th>Header_1</th></tr><tbody><!--@>'+list[i].sName+'--><tr><td>column_name1</td></tr><!--@<'+list[i].sName+'--></tbody></table>';
|
||||
optionValue = gridValue;
|
||||
}
|
||||
}
|
||||
option = document.createElement("OPTION");
|
||||
option.value = prefix+list[i].sName;
|
||||
option.value = optionValue;
|
||||
option.text = prefix+list[i].sName+' ('+list[i].sLabel+')';
|
||||
combo.add(option);
|
||||
}
|
||||
|
||||
@@ -66,6 +66,20 @@ $html .= '<select name="type_variables" id="type_variables">';
|
||||
$html .= '<option value="all">'.$filter->xssFilterHard(G::LoadTranslation( 'ID_TINY_ALL_VARIABLES' )).'</option>';
|
||||
$html .= '<option value="system">'.$filter->xssFilterHard(G::LoadTranslation( 'ID_TINY_SYSTEM_VARIABLES' )).'</option>';
|
||||
$html .= '<option value="process">'.$filter->xssFilterHard(G::LoadTranslation( 'ID_TINY_PROCESS_VARIABLES' )).'</option>';
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(BpmnProjectPeer::PRJ_UID);
|
||||
$oCriteria->add(BpmnProjectPeer::PRJ_UID, $_REQUEST['sProcess']);
|
||||
$oDataset = ProcessPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro'));
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$row = $oDataset->getRow();
|
||||
$isBpmn = false;
|
||||
if (isset($row["PRJ_UID"])) {
|
||||
$isBpmn = true;
|
||||
$html .= '<option value="grid">'.$filter->xssFilterHard(G::LoadTranslation( 'ID_TINY_GRID_VARIABLES' )).'</option>';
|
||||
}
|
||||
|
||||
$html .= '</select> ';
|
||||
$html .= '</td>';
|
||||
|
||||
@@ -104,7 +118,14 @@ if (isset($_REQUEST['displayOption'])){
|
||||
$html .= '<select name="_Var_Form_" id="_Var_Form_" size="8" style="width:100%;' . (! isset( $_POST['sNoShowLeyend'] ) ? 'height:170;' : '') . '" '.$displayOption.'>';
|
||||
|
||||
foreach ($aFields as $aField) {
|
||||
$html .= '<option value="' . $_REQUEST['sSymbol'] . $aField['sName'] . '">' . $_REQUEST['sSymbol'] . $aField['sName'] . ' (' . $aField['sType'] . ')</option>';
|
||||
$value = $_REQUEST['sSymbol'] . $aField['sName'];
|
||||
if ($isBpmn) {
|
||||
if(strtolower($aField['sType']) == 'grid') {
|
||||
$gridValue = 'gridt<table border=1 cellspacing=0> <tr> <th>Header_1</th> </tr> <!--@>'.$aField['sName'].'--> <tr> <td>column_name1</td> </tr><!--@<'.$aField['sName'].'--> </table>';
|
||||
$value = htmlentities($gridValue);
|
||||
}
|
||||
}
|
||||
$html .= '<option value="' . $value . '">' . $_REQUEST['sSymbol'] . $aField['sName'] . ' (' . $aField['sType'] . ')</option>';
|
||||
}
|
||||
|
||||
$aRows[0] = Array ('fieldname' => 'char','variable' => 'char','type' => 'type','label' => 'char');
|
||||
@@ -114,6 +135,13 @@ foreach ($aFields as $aField) {
|
||||
}
|
||||
$html .= '</select>';
|
||||
|
||||
if ($isBpmn) {
|
||||
$valueBpmn = 1;
|
||||
} else {
|
||||
$valueBpmn = 0;
|
||||
}
|
||||
$html .= '<input type="hidden" id="isBpmn" value="'.$valueBpmn.'">';
|
||||
|
||||
$html .= '</td>';
|
||||
$html .= '</tr>';
|
||||
$html .= '</table>';
|
||||
|
||||
@@ -806,15 +806,21 @@ try {
|
||||
G::LoadClass('xmlfield_InputPM');
|
||||
$proUid = isset($_REQUEST['process']) ? $_REQUEST['process'] : '';
|
||||
$queryText = isset($_REQUEST['queryText']) ? $_REQUEST['queryText'] : '';
|
||||
if ($_REQUEST['type'] == 'system') {
|
||||
$isSystem = true;
|
||||
} else {
|
||||
$isSystem = false;
|
||||
switch($_REQUEST['type']) {
|
||||
case 'system';
|
||||
$typeVars = $_REQUEST['type'];
|
||||
break;
|
||||
case 'process';
|
||||
$typeVars = $_REQUEST['type'];
|
||||
break;
|
||||
case 'grid';
|
||||
$typeVars = $_REQUEST['type'];
|
||||
break;
|
||||
}
|
||||
if ($_REQUEST['type'] == 'all') {
|
||||
$aFields = getDynaformsVars($proUid);
|
||||
} else {
|
||||
$aFields = getDynaformsVars($proUid, $isSystem, isset($_REQUEST['bIncMulSelFields']) ? $_REQUEST['bIncMulSelFields'] : 1);
|
||||
$aFields = getDynaformsVars($proUid, $typeVars, isset($_REQUEST['bIncMulSelFields']) ? $_REQUEST['bIncMulSelFields'] : 1);
|
||||
}
|
||||
$aVariables = array();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user