function showEditForm($memNum, $country = "US") { $dbc = $this->db(); $account = self::getAccount(); /** Check parameters setting to decide whether the discount value from custdata should be displayed vs the discount value from memtype */ $modeR = $dbc->query("\n SELECT p.param_value\n FROM parameters AS p\n WHERE param_key='useMemTypeTable'\n AND store_id=0\n AND lane_id=0"); $discount_mode = 'custdata.discount'; if ($modeR && ($modeW = $dbc->fetch_row($modeR))) { if ($modeW['param_value'] == 1) { $discount_mode = 'memtype.discount'; } } $ret = "<div class=\"panel panel-default\">\n <div class=\"panel-heading\">Membership Type</div>\n <div class=\"panel-body\">"; $ret .= '<div class="form-group form-inline">'; $ret .= '<span class="label primaryBackground">Type</span> '; $ret .= '<select name="MemType_type" class="form-control">'; $disc = 0; $mDesc = ''; $types = new MemtypeModel($dbc); foreach ($types->find('memtype') as $type) { $ret .= sprintf("<option value=%d %s>%s</option>", $type->memtype(), $account['customerTypeID'] == $type->memtype() ? 'selected' : '', $type->memDesc()); if ($account['customerTypeID'] == $type->memtype()) { $mDesc = $type->memDesc(); $disc = $type->discount(); if ($discount_mode = 'custdata.discount') { foreach ($account['customers'] as $c) { if ($c['accountHolder']) { $disc = $c['discount']; break; } } } } } $ret .= "</select> "; $ret .= '<input type="hidden" name="MemType_inactive" value="' . $account['activeStatus'] . '" />'; if ($discount_mode == 'memtype.discount') { $discountTip = " title=\"The discount for the Member's current Type: " . "{$mDesc}\""; } else { $discountTip = " title=\"The Member's current Discount, " . "regardless of assigned Type, which is: " . "{$mDesc}\""; } $ret .= '<span class="label primaryBackground"' . $discountTip . '>Discount</span> '; $ret .= sprintf('%d%%', $disc); $ret .= '</div>'; $ret .= '</div>'; $ret .= '</div>'; return $ret; }
public function form_content() { $ret = '<form method="get">'; $ret .= '<div class="row">'; $ret .= FormLib::standardItemFields(); $ret .= FormLib::standardDateFields(); $ret .= '</div>'; $ret .= '<div class="row">'; $ret .= '<div class="form-group col-sm-5 form-inline">'; $ret .= '<label>Customer Type</label> '; $ret .= '<select name="memtype" class="form-control">'; $dbc = $this->connection; $dbc->selectDB($this->config->get('OP_DB')); $types = new MemtypeModel($dbc); foreach ($types->find() as $t) { $ret .= sprintf('<option value="%d">%s</option>', $t->memtype(), $t->memDesc()); } $ret .= '</select>'; $ret .= ' <button type="submit" class="btn btn-default">Submit</button>'; $ret .= '</div>'; $ret .= '</div>'; return $ret; }
/** Get account using newer tables */ private static function getAccount($dbc, $id) { if ($id == 0) { return self::getAllAccounts($dbc); } $account = new \CustomerAccountsModel($dbc); $customers = new \CustomersModel($dbc); $account->cardNo($id); if (!$account->load()) { // migrate already at this point? return false; } $customers->customerAccountID($account->customerAccountID()); $ret = $account->toJSON(); $ret['customers'] = array(); foreach ($customers->find('accountHolder', true) as $c) { $ret['customers'][] = $c->toJSON(); } $type = new \MemtypeModel($dbc); $type->memtype($account->customerTypeID()); $type->load(); $ret['customerType'] = $type->memDesc(); return $ret; }
function addTempMembers($dbc = "") { //global $dbConn2; global $tempMemberRange; /* End of range to fill with NEW MEMBER records. * 0 means "do no fill" */ global $tempMemberRangeMax; /* Placeholder custdata.LastName that will be: * - ignored when it occurrs in the range of synced records * - assigned to new placeholder records if filling is being done. */ global $tempMemberLastName; /* custdata.memType for placeholder records. * Must be real. */ global $tempMemberMemberType; /* memContact.pref for placeholder records. * Must be real. */ global $tempMemberContactPref; $retval = null; $errors = ''; if ($dbc == "") { $errors = "addTempMembers() no database connection supplied."; return $errors; } /* Much of what follows is lifted from $MEM/NewMemberTool.php */ $name = $tempMemberLastName; /* Validate in memtypes.memtype */ $mtype = $tempMemberMemberType; $memtypes = new MemtypeModel($dbc); $memtypes->memtype($mtype); $mtypes = $memtypes->find(); if (count($mtypes) == 0) { $errors = "Member type {$mtype} is not known."; return $errors; } /* Validate in memContactPrefs.pref_id */ $pref = $tempMemberContactPref; $memprefs = new MemContactPrefsModel($dbc); $memprefs->pref_id($pref); $mprefs = $memprefs->find(); if (count($mprefs) == 0) { $errors = "Contact preference {$pref} is not known."; return $errors; } $mt = $dbc->tableDefinition('memtype'); $dQuery = "SELECT custdataType,discount,staff,ssi from memtype " . "WHERE memtype=?"; $defaultsQ = $dbc->prepare_statement($dQuery); if ($dbc->tableExists('memdefaults') && (!isset($mt['custdataType']) || !isset($mt['discount']) || !isset($mt['staff']) || !isset($mt['ssi']))) { $dQuery = "SELECT cd_type as custdataType,discount,staff,SSI as ssi " . "FROM memdefaults WHERE memtype=?"; $defaultsQ = $dbc->prepare_statement($dQuery); } $defaultsR = $dbc->exec_statement($defaultsQ, array($mtype)); $defaults = $dbc->fetch_row($defaultsR); $start = $tempMemberRange + 1; $end = $tempMemberRangeMax; $custdata = new CustdataModel($dbc); /* Pre-populate most custdata fields. */ $custdata->personNum(1); $custdata->LastName($name); $custdata->FirstName(''); $custdata->CashBack(999.99); $custdata->Balance(0); $custdata->memCoupons(0); $custdata->Discount($defaults['discount']); $custdata->Type($defaults['custdataType']); $custdata->staff($defaults['staff']); $custdata->SSI($defaults['ssi']); $custdata->memType($mtype); $meminfo = new MeminfoModel($dbc); /* Pre-populate most meminfo fields. */ $meminfo->last_name(''); $meminfo->first_name(''); $meminfo->othlast_name(''); $meminfo->othfirst_name(''); $meminfo->street(''); $meminfo->city(''); $meminfo->state(''); $meminfo->zip(''); $meminfo->phone(''); $meminfo->email_1(''); $meminfo->email_2(''); $chkP = $dbc->prepare_statement('SELECT CardNo FROM custdata WHERE CardNo=?'); $mdP = $dbc->prepare_statement("INSERT INTO memDates VALUES (?,NULL,NULL)"); $mcP = $dbc->prepare_statement("INSERT INTO memContact (card_no,pref) VALUES (?,?)"); $membersAdded = 0; for ($i = $start; $i <= $end; $i++) { // skip if record already exists $chkR = $dbc->exec_statement($chkP, array($i)); if ($dbc->num_rows($chkR) > 0) { continue; } $custdata->CardNo($i); $custdata->blueLine($i . ' ' . $name); $custdata->save(); $meminfo->card_no($i); $meminfo->save(); /* memDates */ $dbc->exec_statement($mdP, array($i)); /* memContact */ $dbc->exec_statement($mcP, array($i, $pref)); $membersAdded++; } $retval = $errors ? $errors : $membersAdded; return $retval; // addTempMembers() }
public function form_content() { $dbc = $this->connection; $dbc->selectDB($this->config->get('OP_DB')); $memtypes = new MemtypeModel($dbc); ob_start(); ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?> " method="get"> <div class="panel panel-default"> <div class="panel-heading">Include these Types</div> <div class="panel panel-body"> <?php foreach ($memtypes->find('memtype') as $m) { printf(' <div class="form-group"> <label> <input type="checkbox" class="checkbox-inline" name="type[]" value="%d" %s /> %s </label> </div>', $m->memtype(), $m->custdataType() == 'PC' ? 'checked' : '', $m->memDesc()); } ?> <div class="form-group"> <select name="suspended" class="form-control"> <option value="1">Include suspended accounts</option> <option value="0">Exclude suspended accounts</option> </select> </div> <p> <button type="submit" class="btn btn-default">List Members</button> </p> </div> <!-- panel-body --> </div> <!-- panel --> </form> <?php return ob_get_clean(); }
protected function get_id_view() { global $FANNIE_OP_DB, $FANNIE_URL; $dbc = FannieDB::get($FANNIE_OP_DB); $limitedEdit = $this->auth_mode == 'Full' ? False : True; ob_start(); echo '<form action="PIMemberPage.php" '; if (FormLib::get_form_value('edit', False) === False) { echo 'method="get">'; } else { echo 'method="post">'; } echo '<input type="hidden" name="id" value="' . $this->card_no . '" />'; echo "<table>"; echo "<tr>"; echo "<td class=\"greenbg yellowtxt\">Owner Num</td>"; echo "<td class=\"greenbg yellowtxt\">" . $this->card_no . "</td>"; $status = $this->account['activeStatus']; if ($status == '') { $status = $this->account['memberStatus']; } switch ($status) { case 'PC': $status = 'ACTIVE'; break; case 'REG': $status = 'NONMEM'; break; case 'INACT2': $status = 'TERM (PENDING)'; break; } if (isset($this->__models['suspended'])) { echo "<td bgcolor='#cc66cc'>{$status}</td>"; echo "<td colspan=1>"; if ($this->__models['suspended']->reason() != '') { echo $this->__models['suspended']->reason(); } else { $reasons = new ReasoncodesModel($dbc); foreach ($reasons->find('mask') as $r) { if (((int) $r->mask() & (int) $this->__models['suspended']->reasoncode()) != 0) { echo $r->textStr() . ' '; } } } echo '</td>'; } else { echo "<td>{$status}</td>"; } echo "<td colspan=2><a href=PISuspensionPage.php?id=" . $this->card_no . ">History</a>"; if ($this->auth_mode == 'Full') { echo ' <a href="PISuspensionPage.php?edit=1&id=' . $this->card_no . '">Change Status</a>'; } else { if ($this->auth_mode == 'Limited' && isset($this->__models['suspended']) && $this->__models['suspended']->reasoncode() == 16) { echo ' <a href="PISuspensionPage.php?fixaddress=1&id=' . $this->card_no . '" onclick="return confirm(\'Address is correct?\');">Address Corrected</a>'; } } echo '</td>'; echo "<td><a href=\"{$FANNIE_URL}ordering/clearinghouse.php?card_no=" . $this->card_no . "\">Special Orders</a></td>"; if (FannieAuth::validateUserQuiet('GiveUsMoney')) { echo "<td><a href=\"{$FANNIE_URL}modules/plugins2.0/GiveUsMoneyPlugin/GumMainPage.php?id=" . $this->card_no . "\">Owner Loans</a></td>"; } echo "</tr>"; echo "<tr>"; echo '<input type="hidden" name="customerID" value="' . $this->primary_customer['customerID'] . '" />'; echo "<td class=\"yellowbg\">First Name: </td>"; echo '<td>' . $this->text_or_field('FirstName', $this->primary_customer['firstName']) . '</td>'; echo "<td class=\"yellowbg\">Last Name: </td>"; echo '<td>' . $this->text_or_field('LastName', $this->primary_customer['lastName']) . '</td>'; echo '</tr>'; echo "<tr>"; echo "<td class=\"yellowbg\">Address1: </td>"; echo '<td>' . $this->text_or_field('address1', $this->account['addressFirstLine']) . '</td>'; echo "<td class=\"yellowbg\">Gets mailings: </td>"; echo '<td>' . $this->text_or_select('mailflag', $this->account['contactAllowed'], array(1, 0), array('Yes', 'No')) . '</td>'; echo "</tr>"; echo "<tr>"; echo "<td class=\"yellowbg\">Address2: </td>"; echo '<td>' . $this->text_or_field('address2', $this->account['addressSecondLine']) . '</td>'; echo "<td class=\"yellowbg\">UPC: </td>"; echo '<td colspan=\\"2\\">' . $this->text_or_field('upc', $this->account['idCardUPC']) . '</td>'; echo "</tr>"; echo "<tr>"; echo "<td class=\"yellowbg\">City: </td>"; echo '<td>' . $this->text_or_field('city', $this->account['city']) . '</td>'; echo "<td class=\"yellowbg\">State: </td>"; echo '<td>' . $this->text_or_field('state', $this->account['state']) . '</td>'; echo "<td class=\"yellowbg\">Zip: </td>"; echo '<td>' . $this->text_or_field('zip', $this->account['zip']) . '</td>'; echo "</tr>"; echo "<tr>"; echo "<td class=\"yellowbg\">Phone Number: </td>"; echo '<td>' . $this->text_or_field('phone', $this->primary_customer['phone']) . '</td>'; echo "<td class=\"yellowbg\">Start Date: </td>"; $start = $this->account['startDate']; if (strstr($start, ' ') !== False) { list($start, $junk) = explode(' ', $start, 2); } if ($start == '1900-01-01') { echo '<input type="hidden" name="nonBlankStart" value="' . $start . '" />'; } if ($start == '1900-01-01' || $start == '0000-00-00') { $start = ''; } echo '<td>' . $this->text_or_field('start_date', $start, array(), $limitedEdit) . '</td>'; echo "<td class=\"yellowbg\">End Date: </td>"; $end = $this->account['endDate']; if (strstr($end, ' ') !== False) { list($end, $junk) = explode(' ', $end, 2); } if ($end == '1900-01-01' || $end == '0000-00-00') { $end = ''; } echo '<td>' . $this->text_or_field('end_date', $end, array(), $limitedEdit) . '</td>'; echo "</tr>"; echo "<tr>"; echo "<td class=\"yellowbg\">Alt. Phone: </td>"; echo '<td>' . $this->text_or_field('phone2', $this->primary_customer['altPhone']) . '</td>'; echo "<td class=\"yellowbg\">E-mail: </td>"; echo '<td>' . $this->text_or_field('email', $this->primary_customer['email']) . '</td>'; echo "</tr>"; echo "<tr>"; echo "<td class=\"yellowbg\">Stock Purchased: </td>"; echo "<td>" . sprintf('%.2f', $this->__models['equity']->payments()) . '</td>'; echo "<td class=\"yellowbg\">Mem Type: </td>"; $labels = array(); $opts = array(); $memtypes = new MemtypeModel($dbc); foreach ($memtypes->find('memtype') as $mt) { $labels[] = $mt->memDesc(); $opts[] = $mt->memtype(); } echo '<td>' . $this->text_or_select('memType', $this->account['customerTypeID'], $opts, $labels, array(), $limitedEdit) . '</td>'; echo "<td class=\"yellowbg\">Discount: </td>"; echo '<td>' . $this->primary_customer['discount'] . '</td>'; echo "</tr>"; echo "<tr>"; echo "<td class=\"yellowbg\">Charge Limit: </td>"; echo '<td>' . $this->text_or_field('chargelimit', $this->account['chargeLimit'], array(), $limitedEdit) . '</td>'; echo "<td class=\"yellowbg\">Current Balance: </td>"; echo '<td>' . sprintf('%.2f', $this->__models['ar']->balance()) . '</td>'; echo "</tr>"; echo "<tr class=\"yellowbg\"><td colspan=6></td></tr>"; echo "<tr>"; echo '<td colspan="2" class="greenbg yellowtxt">Additional household members</td>'; echo '<td></td>'; echo '<td class="greenbg yellowtxt">Additional Notes</td>'; echo "<td><a href=PINoteHistoryPage.php?id=" . $this->card_no . ">Notes history</a></td>"; echo "</tr>"; echo "<tr>"; echo '<td></td>'; echo '<td class="yellowbg">First Name</td>'; echo '<td class="yellowbg">Last Name</td>'; echo "<td colspan=4 width=\"300px\" valign=\"top\" rowspan=8>"; echo $this->text_or_area('notetext', $this->__models['note'], array('rows' => 7, 'cols' => 50), 2); echo "</td>"; echo '</tr>'; $i = 0; foreach ($this->account['customers'] as $c) { if ($c['accountHolder']) { continue; } echo '<tr>'; echo '<td class="yellowbg">' . ($i + 1) . '</td>'; echo '<td>' . $this->text_or_field('fn[]', $c['firstName']) . '</td>'; echo '<td>' . $this->text_or_field('ln[]', $c['lastName']) . '</td>'; echo '<input type="hidden" name="hhID[]" value="' . $c['customerID'] . '" />'; $i++; } for ($i; $i < 3; $i++) { echo '<tr>'; echo '<td class="yellowbg">' . ($i + 1) . '</td>'; echo '<td>' . $this->text_or_field('fn[]', '') . '</td>'; echo '<td>' . $this->text_or_field('ln[]', '') . '</td>'; echo '<input type="hidden" name="hhID[]" value="0" />'; } echo '</tr>'; echo '<tr>'; echo '<td colspan="3">'; if (FormLib::get_form_value('edit', False) === False) { if ($this->current_user) { echo '<input type="hidden" name="edit" />'; echo '<input type="submit" value="Edit Member" />'; } else { echo '<input type="hidden" name="login" />'; echo '<input type="submit" value="Log In" />'; } echo ' '; echo '<a href="PIMemberPage.php?id=' . ($this->card_no - 1) . '">Prev Mem</a>'; echo ' '; echo '<a href="PIMemberPage.php?id=' . ($this->card_no + 1) . '">Next Mem</a>'; } else { echo '<input type="submit" value="Save Member" />'; } echo '</td>'; echo '</tr>'; echo "</table>"; return ob_get_clean(); }
protected function hookAddColumnSsi() { if ($this->connection->table_exists('memdefaults')) { $dataR = $this->connection->query('SELECT memtype, SSI FROM memdefaults'); $tempModel = new MemtypeModel($this->connection); while ($dataW = $this->connection->fetch_row($dataR)) { $tempModel->reset(); $tempModel->memtype($dataW['memtype']); if ($tempModel->load()) { $tempModel->ssi($dataW['SSI']); $tempModel->save(); } } } }