Example #1
0
 /**
  *
  *
  * Creates a Dynaform based on a PMTable
  *
  * @name createFromPMTable
  * @author gustavo cruz gustavo[at]colosa[dot]com
  * @param array $aData Fields with :
  * $aData['DYN_UID'] the dynaform id
  * $aData['USR_UID'] the userid
  * string $pmTableUid uid of the PMTable
  *
  */
 public function createFromPMTable($aData, $pmTableUid)
 {
     $this->create($aData);
     $aData['DYN_UID'] = $this->getDynUid();
     //krumo(BasePeer::getFieldnames('Content'));
     $fields = array();
     //$oCriteria = new Criteria('workflow');
     $pmTable = AdditionalTablesPeer::retrieveByPK($pmTableUid);
     $addTabName = $pmTable->getAddTabName();
     $keys = '';
     if (isset($aData['FIELDS'])) {
         foreach ($aData['FIELDS'] as $iRow => $row) {
             if ($keys != '') {
                 $keys = $keys . '|' . $row['PRO_VARIABLE'];
             } else {
                 $keys = $row['PRO_VARIABLE'];
             }
         }
     } else {
         $keys = ' ';
     }
     //      $addTabKeys = $pmTable->getAddTabDynavars();
     //      $addTabKeys = unserialize($addTabKeys);
     //      $keys = '';
     //      foreach ( $addTabKeys as $addTabKey ){
     //        if (trim($addTabKey['CASE_VARIABLE'])!=''&&$keys!=''){
     //            $keys = $keys.'|'.$addTabKey['CASE_VARIABLE'];
     //        } else {
     //            $keys = $addTabKey['CASE_VARIABLE'];
     //        }
     //
     //      }
     // Determines the engine to use
     // For a description of a table
     $sDataBase = 'database_' . strtolower(DB_ADAPTER);
     if (G::LoadSystemExist($sDataBase)) {
         G::LoadSystem($sDataBase);
         $oDataBase = new database();
         $sql = $oDataBase->getTableDescription($addTabName);
     } else {
         $sql = 'DESC ' . $addTabName;
     }
     $dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
     $sth = $dbh->createStatement();
     $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     $file = $aData['PRO_UID'] . '/' . $aData['DYN_UID'];
     $dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
     $ses = new DBSession($dbc);
     $fieldXML = new DynaFormField($dbc);
     $pmConnectionName = $addTabName . '_CONNECTION';
     if ($aData['DYN_TYPE'] == 'xmlform') {
         $labels = array();
         $options = array();
         $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $pmConnectionName, 'TYPE' => 'pmconnection', 'PMTABLE' => $pmTableUid, 'KEYS' => $keys);
         $fieldXML->Save($attributes, $labels, $options);
     }
     $keyRequered = '';
     $countKeys = 0;
     while ($res->next()) {
         if ($res->get('Key') != '') {
             $countKeys++;
         }
         if ($res->get('Extra') == 'auto_increment') {
             $keyRequered .= $res->get('Field');
         }
     }
     $dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
     $sth = $dbh->createStatement();
     $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     while ($res->next()) {
         // if(strtoupper($res->get('Null'))=='NO') {
         if (strtoupper($res->get($oDataBase->getFieldNull())) == 'NO') {
             if ($countKeys == 1 && $res->get('Field') == $keyRequered) {
                 $required = '0';
             } else {
                 $required = '1';
             }
         } else {
             $required = '0';
         }
         $fieldName = $res->get('Field');
         $defaultValue = $res->get('Default');
         $labels = array(SYS_LANG => $fieldName);
         $options = array();
         $type = explode('(', $res->get('Type'));
         switch ($type[0]) {
             case 'text':
                 $type = 'textarea';
                 break;
             case 'date':
                 $type = 'date';
                 break;
             default:
                 $type = 'text';
                 break;
         }
         if ($aData['DYN_TYPE'] == 'xmlform') {
             $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $fieldName, 'TYPE' => $type, 'PMCONNECTION' => $pmConnectionName, 'PMFIELD' => $fieldName, 'REQUIRED' => $required, 'DEFAULTVALUE' => $defaultValue);
         } else {
             $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $fieldName, 'TYPE' => $type, 'REQUIRED' => $required, 'DEFAULTVALUE' => $defaultValue);
         }
         $fieldXML->Save($attributes, $labels, $options);
     }
     $labels = array(SYS_LANG => 'Submit');
     $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => 'SUBMIT', 'TYPE' => 'submit');
     $fieldXML->Save($attributes, $labels, $options);
 }
