This commit is contained in:
Roly Rudy Gutierrez Pinto
2015-07-23 15:59:53 -04:00
parent 89a026658b
commit 0e702a12b2

View File

@@ -148,6 +148,8 @@ class pmDynaform
$json->sql = "";
if (!isset($json->options))
$json->options = array();
if (!isset($json->optionsSql))
$json->optionsSql = array();
else {
//convert stdClass to array
if (is_array($json->options)) {
@@ -172,7 +174,7 @@ class pmDynaform
"label" => isset($row[1]) ? $row[1] : $row[0],
"value" => $row[0]
);
array_push($json->options, $option);
array_push($json->optionsSql, $option);
}
} catch (Exception $e) {
@@ -182,7 +184,7 @@ class pmDynaform
$json->data = $json->options[0];
$no = count($json->options);
for ($io = 0; $io < $no; $io++) {
if ($json->options[$io]["value"] === $json->defaultValue) {
if ((is_array($json->options[$io]) ? $json->options[$io]["value"] : $json->options[$io]->value) === $json->defaultValue) {
$json->data = $json->options[$io];
}
}
@@ -197,21 +199,6 @@ class pmDynaform
if ($json->data["label"] === "") {
$json->data["label"] = $json->data["value"];
}
//synchronize data label
$withoutOptions = true;
foreach ($json->options as $io) {
if ($json->data["value"] === $io["value"]) {
if ($json->data["label"] != $io["label"]) {
$this->dependent = $json->variable; //todo
$json->data["label"] = $io["label"];
$withoutOptions = false;
}
}
}
if ($withoutOptions) {
$json->data["label"] = $json->data["value"];//todo
}
//end synchronize data label
}
if ($key === "type" && ($value === "checkbox")) {
$json->data = array(
@@ -281,27 +268,6 @@ class pmDynaform
}
}
public function jsond(&$json)
{
foreach ($json as $key => &$value) {
$sw1 = is_array($value);
$sw2 = is_object($value);
if ($sw1 || $sw2) {
$this->jsond($value);
}
if (!$sw1 && !$sw2) {
if (isset($json->dbConnection) && $json->dbConnection !== "" && $json->dbConnection !== "none" && isset($json->sql) && $json->sql != "") {
$prefix = array("@@", "@#", "@%", "@?", "@$", "@=");
foreach ($prefix as $val) {
if (strpos($json->sql, $val . $this->dependent) !== false) {
$json->data = array("value" => "", "label" => "");
}
}
}
}
}
}
public function isResponsive()
{
return $this->record != null && $this->record["DYN_VERSION"] == 2 ? true : false;
@@ -322,7 +288,6 @@ class pmDynaform
}
$this->jsonr($json);
$this->jsond($json); //todo
$javascript = "
<script type=\"text/javascript\">
@@ -379,7 +344,6 @@ class pmDynaform
ob_clean();
$json = G::json_decode($this->record["DYN_CONTENT"]);
$this->jsonr($json);
$this->jsond($json); //todo
$javascrip = "" .
"<script type='text/javascript'>\n" .
"var jsondata = " . G::json_encode($json) . ";\n" .
@@ -425,7 +389,6 @@ class pmDynaform
ob_clean();
$json = G::json_decode($this->record["DYN_CONTENT"]);
$this->jsonr($json);
$this->jsond($json); //todo
if (!isset($this->fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["PREVIOUS_STEP"])) {
$this->fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["PREVIOUS_STEP"] = "";
}
@@ -473,7 +436,6 @@ class pmDynaform
ob_clean();
$json = G::json_decode($this->record["DYN_CONTENT"]);
$this->jsonr($json);
$this->jsond($json); //todo
$javascrip = "" .
"<script type='text/javascript'>\n" .
"var jsondata = " . G::json_encode($json) . ";\n" .
@@ -509,7 +471,6 @@ class pmDynaform
$this->record = $record;
$json = G::json_decode($this->record["DYN_CONTENT"]);
$this->jsonr($json);
$this->jsond($json); //todo
$javascrip = "" .
"<script type='text/javascript'>\n" .
"var jsondata = " . G::json_encode($json) . ";\n" .
@@ -541,7 +502,6 @@ class pmDynaform
{
$json = G::json_decode($this->record["DYN_CONTENT"]);
$this->jsonr($json);
$this->jsond($json); //todo
$javascrip = "" .
"<script type='text/javascript'>" .
"var jsonData = " . G::json_encode($json) . ";" .
@@ -560,7 +520,6 @@ class pmDynaform
$this->record = $record;
$json = G::json_decode($this->record["DYN_CONTENT"]);
$this->jsonr($json);
$this->jsond($json); //todo
$javascrip = "" .
"<script type='text/javascript'>\n" .
"var jsondata = " . G::json_encode($json) . ";\n" .