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()
}
Exemple #2
0
 function results_content()
 {
     global $FANNIE_OP_DB, $FANNIE_SERVER_DBMS;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $mtype = FormLib::get_form_value('memtype', 0);
     $num = FormLib::get_form_value('num', 0);
     $name = FormLib::get_form_value('name', 'NEW MEMBER');
     $manual_start = FormLib::get_form_value('start', false);
     if (!is_numeric($manual_start)) {
         $manual_start = false;
     }
     $mt = $dbc->tableDefinition('memtype');
     $defaultsQ = $dbc->prepare_statement("SELECT custdataType,discount,staff,ssi from memtype WHERE memtype=?");
     if ($dbc->tableExists('memdefaults') && (!isset($mt['custdataType']) || !isset($mt['discount']) || !isset($mt['staff']) || !isset($mt['ssi']))) {
         $defaultsQ = $dbc->prepare_statement("SELECT cd_type as custdataType,discount,staff,SSI as ssi\n                    FROM memdefaults WHERE memtype=?");
     }
     $defaultsR = $dbc->exec_statement($defaultsQ, array($mtype));
     $defaults = $dbc->fetch_row($defaultsR);
     /**
       1Jul2015
       Use FannieREST API calls to create new members
       Not tested yet.
     $json = array(
         'customerTypeID' => $mtype,
         'memberStatus' => $mt['custdataType'],
         'addressFirstLine' => '',
         'addressSecondLine' => '',
         'city' => '',
         'state' => '',
         'zip' => '',
         'contactAllowed' => 1,
         'contactMethod' => 'mail',
         'customers' => array(
             array(
                 'firstName' => '',
                 'lastName' => $name,
                 'phone' => '',
                 'altPhone' => '',
                 'email' => 1,
                 'discount' => $mt['discount'],
                 'staff' => $mt['staff'],
                 'lowIncomeBenefits' => $mt['ssi'],
             ),
         ),
     );
     
     $start = PHP_INT_MAX;
     $end = 0;
     for ($i=0; $i<$num; $i++) {
         if ($manual_start) {
             $resp = \COREPOS\Fannie\API\member\MemberREST::post($manual_start+$i, $json);
         } else {
             $resp = \COREPOS\Fannie\API\member\MemberREST::post(0, $json);
         }
     
         if (isset($resp['account']) && $resp['account']['cardNo'] > $end) {
             $end = $resp['account']['cardNo'];
         }
         if (isset($resp['account']) && $resp['account']['cardNo'] < $start) {
             $start = $resp['account']['cardNo'];
         }
     }
     */
     /* going to create memberships
        part of the insert arrays can
        be prepopulated */
     $meminfo = array('last_name' => "''", 'first_name' => "''", 'othlast_name' => "''", 'othfirst_name' => "''", 'street' => "''", 'city' => "''", 'state' => "''", 'zip' => "''", 'phone' => "''", 'email_1' => "''", 'email_2' => "''", 'ads_OK' => 1);
     /* everything's set but the actual member #s */
     $numQ = $dbc->prepare_statement("SELECT MAX(CardNo) FROM custdata");
     if ($FANNIE_SERVER_DBMS == 'MSSQL') {
         $numQ = $dbc->prepare_statement("SELECT MAX(CAST(CardNo AS int)) FROM custdata");
     }
     $numR = $dbc->exec_statement($numQ);
     $start = 1;
     if ($dbc->num_rows($numR) > 0) {
         $numW = $dbc->fetch_row($numR);
         if (!empty($numW[0])) {
             $start = $numW[0] + 1;
         }
     }
     if ($manual_start) {
         $start = (int) $manual_start;
     }
     $end = $start + $num - 1;
     $ret = "<b>Starting number</b>: {$start}<br />";
     $ret .= "<b>Ending number</b>: {$end}<br />";
     $model = new CustdataModel($dbc);
     $model->personNum(1);
     $model->LastName($name);
     $model->FirstName('');
     $model->CashBack(999.99);
     $model->Balance(0);
     $model->memCoupons(0);
     $model->Discount($defaults['discount']);
     $model->Type($defaults['custdataType']);
     $model->staff($defaults['staff']);
     $model->SSI($defaults['ssi']);
     $model->memType($mtype);
     $meminfo = new MeminfoModel($dbc);
     $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 (?,1)");
     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;
         }
         $model->CardNo($i);
         $model->blueLine($i . ' ' . $name);
         $model->save();
         $meminfo->card_no($i);
         $meminfo->save();
         $dbc->exec_statement($mdP, array($i));
         $dbc->exec_statement($mcP, array($i));
     }
     return $ret;
 }
