function formulize_setupPreviousEntryUI($screen, $element_id, $type, $owner, $de = false, $entryId = "", $ele_handle, $fid)
 {
     // 1. need to get and cache the values of the entry for this screen
     // 2. need to put the values into a dropdown list with an onchange event that populates the actual form element
     // this should be cached in some other way, since every instance of the renderer will need to cache this.  If it were a GLOBAL or this whole thing were in some other function, that would work.
     static $cachedEntries = array();
     if (!isset($cachedEntries[$screen->getVar('sid')])) {
         // identify the entry belonging to this user's group(s) in the other form.  Currently only group correspondence is supported.
         global $xoopsUser;
         $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS);
         $member_handler =& xoops_gethandler('member');
         $gperm_handler =& xoops_gethandler('groupperm');
         $mid = getFormulizeModId();
         $owner_groups =& $member_handler->getGroupsByUser($owner, FALSE);
         // in this particular case, it's okay to make the owner_groups based on the users's memberships, since we want to present the single entry that belongs to whichever groups the user is a member of...I think.  :-)
         $singleData = getSingle($screen->getVar('paraentryform'), $owner, $owner_groups, $member_handler, $gperm_handler, $mid);
         if ($singleData['flag'] == "group" and $singleData['entry'] > 0) {
             // only proceed if there is a one-entry-per-group situation in the target form
             formulize_benchmark("Ready to do previous entry query.");
             $cachedEntries[$screen->getVar('sid')] = getData("", $screen->getVar('paraentryform'), $singleData['entry']);
             formulize_benchmark("Done query.");
         } else {
             return "";
         }
     }
     $entries = $cachedEntries[$screen->getVar('sid')];
     // big assumption below is corresponding captions.  In future there will be more ad hoc ways of describing which elements align to which other ones.
     // 1. figure out the corresponding element ID based on matching captions
     // 2. grab the previous value from the $entry/entries
     // 3. create the dropdown list with these values, including javascript
     $formHandler =& xoops_getmodulehandler('forms', 'formulize');
     $currentForm = $formHandler->get($screen->getVar('fid'));
     $previousForm = $formHandler->get($screen->getVar('paraentryform'));
     $currentCaptions = $currentForm->getVar('elementCaptions');
     $captionToMatch = $currentCaptions[$ele_handle];
     $previousCaptions = $previousForm->getVar('elementCaptions');
     $previousElementHandle = array_search($captionToMatch, $previousCaptions);
     if (!$previousElementHandle) {
         return "";
     }
     $elementName = $de ? "de_" . $fid . "_" . $entryId . "_" . $element_id : "ele_" . $element_id;
     // displayElement elements have different names from regular elements
     $previousElementId = formulize_getIdFromElementHandle($previousElementHandle);
     // function is in extract.php
     // setup the javascript based on the type of question, and setup other data that is required
     switch ($type) {
         case "text":
         case "date":
             $javascript = "onchange='javascript:this.form." . $elementName . ".value=this.form.prev_" . $element_id . ".value;'";
             break;
         case "radio":
             // need to get the options of the question so we know what to match
             $prevElementMetaData = formulize_getElementMetaData($previousElementId);
             // use this function in extract instead of the get element method in handler, since this is guaranteed to be already be cached in memory
             $prevElement_ele_value = unserialize($prevElementMetaData['ele_value']);
             $prevElementOptions = array_keys($prevElement_ele_value);
             $javascript = "onchange='javascript:if(this.form.prev_" . $element_id . ".value !== \"\") { this.form." . $elementName . "[this.form.prev_" . $element_id . ".value].checked=true; }'";
             break;
         case "yn":
             $javascript = "onchange='javascript:if(this.form.prev_" . $element_id . ".value !== \"\") { this.form." . $elementName . "[this.form.prev_" . $element_id . ".value].checked=true; }'";
             break;
     }
     $previousOptions = array();
     $prevOptionsExist = false;
     foreach ($entries as $id => $entry) {
         $value = htmlspecialchars(strip_tags(display($entry, $previousElementHandle)));
         if (is_array($value)) {
             $value = printSmart(implode(", ", $value));
         }
         if (trim($value) === "" or trim($value) == "0000-00-00") {
             continue;
         }
         $prevOptionsExist = true;
         switch ($type) {
             case "text":
             case "date":
                 $previousOptions[$value] = $value;
                 break;
             case "radio":
                 $prevElementPosition = array_search($value, $prevElementOptions);
                 // need to figure out which option matches the text of the value
                 if ($prevElementPosition !== false) {
                     $previousOptions[$prevElementPosition] = $value;
                     // for radio buttons, we need to pass the position of the option
                 }
                 break;
             case "yn":
                 if ($value == _formulize_TEMP_QYES) {
                     $previousOptions[0] = $value;
                 } elseif ($value == _formulize_TEMP_QNO) {
                     $previousOptions[1] = $value;
                 }
                 break;
         }
     }
     if (!$prevOptionsExist) {
         return "";
     }
     $prevUI = new xoopsFormSelect('', 'prev_' . $element_id, '123qweasdzxc', 1, false);
     // 123qweasdzxc is meant to be a unique value that will never be selected, since we don't ever want a previous selection showing by default
     $prevUI->addOption('', _AM_FORMULIZE_PREVIOUS_OPTION);
     $prevUI->addOptionArray($previousOptions);
     $prevUI->setExtra($javascript);
     return $prevUI;
 }
