Beispiel #1
0
 public function report_description_content()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $memtypes = new MemtypeModel($dbc);
     $ret = 'List of: ';
     if (!is_array($this->form->type)) {
         $this->form->type = array($this->form->type);
     }
     foreach ($this->form->type as $type) {
         $memtypes->memtype($type);
         $memtypes->load();
         $ret .= $memtypes->memDesc() . ', ';
     }
     return array($ret);
 }
Beispiel #2
0
 /**
   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()
}
Beispiel #4
0
 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;
 }
Beispiel #5
0
 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();
             }
         }
     }
 }