/** * * * 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); }
CONCAT(U.USR_LASTNAME, ' ', U.USR_FIRSTNAME) AS USR_FULLNAME FROM TASK_USER AS TU LEFT JOIN USERS AS U ON ( TU.USR_UID = U.USR_UID ) WHERE TU.TAS_UID = '" . $_POST['TAS_UID'] . "' AND TU.TU_TYPE = 1 AND TU.TU_RELATION = 1 AND U.USR_STATUS = 1"); */ $sDataBase = 'database_' . strtolower(DB_ADAPTER); if (G::LoadSystemExist($sDataBase)) { G::LoadSystem($sDataBase); $oDataBase = new database(); $sConcat = $oDataBase->concatString("U.USR_LASTNAME", "' '", "U.USR_FIRSTNAME"); } $sSQL = " SELECT\n TU.USR_UID AS USR_UID, " . $sConcat . " AS USR_FULLNAME\n FROM\n TASK_USER AS TU\n LEFT JOIN\n USERS AS U\n ON (\n TU.USR_UID = U.USR_UID\n )\n WHERE\n TU.TAS_UID = '" . $_POST['TAS_UID'] . "' AND\n TU.TU_TYPE = 1 AND\n TU.TU_RELATION = 1 AND\n U.USR_STATUS = 1"; $oDataset = $oSession->Execute($sSQL); while ($aRow = $oDataset->Read()) { $sAux .= '<option value="' . $aRow['USR_UID'] . '">' . $aRow['USR_FULLNAME'] . '</option>'; } $sAux .= '</select>'; echo $sAux; break; case 'EVALUATE': G::LoadClass('application'); $oApplication = new Application(new DBConnection());
public function update($fields) { $con = Propel::getConnection(ReportTablePeer::DATABASE_NAME); try { $con->begin(); $this->load($fields['REP_TAB_UID']); $this->fromArray($fields, BasePeer::TYPE_FIELDNAME); $sDataBase = 'database_' . strtolower(DB_ADAPTER); if (G::LoadSystemExist($sDataBase)) { G::LoadSystem($sDataBase); $oDataBase = new database(); $oValidate = $oDataBase->getValidate($this->validate()); } else { $oValidate = $this->validate(); } // if($this->validate()) if ($oValidate) { $contentResult = 0; if (array_key_exists("REP_TAB_TITLE", $fields)) { $contentResult += $this->setRepTabTitle($fields["REP_TAB_TITLE"]); } $result = $this->save(); $result = $result == 0 ? $contentResult > 0 ? 1 : 0 : $result; $con->commit(); return $result; } else { $con->rollback(); $validationE = new Exception("Failed Validation in class " . get_class($this) . "."); $validationE->aValidationFailures = $this->getValidationFailures(); throw $validationE; } } catch (Exception $e) { $con->rollback(); throw $e; } }
/** * Function tableExist * Check if table exists * * @access public * @return boolean */ public function tableExist() { /* $bExists = true; $oConnection = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $oDataset = mysql_query('SELECT COUNT(*) FROM REPORT_TABLE') || ($bExists = false); return $bExists; */ $bExists = true; $sDataBase = 'database_' . strtolower(DB_ADAPTER); if (G::LoadSystemExist($sDataBase)) { G::LoadSystem($sDataBase); $oDataBase = new database(); $bExists = $oDataBase->reportTableExist(); } return $bExists; }
public function verifyTable() { $oCriteria = new Criteria('workflow'); $del = DBAdapter::getStringDelimiter(); $sDataBase = 'database_' . strtolower(DB_ADAPTER); if (G::LoadSystemExist($sDataBase)) { G::LoadSystem($sDataBase); $oDataBase = new database(); $sql = $oDataBase->createTableObjectPermission(); } $con = Propel::getConnection("workflow"); $stmt = $con->prepareStatement($sql); $rs = $stmt->executeQuery(); }
/** * * * 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); } }
/** * This function gets DB-s version * * @param string $driver * @return void */ public function getDbServerVersion($driver) { if (!isset($this->ip)) { $this->ip = getenv('HTTP_CLIENT_IP'); } if (isset($this->ip) && isset($this->db_user) && isset($this->db_passwd)) { try { if (!isset($this->db_sourcename)) { $this->db_sourcename = DB_NAME; } $value = 'none'; $sDataBase = 'database_' . strtolower(DB_ADAPTER); if (G::LoadSystemExist($sDataBase)) { G::LoadSystem($sDataBase); $oDataBase = new database(); $value = $oDataBase->getServerVersion($driver, $this->ip, $this->db_port, $this->db_user, $this->db_passwd, $this->db_sourcename); } return $value; } catch (Exception $e) { throw new Exception($e->getMessage()); } } else { throw new Exception('NET::Error->No params for Data Base Server!'); } }
/** * @covers G::LoadSystemExist * @todo Implement testLoadSystemExist(). */ public function testLoadSystemExist() { $this->assertTrue(G::LoadSystemExist("controller")); $this->assertFalse(G::LoadSystemExist("noExist")); }
/** * @param $sAppUid * @return Criteria */ public function getTransferHistoryCriteria($sAppUid) { $c = new Criteria('workflow'); $c->addAsColumn('TAS_TITLE', 'TAS_TITLE.CON_VALUE'); $c->addSelectColumn(UsersPeer::USR_FIRSTNAME); $c->addSelectColumn(UsersPeer::USR_LASTNAME); $c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE); $c->addSelectColumn(AppDelegationPeer::PRO_UID); $c->addSelectColumn(AppDelegationPeer::TAS_UID); $c->addSelectColumn(AppDelegationPeer::APP_UID); $c->addSelectColumn(AppDelegationPeer::DEL_INDEX); ///-- $c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)"); $sDataBase = 'database_' . strtolower(DB_ADAPTER); if (G::LoadSystemExist($sDataBase)) { G::LoadSystem($sDataBase); $oDataBase = new \database(); $c->addAsColumn('USR_NAME', $oDataBase->concatString("USR_LASTNAME", "' '", "USR_FIRSTNAME")); $c->addAsColumn( 'DEL_FINISH_DATE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'-'", AppDelegationPeer::DEL_FINISH_DATE) ); $c->addAsColumn( 'APP_TYPE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'IN_PROGRESS'", AppDelayPeer::APP_TYPE) ); } $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE); $c->addSelectColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE); $c->addSelectColumn(AppDelayPeer::APP_DISABLE_ACTION_DATE); //APP_DELEGATION LEFT JOIN USERS $c->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); //APP_DELAY FOR MORE DESCRIPTION //$c->addJoin(AppDelegationPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX, Criteria::LEFT_JOIN); //$c->addJoin(AppDelegationPeer::APP_UID, AppDelayPeer::APP_UID, Criteria::LEFT_JOIN); $del = \DBAdapter::getStringDelimiter(); $app = array(); $app[] = array(AppDelegationPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX); $app[] = array(AppDelegationPeer::APP_UID, AppDelayPeer::APP_UID); $c->addJoinMC($app, Criteria::LEFT_JOIN); //LEFT JOIN CONTENT TAS_TITLE $c->addAlias("TAS_TITLE", 'CONTENT'); $del = \DBAdapter::getStringDelimiter(); $appTitleConds = array(); $appTitleConds[] = array(AppDelegationPeer::TAS_UID, 'TAS_TITLE.CON_ID'); $appTitleConds[] = array('TAS_TITLE.CON_CATEGORY', $del . 'TAS_TITLE' . $del); $appTitleConds[] = array('TAS_TITLE.CON_LANG', $del . SYS_LANG . $del); $c->addJoinMC($appTitleConds, Criteria::LEFT_JOIN); //WHERE $c->add(AppDelegationPeer::APP_UID, $sAppUid); //ORDER BY $c->clearOrderByColumns(); $c->addAscendingOrderByColumn(AppDelegationPeer::DEL_DELEGATE_DATE); return $c; }