Esempio n. 2
0
     case "min":
         $calc_name = _formulize_DE_CALC_MIN;
         break;
     case "max":
         $calc_name = _formulize_DE_CALC_MAX;
         break;
     case "count":
         $calc_name = _formulize_DE_CALC_COUNT;
         break;
     case "per":
         $calc_name = _formulize_DE_CALC_PER;
         break;
 }
 $tray = new xoopsFormElementTray("&nbsp;&nbsp&nbsp;" . $calc_name, "<br>");
 $tempcalc1 = new xoopsFormSelect("", $tempname, $current_val);
 $tempcalc1->addOption("noblanks", _formulize_DE_CALCNOBLANKS);
 $tempcalc1->addOption("all", _formulize_DE_CALCALL);
 $tempcalc1->addOption("onlyblanks", _formulize_DE_CALCONLYBLANKS);
 $tempcalc1->addOption("justnoblanks", _formulize_DE_CALCJUSTNOBLANKS);
 $tempcalc1->addOption("justnozeros", _formulize_DE_CALCJUSTNOZEROS);
 $tempcalc1->addOption("custom", _formulize_DE_CALCCUSTOM);
 $tempcalc1->setExtra("onchange='javascript:setCalcCustom(\"" . $calc . $hidden['column'] . "\");'");
 $tempcalcCustom = new xoopsFormText("", $tempname . "_custom", 12, 255, $current_val_custom);
 $tempcalcCustom->setExtra("onclick='javascript:window.document.pickcalc.elements[\"" . $calc . $hidden['column'] . "\"].options[5].selected = true;window.document.pickcalc.elements[\"" . $calc . $hidden['column'] . "\"].value=\"custom\"'");
 $tempcalclabel = new xoopsFormLabel("", _formulize_DE_CALC_BTEXT . " " . $tempcalc1->render() . " " . $tempcalcCustom->render());
 $groupingDefaults = explode("!@^%*", $_POST['grouping_' . $calc . "_" . $hidden['column']]);
 // get the individual grouping settings from the one value that has been passed back
 $groupingDefaults1 = $groupingDefaults[0];
 if (isset($_POST['grouping2_' . $calc . "_" . $hidden['column']])) {
     $groupingDefaults2 = $_POST['grouping2_' . $calc . "_" . $hidden['column']];
 } elseif (isset($groupingDefaults[1])) {
Esempio n. 3
0
print "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"{$themecss}\" />\n";
print "</head>";
print "<body style=\"background: white; margin-top:20px;\"><center>";
print "<table style=\"width: 100%;\"><tr><td style=\"width: 5%;\"></td><td style=\"width: 90%;\">";
$advsearch = new xoopsThemeForm(_formulize_DE_BUILDQUERY, 'buildq', XOOPS_URL . "/modules/formulize/include/advsearch.php?fid={$fid}&frid={$frid}");
//$returned = addReqdCalcs($pickcalc);
//$pickcalc = $returned['form'];
$columns_andor = new xoopsFormElementTray('', "<br />");
$columns_and = new xoopsFormRadio('', 'multi_andor', '1');
$columns_and->addOption(1, _formulize_DE_AS_MULTI_AND);
$columns_andor->addElement($columns_and);
$columns_or = new xoopsFormRadio('', 'multi_andor', '1');
$columns_or->addOption(2, _formulize_DE_AS_MULTI_OR);
$columns_andor->addElement($columns_or);
$columns = new xoopsFormSelect(_formulize_DE_AS_FIELD . "<br /><br />" . $columns_andor->render(), 'column', '', 5, true);
$columns->addOption("creation_uid", _formulize_DE_CALC_CREATOR);
$columns->addOption("mod_uid", _formulize_DE_CALC_MODIFIER);
$columns->addOption("creation_datetime", _formulize_DE_CALC_CREATEDATE . ' (YYYY-mm-dd)');
$columns->addOption("mod_datetime", _formulize_DE_CALC_MODDATE . ' (YYYY-mm-dd)');
$columns->addOption("creator_email", _formulize_DE_CALC_CREATOR_EMAIL);
$columns->addOptionArray($options);
$opterm = new xoopsFormElementTray(_formulize_DE_AS_OPTERM, "&nbsp;&nbsp;");
$op = new xoopsFormSelect('', 'op');
$ops['=='] = "=";
$ops['!='] = "NOT";
$ops['>'] = ">";
$ops['<'] = "<";
$ops['>='] = ">=";
$ops['<='] = "<=";
$ops['LIKE'] = "LIKE";
$ops['NOT LIKE'] = "NOT LIKE";