. * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. * * @package workflow.engine.classes **/ class XmlForm_Field_TextPM extends XmlForm_Field_SimpleText { public $size = 15; public $maxLength = 64; public $validate = 'Any'; public $mask = ''; public $defaultValue = ''; public $required = false; public $dependentFields = ''; public $linkField = ''; //Possible values:(-|UPPER|LOWER|CAPITALIZE) public $strTo = ''; public $readOnly = false; public $sqlConnection = 0; public $sql = ''; public $sqlOption = array (); //Atributes only for grids public $formula = ''; public $function = ''; public $replaceTags = 0; public $showVars = 0; public $process = ''; public $symbol = '@@'; /** * Function render * * @author Julio Cesar Laura Avendano * @access public * @param eter string value * @param eter string owner * @return string */ public function render ($value = null, $owner = null) { //$this->executeSQL(); //if (isset($this->sqlOption)) { // reset($this->sqlOption); // $firstElement=key($this->sqlOption); // if (isset($firstElement)) $value = $firstElement; //} //NOTE: string functions must be in G class if ($this->strTo === 'UPPER') { $value = strtoupper( $value ); } if ($this->strTo === 'LOWER') { $value = strtolower( $value ); } //if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value); $onkeypress = G::replaceDataField( $this->onkeypress, $owner->values ); if ($this->replaceTags == 1) { $value = G::replaceDataField( $value, $owner->values ); } if ($this->showVars == 1) { $this->process = G::replaceDataField( $this->process, $owner->values ); //$sShowVars = ' ' . $this->symbol . ''; $sShowVars = ' '; } else { $sShowVars = ''; } if ($this->mode === 'edit') { if ($this->readOnly) { return 'htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $sShowVars; } else { return 'htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $sShowVars; } } elseif ($this->mode === 'view') { return 'htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' style="display:none;' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); } else { return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); } } /** * Function renderGrid * * @author Julio Cesar Laura Avendano * @access public * @param eter array values * @param eter string owner * @return string */ public function renderGrid ($values = array(), $owner) { $result = array (); $r = 1; foreach ($values as $v) { if ($this->replaceTags == 1) { $v = G::replaceDataField( $v, $owner->values ); } if ($this->showVars == 1) { $this->process = G::replaceDataField( $this->process, $owner->values ); //$sShowVars = ' ' . $this->symbol . ''; $sShowVars = ' '; } else { $sShowVars = ''; } if ($this->mode === 'edit') { if ($this->readOnly) { $result[] = '' . $sShowVars; } else { $result[] = '' . $sShowVars; } } elseif ($this->mode === 'view') { $result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ); } else { $result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ); } $r ++; } return $result; } /** * Function attachEvents * * @access public * @param eter string $element * @return string */ public function attachEvents ($element) { return "myForm.aElements[i] = new G_Text(myForm, $element,'{$this->name}'); myForm.aElements[i].setAttributes(" . $this->getAttributes() . ");"; } } /** * Class XmlForm_Field_TextareaPM */ class XmlForm_Field_TextareaPM extends XmlForm_Field { public $rows = 12; public $cols = 40; public $required = false; public $readOnly = false; public $wrap = 'OFF'; public $showVars = 0; public $process = ''; public $symbol = '@@'; /** * Function render * * @author Julio Cesar Laura Avendao * @access public * @param eter string value * @param eter string owner * @return string */ public function render ($value = null, $owner) { if ($this->showVars == 1) { $this->process = G::replaceDataField( $this->process, $owner->values ); $sShowVars = ' '; } else { $sShowVars = ''; } if ($this->mode === 'edit') { if ($this->readOnly) { return '' . $sShowVars; } else { return '' . $sShowVars; } } elseif ($this->mode === 'view') { return ''; } else { return ''; } } /** * Function renderGrid * * @author Julio Cesar Laura Avendano * @access public * @param eter string values * @param eter string owner * @return string */ public function renderGrid ($owner, $values = null) { $result = array (); $r = 1; foreach ($values as $v) { if ($this->showVars == 1) { $this->process = G::replaceDataField( $this->process, $owner->values ); //$sShowVars = ' ' . $this->symbol . ''; $sShowVars = ' '; } else { $sShowVars = ''; } if ($this->mode === 'edit') { if ($this->readOnly) { $result[] = 'htmlentities( $v, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly"/>' . $sShowVars; } else { $result[] = 'htmlentities( $v, ENT_COMPAT, 'utf-8' ) . '\' />' . $sShowVars; } } elseif ($this->mode === 'view') { if (stristr( $_SERVER['HTTP_USER_AGENT'], 'iPhone' )) { //$result[] = '
'.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'
'; $result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ); } else { //$result[] = '
'.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'
'; $result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ); } } else { $result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ); } $r ++; } return $result; } } /** * Class XmlForm_Field_hours */ class XmlForm_Field_hours extends XmlForm_Field_SimpleText { public $size = 15; public $maxLength = 64; public $validate = 'Any'; public $mask = ''; public $defaultValue = ''; public $required = false; public $dependentFields = ''; public $linkField = ''; //Possible values:(-|UPPER|LOWER|CAPITALIZE) public $strTo = ''; public $readOnly = false; public $sqlConnection = 0; public $sql = ''; public $sqlOption = array (); //Atributes only for grids public $formula = ''; public $function = ''; public $replaceTags = 0; public $showVars = 0; public $process = ''; public $symbol = '@@'; /** * Function render * * @author Julio Cesar Laura Avendano * @access public * @param eter string value * @param eter string owner * @return string */ public function render ($value = null, $owner = null) { if ($this->strTo === 'UPPER') { $value = strtoupper( $value ); } if ($this->strTo === 'LOWER') { $value = strtolower( $value ); } //if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value); $onkeypress = G::replaceDataField( $this->onkeypress, $owner->values ); if ($this->replaceTags == 1) { $value = G::replaceDataField( $value, $owner->values ); } if ($this->showVars == 1) { $this->process = G::replaceDataField( $this->process, $owner->values ); //$sShowVars = ' ' . $this->symbol . ''; $sShowVars = ' '; } else { $sShowVars = ''; } if ($this->mode === 'edit') { if ($this->readOnly) { return 'htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $sShowVars; } else { return 'htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $sShowVars; } } elseif ($this->mode === 'view') { return 'htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' style="display:none;' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); } else { return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); } } /** * Function renderGrid * * @author Julio Cesar Laura Avendano * @access public * @param eter array values * @param eter string owner * @return string */ public function renderGrid ($values = array(),$owner) { $result = array (); $r = 1; foreach ($values as $v) { if ($this->replaceTags == 1) { $v = G::replaceDataField( $v, $owner->values ); } if ($this->showVars == 1) { $this->process = G::replaceDataField( $this->process, $owner->values ); //$sShowVars = ' ' . $this->symbol . ''; $sShowVars = ' '; } else { $sShowVars = ''; } if ($this->mode === 'edit') { if ($this->readOnly) { $result[] = '' . $sShowVars; } else { $result[] = '' . $sShowVars; } } elseif ($this->mode === 'view') { $result[] = '

' . $this->htmlentities( number_format( $v, 2 ), ENT_COMPAT, 'utf-8' ) . '

'; } else { $result[] = '

' . $this->htmlentities( number_format( $v, 2 ), ENT_COMPAT, 'utf-8' ) . '

'; } $r ++; } return $result; } /** * Function attachEvents * * @access public * @param eter string $element * @return string */ public function attachEvents ($element) { return "myForm.aElements[i] = new G_Text(myForm, $element,'{$this->name}'); myForm.aElements[i].setAttributes(" . $this->getAttributes() . ");"; } } /** * Function getDynaformsVars * * @access public * @param eter string $sProcessUID * @param eter boolean $bSystemVars * @return array */ function getDynaformsVars ($sProcessUID, $typeVars = 'all', $bIncMulSelFields = 0) { $aFields = array (); $aFieldsNames = array (); 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')); } //we're adding the ping variable to the system list $aFields[] = array ('sName' => 'PIN','sType' => 'system','sLabel' => G::LoadTranslation('ID_TINY_SYSTEM_VARIABLES')); } $aInvalidTypes = array("title", "subtitle", "file", "button", "reset", "submit", "javascript", "pmconnection"); $aMultipleSelectionFields = array("listbox", "checkgroup"); if ($bIncMulSelFields != 0) { $aInvalidTypes = array_merge( $aInvalidTypes, $aMultipleSelectionFields ); } // getting bpmn projects $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(BpmnProjectPeer::PRJ_UID); $oCriteria->add(BpmnProjectPeer::PRJ_UID, $sProcessUID); $oDataset = ProcessPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro')); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $row = $oDataset->getRow(); if (isset($row["PRJ_UID"])) { 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 = ProcessVariablesPeer::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(isset($val[0]['type']) && $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' ); $oCriteria->addSelectColumn( DynaformPeer::DYN_FILENAME ); $oCriteria->add( DynaformPeer::PRO_UID, $sProcessUID ); $oCriteria->add( DynaformPeer::DYN_TYPE, 'xmlform' ); $oDataset = DynaformPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if (file_exists( PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml' )) { $G_FORM = new Form( $aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG ); if (($G_FORM->type == 'xmlform') || ($G_FORM->type == '')) { foreach ($G_FORM->fields as $k => $v) { if (! in_array( $v->type, $aInvalidTypes )) { if (! in_array( $k, $aFieldsNames )) { $aFields[] = array ('sName' => $k,'sType' => $v->type,'sLabel' => ($v->type != 'grid' ? $v->label : '[ ' . G::LoadTranslation( 'ID_GRID' ) . ' ]') ); $aFieldsNames[] = $k; } } } } } $oDataset->next(); } } return $aFields; } /** * Function getGridsVars * * @access public * @param eter string $sProcessUID * @return array */ function getGridsVars ($sProcessUID) { $aFields = array (); $aFieldsNames = array (); require_once 'classes/model/Dynaform.php'; $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( DynaformPeer::DYN_FILENAME ); $oCriteria->add( DynaformPeer::PRO_UID, $sProcessUID ); $oDataset = DynaformPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $G_FORM = new Form( $aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG ); if ($G_FORM->type == 'xmlform') { foreach ($G_FORM->fields as $k => $v) { if ($v->type == 'grid') { if (! in_array( $k, $aFieldsNames )) { $aFields[] = array ('sName' => $k,'sXmlForm' => str_replace( $sProcessUID . '/', '', $v->xmlGrid )); $aFieldsNames[] = $k; } } } } $oDataset->next(); } return $aFields; } /** * Function getVarsGrid returns all variables of Grid * * @access public * @param string proUid process ID * @param string dynUid dynaform ID * @return array */ function getVarsGrid ($proUid, $dynUid) { G::LoadClass( 'dynaformhandler' ); G::LoadClass( 'AppSolr' ); $dynaformFields = array (); if (is_file( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'.$dynUid. '.xml' ) && filesize( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'. $dynUid .'.xml' ) > 0) { $dyn = new dynaFormHandler( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/' .$proUid. '/' . $dynUid .'.xml' ); $dynaformFields[] = $dyn->getFields(); } $dynaformFieldTypes = array (); foreach ($dynaformFields as $aDynFormFields) { foreach ($aDynFormFields as $field) { if ($field->getAttribute( 'validate' ) == 'Int') { $dynaformFieldTypes[$field->nodeName] = 'Int'; } elseif ($field->getAttribute( 'validate' ) == 'Real') { $dynaformFieldTypes[$field->nodeName] = 'Real'; } else { $dynaformFieldTypes[$field->nodeName] = $field->getAttribute( 'type' ); } } } return $dynaformFieldTypes; } /** * Class XmlForm_Field_CheckBoxTable */ class XmlForm_Field_CheckBoxTable extends XmlForm_Field_Checkbox { /** * 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 = ' '; return $html; } }