web entry - update last observations, and add post in submit

This commit is contained in:
jonathan
2015-02-18 15:36:20 -04:00
parent ef672d1b0d
commit 67115f62e1
6 changed files with 38 additions and 24 deletions

View File

@@ -17,8 +17,9 @@ class pmDynaform
public $items = array();
public $data = array();
public $variables = array();
public $arrayFieldRequired = array();
public function __construct($dyn_uid, $app_data)
public function __construct($dyn_uid, $app_data = array())
{
$this->dyn_uid = $dyn_uid;
$this->app_data = $app_data;
@@ -28,8 +29,15 @@ class pmDynaform
$dynContent = G::json_decode($this->record["DYN_CONTENT"]);
if (isset($dynContent->items)) {
$this->items = $dynContent->items[0]->items;
for($i=0; $i<count($this->items); $i++){
for($j=0; $j<count($this->items[$i]); $j++){
if($this->items[$i][$j]->required == 1){
array_push($this->arrayFieldRequired, $this->items[$i][$j]->name);
}
}
}
}
if($app_data != array()){
if(!empty($app_data)){
//data
$cases = new \ProcessMaker\BusinessModel\Cases();
$this->data = $cases->getCaseVariables($app_data["APPLICATION"]);
@@ -61,7 +69,7 @@ class pmDynaform
while ($ds->next()) {
$row = $ds->getRow();
//options
$rows2 = json_decode($row["VAR_ACCEPTED_VALUES"]);
$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);
@@ -240,12 +248,13 @@ class pmDynaform
$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("{credentials}", json_encode($clientToken), $file);
$file = str_replace("{PORT}", $_SERVER["SERVER_PORT"] , $file);
$file = str_replace("{credentials}", G::json_encode($clientToken), $file);
echo $file;
exit();
}
public function printWebEntry()
public function printWebEntry($filename)
{
ob_clean();
$a = $this->clientToken();
@@ -263,7 +272,10 @@ class pmDynaform
$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);
$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);
echo $file;
exit();
}

View File

@@ -49,7 +49,7 @@ $(window).load(function () {
submitRest: false
});
new PMDynaform.core.Proxy({
url: "http://" + window.project.keys.server + "/" + window.project.keys.apiName + "/" + window.project.keys.apiVersion + "/" + window.project.keys.workspace + "/cases/" + app_uid + "/variables",
url: "http://" + window.project.keys.server + ":"+port +"/" + window.project.keys.apiName + "/" + window.project.keys.apiVersion + "/" + window.project.keys.workspace + "/cases/" + app_uid + "/variables",
method: 'GET',
data: {},
keys: window.project.token,

View File

@@ -37,15 +37,6 @@ $(window).load(function () {
token: credentials,
submitRest: false
});
new PMDynaform.core.Proxy({
url: "http://" + window.project.keys.server + "/" + window.project.keys.apiName + "/" + window.project.keys.apiVersion + "/" + window.project.keys.workspace + "/cases/" + app_uid + "/variables",
method: 'GET',
data: {},
keys: window.project.token,
successCallback: function (xhr, response) {
window.project.setData2(response);
}
});
var type = document.createElement("input");
type.type = "hidden";
@@ -66,13 +57,18 @@ $(window).load(function () {
var dynaformname = document.createElement("input");
dynaformname.type = "hidden";
dynaformname.name = "__DynaformName__";
dynaformname.value = __DynaformName__;
//dynaformname.value = __DynaformName__;
var appuid = document.createElement("input");
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;
//appuid.value = app_uid;
var form = document.getElementsByTagName("form")[0];
form.action = "cases_SaveData?UID=" + dyn_uid + "&APP_UID=" + app_uid;
form.action = filePost;
form.method = "post";
form.appendChild(type);
form.appendChild(uid);
@@ -80,6 +76,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 () {

View File

@@ -400,7 +400,7 @@ class WebEntry
$fileContent .= "G::LoadClass('pmDynaform');\n";
$fileContent .= "\$a = new pmDynaform('".$arrayWebEntryData["DYN_UID"]."', array());\n";
$fileContent .= "if(\$a->isResponsive()){";
$fileContent .= "\$a->printWebEntry();";
$fileContent .= "\$a->printWebEntry('".$fileName."Post.php');";
$fileContent .= "}else {";
$fileContent .= "\$G_PUBLISH->AddContent(\"dynaform\", \"xmlform\", \"" . $processUid . "/" . $dynaFormUid . "\", \"\", array(), \"" . $fileName . "Post.php\");\n";
$fileContent .= "G::RenderPage(\"publish\", \"blank\");";

View File

@@ -28,6 +28,10 @@
//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>

View File

@@ -27,6 +27,7 @@
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>