Example #2
0
$dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
$ses = new DBSession($dbc);
//TODO: Improve how to obtain the PRO_UID.
$aFile = explode('/', str_replace('\\', '/', $file));
$proUid = $aFile[0];
$dynUid = str_replace("_tmp0", "", $aFile[1]);
require_once 'classes/model/Dynaform.php';
$k = new Criteria('workflow');
$k->addSelectColumn(DynaformPeer::DYN_TYPE);
$k->add(DynaformPeer::DYN_UID, $dynUid);
$ods = DynaformPeer::doSelectRS($k);
$ods->next();
$row = $ods->getRow();
$dynType = $row[0];
$Fields['PME_DYN_TYPE'] = $dynType;
$fields = new DynaFormField($dbc);
$fields->Fields['XMLNODE_NAME'] = isset($_GET['XMLNODE_NAME']) ? urldecode($_GET['XMLNODE_NAME']) : '';
$fields->Load($fields->Fields['XMLNODE_NAME']);
/* Start Comment: Modify the options grid to set dynamically the language
 * label columns.
 */
//  $dbc2 = new DBConnection( PATH_XMLFORM . 'dynaforms/fields/_options.xml' ,'','','','myxml' );
//  $ses2 = new DBSession($dbc2);
//  $ses2->execute("DELETE FROM dynaForm WHERE XMLNODE_NAME like 'LABEL_%' ");
//  $ses2->execute("DELETE FROM dynaForm WHERE XMLNODE_NAME = '' ");
//  $langs=array(SYS_LANG/*,'es','fa'*/);
//  foreach( $langs as $lang ) {
//    $LANG = strtoupper($lang);
//    $Label = 'Label';
//    $ses2->execute("INSERT INTO dynaForm (XMLNODE_NAME,XMLNODE_TYPE,XMLNODE_VALUE) VALUES ('', 'cdata', '\n') ");
//    $ses2->execute("INSERT INTO dynaForm (XMLNODE_NAME,TYPE) VALUES ('LABEL_{$LANG}', 'text') ");
Example #3
0
 /**
  *
  *
  * Creates a Dynaform based on a PMTable
  *
  * @name createFromPMTable
  * @author gustavo cruz gustavo[at]colosa[dot]com
  * @param array $aData Fields with :
  * $aData['DYN_UID'] the dynaform id
  * $aData['USR_UID'] the userid
  * string $pmTableUid uid of the PMTable
  *
  */
 public function createFromPMTable($aData, $pmTableUid)
 {
     $this->create($aData, $pmTableUid);
     $aData['DYN_UID'] = $this->getDynUid();
     //krumo(BasePeer::getFieldnames('Content'));
     $fields = array();
     //$oCriteria = new Criteria('workflow');
     $pmTable = AdditionalTablesPeer::retrieveByPK($pmTableUid);
     $addTabName = $pmTable->getAddTabName();
     $keys = '';
     if (isset($aData['FIELDS'])) {
         foreach ($aData['FIELDS'] as $iRow => $row) {
             if ($keys != '') {
                 $keys = $keys . '|' . $row['PRO_VARIABLE'];
             } else {
                 $keys = $row['PRO_VARIABLE'];
             }
         }
     } else {
         $keys = ' ';
     }
     //      $addTabKeys = $pmTable->getAddTabDynavars();
     //      $addTabKeys = unserialize($addTabKeys);
     //      $keys = '';
     //      foreach ( $addTabKeys as $addTabKey ){
     //        if (trim($addTabKey['CASE_VARIABLE'])!=''&&$keys!=''){
     //            $keys = $keys.'|'.$addTabKey['CASE_VARIABLE'];
     //        } else {
     //            $keys = $addTabKey['CASE_VARIABLE'];
     //        }
     //
     //      }
     // Determines the engine to use
     // For a description of a table
     $sDataBase = 'database_' . strtolower(DB_ADAPTER);
     if (G::LoadSystemExist($sDataBase)) {
         G::LoadSystem($sDataBase);
         $oDataBase = new database();
         $sql = $oDataBase->getTableDescription($addTabName);
     } else {
         $sql = 'DESC ' . $addTabName;
     }
     $dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
     $sth = $dbh->createStatement();
     $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     $file = $aData['PRO_UID'] . '/' . $aData['DYN_UID'];
     $dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
     $ses = new DBSession($dbc);
     $fieldXML = new DynaFormField($dbc);
     $pmConnectionName = $addTabName . '_CONNECTION';
     if ($aData['DYN_TYPE'] == 'xmlform') {
         $labels = array();
         $options = array();
         $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $pmConnectionName, 'TYPE' => 'pmconnection', 'PMTABLE' => $pmTableUid, 'KEYS' => $keys);
         $fieldXML->Save($attributes, $labels, $options);
     }
     $keyRequered = '';
     $countKeys = 0;
     while ($res->next()) {
         if ($res->get('Key') != '') {
             $countKeys++;
         }
         if ($res->get('Extra') == 'auto_increment') {
             $keyRequered .= $res->get('Field');
         }
     }
     $dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
     $sth = $dbh->createStatement();
     $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     while ($res->next()) {
         // if(strtoupper($res->get('Null'))=='NO') {
         if (strtoupper($res->get($oDataBase->getFieldNull())) == 'NO') {
             if ($countKeys == 1 && $res->get('Field') == $keyRequered) {
                 $required = '0';
             } else {
                 $required = '1';
             }
         } else {
             $required = '0';
         }
         $fieldName = $res->get('Field');
         $defaultValue = $res->get('Default');
         $labels = array(SYS_LANG => $fieldName);
         $options = array();
         $type = explode('(', $res->get('Type'));
         switch ($type[0]) {
             case 'text':
                 $type = 'textarea';
                 break;
             case 'date':
                 $type = 'date';
                 break;
             default:
                 $type = 'text';
                 break;
         }
         if ($aData['DYN_TYPE'] == 'xmlform') {
             $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $fieldName, 'TYPE' => $type, 'PMCONNECTION' => $pmConnectionName, 'PMFIELD' => $fieldName, 'REQUIRED' => $required, 'DEFAULTVALUE' => $defaultValue);
         } else {
             $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $fieldName, 'TYPE' => $type, 'REQUIRED' => $required, 'DEFAULTVALUE' => $defaultValue);
         }
         $fieldXML->Save($attributes, $labels, $options);
     }
     $labels = array(SYS_LANG => 'Submit');
     $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()) {
             //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;
             }
             //variables
             $arrayData = array("var_name" => $res->get('Field'), "var_label" => $res->get('Field'), "var_field_type" => $dataType, "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);
             array_push($items, array(array("type" => $type, "dataType" => $dataType, "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);
     }
 }
Example #4
0
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 *
 */
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
    return $RBAC_Response;
}
//G::genericForceLogin( 'WF_MYINFO' , 'login/noViewPage', $urlLogin = '******' );
G::LoadClass('dynaFormField');
if (!(isset($_POST['A']) && $_POST['A'] !== '')) {
    return;
}
$file = G::decrypt($_POST['A'], URL_KEY);
$dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
$ses = new DBSession($dbc);
$fields = new DynaFormField($dbc);
if (!isset($_POST['XMLNODE_NAME'])) {
    return;
}
$fields->Delete($_POST['XMLNODE_NAME']);
G::LoadClass('xmlDb');
$i = 0;
$aFields = array();
$aFields[] = array('XMLNODE_NAME' => 'char', 'TYPE' => 'char', 'UP' => 'char', 'DOWN' => 'char');
$oSession = new DBSession(new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml'));
$oDataset = $oSession->Execute('SELECT * FROM dynaForm WHERE NOT( XMLNODE_NAME = "" )');
$iMaximun = $oDataset->count();
while ($aRow = $oDataset->Read()) {
    $aFields[] = array('XMLNODE_NAME' => $aRow['XMLNODE_NAME'], 'TYPE' => $aRow['TYPE'], 'UP' => $i > 0 ? G::LoadTranslation('ID_UP') : '', 'DOWN' => $i < $iMaximun - 1 ? G::LoadTranslation('ID_DOWN') : '');
    $i++;
}
Example #5
0
                unset($_POST['form']['PME_OPTIONS']);
            }
        }
    }
}
foreach ($_POST['form'] as $key => $value) {
    if (substr($key, 0, 4) === 'PME_') {
        $res[substr($key, 4)] = $value;
    } else {
        $res[$key] = $value;
    }
}
$_POST['form'] = $res;
$dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
$ses = new DBSession($dbc);
$fields = new DynaFormField($dbc);
if ($_POST['form']['XMLNODE_NAME'] === '') {
    return;
}
$attributes = $_POST['form'];
if (isset($attributes['HINT'])) {
    $attributes['HINT'] = addslashes($attributes['HINT']);
    $attributes['HINT'] = htmlspecialchars($attributes['HINT'], ENT_QUOTES, "UTF-8");
}
if (isset($attributes['CODE'])) {
    $attributes['XMLNODE_VALUE'] = $attributes['CODE'];
}
$labels = array();
if (isset($attributes['LABEL'])) {
    $labels = array(SYS_LANG => $attributes['LABEL']);
}
Example #6
0
                unset($_POST['form']['PME_OPTIONS']);
            }
        }
    }
}
foreach ($_POST['form'] as $key => $value) {
    if (substr($key, 0, 4) === 'PME_') {
        $res[substr($key, 4)] = $value;
    } else {
        $res[$key] = $value;
    }
}
$_POST['form'] = $res;
$dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
$ses = new DBSession($dbc);
$fields = new DynaFormField($dbc);
if ($_POST['form']['XMLNODE_NAME'] === '') {
    return;
}
$attributes = $_POST['form'];
if (isset($attributes['HINT'])) {
    $attributes['HINT'] = addslashes($attributes['HINT']);
    $attributes['HINT'] = htmlspecialchars($attributes['HINT'], ENT_QUOTES, "UTF-8");
}
if (isset($attributes['CODE'])) {
    $attributes['XMLNODE_VALUE'] = $attributes['CODE'];
}
$labels = array();
if (isset($attributes['LABEL'])) {
    $labels = array(SYS_LANG => $attributes['LABEL']);
}