function preprocess() { global $FANNIE_PLUGIN_LIST, $FANNIE_PLUGIN_SETTINGS; if (!isset($FANNIE_PLUGIN_LIST) || !in_array('CoopCred', $FANNIE_PLUGIN_LIST)) { $this->errors .= _("Error: The Coop Cred Plugin is not enabled."); return True; } if (!array_key_exists('CoopCredDatabase', $FANNIE_PLUGIN_SETTINGS) || $FANNIE_PLUGIN_SETTINGS['CoopCredDatabase'] == "") { $this->errors .= _("Error: Coop Cred Database not named in Plugin Settings."); return True; } /* Get values from the Whole-Project (Plugin) config table. */ $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['CoopCredDatabase']); $config = new CCredConfigModel($dbc); $config->configID(1); if (!$config->load()) { $this->errors .= _("Error: Coop Cred configuration not available."); return True; } $this->dummyTenderCode = $config->dummyTenderCode(); $this->dummyDepartment = $config->dummyDepartment(); $this->deptMin = $config->deptMin(); $this->deptMax = $config->deptMax(); $this->dummyBanker = $config->dummyBanker(); $this->bankerMin = $config->bankerMin(); $this->bankerMax = $config->bankerMax(); /* For CCredPrograms.modifiedBy */ $this->authUserNumber = 0; $authName = FannieAuth::checkLogin(); if (!($authName == 'null' || $authName == 'init' || $authName == False)) { $this->authUserNumber = FannieAuth::getUID($authName); } /* Support ajax calls to this program. * If there is a form submission with an action go do it. * The form submission may be via AJAX instead of <form ...> * with action= in the query string with other parameters. */ if (FormLib::get_form_value('action') !== '') { $this->ajax_response(FormLib::get_form_value('action')); /* How to handle errors/problems esp. in save? * Possibly code readinessCheck() */ return False; } /* If the call was not by form, e.g. from the initial menu * or the <form action=> is '' (when does that happen?) * FanniePage::draw_page() continues to $this->body_content() * which returns the the program-select form. */ return True; // preprocess() }
private function ajax_display_program($id) { global $FANNIE_PLUGIN_SETTINGS, $FANNIE_URL, $FANNIE_OP_DB; $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['CoopCredDatabase']); /* A set of vars for all fields this editor handles. */ $cConfigID = 0; $cDummyTenderCode = ''; $cDummyDepartment = 0; $cDeptMin = 0; $cDeptMax = 0; // $cDummyBanker = 0; $cBankerMin = 0; $cBankerMax = 0; // $cRegularMemberMin = 0; $cRegularMemberMax = 0; // $cModified = ''; $cModifiedBy = 0; /* Prepare to display existing record. * -1 means create new record */ if ($id != -1) { $config = new CCredConfigModel($dbc); $config->configID($id); $loadOK = $config->load(); // Assuming the lookup/load didn't fail, load values to local vars. // First row $cDummyTenderCode = $config->dummyTenderCode(); $cDummyDepartment = $config->dummyDepartment(); $cDeptMin = $config->deptMin(); $cDeptMax = $config->deptMax(); // $cDummyBanker = $config->dummyBanker(); $cBankerMin = $config->bankerMin(); $cBankerMax = $config->bankerMax(); // $cRegularMemberMin = $config->regularMemberMin(); $cRegularMemberMax = $config->regularMemberMax(); // $cModified = $config->modified(); $cModifiedDatestamp = $cModified; $cModifiedBy = $config->modifiedBy(); } /* $hb (helpbit) is an array keyed on the id= of the input being described. * Each element is an array with 2 elements: * ['a'] which contains the <a onclick=target-id><img></a> * ['t'] containing the <fieldset id=target-id>long help</fieldset> */ $hbPrefix = '_CCCE'; $hbNumber = 1000; $hb = array(); $hbShortMessage = array(); $hbLongMessage = array(); $hbIcon = "{$FANNIE_URL}src/img/buttons/help16.png"; $hbMore = " " . _("(Click for more)"); $hbNoMore = ""; $hbLongWidth = 50; // em /* Steps for each HelpBit * Copy this template and fill it in. $hbKey = 'foo'; $hbKeys[] = $hbKey; $hbShortMessage["$hbKey"] = "One " . "Two." . "" . ""; $hbLongMessage["$hbKey"] = "{$hbShortMessage[$hbKey]}" . "<br />One " . "two " . "<br /> " . "" . ""; */ /* First row helps */ $hbKey = 'dummyTenderCode'; $hbKeys[] = $hbKey; $hbShortMessage["{$hbKey}"] = "A placeholder Tender Code until the real Tender Code is assigned."; $hbLongMessage["{$hbKey}"] = "{$hbShortMessage[$hbKey]}" . "<br />You might want to pre-populate a range of tenders " . "to make it easier to set up new Programs." . "" . ""; $hbKey = 'dummyDepartment'; $hbKeys[] = $hbKey; $hbShortMessage["{$hbKey}"] = "A placeholder Payment Department Code until the real Department Code is assigned."; $hbLongMessage["{$hbKey}"] = "{$hbShortMessage[$hbKey]}" . "" . ""; $hbKey = 'deptMin'; $hbKeys[] = $hbKey; $hbShortMessage["{$hbKey}"] = "The low end of the range of payment department numbers reserved for Coop Cred."; $hbLongMessage["{$hbKey}"] = "{$hbShortMessage[$hbKey]}" . "<br />You might want to pre-populate at least part of this range " . "to make it easier to set up new Programs." . "" . ""; $hbKey = 'deptMax'; $hbKeys[] = $hbKey; $hbShortMessage["{$hbKey}"] = "The high end of the range of payment department numbers reserved for Coop Cred."; $hbLongMessage["{$hbKey}"] = "{$hbShortMessage[$hbKey]}" . "" . ""; /* Second row helps */ $hbKey = 'dummyBanker'; $hbKeys[] = $hbKey; $hbShortMessage["{$hbKey}"] = "A placeholder Banker Member ID until the real Banker ID is assigned."; $hbLongMessage["{$hbKey}"] = "{$hbShortMessage[$hbKey]}" . "" . ""; $hbKey = 'bankerMin'; $hbKeys[] = $hbKey; $hbShortMessage["{$hbKey}"] = "The low end of the range of member numbers reserved for Coop Cred Bankers."; $hbLongMessage["{$hbKey}"] = "{$hbShortMessage[$hbKey]}" . "<br />You might want to pre-populate at least part of this range " . "to make it easier to set up new Programs." . ""; $hbKey = 'bankerMax'; $hbKeys[] = $hbKey; $hbShortMessage["{$hbKey}"] = "The high end of the range of member numbers reserved for Coop Cred Bankers."; $hbLongMessage["{$hbKey}"] = "{$hbShortMessage[$hbKey]}" . "" . ""; $hbKey = 'regularMemberMin'; $hbKeys[] = $hbKey; $hbShortMessage["{$hbKey}"] = "The low end of the range of member numbers for Regular Coop Cred members."; $hbLongMessage["{$hbKey}"] = "{$hbShortMessage[$hbKey]}" . "" . ""; $hbKey = 'regularMemberMax'; $hbKeys[] = $hbKey; $hbShortMessage["{$hbKey}"] = "The high end of the range of member numbers for Regular Coop Cred members."; $hbLongMessage["{$hbKey}"] = "{$hbShortMessage[$hbKey]}" . "" . ""; /* After all the help messages are defined, compose the code that uses them. * Insert the ['a'] like: <th>Active{$hb['isactive']['a']}</th> * The ['t']s are automatically placed in a certain area of the page. */ foreach ($hbKeys as $hbKey) { $hbTarget = "{$hbPrefix}" . ++$hbNumber; if (isset($hbLongMessage["{$hbKey}"]) && $hbLongMessage["{$hbKey}"] != "") { $anyMore = $hbMore; $onClick = " onclick=\"\$('#{$hbTarget}').toggle();return false;\" "; $helpCloser = "<br /><a href='' {$onClick} style='font-weight:bold;'>Close</a>"; } else { $anyMore = $hbNoMore; $onClick = ""; } $hb["{$hbKey}"]['a'] = " <a " . $onClick . "href=''>" . "<img title='{$hbShortMessage["{$hbKey}"]}{$anyMore}' src='{$hbIcon}'>" . "</a>"; $hb["{$hbKey}"]['t'] = "<fieldset id='{$hbTarget}' name='{$hbTarget}' " . "class='helpbit' " . "style='width:{$hbLongWidth}em;'" . ">" . $hbLongMessage["{$hbKey}"] . $helpCloser . "</fieldset>"; } /* This and similar horrors are to overcome bootstrap * until I have time to figure out how to code this * in a bootstrap-compliant way. */ $tableStyle = " style='border-spacing:5px; border-collapse: separate;'"; $ret = "<table id='edtable'{$tableStyle}>"; // First row of headings. $ret .= "<tr class='vTop'>"; $ret .= "<th>Config ID</th>"; $ret .= "<th>Dummy Tender{$hb['dummyTenderCode']['a']}</th>"; $ret .= "<th>Dummy Department{$hb['dummyDepartment']['a']}</th>"; $ret .= "<th>First Department{$hb['deptMin']['a']}</th>"; $ret .= "<th>Last Department{$hb['deptMax']['a']}</th>"; $ret .= "</tr>"; // First row of inputs. $ret .= "<tr class='vTop'>"; $ret .= "<td class='iCenter'{$edtd}>"; /* Not editable. * Don't think there will ever be more than one. * Maybe no point in displaying. */ if ($id == -1) { $ret .= _("Will be assigned upon Save"); $ret .= "<input type=hidden id=configno name=configno value='' />"; // id must be the same as in the hidden. //$ret .= "<input type=text size=4 id=progno />"; } else { $ret .= $id; } $ret .= "</td>"; // dummyTenderCode $ret .= "<td colspan=1><input type=text size=2 maxlength=2 id=dummytender " . "value=\"{$cDummyTenderCode}\" /></td>"; /* dummyDepartment * If it exists, should that be noted, name displayed? */ $ret .= "<td colspan=1><input type=text size=4 maxlength=5 id=dummydept " . "value=\"{$cDummyDepartment}\" /></td>"; /* deptMin * If it exists, should that be noted, name displayed? */ $ret .= "<td colspan=1><input type=text size=4 maxlength=5 id=deptmin " . "value=\"{$cDeptMin}\" /></td>"; /* deptMax * If it exists, should that be noted, name displayed? */ $ret .= "<td colspan=1><input type=text size=4 maxlength=5 id=deptmax " . "value=\"{$cDeptMax}\" /></td>"; $ret .= "</tr>"; /* Second row of headings. */ $ret .= "<tr class='vBottom'>"; $ret .= "<th>Dummy Banker{$hb['dummyBanker']['a']}</th>"; $ret .= "<th>First Banker{$hb['bankerMin']['a']}</th>"; $ret .= "<th>Last Banker{$hb['bankerMax']['a']}</th>"; $ret .= "<th>First Member{$hb['regularMemberMin']['a']}</th>"; $ret .= "<th>Last Member{$hb['regularMemberMax']['a']}</th>"; $ret .= "</tr>"; /* Second row of inputs. */ $ret .= "<tr class='vTop'>"; /* dummyBanker * If it exists, should that be noted, name displayed? */ $ret .= "<td colspan=1><input type=text size=5 maxlength=5 id=dummybanker " . "value=\"{$cDummyBanker}\" /></td>"; /* bankerMin * If it exists, should that be noted, name displayed? */ $ret .= "<td colspan=1><input type=text size=5 maxlength=5 id=bankermin " . "value=\"{$cBankerMin}\" /></td>"; /* bankerMax * If it exists, should that be noted, name displayed? */ $ret .= "<td colspan=1><input type=text size=5 maxlength=5 id=bankermax " . "value=\"{$cBankerMax}\" /></td>"; "value=\"{$cDummyBanker}\" /></td>"; /* regularMemberMin * If it exists, should that be noted, name displayed? */ $ret .= "<td colspan=1><input type=text size=5 maxlength=5 id=membermin " . "value=\"{$cRegularMemberMin}\" /></td>"; /* regularMemberMax * If it exists, should that be noted, name displayed? */ $ret .= "<td colspan=1><input type=text size=5 maxlength=5 id=membermax " . "value=\"{$cRegularMemberMax}\" /></td>"; $ret .= "</tr>"; $ret .= "</table>"; /* Place for long help messages. * Each in its own fieldset or possibly other container. * Revealed when 2nd-level help is clicked; hidden when clicked again. */ foreach ($hbKeys as $hbKey) { if (isset($hbLongMessage["{$hbKey}"]) && $hbLongMessage["{$hbKey}"] != "") { $ret .= $hb["{$hbKey}"]['t']; } } // Remember that these are also in JS. if ($id == -1) { $ret .= "<input type=hidden id=isnew value=1 />"; } else { $ret .= "<input type=hidden id=isnew value=0 />"; // id must be the same as in the form, the <select> of programs. $ret .= "<input type=hidden id=configno value=\"{$id}\" />"; } /* The onclick= is what happens instead of <form action=> in * regular form submissions. */ $ret .= "<p /><input type=submit value=Save onclick=\"programSave(); return false;\" />"; echo $ret; // ajax_display_program() }
function preprocess() { global $FANNIE_ROOT, $FANNIE_URL, $FANNIE_PLUGIN_LIST, $FANNIE_PLUGIN_SETTINGS; if (!isset($FANNIE_PLUGIN_LIST) || !in_array('CoopCred', $FANNIE_PLUGIN_LIST)) { $this->errors[] = "The Coop Cred plugin is not enabled."; return True; } if (array_key_exists('CoopCredDatabase', $FANNIE_PLUGIN_SETTINGS) && $FANNIE_PLUGIN_SETTINGS['CoopCredDatabase'] != "") { $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['CoopCredDatabase']); } else { $this->errors[] = "The Coop Cred database is not assigned in the " . "Coop Cred plugin configuration."; return True; } $config = new CCredConfigModel($dbc); $config->configID(1); $loadOK = $config->load(); if (!$loadOK) { $msg = "Problem: Please 'Configure Coop Cred' from the Coop Cred Admin menu."; $this->errors[] = $msg; return True; } else { $this->bankerMin = $config->bankerMin(); $this->bankerMax = $config->bankerMax(); } /** Whether invoked by form submission. */ if (isset($_REQUEST['programID'])) { // Better to do this in JS in the form. if ($_REQUEST['programID'] == "") { $this->errors[] = "Please choose a Program"; $this->add_script("{$FANNIE_URL}src/CalendarControl.js"); return True; } $programID = (int) $_REQUEST['programID']; $ccpModel = new CCredProgramsModel($dbc); $ccpModel->programID($programID); $prog = array_pop($ccpModel->find()); if ($prog != null) { $this->programID = $prog->programID(); $this->programName = $prog->programName(); $this->programBankID = $prog->bankID(); //obs. $this->bankID = $prog->bankID(); $this->paymentDepartment = $prog->paymentDepartment(); $this->programStartDate = preg_match("/^[12]\\d{3}-\\d{2}-\\d{2}/", $prog->startDate()) ? $prog->startDate() : '1970-01-01'; } else { $this->errors[] = "Error: Program ID {$programID} is not known."; return True; } if (!FormLib::get_form_value('sortable', False)) { $this->sortable = False; $this->report_headers = array('When', 'Member#', 'Member Name', 'Event', '$ Amount', 'Comment'); } else { $this->report_headers = array('Date', 'When', 'Member#', 'Member Name', 'Event', '$ Amount', 'Comment'); } $this->content_function = "report_content"; if (isset($_REQUEST['excel']) && $_REQUEST['excel'] == 'xls') { $this->report_format = 'xls'; $this->has_menus(False); } elseif (isset($_REQUEST['excel']) && $_REQUEST['excel'] == 'csv') { $this->report_format = 'csv'; $this->has_menus(False); } } else { if (FormLib::get_form_value('pid', 0) != 0) { $this->pid = FormLib::get_form_value('pid', 0); } $this->add_script("{$FANNIE_URL}src/CalendarControl.js"); } return True; // preprocess() }
function ShowEditForm($memNum, $country = "US", $inProgramID = -1) { global $FANNIE_URL; global $FANNIE_PLUGIN_LIST, $FANNIE_PLUGIN_SETTINGS; if (!isset($FANNIE_PLUGIN_LIST) || !in_array('CoopCred', $FANNIE_PLUGIN_LIST)) { $msg = "Problem: The '" . $this->pluginName . "' plugin is not enabled."; return $this->FormatReturnMessage($msg); } if (array_key_exists('CoopCredDatabase', $FANNIE_PLUGIN_SETTINGS) && $FANNIE_PLUGIN_SETTINGS['CoopCredDatabase'] != "") { $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['CoopCredDatabase']); } else { $msg = "Problem: Connection to the database for the '" . $this->pluginName . "' plugin failed."; return $this->FormatReturnMessage($msg); } $config = new CCredConfigModel($dbc); $config->configID(1); $loadOK = $config->load(); if (!$loadOK) { $msg = "Problem: Please 'Configure Coop Cred' from the Coop Cred Admin menu."; return $this->FormatReturnMessage($msg); } else { $this->regularMemberMin = $config->regularMemberMin(); $this->regularMemberMax = $config->regularMemberMax(); } /* Needs to get: * -all programs or * -all active programs * regardless whether member is in them * distinguish the ones he/does belong to by CAPS or colour or something * set SELECTED for the first one he/she belongs to, else Choose * and show the current balance for that * and set the default params for: * -transfer * -fix * -Activity Report * to that. */ $programID = 0; $programBankNumber = 0; /* Get all programs first, then see if the member is in them. */ $progQ = "SELECT programID, programName, bankID\n FROM CCredPrograms\n WHERE active =1\n ORDER BY programName ASC"; $progS = $dbc->prepare_statement($progQ); $progR = $dbc->exec_statement($progS, array()); $ccred_programs = array(); $pID = ''; // format: P01 $firstMpID = ''; // a $pID $programCount = 0; while ($progW = $dbc->fetch_row($progR)) { $programCount++; $pID = sprintf("P%02d", $progW['programID']); if ($programCount == 1) { $firstMpID = $pID; } $ccred_programs["{$pID}"] = array('programID' => $progW['programID'], 'programName' => $progW['programName'], 'bankID' => $progW['bankID'], 'creditOK' => 0, 'membershipID' => 0, 'balance' => NULL, 'maxCreditBalance' => 0, 'isDefault' => 0); } /* Then get balance for the ones the member belongs to. * Decide which one will be displayed, the default, * in order of preference. * 1. The first one the member belongs to where creditOK is True, * i.e. that he/she can purchase with. * 2. The first one he/she belongs to. * 3. The first one that exists. * 4. Override with parameter $inProgramID. * */ $infoQ = "SELECT m.programID, m.cardNo, m.creditOK, m.membershipID,\n m.maxCreditBalance,\n b.balance\n FROM CCredMemberships AS m\n JOIN CCredLiveBalance AS b ON m.cardNo = b.cardNo\n AND m.programID = b.programID\n JOIN CCredPrograms AS p ON m.programID = p.programID\n WHERE m.cardNo =?\n AND p.active =1"; $infoS = $dbc->prepare_statement($infoQ); $infoR = $dbc->exec_statement($infoS, array($memNum)); $membershipCount = 0; $firstCreditOK = $inProgramID > -1 ? 1 : 0; // This may not be getting a real value if Member does not belong to any yet. if ($firstMpID == '') { // Means there are no Programs $pID = sprintf("P%02d", 0); $ccred_programs["{$pID}"] = array('programID' => 0, 'programName' => "No Programs Exist", 'bankID' => 0, 'creditOK' => 0, 'membershipID' => 0, 'balance' => NULL, 'maxCreditBalance' => 0, 'isDefault' => 1); } else { $pID = $firstMpID; // format: P01 } $defaultMembership = $inProgramID > -1 ? sprintf("P%02d", $inProgramID) : $pID; $firstPID = ''; // a $pID while ($infoW = $dbc->fetch_row($infoR)) { $membershipCount++; $pID = sprintf("P%02d", $infoW['programID']); if ($membershipCount == 1) { $firstPID = $pID; } /* ?Details for programs other than the default were gathered * for when I was going to compose JS to do the program change. */ $ccred_programs["{$pID}"]['balance'] = $infoW['balance']; $ccred_programs["{$pID}"]['creditOK'] = $infoW['creditOK']; $ccred_programs["{$pID}"]['maxCreditBalance'] = $infoW['maxCreditBalance']; $ccred_programs["{$pID}"]['membershipID'] = $infoW['membershipID']; if ($inProgramID > -1) { if ($infoW['programID'] == $inProgramID) { $ccred_programs["{$pID}"]['isDefault'] = 1; $defaultMembership = $pID; $programID = $ccred_programs["{$pID}"]['programID']; $programName = $ccred_programs["{$pID}"]['programName']; $programBankNumber = $ccred_programs["{$pID}"]['bankID']; $firstCreditOK = 1; continue; } } else { if ($ccred_programs["{$pID}"]['creditOK'] && $firstCreditOK == 0) { $ccred_programs["{$pID}"]['isDefault'] = 1; $defaultMembership = $pID; $programID = $ccred_programs["{$pID}"]['programID']; $programName = $ccred_programs["{$pID}"]['programName']; $programBankNumber = $ccred_programs["{$pID}"]['bankID']; $firstCreditOK = 1; } } } /* If Member belongs to at least one but none is inputOK yet * default to the first one belonged to. */ if ($membershipCount > 0 && $firstCreditOK == 0) { $ccred_programs["{$firstPID}"]['isDefault'] = 1; $defaultMembership = $firstPID; $programID = $ccred_programs["{$firstPID}"]['programID']; $programName = $ccred_programs["{$firstPID}"]['programName']; $programBankNumber = $ccred_programs["{$firstPID}"]['bankID']; } /* If Member belongs to none $defaultMembership is still "". * The formlet can refer to Programs that Member doesn't belong to * but not to values that come from CCredMemberships. * The membership values are dummy. */ $programMemberType = $memNum == $programBankNumber ? "{$programName}" : "Member"; $ret = ""; /* Later, AJAX-driven, calls ($inProgramID > -1) re-populate this <div> * but must not write it again. * CSS is temporary until boostrap coding is done. */ if ($inProgramID == -1) { $ret .= "<style type='text/css'>\n.MemFormTable th {\n font-size: 75%;\n text-align: right;\n color: #fff;\n padding: 0 5px 0 2px;\n border: solid white 2px;\n}\n.MemFormTable td {\n padding: 2px 2px 2px 2px;\n}\n/* The interveneing ccredmemdiv prevents bootstrap's\n * gradient from appearing.\n */\n.ccredpanelhead {\n background-color: #f5f5f5;\n border-bottom: 1px solid #ddd;\n}\n</style>"; $ret .= "<div class='panel panel-default'>"; $ret .= "<div id='ccredmemdiv'>"; } $ret .= "<div class=\"panel-heading ccredpanelhead\">Coop Cred - {$programMemberType}"; //</div>"; $ret .= " <a onclick=\"\$('#_fhtt14102004').toggle();return false;\" href=''>" . "<img title='Let the Member make purchases against money in an account " . "(Click for more)' src='{$FANNIE_URL}src/img/buttons/help16.png'>" . "</a>"; $ret .= "</div><!-- /.panel-heading -->"; $ret .= "<div class=\"panel-body\">"; /* For bootstrapped v.1 retain the table coding. */ $ret .= "<table class='MemFormTable' border='0' width='100%'>"; if ($memNum != $programBankNumber) { $ret .= "<tr>"; $ret .= "<td colspan=3>"; if ($memNum >= $this->regularMemberMin && $memNum <= $this->regularMemberMax) { $ret .= "<select id='ccred_program' name='ccred_program' " . "onchange='memProgramChange();' >"; $ret .= "<option value='0'>Choose Program</option>"; foreach ($ccred_programs as $pID => $prog) { $p_sel = ($membershipCount > 0 || $inProgramID > -1) && $pID == $defaultMembership ? ' selected="1" ' : ''; $o_style = $prog['creditOK'] == 1 ? "style='font-weight:bold;'" : ""; $ret .= "<option value='{$prog['programID']}'{$p_sel}{$o_style}>" . "{$prog['programName']}</option>"; } $ret .= "</select>"; } else { $ret .= " "; } $ret .= "</td>"; $ret .= "<th title='The amount of Coop Cred the member has to use.'>Current Balance</th>"; $ret .= "<th title='The maximum Coop Cred the member may accumulate.'>Max Balance</th>"; $ret .= "</tr>"; } $ret .= "<tr>"; $ucc = $ccred_programs["{$defaultMembership}"]['creditOK'] ? ' checked="" ' : ''; $uccDisabled = $memNum == $programBankNumber ? ' disabled ' : ""; $ret .= "<th title='Allow/prevent the member's use of the selected type of Coop Cred.'>Use Coop Cred</th>"; $ret .= sprintf('<td><input type="checkbox" name="use_coop_cred" %s %s/> </td>', $ucc, $uccDisabled); // In Coop Cred $limit is always 0. $limit = 0; $ret .= "<input type='hidden' name='CC_limit' value='{$limit}'>"; if ($memNum == $programBankNumber) { $ret .= "<th title='The amount of Coop Cred the member has to use.'>Current Balance</th>"; } else { $ret .= "<td> </td>"; } $ret .= sprintf('<td id="cbal" name="cbal">%.2f</td>', $ccred_programs["{$defaultMembership}"]['balance'] * -1); if ($memNum == $programBankNumber) { $today = date('Y-m-d'); $cellContent = "<p style='margin:0em; font-family:Arial;line-height:1.0em;'>\n <a href=\"{$FANNIE_URL}{$this->pluginHome}reports/ProgramEvents/" . "ProgramEventsReport.php?date1=&date2=&card_no={$memNum}" . "&sortable=on" . "&programID={$programID}\"\n title='List inputs to and payments from the program before today'\n target='_coop_cred_events'\n >Event History</a>\n <br />\n <a href=\"{$FANNIE_URL}{$this->pluginHome}reports/ProgramEvents/" . "ProgramEventsReport.php?date1={$today}&date2={$today}" . "&sortable=on" . "&other_dates=on&submit=Submit&card_no={$memNum}" . "&programID={$programID}\"\n title='List inputs to and payments from the program today'\n target='_coop_cred_events'\n >Events Today</a>\n </p>\n "; } else { $template = '<input type="text" size=8 maxlength=10 id="maxbal" ' . 'name="maxbal" value="%.2f" >'; $cellContent = sprintf("{$template}", $ccred_programs["{$defaultMembership}"]['maxCreditBalance'] * -1); } $ret .= "<td>" . $cellContent; $ret .= "</td>"; $ret .= "</tr>"; $ret .= "<tr>"; if ($memNum == $programBankNumber) { $transferTitle = 'Move funds to a member account or return them to ' . 'the Program Account.'; } else { $transferTitle = 'Get funds for the member from, or return the ' . 'member's funds to, the Program Account or another member.'; } if ($programID == 0) { $transferTitle .= "\nAdd the member to a Program and Save before " . "doing a Transfer."; } $args1 = "memIN={$memNum}&memEDIT={$memNum}&" . "programID={$programID}"; $ret .= "<td colspan=\"2\"><a id='tlink' name='tlink'\n href=\"{$FANNIE_URL}{$this->pluginHome}membership/CoopCredTransferTool.php?{$args1}\"\n title='{$transferTitle}'\n >Transfer Coop Cred</a></td>"; $args2 = "memIN={$memNum}&memEDIT={$memNum}&" . "programID={$programID}"; $ret .= "<td><a id='flink' name='flink'\n href=\"{$FANNIE_URL}{$this->pluginHome}membership/CoopCredJiggerTool.php?{$args2}\"\n title='Fix errors and problems'\n >Fix Coop Cred</a></td>"; /* In this program only the Program Account may accept inputs. * -> Needs to come from Program */ $ret .= "<td colspan='2' style='text-align:center;'>"; if ($memNum == $programBankNumber) { $args3 = $args2; $ret .= "<a id='ilink' name='ilink'\n href=\"{$FANNIE_URL}{$this->pluginHome}membership/CoopCredInputTool.php?{$args3}\"\n title='Input (deposit) external funds to the Program Account'\n >Input Coop Cred</a>"; } elseif ($memNum >= $this->regularMemberMin && $memNum <= $this->regularMemberMax) { $reportLink = "<a id='arlink' name='arlink' " . "href=\"{$FANNIE_URL}{$this->pluginHome}reports/" . "Activity/ActivityReport.php?" . "memNum={$memNum}&programID={$programID}\"" . " title='List earnings and purchases for this member'" . " target='_blank'" . "><p style='margin:0em; font-family:Arial;line-height:1.0em;'>" . "Activity Report</p></a>"; $ret .= $reportLink; } else { $ret .= " "; } $ret .= "</td>"; $ret .= "</tr>"; $ret .= "</table>"; //$ret .= "</fieldset>"; $ret .= "</div><!-- /.panel-body -->"; if ($inProgramID == -1) { /* The fieldset goes in the ccremdiv container. */ $ret .= "</div> <!-- /ccredmemdiv -->"; $ret .= '<fieldset id="_fhtt14102004" style="display:none; width:440px;">' . "Let the Member make purchases against money in an account. " . "<br />A Member may have an account in (be a member of) more than one Program." . "<br />'Balance' shows how much is left in the account." . "<br />Un-ticking 'OK' will suspend the account when member data is refreshed on lanes. " . "<br />Use the 'Transfer' link to add money to the account from the Program Bank." . "<br />The Member is allowed to use all accounts in the Program dropdown " . "that are in <b>bold</b>." . "<br />To add a Member to a Program (allow him/her to use it) " . "select the Program, tick 'Use Coop Cred' and click 'Save'" . "<!-- br />The Transfer, Fix and Activity links are for the Program that " . "is selected when the form initially displays. " . "To use Transfer etc. for another Program, temporarily untick 'Use Coop Cred', " . "click Save, and Edit the same Member again." . "This will expose the next Program the Member belongs to." . "<br />After making and Saving the changes, select the initial Program again, " . "tick 'Use Coop Cred' and click Save." . " -->" . "</fieldset>"; $ret .= sprintf("<input type='hidden' id='memNum' name='memNum' value='%d' />", $memNum); $ret .= sprintf("<input type='hidden' id='pathTo' name='pathTo' value='%s' />", $FANNIE_URL . $this->pluginHome . 'membership/'); $ret .= "</div><!-- /.panel .panel-default -->"; $ret .= $this->getEditJavascript(); } return $ret; // ShowEditForm() }