function process_file($linedata) { global $FANNIE_OP_DB; $dbc = FannieDB::get($FANNIE_OP_DB); $cn_index = $this->get_column_index('check_no'); $td_index = $this->get_column_index('tdate'); $p = new PatronageModel($dbc); foreach ($linedata as $line) { $check_no = $line[$cn_index]; if (!is_numeric($check_no)) { continue; } // skip bad record $p->check_number($check_no); $matches = $p->find(); if (count($matches) == 0) { $this->stats['errors'][] = 'No check on file with #' . $check_no; continue; } // there shouldn't be more than one match // but loop anyway foreach ($matches as $obj) { if ($obj->cashed_date() != '') { // if check has already been marked as cash, do not // update the date. just leave it as is and // count the record as imported successfully $this->stats['imported']++; } else { // tag the record with today's date OR the // spreadsheet-supplied date $tdate = date('Y-m-d'); if ($td_index !== false && $line[$td_index] != '') { $stamp = strtotime($line[$td_index]); if ($stamp) { $tdate = date('Y-m-d', $stamp); } } $obj->cashed_date($tdate); $updated = $obj->save(); if ($updated) { $this->stats['imported']++; } else { $this->stats['errors'][] = $dbc->error(); } } } } return true; }