PM-1340-74-1593-1511
This commit is contained in:
2
Rakefile
2
Rakefile
@@ -192,7 +192,7 @@ def buildPmdynaform(homeDir, targetDir, mode)
|
||||
template += s
|
||||
end
|
||||
|
||||
htmlTemplates=["cases_Step_Pmdynaform.html","cases_Step_Pmdynaform_Preview.html","cases_Step_Pmdynaform_View.html","WebEntry_Pmdynaform.html"]
|
||||
htmlTemplates=["pmdynaform.html"]
|
||||
htmlTemplates.each do |htmlTemplate|
|
||||
|
||||
FileUtils.cp("#{Dir.pwd}/workflow/engine/templates/cases/#{htmlTemplate}", "#{pmdynaformDir}/build/#{htmlTemplate}")
|
||||
|
||||
@@ -11,9 +11,11 @@ class pmDynaform
|
||||
{
|
||||
|
||||
public static $instance = null;
|
||||
private $debugMode = false;
|
||||
public $dyn_uid = null;
|
||||
public $record = null;
|
||||
public $app_data = null;
|
||||
public $credentials = null;
|
||||
public $items = array();
|
||||
public $data = array();
|
||||
public $variables = array();
|
||||
@@ -24,73 +26,11 @@ class pmDynaform
|
||||
$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;
|
||||
$n = count($this->items);
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
$m = count($this->items[$i]);
|
||||
for ($j = 0; $j < $m; $j++) {
|
||||
if (isset($this->items[$i][$j]->required) && $this->items[$i][$j]->required == 1) {
|
||||
array_push($this->arrayFieldRequired, $this->items[$i][$j]->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($app_data) && isset($app_data["APPLICATION"])){
|
||||
//data
|
||||
$this->getCredentials();
|
||||
if (isset($app_data["APPLICATION"])) {
|
||||
$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);
|
||||
|
||||
$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);
|
||||
|
||||
$a->add($c1);
|
||||
|
||||
$ds = ProcessPeer::doSelectRS($a);
|
||||
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($ds->next()) {
|
||||
$row = $ds->getRow();
|
||||
//options
|
||||
$rows2 = G::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" && $row["VAR_SQL"] !== "") {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getDynaform()
|
||||
@@ -109,95 +49,113 @@ class pmDynaform
|
||||
$ds->next();
|
||||
$row = $ds->getRow();
|
||||
$this->record = isset($row) ? $row : null;
|
||||
|
||||
return $this->record;
|
||||
}
|
||||
|
||||
private function searchValues($varName, $value)
|
||||
public function getCredentials()
|
||||
{
|
||||
if (!$varName || !isset($this->variables[$varName])) {
|
||||
return "";
|
||||
}
|
||||
$options = $this->variables[$varName];
|
||||
foreach ($options as $valueOptions) {
|
||||
if ($valueOptions[0] === $value) {
|
||||
return $valueOptions[1];
|
||||
}
|
||||
if ($this->credentials != null) {
|
||||
return $this->credentials;
|
||||
}
|
||||
$a = $this->clientToken();
|
||||
$this->credentials = 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"]
|
||||
);
|
||||
return $this->credentials;
|
||||
}
|
||||
|
||||
private function mergeAppData($app_uid, &$items)
|
||||
public function jsonr(&$json)
|
||||
{
|
||||
foreach ($items as $key => $value) {
|
||||
if (is_array($items[$key])) {
|
||||
$this->mergeAppData($app_uid, $items[$key]);
|
||||
} else {
|
||||
if (isset($items[$key]->name) && isset($this->data[$items[$key]->name])) {
|
||||
if ($items[$key]->type === "grid") {
|
||||
$rows = $this->data[$items[$key]->name];
|
||||
foreach ($json as $key => $value) {
|
||||
$sw1 = is_array($value);
|
||||
$sw2 = is_object($value);
|
||||
if ($sw1 || $sw2) {
|
||||
$this->jsonr($value);
|
||||
}
|
||||
if (!$sw1 && !$sw2) {
|
||||
//property
|
||||
$prefixs = array("@@", "@#", "@%", "@?", "@$", "@=");
|
||||
if (is_string($value) && in_array(substr($value, 0, 2), $prefixs)) {
|
||||
$triggerValue = substr($value, 2);
|
||||
if (isset($this->app_data[$triggerValue])) {
|
||||
$json->$key = $this->app_data[$triggerValue];
|
||||
}
|
||||
}
|
||||
//data
|
||||
if ($key === "type" && ($value === "text" || $value === "textarea" || $value === "dropdown")) {
|
||||
$json->data = array(
|
||||
"value" => isset($this->data[$json->name]) ? $this->data[$json->name] : "",
|
||||
"label" => isset($this->data[$json->name . "_label"]) ? $this->data[$json->name . "_label"] : ""
|
||||
);
|
||||
}
|
||||
if ($key === "type" && ($value === "suggets")) {
|
||||
$json->data = array(
|
||||
"value" => isset($this->data[$json->name . "_label"]) ? $this->data[$json->name . "_label"] : "",
|
||||
"label" => isset($this->data[$json->name]) ? $this->data[$json->name] : ""
|
||||
);
|
||||
}
|
||||
//query & options
|
||||
if ($key === "type" && ($value === "text" || $value === "textarea" || $value === "dropdown" || $value === "suggets")) {
|
||||
if (!isset($json->dbConnection))
|
||||
$json->dbConnection = "none";
|
||||
if (!isset($json->sql))
|
||||
$json->sql = "";
|
||||
if (!isset($json->options))
|
||||
$json->options = array();
|
||||
if ($json->dbConnection !== "none" && $json->sql !== "") {
|
||||
$cnn = Propel::getConnection($json->dbConnection);
|
||||
$stmt = $cnn->createStatement();
|
||||
$rs = $stmt->executeQuery(\G::replaceDataField($json->sql, array()), \ResultSet::FETCHMODE_NUM);
|
||||
while ($rs->next()) {
|
||||
$row = $rs->getRow();
|
||||
$option = array(
|
||||
"label" => $row[1],
|
||||
"value" => $row[0]
|
||||
);
|
||||
array_push($json->options, $option);
|
||||
}
|
||||
$json->data = isset($json->options[0]) ? $json->options[0] : $json->data;
|
||||
}
|
||||
}
|
||||
//grid
|
||||
if ($key === "type" && ($value === "grid")) {
|
||||
if (isset($this->data[$json->name])) {
|
||||
//rows
|
||||
$rows = $this->data[$json->name];
|
||||
foreach ($rows as $keyRow => $row) {
|
||||
$newRow = array();
|
||||
foreach ($row as $keyCelda => $celda) {
|
||||
array_push($newRow, array(
|
||||
"value" => $celda,
|
||||
"label" => $this->searchValues($keyCelda, $celda)
|
||||
));
|
||||
//cells
|
||||
$cells = array();
|
||||
foreach ($json->columns as $column) {
|
||||
//data
|
||||
if ($column->type === "text" || $column->type === "textarea" || $column->type === "dropdown") {
|
||||
array_push($cells, array(
|
||||
"value" => $row[$column->name],
|
||||
"label" => $row[$column->name . "_label"]
|
||||
));
|
||||
}
|
||||
if ($column->type === "suggest") {
|
||||
array_push($cells, array(
|
||||
"value" => $row[$column->name . "_label"],
|
||||
"label" => $row[$column->name]
|
||||
));
|
||||
}
|
||||
}
|
||||
$rows[$keyRow] = $newRow;
|
||||
$rows[$keyRow] = $cells;
|
||||
}
|
||||
$items[$key]->rows = count($rows);
|
||||
$items[$key]->data = $rows;
|
||||
$json->rows = count($rows);
|
||||
$json->data = $rows;
|
||||
}
|
||||
if ($items[$key]->type !== "grid") {
|
||||
$value = $this->data[$items[$key]->name];
|
||||
$label = "";
|
||||
if (isset($this->data[$items[$key]->name . "_label"])) {
|
||||
$value = $this->data[$items[$key]->name];
|
||||
$label = $this->data[$items[$key]->name . "_label"];
|
||||
}
|
||||
if (isset($this->data[$items[$key]->name . "_value"])) {
|
||||
$value = $this->data[$items[$key]->name . "_value"];
|
||||
$label = $this->data[$items[$key]->name];
|
||||
}
|
||||
$items[$key]->data = array(
|
||||
"value" => $value,
|
||||
"label" => $label
|
||||
);
|
||||
}
|
||||
}
|
||||
if (isset($items[$key]->options) && isset($this->variables[$items[$key]->name])) {
|
||||
$options = $this->variables[$items[$key]->name];
|
||||
$n = count($options);
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
$options[$i] = array(
|
||||
"value" => $options[$i][0],
|
||||
"label" => $options[$i][1]
|
||||
);
|
||||
}
|
||||
$items[$key]->options = $options;
|
||||
}
|
||||
if (isset($items[$key]->columns)) {
|
||||
$this->mergeAppData($app_uid, $items[$key]->columns);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function mergeDynContentAppData($app_uid, &$items)
|
||||
{
|
||||
$dynContent = G::json_decode($this->record["DYN_CONTENT"]);
|
||||
if (isset($dynContent->items)) {
|
||||
$this->items = $dynContent->items[0]->items;
|
||||
}
|
||||
|
||||
$this->mergeAppData($app_uid, $items);
|
||||
$dynContent->items[0]->items = $this->items;
|
||||
|
||||
$a = G::json_encode($dynContent);
|
||||
$a = str_replace("\/", "/", $a);
|
||||
$this->record["DYN_CONTENT"] = $a;
|
||||
}
|
||||
|
||||
public function isResponsive()
|
||||
{
|
||||
return $this->record != null && $this->record["DYN_VERSION"] == 2 ? true : false;
|
||||
@@ -206,7 +164,8 @@ class pmDynaform
|
||||
public function printView($pm_run_outside_main_app, $application)
|
||||
{
|
||||
ob_clean();
|
||||
$this->mergeDynContentAppData($application, $this->items);
|
||||
$json = G::json_decode($this->record["DYN_CONTENT"]);
|
||||
$this->jsonr($json);
|
||||
|
||||
$a = $this->clientToken();
|
||||
$clientToken = array(
|
||||
@@ -219,15 +178,43 @@ class pmDynaform
|
||||
"clientSecret" => $a["client_secret"]
|
||||
);
|
||||
|
||||
$file = file_get_contents(PATH_HOME . 'public_html/lib/pmdynaform/build/cases_Step_Pmdynaform_View.html');
|
||||
$file = str_replace("{JSON_DATA}", $this->record["DYN_CONTENT"], $file);
|
||||
$file = str_replace("{PM_RUN_OUTSIDE_MAIN_APP}", $pm_run_outside_main_app, $file);
|
||||
$file = str_replace("{DYN_UID}", $this->dyn_uid, $file);
|
||||
$file = str_replace("{DYNAFORMNAME}", $this->record["PRO_UID"] . "_" . $this->record["DYN_UID"], $file);
|
||||
$file = str_replace("{APP_UID}", $application, $file);
|
||||
$file = str_replace("{PRJ_UID}", $this->app_data["PROCESS"], $file);
|
||||
$file = str_replace("{WORKSPACE}", $this->app_data["SYS_SYS"], $file);
|
||||
$file = str_replace("{credentials}", json_encode($clientToken), $file);
|
||||
$javascrip = "" .
|
||||
"<script type='text/javascript'>\n" .
|
||||
"var jsondata = " . G::json_encode($json) . ";\n" .
|
||||
"var pm_run_outside_main_app = '" . $pm_run_outside_main_app . "';\n" .
|
||||
"var dyn_uid = '" . $this->dyn_uid . "';\n" .
|
||||
"var __DynaformName__ = '" . $this->record["PRO_UID"] . "_" . $this->record["DYN_UID"] . "';\n" .
|
||||
"var app_uid = '" . $application . "';\n" .
|
||||
"var prj_uid = '" . $this->app_data["PROCESS"] . "';\n" .
|
||||
"var step_mode = null;\n" .
|
||||
"var workspace = '" . $this->app_data["SYS_SYS"] . "';\n" .
|
||||
"var credentials = " . G::json_encode($clientToken) . ";\n" .
|
||||
"var filePost = null;\n" .
|
||||
"var fieldsRequired = null;\n" .
|
||||
"$(window).load(function () {\n" .
|
||||
" var data = jsondata;\n" .
|
||||
" data.items[0].mode = 'view';\n" .
|
||||
" window.project = new PMDynaform.core.Project({\n" .
|
||||
" data: data,\n" .
|
||||
" keys: {\n" .
|
||||
" server: location.host,\n" .
|
||||
" projectId: prj_uid,\n" .
|
||||
" workspace: workspace\n" .
|
||||
" },\n" .
|
||||
" token: credentials,\n" .
|
||||
" submitRest: false\n" .
|
||||
" });\n" .
|
||||
" $(document).find('form').submit(function (e) {\n" .
|
||||
" e.preventDefault();\n" .
|
||||
" return false;\n" .
|
||||
" });\n" .
|
||||
"});\n" .
|
||||
"</script>\n";
|
||||
|
||||
$file = file_get_contents(PATH_HOME . 'public_html/lib/pmdynaform/build/pmdynaform.html');
|
||||
$file = str_replace("{javascript}", $javascrip, $file);
|
||||
|
||||
$this->debug();
|
||||
echo $file;
|
||||
exit();
|
||||
}
|
||||
@@ -235,34 +222,43 @@ class pmDynaform
|
||||
public function printEdit($pm_run_outside_main_app, $application, $headData, $step_mode = 'EDIT')
|
||||
{
|
||||
ob_clean();
|
||||
$this->mergeDynContentAppData($application, $this->items);
|
||||
$json = G::json_decode($this->record["DYN_CONTENT"]);
|
||||
$this->jsonr($json);
|
||||
$javascrip = "" .
|
||||
"<script type='text/javascript'>\n" .
|
||||
"var jsondata = " . G::json_encode($json) . ";\n" .
|
||||
"var pm_run_outside_main_app = '" . $pm_run_outside_main_app . "';\n" .
|
||||
"var dyn_uid = '" . $this->dyn_uid . "';\n" .
|
||||
"var __DynaformName__ = '" . $this->record["PRO_UID"] . "_" . $this->record["DYN_UID"] . "';\n" .
|
||||
"var app_uid = '" . $application . "';\n" .
|
||||
"var prj_uid = '" . $this->app_data["PROCESS"] . "';\n" .
|
||||
"var step_mode = '" . $step_mode . "';\n" .
|
||||
"var workspace = '" . $this->app_data["SYS_SYS"] . "';\n" .
|
||||
"var credentials = " . G::json_encode($this->credentials) . ";\n" .
|
||||
"var filePost = null;\n" .
|
||||
"var fieldsRequired = null;\n" .
|
||||
"</script>\n" .
|
||||
"<script type='text/javascript' src='/jscore/cases/core/cases_Step.js'></script>\n" .
|
||||
"<script type='text/javascript' src='/jscore/cases/core/pmDynaform.js'></script>\n" .
|
||||
"<table width='100%' align='center'>\n" .
|
||||
" <tr class='userGroupTitle'>\n" .
|
||||
" <td width='100%' align='center'>" . $headData["CASE"] . " #: " . $headData["APP_NUMBER"] . " " . $headData["TITLE"] . ": " . $headData["APP_TITLE"] . "</td>\n" .
|
||||
" </tr>\n" .
|
||||
"</table>\n" .
|
||||
"<div style='width:100%;padding: 0px 10px 0px 10px'>\n" .
|
||||
" <img src='/images/bulletButtonLeft.gif' style='float:left;'> \n" .
|
||||
" <a id='dyn_backward' href='' style='float:left;'>\n" .
|
||||
" </a>\n" .
|
||||
" <img src='/images/bulletButton.gif' style='float:right;'> \n" .
|
||||
" <a id='dyn_forward' href='' style='float:right;font-size:12px;line-height:1;margin:0px 5px 1px 0px;'>\n" .
|
||||
" Next Step\n" .
|
||||
" </a>\n" .
|
||||
"</div>";
|
||||
|
||||
$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/pmdynaform.html');
|
||||
$file = str_replace("{javascript}", $javascrip, $file);
|
||||
|
||||
$file = file_get_contents(PATH_HOME . 'public_html/lib/pmdynaform/build/cases_Step_Pmdynaform.html');
|
||||
$file = str_replace("{JSON_DATA}", $this->record["DYN_CONTENT"], $file);
|
||||
$file = str_replace("{CASE}", $headData["CASE"], $file);
|
||||
$file = str_replace("{APP_NUMBER}", $headData["APP_NUMBER"], $file);
|
||||
$file = str_replace("{TITLE}", $headData["TITLE"], $file);
|
||||
$file = str_replace("{APP_TITLE}", $headData["APP_TITLE"], $file);
|
||||
$file = str_replace("{PM_RUN_OUTSIDE_MAIN_APP}", $pm_run_outside_main_app, $file);
|
||||
$file = str_replace("{DYN_UID}", $this->dyn_uid, $file);
|
||||
$file = str_replace("{DYNAFORMNAME}", $this->record["PRO_UID"] . "_" . $this->record["DYN_UID"], $file);
|
||||
$file = str_replace("{APP_UID}", $application, $file);
|
||||
$file = str_replace("{PRJ_UID}", $this->app_data["PROCESS"], $file);
|
||||
$file = str_replace("{STEP_MODE}", $step_mode, $file);
|
||||
$file = str_replace("{WORKSPACE}", $this->app_data["SYS_SYS"], $file);
|
||||
$file = str_replace("{PORT}", $_SERVER["SERVER_PORT"] , $file);
|
||||
$file = str_replace("{credentials}", G::json_encode($clientToken), $file);
|
||||
$this->debug();
|
||||
echo $file;
|
||||
exit();
|
||||
}
|
||||
@@ -270,25 +266,51 @@ class pmDynaform
|
||||
public function printWebEntry($filename)
|
||||
{
|
||||
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("{FILEPOST}", $filename, $file);
|
||||
$file = str_replace("{PORT}", $_SERVER["SERVER_PORT"] , $file);
|
||||
$file = str_replace("{credentials}", G::json_encode($clientToken), $file);
|
||||
$file = str_replace("{FIELDSREQUIRED}", G::json_encode($this->arrayFieldRequired), $file);
|
||||
$json = G::json_decode($this->record["DYN_CONTENT"]);
|
||||
$this->jsonr($json);
|
||||
$javascrip = "" .
|
||||
"<script type='text/javascript'>\n" .
|
||||
"var jsondata = " . G::json_encode($json) . ";\n" .
|
||||
"var pm_run_outside_main_app = null;\n" .
|
||||
"var dyn_uid = '" . $this->dyn_uid . "';\n" .
|
||||
"var __DynaformName__ = null;\n" .
|
||||
"var app_uid = null;\n" .
|
||||
"var prj_uid = '" . $this->record["PRO_UID"] . "';\n" .
|
||||
"var step_mode = null;\n" .
|
||||
"var workspace = '" . SYS_SYS . "';\n" .
|
||||
"var credentials = " . G::json_encode($this->credentials) . ";\n" .
|
||||
"var filePost = '" . $filename . "';\n" .
|
||||
"var fieldsRequired = " . G::json_encode($this->arrayFieldRequired) . ";\n" .
|
||||
"</script>\n" .
|
||||
"<script type='text/javascript' src='/jscore/cases/core/pmDynaform.js'></script>\n" .
|
||||
"<div style='width:100%;padding: 0px 10px 0px 10px;margin:15px 0px 0px 0px;'>\n" .
|
||||
" <img src='/images/bulletButton.gif' style='float:right;'> \n" .
|
||||
" <a id='dyn_forward' href='' style='float:right;font-size:12px;line-height:1;margin:0px 5px 1px 0px;'>\n" .
|
||||
" Next Step\n" .
|
||||
" </a>\n" .
|
||||
"</div>";
|
||||
|
||||
$file = file_get_contents(PATH_HOME . 'public_html/lib/pmdynaform/build/pmdynaform.html');
|
||||
$file = str_replace("{javascript}", $javascrip, $file);
|
||||
|
||||
$this->debug();
|
||||
echo $file;
|
||||
exit();
|
||||
}
|
||||
|
||||
public function printPmDynaform()
|
||||
{
|
||||
$json = G::json_decode($this->record["DYN_CONTENT"]);
|
||||
$this->jsonr($json);
|
||||
$javascrip = "" .
|
||||
"<script type='text/javascript'>" .
|
||||
"var jsonData = " . G::json_encode($json) . ";" .
|
||||
"</script>";
|
||||
|
||||
$file = file_get_contents(PATH_HOME . 'public_html/lib/pmdynaform/build/pmdynaform.html');
|
||||
$file = str_replace("{javascript}", $javascrip, $file);
|
||||
|
||||
$this->debug();
|
||||
echo $file;
|
||||
exit();
|
||||
}
|
||||
@@ -360,4 +382,13 @@ class pmDynaform
|
||||
return array('dsn' => $dsn, 'username' => DB_USER, 'password' => DB_PASS);
|
||||
}
|
||||
|
||||
private function debug()
|
||||
{
|
||||
if ($this->debugMode) {
|
||||
echo "<pre>";
|
||||
echo G::json_encode($json);
|
||||
echo "</pre>";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,14 +26,13 @@ $(window).load(function () {
|
||||
if (parent.showCaseNavigatorPanel) {
|
||||
parent.showCaseNavigatorPanel('DRAFT');
|
||||
}
|
||||
|
||||
if (parent.setCurrent) {
|
||||
parent.setCurrent(dyn_uid);
|
||||
}
|
||||
}
|
||||
|
||||
var data = jsondata;
|
||||
data.items[0].mode = step_mode.toLowerCase();
|
||||
if (step_mode)
|
||||
data.items[0].mode = step_mode.toLowerCase();
|
||||
window.project = new PMDynaform.core.Project({
|
||||
data: data,
|
||||
keys: {
|
||||
@@ -69,8 +68,12 @@ $(window).load(function () {
|
||||
appuid.type = "hidden";
|
||||
appuid.name = "APP_UID";
|
||||
appuid.value = app_uid;
|
||||
var arrayRequired = document.createElement("input");
|
||||
arrayRequired.type = "hidden";
|
||||
arrayRequired.name = "DynaformRequiredFields";
|
||||
arrayRequired.value = fieldsRequired;
|
||||
var form = document.getElementsByTagName("form")[0];
|
||||
form.action = "cases_SaveData?UID=" + dyn_uid + "&APP_UID=" + app_uid;
|
||||
form.action = filePost ? filePost : "cases_SaveData?UID=" + dyn_uid + "&APP_UID=" + app_uid;
|
||||
form.method = "post";
|
||||
form.enctype = "multipart/form-data";
|
||||
form.appendChild(type);
|
||||
@@ -79,7 +82,7 @@ $(window).load(function () {
|
||||
form.appendChild(action);
|
||||
form.appendChild(dynaformname);
|
||||
form.appendChild(appuid);
|
||||
|
||||
form.appendChild(arrayRequired);
|
||||
var dyn_forward = document.getElementById("dyn_forward");
|
||||
dyn_forward.onclick = function () {
|
||||
form.submit();
|
||||
@@ -1,86 +0,0 @@
|
||||
function dynaFormChanged(frm) {
|
||||
for (var i1 = 0; i1 <= frm.elements.length - 1; i1++) {
|
||||
if ((frm.elements[i1].type === "radio" || frm.elements[i1].type === "checkbox") && (frm.elements[i1].checked !== frm.elements[i1].defaultChecked)) {
|
||||
return true;
|
||||
}
|
||||
if ((frm.elements[i1].type === "textarea" || frm.elements[i1].type === "text" || frm.elements[i1].type === "file") && (frm.elements[i1].value !== frm.elements[i1].defaultValue)) {
|
||||
return true;
|
||||
}
|
||||
if (frm.elements[i1].tagName.toLowerCase() === "select") {
|
||||
var selectDefaultValue = frm.elements[i1].value;
|
||||
for (var i2 = 0; i2 <= frm.elements[i1].options.length - 1; i2++) {
|
||||
if (frm.elements[i1].options[i2].defaultSelected) {
|
||||
selectDefaultValue = frm.elements[i1].options[i2].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (frm.elements[i1].value !== selectDefaultValue) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$(window).load(function () {
|
||||
/*if ((navigator.userAgent.indexOf("MSIE") !== -1) || (navigator.userAgent.indexOf("Trident") !== -1)) {
|
||||
document.body.innerHTML = "<div style='margin:15px'>Responsive Dynaforms are not supported in this browser.</div>";
|
||||
return;
|
||||
}*/
|
||||
var data = jsondata;
|
||||
window.project = new PMDynaform.core.Project({
|
||||
data: data,
|
||||
keys: {
|
||||
server: location.host,
|
||||
projectId: prj_uid,
|
||||
workspace: workspace
|
||||
},
|
||||
token: credentials,
|
||||
submitRest: false
|
||||
});
|
||||
|
||||
var type = document.createElement("input");
|
||||
type.type = "hidden";
|
||||
type.name = "TYPE";
|
||||
type.value = "ASSIGN_TASK";
|
||||
var uid = document.createElement("input");
|
||||
uid.type = "hidden";
|
||||
uid.name = "UID";
|
||||
uid.value = dyn_uid;
|
||||
var position = document.createElement("input");
|
||||
position.type = "hidden";
|
||||
position.name = "POSITION";
|
||||
position.value = "10000";
|
||||
var action = document.createElement("input");
|
||||
action.type = "hidden";
|
||||
action.name = "ACTION";
|
||||
action.value = "ASSIGN";
|
||||
var dynaformname = document.createElement("input");
|
||||
dynaformname.type = "hidden";
|
||||
dynaformname.name = "__DynaformName__";
|
||||
//dynaformname.value = __DynaformName__;
|
||||
var appuid = document.createElement("input");
|
||||
appuid.type = "hidden";
|
||||
appuid.name = "APP_UID";
|
||||
|
||||
var arrayRequired = document.createElement("input");
|
||||
arrayRequired.type = "hidden";
|
||||
arrayRequired.name = "DynaformRequiredFields";
|
||||
arrayRequired.value = fieldsRequired;
|
||||
//appuid.value = app_uid;
|
||||
var form = document.getElementsByTagName("form")[0];
|
||||
form.action = filePost;
|
||||
form.method = "post";
|
||||
form.appendChild(type);
|
||||
form.appendChild(uid);
|
||||
form.appendChild(position);
|
||||
form.appendChild(action);
|
||||
form.appendChild(dynaformname);
|
||||
form.appendChild(appuid);
|
||||
form.appendChild(arrayRequired);
|
||||
|
||||
var dyn_forward = document.getElementById("dyn_forward");
|
||||
dyn_forward.onclick = function () {
|
||||
form.submit();
|
||||
return false;
|
||||
};
|
||||
});
|
||||
6
workflow/engine/methods/cases/pmDynaform.php
Normal file
6
workflow/engine/methods/cases/pmDynaform.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
$DYN_UID = $_GET["dyn_uid"];
|
||||
G::LoadClass('pmDynaform');
|
||||
$a = new pmDynaform($DYN_UID);
|
||||
$a->printPmDynaform();
|
||||
@@ -1,53 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>PMDynaform</title>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<link rel="stylesheet" href="/lib/pmdynaform/libs/bootstrap-3.1.1/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/lib/pmdynaform/build/css/PMDynaform.css">
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/jquery/jquery-1.11.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/bootstrap-3.1.1/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/underscore/underscore-1.6.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/backbone/backbone-min.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/restclient/restclient.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
###TEMPLATES###
|
||||
<script type="text/javascript" src="/lib/pmdynaform/build/js/PMDynaform.js"></script>
|
||||
<script type="text/javascript">
|
||||
var jsondata = {JSON_DATA};
|
||||
//var pm_run_outside_main_app = '{PM_RUN_OUTSIDE_MAIN_APP}';
|
||||
var dyn_uid = '{DYN_UID}';
|
||||
//var __DynaformName__ = '{DYNAFORMNAME}';
|
||||
//var app_uid = '{APP_UID}';
|
||||
var prj_uid = '{PRJ_UID}';
|
||||
//var step_mode = '{STEP_MODE}';
|
||||
var workspace = '{WORKSPACE}';
|
||||
var credentials = {credentials};
|
||||
var filePost = '{FILEPOST}';
|
||||
var port = '{PORT}';
|
||||
var fieldsRequired = {FIELDSREQUIRED};
|
||||
|
||||
</script>
|
||||
<script type="text/javascript" src="/jscore/cases/core/cases_Step.js"></script>
|
||||
<script type="text/javascript" src="/jscore/cases/core/webentry_pmdynaform.js"></script>
|
||||
<table width="100%" align="center">
|
||||
<tr class="userGroupTitle">
|
||||
<!--td width="100%" align="center">{CASE} #: {APP_NUMBER} {TITLE}: {APP_TITLE}</td-->
|
||||
</tr>
|
||||
</table>
|
||||
<div style="width:100%;padding: 0px 10px 0px 10px">
|
||||
<img src="/images/bulletButtonLeft.gif" style="float:left;">
|
||||
<a id="dyn_backward" href="" style="float:left;">
|
||||
</a>
|
||||
<img src="/images/bulletButton.gif" style="float:right;">
|
||||
<a id="dyn_forward" href="" style="float:right;font-size:12px;line-height:1;margin:0px 5px 1px 0px;">
|
||||
Next Step
|
||||
</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,53 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>PMDynaform</title>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<link rel="stylesheet" href="/lib/pmdynaform/libs/bootstrap-3.1.1/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/lib/pmdynaform/build/css/PMDynaform.css">
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/jquery/jquery-1.11.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/bootstrap-3.1.1/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/underscore/underscore-1.6.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/backbone/backbone-min.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/restclient/restclient.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/html5/html5.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/respondjs/respond.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
###TEMPLATES###
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/underscore/underscore-1.6.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/build/js/PMDynaform.js"></script>
|
||||
<script type="text/javascript">
|
||||
var jsondata = {JSON_DATA};
|
||||
var pm_run_outside_main_app = '{PM_RUN_OUTSIDE_MAIN_APP}';
|
||||
var dyn_uid = '{DYN_UID}';
|
||||
var __DynaformName__ = '{DYNAFORMNAME}';
|
||||
var app_uid = '{APP_UID}';
|
||||
var prj_uid = '{PRJ_UID}';
|
||||
var step_mode = '{STEP_MODE}';
|
||||
var workspace = '{WORKSPACE}';
|
||||
var port = '{PORT}';
|
||||
var credentials = {credentials};
|
||||
</script>
|
||||
<script type="text/javascript" src="/jscore/cases/core/cases_Step.js"></script>
|
||||
<script type="text/javascript" src="/jscore/cases/core/cases_Step_Pmdynaform.js"></script>
|
||||
<table width="100%" align="center">
|
||||
<tr class="userGroupTitle">
|
||||
<td width="100%" align="center">{CASE} #: {APP_NUMBER} {TITLE}: {APP_TITLE}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="width:100%;padding: 0px 10px 0px 10px">
|
||||
<img src="/images/bulletButtonLeft.gif" style="float:left;">
|
||||
<a id="dyn_backward" href="" style="float:left;">
|
||||
</a>
|
||||
<img src="/images/bulletButton.gif" style="float:right;">
|
||||
<a id="dyn_forward" href="" style="float:right;font-size:12px;line-height:1;margin:0px 5px 1px 0px;">
|
||||
Next Step
|
||||
</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,53 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>PMDynaform</title>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<link rel="stylesheet" href="/lib/pmdynaform/libs/bootstrap-3.1.1/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/lib/pmdynaform/build/css/PMDynaform.css">
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/jquery/jquery-1.11.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/bootstrap-3.1.1/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/underscore/underscore-1.6.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/backbone/backbone-min.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/restclient/restclient.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/html5/html5.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/respondjs/respond.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
###TEMPLATES###
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/underscore/underscore-1.6.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/build/js/PMDynaform.js"></script>
|
||||
<script type="text/javascript">
|
||||
var jsondata = {JSON_DATA};
|
||||
var pm_run_outside_main_app = '{PM_RUN_OUTSIDE_MAIN_APP}';
|
||||
var dyn_uid = '{DYN_UID}';
|
||||
var __DynaformName__ = '{DYNAFORMNAME}';
|
||||
var app_uid = '{APP_UID}';
|
||||
var prj_uid = '{PRJ_UID}';
|
||||
var workspace = '{WORKSPACE}';
|
||||
var credentials = {credentials};
|
||||
$(window).load(function () {
|
||||
var data = jsondata;
|
||||
data.items[0].mode = "view";
|
||||
window.project = new PMDynaform.core.Project({
|
||||
data: data,
|
||||
keys: {
|
||||
server: location.host,
|
||||
projectId: prj_uid,
|
||||
workspace: workspace
|
||||
},
|
||||
token: credentials,
|
||||
submitRest: false
|
||||
});
|
||||
$(document).find('form').submit(function (e) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -13,13 +13,13 @@
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/underscore/underscore-1.6.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/backbone/backbone-min.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/restclient/restclient.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/html5/html5.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/respondjs/respond.min.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/html5/html5.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/respondjs/respond.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
###TEMPLATES###
|
||||
<script type="text/javascript" src="/lib/pmdynaform/libs/underscore/underscore-1.6.js"></script>
|
||||
<script type="text/javascript" src="/lib/pmdynaform/build/js/PMDynaform.js"></script>
|
||||
{javascript}
|
||||
</body>
|
||||
</html>
|
||||
@@ -27,7 +27,7 @@ function parseItemArray($array) {
|
||||
* @return array of objects
|
||||
*/
|
||||
function convertFormToWSObjects($form) {
|
||||
|
||||
$aVariables = array();
|
||||
foreach ( $form as $key => $val ) {
|
||||
if (! is_array($val)) { //Normal Variables
|
||||
$obj = new stdClass();
|
||||
|
||||
@@ -27,7 +27,7 @@ function parseItemArray($array) {
|
||||
* @return array of objects
|
||||
*/
|
||||
function convertFormToWSObjects($form) {
|
||||
|
||||
$aVariables = array();
|
||||
foreach ( $form as $key => $val ) {
|
||||
if (! is_array($val)) { //Normal Variables
|
||||
$obj = new stdClass();
|
||||
|
||||
Reference in New Issue
Block a user