Exemplo n.º 1
0
 public function get_reprint_mem_fy_handler()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $custdata = new CustdataModel($dbc);
     $meminfo = new MeminfoModel($dbc);
     $custdata->CardNo($this->mem);
     $custdata->personNum(1);
     $custdata->load();
     $meminfo->card_no($this->mem);
     $meminfo->load();
     $patronage = new PatronageModel($dbc);
     $patronage->cardno($this->mem);
     $patronage->FY($this->fy);
     $patronage->load();
     $pdf = new FPDF('P', 'mm', 'Letter');
     $pdf->SetMargins(6.35, 6.35, 6.35);
     // quarter-inch margins
     $pdf->SetAutoPageBreak(false);
     $pdf->AddPage();
     $pdf->Image('rebate_body.png', 10, 0, 190);
     $check = new GumCheckTemplate($custdata, $meminfo, $patronage->cash_pat(), 'Rebate ' . $this->fy, $patronage->check_number());
     $check->renderAsPDF($pdf);
     $pdf->Output('Rebate_' . $this->mem . '_' . $this->fy . '.pdf', 'I');
     return false;
 }
Exemplo n.º 2
0
 public function testPatronageChecks()
 {
     $config = FannieConfig::factory();
     $task = new PatronageCheckTask();
     $dbc = FannieDB::get($config->get('OP_DB'));
     $dbc->query('TRUNCATE TABLE patronage');
     $p = new PatronageModel($dbc);
     $p->cardno(1);
     $p->FY(2000);
     $p->check_number(1);
     $p->cashed_date(null);
     $p->cashed_here(0);
     $p->save();
     $dbc = FannieDB::get($config->get('TRANS_DB'));
     $dbc->query('TRUNCATE TABLE dlog_15');
     $d = new DLog15Model($dbc);
     $d->tdate('2000-01-01 00:00:00');
     $d->trans_type('T');
     $d->description('REBATE CHECK');
     $d->total(1.23);
     $d->card_no(1);
     $d->save();
     $task->run();
     $dbc = FannieDB::get($config->get('OP_DB'));
     $p->reset();
     $p->cardno(1);
     $p->FY(2000);
     $loaded = $p->load();
     $this->assertEquals(true, $loaded, 'Failed to load patronage record');
     $this->assertEquals('2000-01-01 00:00:00', $p->cashed_date(), 'Cashed date missing');
     $this->assertEquals(1, $p->cashed_here(), 'Not marked as cashed');
 }
Exemplo n.º 3
0
 public function post_id_handler()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $prep = $dbc->prepare('
         INSERT INTO patronage
         (cardno, purchase, discounts, rewards, net_purch, tot_pat, cash_pat, equit_pat, FY)
         SELECT cardno,
             purchase,
             discounts,
             rewards,
             net_purch,
             ?,
             ?,
             ?,
             FY
         FROM patronage_workingcopy
         WHERE FY=?
             AND cardno=?');
     $args = array(FormLib::get('cash') + FormLib::get('retain'), FormLib::get('cash'), FormLib::get('retain'), FormLib::get('fy'), $this->id);
     $this->success = $dbc->execute($prep, $args);
     if ($this->success) {
         $pat = new PatronageModel($dbc);
         $pat->cardno($this->id);
         $pat->FY(FormLib::get('fy'));
         $number = GumLib::allocateCheck($patronage, false);
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $pat->check_number($number);
         $pat->save();
     }
     return true;
 }
 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;
 }