Пример #1
0
function reload($fieldName, $fieldParent, $valueRecived, $appid, $filename)
{
    global $HTTP_SESSION_VARS;
    $G_FORM = new Form();
    G::LoadSystem("xmlform");
    G::LoadClass("dynaform");
    $fieldNew[$fieldParent] = $valueRecived;
    $Connection = new DBConnection(DB_HOST, DB_RBAC_USER, DB_RBAC_PASS, DB_RBAC_NAME);
    $ses = new DBSession($Connection);
    $xml = new Xmlform();
    $vars = explode('][', $fieldName);
    if (is_array($vars)) {
        $cant = count($vars);
        $fieldName = $vars[$cant - 1];
        if ($cant > 1) {
            $filename = $vars[0];
        }
    }
    $vars2 = explode('][', $fieldParent);
    if (is_array($vars2)) {
        $cant2 = count($vars2);
        $fieldParent = $vars2[$cant2 - 1];
    }
    $v = $filename;
    $xml->home = PATH_XMLFORM;
    $fieldXmlform = $xml->parseXmlformToArray($v);
    $fieldNew[$fieldParent] = $fieldXmlform[$fieldName][defaultvalue];
    if ($valueRecived != '') {
        $fieldNew[$fieldParent] = $valueRecived;
    }
    $qry = stripslashes($fieldXmlform[$fieldName][Sql]);
    $fieldNew[$fieldParent] = $fieldXmlform[$fieldName][defaultvalue];
    if ($valueRecived != '') {
        $fieldNew[$fieldParent] = $valueRecived;
    }
    if ($qry != '') {
        $conexion = $fieldXmlform[$fieldName][sqlconnection];
        G::LoadClass('dynaform');
        $myDyna = new Dynaform($Connection);
        $fieldsBase = array();
        if ($HTTP_SESSION_VARS['CURRENT_APPLICATION'] != "0") {
            $fieldsBase = $myDyna->getFieldsDefaultDynaform($appid, 0);
        }
        if ($appid != "") {
            $Fields = G::array_merges($fieldsBase, $fieldNew);
            $qry = $myDyna->replaceTextWithFields($qry, $Fields);
        } else {
            $qry = "Select '1', 'dynamically filled' ";
        }
        eval('$Result = "$qry "; ');
        $options = LoadOptions($Result, $Connection);
    }
    return $options;
}