update view pmdynaforms in web entry

This commit is contained in:
jonathan
2015-02-18 09:50:29 -04:00
parent c8d0e60d34
commit ef672d1b0d
5 changed files with 216 additions and 45 deletions

View File

@@ -19,65 +19,67 @@ class pmDynaform
public $variables = array();
public function __construct($dyn_uid, $app_data)
{
{
$this->dyn_uid = $dyn_uid;
$this->app_data = $app_data;
$this->getDynaform();
//items
$dynContent = G::json_decode($this->record["DYN_CONTENT"]);
if (isset($dynContent->items)) {
$this->items = $dynContent->items[0]->items;
}
if($app_data != array()){
//data
$cases = new \ProcessMaker\BusinessModel\Cases();
$this->data = $cases->getCaseVariables($app_data["APPLICATION"]);
//variables
$this->variables = array();
$a = new Criteria("workflow");
$a->addSelectColumn(ProcessVariablesPeer::VAR_NAME);
$a->addSelectColumn(ProcessVariablesPeer::VAR_SQL);
$a->addSelectColumn(ProcessVariablesPeer::VAR_ACCEPTED_VALUES);
$a->addSelectColumn(ProcessVariablesPeer::VAR_DBCONNECTION);
//data
$cases = new \ProcessMaker\BusinessModel\Cases();
$this->data = $cases->getCaseVariables($app_data["APPLICATION"]);
//variables
$this->variables = array();
$a = new Criteria("workflow");
$a->addSelectColumn(ProcessVariablesPeer::VAR_NAME);
$a->addSelectColumn(ProcessVariablesPeer::VAR_SQL);
$a->addSelectColumn(ProcessVariablesPeer::VAR_ACCEPTED_VALUES);
$a->addSelectColumn(ProcessVariablesPeer::VAR_DBCONNECTION);
$c3 = $a->getNewCriterion(ProcessVariablesPeer::VAR_ACCEPTED_VALUES, "", Criteria::ALT_NOT_EQUAL);
$c2 = $a->getNewCriterion(ProcessVariablesPeer::VAR_ACCEPTED_VALUES, "[]", Criteria::ALT_NOT_EQUAL);
$c2->addAnd($c3);
$c3 = $a->getNewCriterion(ProcessVariablesPeer::VAR_ACCEPTED_VALUES, "", Criteria::ALT_NOT_EQUAL);
$c2 = $a->getNewCriterion(ProcessVariablesPeer::VAR_ACCEPTED_VALUES, "[]", Criteria::ALT_NOT_EQUAL);
$c2->addAnd($c3);
$c4 = $a->getNewCriterion(ProcessVariablesPeer::PRJ_UID, $this->app_data["PROCESS"], Criteria::EQUAL);
$c4 = $a->getNewCriterion(ProcessVariablesPeer::PRJ_UID, $this->app_data["PROCESS"], Criteria::EQUAL);
$c1 = $a->getNewCriterion(ProcessVariablesPeer::VAR_SQL, "", Criteria::ALT_NOT_EQUAL);
$c1->addOr($c2);
$c1->addAnd($c4);
$c1 = $a->getNewCriterion(ProcessVariablesPeer::VAR_SQL, "", Criteria::ALT_NOT_EQUAL);
$c1->addOr($c2);
$c1->addAnd($c4);
$a->add($c1);
$a->add($c1);
$ds = ProcessPeer::doSelectRS($a);
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$ds = ProcessPeer::doSelectRS($a);
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($ds->next()) {
$row = $ds->getRow();
//options
$rows2 = json_decode($row["VAR_ACCEPTED_VALUES"]);
$n = count($rows2);
for ($i = 0; $i < $n; $i++) {
$rows2[$i] = array($rows2[$i]->keyValue, $rows2[$i]->value);
}
//query
$arrayVariable = array();
if ($row["VAR_DBCONNECTION"] !== "none") {
$cnn = Propel::getConnection($row["VAR_DBCONNECTION"]);
$stmt = $cnn->createStatement();
$rs = $stmt->executeQuery(\G::replaceDataField($row["VAR_SQL"], $arrayVariable), \ResultSet::FETCHMODE_NUM);
while ($rs->next()) {
array_push($rows2, $rs->getRow());
while ($ds->next()) {
$row = $ds->getRow();
//options
$rows2 = json_decode($row["VAR_ACCEPTED_VALUES"]);
$n = count($rows2);
for ($i = 0; $i < $n; $i++) {
$rows2[$i] = array($rows2[$i]->keyValue, $rows2[$i]->value);
}
//query
$arrayVariable = array();
if ($row["VAR_DBCONNECTION"] !== "none") {
$cnn = Propel::getConnection($row["VAR_DBCONNECTION"]);
$stmt = $cnn->createStatement();
$rs = $stmt->executeQuery(\G::replaceDataField($row["VAR_SQL"], $arrayVariable), \ResultSet::FETCHMODE_NUM);
while ($rs->next()) {
array_push($rows2, $rs->getRow());
}
}
$this->variables[$row["VAR_NAME"]] = $rows2;
}
$this->variables[$row["VAR_NAME"]] = $rows2;
}
}
public function getDynaform()
@@ -94,7 +96,7 @@ class pmDynaform
$ds = ProcessPeer::doSelectRS($a);
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$ds->next();
$row = $ds->getRow();
$row = $ds->getRow();
$this->record = isset($row) ? $row : null;
return $this->record;
@@ -243,6 +245,29 @@ class pmDynaform
exit();
}
public function printWebEntry()
{
ob_clean();
$a = $this->clientToken();
$clientToken = array(
"accessToken" => $a["access_token"],
"expiresIn" => $a["expires_in"],
"tokenType" => $a["token_type"],
"scope" => $a["scope"],
"refreshToken" => $a["refresh_token"],
"clientId" => $a["client_id"],
"clientSecret" => $a["client_secret"]
);
$file = file_get_contents(PATH_HOME . 'public_html/lib/pmdynaform/build/WebEntry_Pmdynaform.html');
$file = str_replace("{JSON_DATA}", $this->record["DYN_CONTENT"], $file);
$file = str_replace("{DYN_UID}", $this->dyn_uid, $file);
$file = str_replace("{PRJ_UID}",$this->record["PRO_UID"], $file);
$file = str_replace("{WORKSPACE}", SYS_SYS, $file);
$file = str_replace("{credentials}", json_encode($clientToken), $file);
echo $file;
exit();
}
private function clientToken()
{
$client = $this->getClientCredentials();