Example #1
0
$options['ele_delim'] = $ele_delim;
$options['ele_delim_custom_value'] = $ele_delim_custom_value;
$options['ele_uitext'] = $ele_uitext;
$options['typetemplate'] = "db:admin/element_type_" . $ele_type . ".html";
// setup various special things per element, including ele_value
if ($ele_type == 'text') {
    $formlink = createFieldList($ele_value[4], true);
    $options['formlink'] = $formlink->render();
} else {
    if ($ele_type == 'textarea') {
        $formlink = createFieldList($ele_value[3], true);
        $options['formlink'] = $formlink->render();
    } else {
        if ($ele_type == 'derived') {
            $derivedOptions = array();
            $allColList = getAllColList($fid);
            foreach ($allColList[$fid] as $thisCol) {
                if ($thisCol['ele_colhead'] != "") {
                    $derivedOptions[trans($thisCol['ele_colhead'])] = printSmart(trans($thisCol['ele_colhead']));
                } else {
                    $derivedOptions[trans(strip_tags($thisCol['ele_caption']))] = printSmart(trans(strip_tags($thisCol['ele_caption'])));
                }
            }
            $listOfElements = new XoopsFormSelect("", 'listofelementsoptions');
            $listOfElements->addOptionArray($derivedOptions);
            $options['listofelementsoptions'] = $listOfElements->render();
            //new relationship dropdown
            $framework_handler = xoops_getmodulehandler('frameworks', 'formulize');
            $allRelationships = $framework_handler->getFrameworksByForm($fid);
            $relationships = array();
            $relationshipIndex = array();
Example #2
0
max
average (mean, median, mode)
counts (blank, non-blank)
percentage breakdowns

Need subtotalling/grouping capability, ie: show intermediate totals for the sum of all students in activity logs for each student, or show percentage breakdown of 1-5 ratings of all activities for each volunteer
--premise is that subtotalling/grouping can be done by any value in another column, or by any metadata for entries.

UI:  semi-wizard based.  pick a column (or pick add calculation column), pick calculation options, including grouping results.  

Note:  calculation columns (difference between order date and ship date for this record, for instance) will be implemented later, if necessary.

*/
// convert URL passed calcs to $_POST array
setURLCalcs();
$cols = getAllColList($fid, $frid, $groups);
$deleted = handleDelete();
// returns 1 if a deletion was made, 0 if not.
$visible_columns = explode(",", $_GET['cols']);
foreach ($cols as $f => $vs) {
    foreach ($vs as $row => $values) {
        if (in_array($values['ele_handle'], $visible_columns)) {
            $reqdcol = 'reqdcalc_column_' . $values['ele_id'];
            if (!in_array($values['ele_id'], $usedvals)) {
                // exclude duplicates...the array is not uniqued above because we don't want to merge it an unique it since that throws things out of order.
                $usedvals[] = $values['ele_id'];
                if (!$_POST[$reqdcol] and !in_array($values['ele_id'], $_POST['column'])) {
                    // Also exclude columns that have been used already.
                    if ($values['ele_colhead'] != "") {
                        $options[$values['ele_id']] = printSmart(trans($values['ele_colhead']), 60);
                    } else {
Example #3
0
            $id_reqs = unserialize($filerow[0]);
        } else {
            $id_reqs = false;
        }
    } else {
        $id_reqs = false;
    }
    $validateOverride = $_POST['validatedata'] == 0 ? true : false;
    importCsv(array($_FILES['csv_name']['name'], $csv_name), $id_reqs, $regfid, $validateOverride);
    print "</td></tr>\n";
} else {
    print "<tr><td class=head><p>" . _formulize_DE_IMPORT_STEP1 . "</p></td><td class=even>";
    // provide a blank template, and a blank update template
    // store the id_reqs and the filename in the DB for later reference in the case of the update template
    // determine if this is the profile form and if so, send special flag to template creation
    $cols1 = getAllColList($fid, "", $groups);
    $cols = array();
    foreach ($cols1[$fid] as $col) {
        $cols[] = $col['ele_id'];
    }
    $headers = getHeaders($cols);
    $template = $regfid == $fid ? "blankprofile" : "blank";
    $blank_template = prepExport($headers, $cols, "", "comma", "", "", $template);
    print "<p><b>" . _formulize_DE_IMPORT_EITHEROR . "</b><p>";
    print "<ul><li>" . _formulize_DE_IMPORT_BLANK . "<br><a href={$blank_template} target=_blank>" . _formulize_DE_IMPORT_BLANK2 . "</a></li></ul>\n";
    print "<Center><p><b>" . _formulize_DE_IMPORT_OR . "</b></p></center>";
    print "<ul><li>" . _formulize_DE_IMPORT_DATATEMP . "<br><a href=\"\" onclick=\"javascript:window.opener.showPop('" . XOOPS_URL . "/modules/formulize/include/export.php?fid={$fid}&frid=&colids=&eq=" . intval($_GET['eq']) . "&type=update');return false;\">" . _formulize_DE_IMPORT_DATATEMP2 . "</a>";
    print "</li></ul></td></tr>\n";
    print "<tr><td class=head><p>" . _formulize_DE_IMPORT_STEP2 . "</p></td><td class=even>" . _formulize_DE_IMPORT_INSTRUCTIONS;
    if ($regfid == $fid) {
        print _formulize_DE_IMPORT_INSTNEWPROFILE;
function removeNotAllowedCols($fid, $frid, $cols, $groups)
{
    // convert old metadata handles to new ones if present
    if ($uidKey = array_search("uid", $cols)) {
        $cols[$uidKey] = "creation_uid";
    }
    if ($proxyidKey = array_search("proxyid", $cols)) {
        $cols[$proxyidKey] = "mod_uid";
    }
    if ($mod_dateKey = array_search("mod_date", $cols)) {
        $cols[$mod_dateKey] = "mod_datetime";
    }
    if ($creation_dateKey = array_search("creation_date", $cols)) {
        $cols[$creation_dateKey] = "creation_datetime";
    }
    $all_allowed_cols = array();
    $allowed_cols_in_view = array();
    // metadata columns always allowed!
    $dataHandler = new formulizeDataHandler(false);
    $metadataFields = $dataHandler->metadataFields;
    foreach ($metadataFields as $field) {
        $lcField = strtolower($field);
        $all_allowed_cols[] = $lcField;
    }
    $all_allowed_cols_raw = getAllColList($fid, $frid, $groups);
    foreach ($all_allowed_cols_raw as $form_id => $values) {
        foreach ($values as $id => $value) {
            if (!in_array($value['ele_handle'], $all_allowed_cols)) {
                $all_allowed_cols[] = $value['ele_handle'];
            }
        }
    }
    $all_cols_from_view = $cols;
    $allowed_cols_in_view = array_intersect($all_allowed_cols, $all_cols_from_view);
    $allowed_cols_in_view = array_values($allowed_cols_in_view);
    return $allowed_cols_in_view;
}
 function adminPrepare($element)
 {
     $fid = $element ? $element->getVar('id_form') : intval($_GET['fid']);
     $ele_value = $element ? $element->getVar('ele_value') : array();
     if (!$element) {
         //Specify default ele_values
         $ele_value[0] = "";
         $ele_value[1] = 0;
         $ele_value[2] = "";
         $ele_value[3] = ".";
         $ele_value[4] = ",";
     }
     $derivedOptions = array();
     $allColList = getAllColList($fid);
     foreach ($allColList[$fid] as $thisCol) {
         if ($thisCol['ele_colhead'] != "") {
             $derivedOptions[trans($thisCol['ele_colhead'])] = printSmart(trans($thisCol['ele_colhead']));
         } else {
             $derivedOptions[trans(strip_tags($thisCol['ele_caption']))] = printSmart(trans(strip_tags($thisCol['ele_caption'])));
         }
     }
     $listOfElements = new XoopsFormSelect("", 'listofelementsoptions');
     $listOfElements->addOptionArray($derivedOptions);
     $listofelementsoptions = $listOfElements->render();
     return array('listofelementsoptions' => $listofelementsoptions, 'ele_value' => $ele_value);
 }
Example #6
0
function getExistingFilter($filterSettings, $filterName, $formWithSourceElements, $formName, $defaultTypeIfNoFilterTypeGiven = "all", $groups = false, $filterAllText = _formulize_GENERIC_FILTER_ALL, $filterConText = _formulize_GENERIC_FILTER_CON, $filterButtonText = _formulize_GENERIC_FILTER_ADDBUTTON)
{
    if (!$filterName or !$formWithSourceElements or !$formName) {
        return false;
    }
    // set all the elements that we want to show the user
    $cols = "";
    if ($groups) {
        $cols = getAllColList($formWithSourceElements, "", $groups);
    } else {
        $cols = getAllColList($formWithSourceElements);
    }
    $options = array('creation_uid' => _formulize_DE_CALC_CREATOR, 'creation_datetime' => _formulize_DE_CALC_CREATEDATE, 'mod_uid' => _formulize_DE_CALC_MODIFIER, 'mod_datetime' => _formulize_DE_CALC_MODDATE);
    if (is_array($cols)) {
        // setup the options array for form elements
        foreach ($cols as $f => $vs) {
            foreach ($vs as $row => $values) {
                if ($values['ele_colhead'] != "") {
                    $options[$values['ele_handle']] = printSmart(trans($values['ele_colhead']), 40);
                } else {
                    $options[$values['ele_handle']] = printSmart(trans(strip_tags($values['ele_caption'])), 40);
                }
            }
        }
    }
    // process existing conditions...setup needed variables
    $oldElementsName = $filterName . "_elements";
    $oldOpsName = $filterName . "_ops";
    $oldTermsName = $filterName . "_terms";
    $oldTypesName = $filterName . "_types";
    // unpack existing conditions
    if (is_array($filterSettings)) {
        ${$oldElementsName} = $filterSettings[0];
        ${$oldOpsName} = $filterSettings[1];
        ${$oldTermsName} = $filterSettings[2];
        if (isset($filterSettings[3])) {
            ${$oldTypesName} = $filterSettings[3];
        } else {
            if (is_array($filterSettings[0])) {
                foreach ($filterSettings[0] as $i => $thisFilterSettingsZero) {
                    ${$oldTypesName}[$i] = $defaultTypeIfNoFilterTypeGiven;
                }
            }
        }
    }
    // setup needed variables for the all or oom
    // > match all of these
    $conditionlist = array();
    // > match one or more of these
    $conditionlistOOM = array();
    if (is_array(${$oldElementsName})) {
        $i = 0;
        foreach (${$oldElementsName} as $x => $thisOldElementsName) {
            // need to add [$i] to the generation of the hidden values here, so the hidden condition keys equal the flag on the deletion X
            // $x will be the order based on the filter settings that were passed in, might not start at 0.  $i will always start at 0, so this way we'll catch/correct any malformed arrays as people edit/save them
            if (${$oldTypesName}[$x] == "all") {
                array_push($conditionlist, $options[${$oldElementsName}[$x]] . " " . ${$oldOpsName}[$x] . " " . ${$oldTermsName}[$x]);
            } else {
                array_push($conditionlistOOM, $options[${$oldElementsName}[$x]] . " " . ${$oldOpsName}[$x] . " " . ${$oldTermsName}[$x]);
            }
            $i++;
        }
    }
    $existingConditions = array();
    $existingConditions['all'] = $conditionlist;
    $existingConditions['oom'] = $conditionlistOOM;
    return $existingConditions;
}