protected function post_id_handler() { global $FANNIE_OP_DB, $FANNIE_TRANS_DB; $this->card_no = $this->id; if ($this->auth_mode == 'None') { return $this->unknownRequestHandler(); } $dbc = FannieDB::get($FANNIE_OP_DB); $note = FormLib::get_form_value('notetext'); $hash = FormLib::get_form_value('_notetext'); if (base64_decode($hash) != $note) { $noteP = $dbc->prepare_statement('INSERT INTO memberNotes (cardno, note, stamp, username) VALUES (?, ?, ' . $dbc->now() . ', ?)'); $noteR = $dbc->exec_statement($noteP, array($this->card_no, str_replace("\n", '<br />', $note), $this->current_user)); } $json = array('cardNo' => $this->id, 'customers' => array()); $account_holder = array('accountHolder' => 1); $account_holder['firstName'] = FormLib::get('FirstName'); $account_holder['lastName'] = FormLib::get('LastName'); $account_holder['customerID'] = FormLib::get('customerID'); $json['addressFirstLine'] = FormLib::get('address1'); $json['addressSecondLine'] = FormLib::get('address2'); $json['city'] = FormLib::get('city'); $json['state'] = FormLib::get('state'); $json['zip'] = FormLib::get('zip'); $account_holder['phone'] = FormLib::get('phone'); $account_holder['altPhone'] = FormLib::get('phone2'); $account_holder['email'] = FormLib::get('email'); $json['contactAllowed'] = FormLib::get('mailflag', 0); $upc = FormLib::get_form_value('upc', false); if ($upc !== false) { if ($upc != '') { $json['idCardUPC'] = BarcodeLib::padUPC($upc); } else { $json['idCardUPC'] = ''; } } if ($this->auth_mode == 'Full') { $json['customerTypeID'] = FormLib::get('memType'); $json['chargeLimit'] = FormLib::get('chargelimit'); $default = new MemtypeModel($dbc); $default->memtype($json['customerTypeID']); $default->load(); $account_holder['discount'] = $default->discount(); $account_holder['staff'] = $default->staff(); $account_holder['chargeAllowed'] = $json['chargeLimit'] == 0 ? 0 : 1; $account_holder['lowIncomeBenefits'] = $default->ssi(); $start = FormLib::get('start_date', ''); /** Interface hides 1900-01-01 dates from the end-user but that's not identical to 0000-00-00. A blank submission should preserve that 1900-01-01 date. */ if ($start == '' && FormLib::get('nonBlankStart') != '') { $start = FormLib::get('nonBlankStart'); } $json['startDate'] = $start; $json['endDate'] = FormLib::get('end_date'); } else { // get account defaults for additional names if needed $account = \COREPOS\Fannie\API\member\MemberREST::get($this->card_no); foreach ($account['customers'] as $c) { if ($c['accountHolder']) { $account_holder['discount'] = $c['discount']; $account_holder['staff'] = $c['staff']; $account_holder['lowIncomeBenefits'] = $c['lowIncomeBenefits']; $account_holder['chargeAllowed'] = $c['chargeAllowed']; } } } $json['customers'][] = $account_holder; $names = array('first' => FormLib::get_form_value('fn'), 'last' => FormLib::get_form_value('ln')); $fn = FormLib::get_form_value('fn'); $ln = FormLib::get_form_value('ln'); $hhID = FormLib::get('hhID'); for ($i = 0; $i < count($fn); $i++) { $set = array('first' => isset($fn[$i]) ? $fn[$i] : '', 'last' => isset($ln[$i]) ? $ln[$i] : '', 'id' => isset($hhID[$i]) ? $hhID[$i] : ''); $json['customers'][] = array('customerID' => $hhID[$i], 'accountHolder' => 0, 'firstName' => $set['first'], 'lastName' => $set['last'], 'discount' => $account_holder['discount'], 'staff' => $account_holder['staff'], 'lowIncomeBenefits' => $account_holder['lowIncomeBenefits'], 'chargeAllowed' => $account_holder['chargeAllowed']); } $resp = \COREPOS\Fannie\API\member\MemberREST::post($this->card_no, $json); $custdata = new CustdataModel($dbc); $custdata->CardNo($this->card_no); foreach ($custdata->find() as $c) { $c->pushToLanes(); } $cards = new MemberCardsModel($dbc); $cards->card_no($this->card_no); $cards->load(); $cards->pushToLanes(); header('Location: PIMemberPage.php?id=' . $this->card_no); return false; }