Exemple #3
0
$MI_FIELDS['city'] = $_POST['city'];
$MI_FIELDS['state'] = $_POST['state'];
$MI_FIELDS['zip'] = $_POST['zip'];
$MI_FIELDS['phone'] = $_POST['phone'];
$MI_FIELDS['email_2'] = $_POST['phone2'];
$MI_FIELDS['email_1'] = $_POST['email'];
$MI_FIELDS['ads_OK'] = $_POST['mailflag'];
$cust = new CustdataModel($dbc);
$cust->CardNo($memNum);
$cust->personNum(1);
$cust->load();
// get all current values
$cust->MemDiscountLimit($_POST['chargeLimit']);
$cust->ChargeLimit($_POST['chargeLimit']);
$cust->ChargeOk($_POST['chargeLimit'] == 0 ? 0 : 1);
$cust->memType($_POST['discList']);
$cust->Type('REG');
$cust->Staff(0);
$cust->Discount(0);
$cards = new MemberCardsModel($dbc);
$cards->card_no($memNum);
$cards->upc($_REQUEST['cardUPC']);
$cards->save();
$mcP = $sql->prepare("UPDATE memContact SET pref=? WHERE card_no=?");
$sql->execute($mcP, array($MI_FIELDS['ads_OK'], $memNum));
if ($cust->memType() == 1 || $cust->memType() == 3) {
    $cust->Type('PC');
}
if ($cust->memType() == 3 || $cust->memType() == 9) {
    $cust->Discount(12);
    $cust->Staff(1);
 function process_file($linedata)
 {
     global $FANNIE_OP_DB, $FANNIE_TRANS_DB;
     $EMP_NO = $this->config->get('EMP_NO');
     $LANE_NO = $this->config->get('REGISTER_NO');
     $OFFSET_DEPT = $this->config->get('MISC_DEPT');
     $card_no = $this->get_column_index('card_no');
     $classA = $this->get_column_index('classA');
     $classB = $this->get_column_index('classB');
     $note = $this->get_column_index('note');
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $dtrans_table = $FANNIE_TRANS_DB . $dbc->sep() . 'dtransactions';
     $prep = $dbc->prepare('SELECT MAX(trans_no) as tn FROM ' . $dtrans_table . ' 
                         WHERE emp_no=? AND register_no=?');
     $result = $dbc->execute($prep, array($EMP_NO, $LANE_NO));
     $trans = 1;
     if ($dbc->num_rows($result) > 0) {
         $row = $dbc->fetch_row($result);
         if ($row['tn'] != '') {
             $trans = $row['tn'] + 1;
         }
     }
     foreach ($linedata as $data) {
         if (!isset($data[$card_no])) {
             continue;
         } elseif (!is_numeric($data[$card_no])) {
             continue;
         }
         $cn = trim($data[$card_no]);
         $a_amt = trim($data[$classA], '$ ');
         $b_amt = trim($data[$classB], '$ ');
         $offset_amt = $a_amt + $b_amt;
         if ($offset_amt == 0) {
             continue;
         }
         $now = date('Y-m-d H:i:s');
         $custdata = new CustdataModel($dbc);
         $custdata->CardNo($cn);
         $custdata->personNum(1);
         $custdata->load();
         $meminfo = new MeminfoModel($dbc);
         $meminfo->card_no($cn);
         $meminfo->load();
         $susp = new SuspensionsModel($dbc);
         $susp->cardno($cn);
         $susp->load();
         $susp->type('T');
         $susp->memtype1($custdata->memType());
         $susp->memtype2($custdata->Type());
         $susp->suspDate($now);
         $susp->discount($custdata->Discount());
         $susp->chargelimit($custdata->ChargeLimit());
         $susp->mailflag($meminfo->ads_OK());
         $susp->reasoncode(64);
         $susp->save();
         $suspHistory = new SuspensionHistoryModel($dbc);
         $suspHistory->username('abandon-import');
         $suspHistory->postdate($now);
         $suspHistory->cardno($cn);
         $suspHistory->reasoncode(64);
         $suspHistory->save();
         $meminfo->ads_OK(0);
         $meminfo->save();
         $custdata->reset();
         $custdata->CardNo($cn);
         foreach ($custdata->find() as $obj) {
             $obj->Type('TERM');
             $obj->memType(0);
             $obj->Discount(0);
             $obj->ChargeLimit(0);
             $obj->MemDiscountLimit(0);
             $obj->save();
         }
         if (isset($data[$note]) && !empty($data[$note])) {
             $memNote = new MemberNotesModel($dbc);
             $memNote->cardno($cn);
             $memNote->note($data[$note]);
             $memNote->stamp($now);
             $memNote->username('abandon-import');
             $memNote->save();
         }
         $trans_id = 1;
         if ($a_amt > 0) {
             $record = DTrans::$DEFAULTS;
             $record['register_no'] = $LANE_NO;
             $record['emp_no'] = $EMP_NO;
             $record['trans_no'] = $trans;
             $record['upc'] = $a_amt . 'DP992';
             $record['description'] = 'Class A Equity';
             $record['trans_type'] = 'D';
             $record['department'] = 992;
             $record['unitPrice'] = -1 * $a_amt;
             $record['total'] = -1 * $a_amt;
             $record['regPrice'] = -1 * $a_amt;
             $record['card_no'] = $cn;
             $record['trans_id'] = $trans_id;
             $trans_id++;
             $info = DTrans::parameterize($record, 'datetime', $dbc->now());
             $prep = $dbc->prepare("INSERT INTO {$dtrans_table} ({$info['columnString']}) VALUES ({$info['valueString']})");
             $dbc->execute($prep, $info['arguments']);
         }
         if ($b_amt > 0) {
             $record = DTrans::$DEFAULTS;
             $record['register_no'] = $LANE_NO;
             $record['emp_no'] = $EMP_NO;
             $record['trans_no'] = $trans;
             $record['upc'] = $a_amt . 'DP991';
             $record['description'] = 'Class B Equity';
             $record['trans_type'] = 'D';
             $record['department'] = 991;
             $record['unitPrice'] = -1 * $b_amt;
             $record['total'] = -1 * $b_amt;
             $record['regPrice'] = -1 * $b_amt;
             $record['card_no'] = $cn;
             $record['trans_id'] = $trans_id;
             $trans_id++;
             $info = DTrans::parameterize($record, 'datetime', $dbc->now());
             $prep = $dbc->prepare("INSERT INTO {$dtrans_table} ({$info['columnString']}) VALUES ({$info['valueString']})");
             $dbc->execute($prep, $info['arguments']);
         }
         $record = DTrans::$DEFAULTS;
         $record['register_no'] = $LANE_NO;
         $record['emp_no'] = $EMP_NO;
         $record['trans_no'] = $trans;
         $record['upc'] = $offset_amt . 'DP' . $OFFSET_DEPT;
         $record['description'] = 'Abandon Equity';
         $record['trans_type'] = 'D';
         $record['department'] = $OFFSET_DEPT;
         $record['unitPrice'] = $offset_amt;
         $record['total'] = $offset_amt;
         $record['regPrice'] = $offset_amt;
         $record['card_no'] = $cn;
         $record['trans_id'] = $trans_id;
         $trans_id++;
         $info = DTrans::parameterize($record, 'datetime', $dbc->now());
         $prep = $dbc->prepare("INSERT INTO {$dtrans_table} ({$info['columnString']}) VALUES ({$info['valueString']})");
         $dbc->execute($prep, $info['arguments']);
         $record = DTrans::$DEFAULTS;
         $record['register_no'] = $LANE_NO;
         $record['emp_no'] = $EMP_NO;
         $record['trans_no'] = $trans;
         $record['upc'] = '0';
         $record['description'] = '63350';
         $record['trans_type'] = 'C';
         $record['trans_subtype'] = 'CM';
         $record['card_no'] = $cn;
         $record['trans_id'] = $trans_id;
         $info = DTrans::parameterize($record, 'datetime', $dbc->now());
         $prep = $dbc->prepare("INSERT INTO {$dtrans_table} ({$info['columnString']}) VALUES ({$info['valueString']})");
         $dbc->execute($prep, $info['arguments']);
         $trans++;
     }
     return true;
 }
Exemple #5
0
 /**
   Update older tables.
 */
 private static function postCustdata($dbc, $id, $json)
 {
     $config = \FannieConfig::factory();
     $ret = array('errors' => 0, 'error-msg' => '');
     /** save dates if provided **/
     if (isset($json['startDate']) || isset($json['endDate'])) {
         $dates = new \MemDatesModel($dbc);
         $dates->start_date($json['startDate']);
         $dates->end_date($json['endDate']);
         $dates->card_no($id);
         if (!$dates->save()) {
             $ret['errors']++;
             $ret['error-msg'] .= 'ErrDates ';
         }
     }
     /** save UPC if provided **/
     if (isset($json['idCardUPC'])) {
         $cards = new \MemberCardsModel($dbc);
         $cards->card_no($id);
         if ($json['idCardUPC'] != '') {
             $cards->upc(\BarcodeLib::padUPC($json['idCardUPC']));
         } else {
             $cards->upc('');
         }
         if (!$cards->save()) {
             $ret['errors']++;
         }
     }
     /** save contact method if provided **/
     if (isset($json['contactMethod'])) {
         $contact = new \MemContactModel($dbc);
         $contact->card_no($id);
         if (isset($json['contactAllowed']) && !$json['contactAllowed']) {
             $contact->pref(0);
         } elseif ($json['contactMethod'] == 'email') {
             $contact->pref(2);
         } elseif ($json['contactMethod'] == 'both') {
             $contact->pref(3);
         } else {
             $contact->pref(1);
         }
         if (!$contact->save()) {
             $ret['errors']++;
             $ret['error-msg'] .= 'ErrUPC ';
         }
     }
     /**
       Custdata and meminfo are messier. Start with account-level
       settings.
     */
     $custdata = new \CustdataModel($dbc);
     $custdata->CardNo($id);
     $custdata_changed = false;
     $meminfo = new \MeminfoModel($dbc);
     $meminfo->card_no($id);
     if (isset($json['addressFirstLine'])) {
         $street = $json['addressFirstLine'];
         if (isset($json['addressSecondLine'])) {
             $street .= "\n" . $json['addressSecondLine'];
         }
         $meminfo->street($street);
     }
     if (isset($json['city'])) {
         $meminfo->city($json['city']);
     }
     if (isset($json['state'])) {
         $meminfo->state($json['state']);
     }
     if (isset($json['zip'])) {
         $meminfo->zip($json['zip']);
     }
     if (isset($json['contactAllowed'])) {
         $meminfo->ads_OK($json['contactAllowed']);
     }
     if (isset($json['activeStatus']) && $json['activeStatus'] != '') {
         $custdata->Type($json['activeStatus']);
         $custdata_changed = true;
     } elseif (isset($json['memberStatus'])) {
         $custdata->Type($json['memberStatus']);
         $custdata_changed = true;
     }
     if (isset($json['customerTypeID'])) {
         $custdata->memType($json['customerTypeID']);
         $custdata_changed = true;
     }
     if (isset($json['chargeLimit'])) {
         $custdata->ChargeLimit($json['chargeLimit']);
         $custdata->MemDiscountLimit($json['chargeLimit']);
         $custdata_changed = true;
     }
     if (isset($json['chargeBalance'])) {
         $custdata->Balance($json['chargeBalance']);
         $custdata_changed = true;
     }
     /**
       Now loop through per-person settings. Assign the primary account holder's
       email address and phone number to the global meminfo, but save the other
       settings using a different per-person custdata instance
     */
     if (isset($json['customers']) && is_array($json['customers']) && count($json['customers']) > 0) {
         $personNum = 2;
         foreach ($json['customers'] as $c_json) {
             if (!isset($c_json['accountHolder'])) {
                 $ret['errors']++;
                 $ret['error-msg'] .= 'ErrAcctHolder ';
                 continue;
             }
             $loopCD = new \CustdataModel($dbc);
             $loopCD->CardNo($id);
             $loopCD_changed = false;
             if ($c_json['accountHolder']) {
                 $loopCD->personNum(1);
                 if (isset($c_json['phone'])) {
                     $meminfo->phone($c_json['phone']);
                 }
                 if (isset($c_json['altPhone'])) {
                     $meminfo->email_2($c_json['altPhone']);
                 }
                 if (isset($c_json['email'])) {
                     $meminfo->email_1($c_json['email']);
                 }
             } elseif (isset($c_json['firstName']) && isset($c_json['lastName']) && $c_json['firstName'] == '' && $c_json['lastName'] == '') {
                 // blank name fields on non-account holder mean
                 // the customer was removed from the account
                 continue;
             } else {
                 $loopCD->personNum($personNum);
                 $personNum++;
             }
             if (isset($c_json['firstName'])) {
                 $loopCD->FirstName($c_json['firstName']);
                 $loopCD_changed = true;
             }
             if (isset($c_json['lastName'])) {
                 $loopCD->LastName($c_json['lastName']);
                 $loopCD_changed = true;
             }
             if (isset($c_json['chargeAllowed'])) {
                 $loopCD->ChargeOk($c_json['chargeAllowed']);
                 $loopCD_changed = true;
             }
             if (isset($c_json['checksAllowed'])) {
                 $loopCD->WriteChecks($c_json['checksAllowed']);
                 $loopCD_changed = true;
             }
             if (isset($c_json['staff'])) {
                 $loopCD->staff($c_json['staff']);
                 $loopCD_changed = true;
             }
             if (isset($c_json['discount'])) {
                 $loopCD->Discount($c_json['discount']);
                 $loopCD_changed = true;
             }
             if (isset($c_json['lowIncomeBenefits'])) {
                 $loopCD->SSI($c_json['lowIncomeBenefits']);
                 $loopCD_changed = true;
             }
             if ($loopCD_changed && !$loopCD->save()) {
                 $ret['errors']++;
                 $ret['error-msg'] .= 'ErrPerson ';
             }
         }
         $cleanP = $dbc->prepare('DELETE FROM custdata WHERE CardNo=? AND personNum>=?');
         $cleanR = $dbc->execute($cleanP, array($id, $personNum));
     }
     if (!$meminfo->save()) {
         $ret['errors']++;
         $ret['error-msg'] .= 'ErrMeminfo ';
     }
     /**
       Finally, apply account-level settings to
       all custdata records for the account.
     */
     if ($custdata_changed) {
         $allCD = new \CustdataModel($dbc);
         $allCD->CardNo($id);
         foreach ($allCD->find() as $c) {
             $custdata->personNum($c->personNum());
             if (!$custdata->save()) {
                 $ret['errors']++;
                 $ret['error-msg'] .= 'ErrGlobal ';
             }
         }
     }
     self::setBlueLines($id);
     // in classic mode sync changes back to the new table if present
     if ($config->get('CUST_SCHEMA') != 1 && $dbc->tableExists('CustomerAccounts')) {
         self::postAccount($dbc, $id, $json);
     }
     $ret['account'] = self::get($id);
     return $ret;
 }
 /**
   Update various legacy tables to match an
   existing CustomerAccounts record. 
   @param $card_no [int] member number
   @return [boolean] success
 */
 public function legacySync($card_no)
 {
     $dbc = $this->connection;
     $custdata = new CustdataModel($dbc);
     $custdata->CardNo($card_no);
     $meminfo = new MeminfoModel($dbc);
     $meminfo->card_no($card_no);
     $memDates = new MemDatesModel($dbc);
     $memDates->card_no($card_no);
     $cards = new MemberCardsModel($dbc);
     $cards->card_no($card_no);
     $contact = new MemContactModel($dbc);
     $contact->card_no($card_no);
     $suspensions = new SuspensionsModel($dbc);
     $suspensions->cardno($card_no);
     $this->reset();
     $this->cardNo($card_no);
     if (!$this->load()) {
         return false;
     }
     if ($this->activeStatus() != '') {
         $suspensions->cardno($card_no);
         $suspensions->memtype1($this->customerTypeID());
         $suspensions->memtype2($this->memberStatus());
         $suspensions->chargelimit($this->chargeLimit());
         $suspensions->mailflag($this->contactAllowed());
         $suspensions->save();
     } else {
         $custdata->Type($this->memberStatus());
         $custdata->memType($this->customerTypeID());
         $custdata->ChargeLimit($this->chargeLimit());
         $custdata->MemDiscountLimit($this->chargeLimit());
         $meminfo->ads_OK($this->contactAllowed());
     }
     $custdata->Balance($this->chargeBalance());
     $allCustdata = new CustdataModel($dbc);
     $allCustdata->CardNo($card_no);
     foreach ($allCustdata as $c) {
         $custdata->personNum($c->personNum());
         $custdata->save();
     }
     $cards->upc($this->idCardUPC());
     $cards->save();
     $memDates->start_date($this->startDate());
     $memDates->end_date($this->endDate());
     $memDates->save();
     if ($this->addressSecondLine() != '') {
         $meminfo->street($this->addressFirstLine() . "\n" . $this->addressSecondLine());
     } else {
         $meminfo->street($this->addressFirstLine());
     }
     $meminfo->city($this->city());
     $meminfo->state($this->state());
     $meminfo->zip($this->zip());
     $meminfo->save();
     if ($this->contactAllowed() == 0) {
         $contact->pref(0);
     } else {
         switch ($this->contactMethod()) {
             case 'mail':
                 $contact->pref(1);
                 break;
             case 'email':
                 $contact->pref(2);
                 break;
             case 'both':
                 $contact->pref(3);
                 break;
         }
     }
     $contact->save();
     return true;
 }