Esempio n. 1
0
    /**
     * Get Dropdown Label
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
    */
    public function getDropdownLabel($appUid, $pro_uid, $dyn_uid, $fieldName, $fieldVal)
    {
        $oCase = new Cases();
        $filename = $pro_uid . PATH_SEP . $dyn_uid . ".xml";

        $G_FORM = new xmlform();
        $G_FORM->home = PATH_DYNAFORM;
        $G_FORM->parseFile($filename, SYS_LANG, true);

        $aFields = $oCase->loadCase($appUid);

        $arrayTmp = array();
        $array = array();
        $sqlQuery = null;

        foreach ($G_FORM->fields as $key => $val) {
            if ($fieldName == $val->name) {
                if ($G_FORM->fields[$key]->sql != "") {
                    $sqlQuery = G::replaceDataField($G_FORM->fields[$key]->sql, $aFields ["APP_DATA"]);
                }
                if ((is_array($val->options)) && (!empty($val->options))) {
                    foreach ($val->options as $key1 => $val1) {
                        $array[] = array("id" => $key1, "value" => $val1);
                    }
                }
                if ($val->type == "yesno") {
                    $array[] = array("id" => 1, "value" => strtoupper(G::LoadTranslation("ID_YES")));
                    $array[] = array("id" => 0, "value" => strtoupper(G::LoadTranslation("ID_NO")));
                }
            }
        }

        if ($sqlQuery != null) {
            $aResult = executeQuery($sqlQuery);
            if ($aResult == false) {
                $aResult = array();
            }
        } else {
            $aResult = array();
        }

        foreach ($aResult as $field) {
            $i = 0;
            foreach ($field as $key => $value) {
                if ($i == 0) {
                    $arrayTmp["id"] = $value;
                    if (count($field) == 1) {
                        $arrayTmp["value"] = $value;
                    }
                }

                if ($i == 1) {
                    $arrayTmp["value"] = $value;
                }
                $i++;
            }
            $array[] = $arrayTmp;
        }

        foreach ($array as $newKey => $newValue) {
            if ($newValue["id"] == $fieldVal) {
                return $newValue["value"];
            }
        }

        return null;
    }
Esempio n. 2
0
 public function getDynaformFields($dynaformUid)
 {
     $content = '';
     $fields = $this->Load($dynaformUid);
     $filename = PATH_DYNAFORM . $fields['PRO_UID'] . PATH_SEP . $fields['DYN_UID'] . '.xml';
     if (file_exists($filename)) {
         $content = file_get_contents($filename);
     }
     $G_FORM = new xmlform($fields['DYN_FILENAME'], PATH_DYNAFORM);
     $G_FORM->parseFile($filename, SYS_LANG, true);
     return $G_FORM->fields;
 }
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$appUid = isset($_POST["appUid"]) ? $_POST["appUid"] : "";
$dynUid = isset($_POST["dynUid"]) ? $_POST["dynUid"] : "";
$proUid = isset($_POST["proUid"]) ? $_POST["proUid"] : "";
$fieldName = isset($_POST["fieldName"]) ? $_POST["fieldName"] : "";
$filename = $proUid . PATH_SEP . $dynUid . ".xml";
$G_FORM = new xmlform();
$G_FORM->home = PATH_DYNAFORM;
$G_FORM->parseFile($filename, SYS_LANG, true);
G::LoadClass("case");
G::LoadClass("pmFunctions");
//Load the variables
$oCase = new Cases();
$sqlQuery = null;
$array = array();
$aFields = $oCase->loadCase($appUid);
foreach ($G_FORM->fields as $key => $val) {
    if ($fieldName == $val->name) {
        if ($G_FORM->fields[$key]->sql != null) {
            $sqlQuery = G::replaceDataField($G_FORM->fields[$key]->sql, $aFields["APP_DATA"]);
        }
        //$coma = "";
        //$data1 = "";
        if (is_array($val->options)) {
            foreach ($val->options as $key1 => $val1) {
                $array[] = array("value" => $key1, "text" => $val1);