コード例 #1
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;
 }
コード例 #2
0
ファイル: GumEquityPayoffPage.php プロジェクト: phpsmith/IS4C
 public function get_id_handler()
 {
     global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']);
     $this->payoff = new GumEquitySharesModel($dbc);
     $this->payoff->gumEquityShareID($this->id);
     if (!$this->payoff->load()) {
         echo _('Error: payoff') . ' #' . $this->id . ' ' . _('does not exist');
         return false;
     }
     $this->all = new GumEquitySharesModel($dbc);
     $this->all->card_no($this->payoff->card_no());
     $bridge = GumLib::getSetting('posLayer');
     $this->custdata = $bridge::getCustdata($this->payoff->card_no());
     $this->meminfo = $bridge::getMeminfo($this->payoff->card_no());
     // bridge may change selected database
     $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']);
     $this->taxid = new GumTaxIdentifiersModel($dbc);
     $this->taxid->card_no($this->payoff->card_no());
     $this->check_info = new GumPayoffsModel($dbc);
     $map = new GumEquityPayoffMapModel($dbc);
     $map->gumEquityShareID($this->id);
     $payoff_id = false;
     foreach ($map->find('gumPayoffID', true) as $obj) {
         // get highest matching ID
         $payoff_id = $obj->gumPayoffID();
         break;
     }
     // none found, allocate new check
     if ($payoff_id === false) {
         $payoff_id = GumLib::allocateCheck($map);
         if ($payoff_id) {
             $this->check_info->gumPayoffID($payoff_id);
             $this->check_info->amount(-1 * $this->payoff->value());
             $this->check_info->issueDate(date('Y-m-d'));
             $this->check_info->save();
             $this->check_info->load();
         }
     } else {
         $this->check_info->gumPayoffID($payoff_id);
         $this->check_info->load();
     }
     $this->settings = new GumSettingsModel($dbc);
     return true;
 }
コード例 #3
0
 function post_printFY_handler()
 {
     global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB, $FANNIE_ROOT;
     $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']);
     if (!class_exists('FPDF')) {
         include $FANNIE_ROOT . 'src/fpdf/fpdf.php';
         define('FPDF_FONTPATH', 'font/');
     }
     $pdf = new FPDF('P', 'mm', 'Letter');
     $pdf->SetMargins(6.35, 6.35, 6.35);
     // quarter-inch margins
     $pdf->SetAutoPageBreak(false);
     $key = FormLib::get('key');
     $privkey = false;
     if ($key) {
         $privkey = openssl_pkey_get_private($key);
     }
     $map = new GumDividendPayoffMapModel($dbc);
     $bridge = GumLib::getSetting('posLayer');
     $dividends = new GumDividendsModel($dbc);
     $dividends->yearEndDate($this->printFY);
     $acc = array();
     $prevCN = -1;
     $combined = array();
     foreach ($dividends->find('card_no') as $dividend) {
         if (!isset($combined[$dividend->card_no()])) {
             $combined[$dividend->card_no()] = array();
         }
         $combined[$dividend->card_no()][] = $dividend;
     }
     foreach ($combined as $card_no => $acc) {
         if (!empty($acc)) {
             $ttl = 0.0;
             // roll up totals to a single amount
             foreach ($acc as $a) {
                 $ttl += $a->dividendAmount();
             }
             // lookup check
             $map->reset();
             $map->gumDividendID($acc[0]->gumDividendID());
             $checkID = false;
             foreach ($map->find('gumPayoffID', true) as $obj) {
                 $checkID = $obj->gumPayoffID();
                 break;
             }
             if ($checkID) {
                 $check = new GumPayoffsModel($dbc);
                 $check->gumPayoffID($checkID);
                 $check->load();
             } else {
                 // allocate a new check if needed
                 $checkID = GumLib::allocateCheck($map);
                 $check = new GumPayoffsModel($dbc);
                 $check->gumPayoffID($checkID);
                 $check->load();
                 $check->amount($ttl);
                 $check->save();
                 // map rolled up dividends to same check
                 foreach ($acc as $a) {
                     $map->gumDividendID($a->gumDividendID());
                     $map->gumPayoffID($checkID);
                     $map->save();
                 }
             }
             $pdf->AddPage();
             $custdata = $bridge::getCustdata($card_no);
             $meminfo = $bridge::getMeminfo($card_no);
             // bridge may change selected database
             $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']);
             $this->taxid = new GumTaxIdentifiersModel($dbc);
             $this->taxid->card_no($custdata->CardNo());
             $ssn = 'Unknown';
             if ($this->taxid->load()) {
                 $ssn = 'xxx-xx-' . $this->taxid->maskedTaxIdentifier();
                 if ($privkey) {
                     $try = openssl_private_decrypt($this->taxid->encryptedTaxIdentifier(), $decrypted, $privkey);
                     if ($try) {
                         $ssn = $decrypted;
                     }
                 }
             }
             $form = new GumTaxDividendFormTemplate($custdata, $meminfo, $ssn, date('Y'), array(1 => sprintf('%.2f', $ttl)));
             $ret .= $form->renderAsPDF($pdf, 105);
             $template = new GumCheckTemplate($custdata, $meminfo, $ttl, 'Dividend Payment', $check->checkNumber());
             $template->renderAsPDF($pdf);
             $check->checkIssued(1);
             $check->issueDate(date('Y-m-d H:i:s'));
             $check->save();
             $pdf->Image('img/new_letterhead.png', 10, 10, 35);
             if (!isset($pdf->fonts['gillsansmtpro-book'])) {
                 $pdf->AddFont('GillSansMTPro-Book', '', 'GillSansMTPro-Book.php');
             }
             $pdf->SetFont('GillSansMTPro-Book', '', 11);
             $l = 55;
             $pdf->SetXY($l, 20);
             $pdf->Cell(0, 5, date('j F Y'), 0, 1);
             $pdf->Ln(5);
             $pdf->SetX($l);
             $pdf->Cell(0, 5, 'Dear Owner:', 0, 1);
             $pdf->Ln(2);
             $pdf->SetX($l);
             $pdf->MultiCell(135, 5, 'Based on the Co-op\'s profitability in Fiscal Year 2015 (July 1, 2014-June 30, 2015), the Board of Directors approved a four percent (4%) dividend on your Class C equity investment. Your dividend is pro-rated based on when you made your investment during that fiscal year. As this check represents an annual return on your investment, the amount cannot be compounded.');
             $pdf->Ln(2);
             $pdf->SetX($l);
             $pdf->MultiCell(135, 5, 'You are welcome to cash your check toward a purchase at the Co-op. Thank you for investing in Whole Foods Co-op');
             $pdf->Ln(4);
             $pdf->SetX($l);
             $pdf->Cell(0, 5, 'Thank you,', 0, 1);
             $pdf->Ln(4);
             $pdf->SetX($l);
             $pdf->Cell(0, 5, 'Sharon Murphy', 0, 1);
             $pdf->Ln(2);
             $pdf->SetX($l);
             $pdf->Cell(0, 5, 'General Manager', 0, 1);
         }
     }
     $pdf->Output('Dividends.pdf', 'I');
     return false;
 }
コード例 #4
-1
ファイル: PatronageChecks.php プロジェクト: phpsmith/IS4C
 public function post_handler()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $fy = FormLib::get('fy');
     $per_page = FormLib::get('per_page');
     $custdata = new CustdataModel($dbc);
     $meminfo = new MeminfoModel($dbc);
     $query = $dbc->prepare('
         SELECT p.cardno,
             p.cash_pat,
             m.zip,
             p.check_number
         FROM patronage AS p
             INNER JOIN meminfo AS m ON p.cardno=m.card_no
             INNER JOIN custdata AS c ON p.cardno=c.CardNo AND c.personNum=1
         WHERE p.FY=?
         ORDER BY m.zip,
             c.LastName,
             c.FirstName');
     $result = $dbc->execute($query, array($fy));
     $pdf = new FPDF('P', 'mm', 'Letter');
     $pdf->SetMargins(6.35, 6.35, 6.35);
     // quarter-inch margins
     $pdf->SetAutoPageBreak(false);
     $filename = '';
     $this->files = array();
     $filenumber = 1;
     set_time_limit(0);
     while ($w = $dbc->fetch_row($result)) {
         if (empty($filename)) {
             $filename = $filenumber . '-' . substr($w['zip'], 0, 5);
         }
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $custdata->CardNo($w['cardno']);
         $custdata->personNum(1);
         $custdata->load();
         $meminfo->card_no($w['cardno']);
         $meminfo->load();
         if ($w['check_number'] == '') {
             $patronage = new PatronageModel($dbc);
             $patronage->cardno($w['cardno']);
             $patronage->FY($fy);
             $number = GumLib::allocateCheck($patronage, false);
             $dbc = FannieDB::get($FANNIE_OP_DB);
             $patronage->check_number($number);
             $patronage->save();
             $w['check_number'] = $number;
         }
         $pdf->AddPage();
         $pdf->Image('rebate_body.png', 10, 0, 190);
         $check = new GumCheckTemplate($custdata, $meminfo, $w['cash_pat'], 'Rebate ' . $fy, $w['check_number']);
         $check->renderAsPDF($pdf);
         if ($pdf->PageNo() == $per_page) {
             $filename .= '-' . substr($w['zip'], 0, 5) . '.pdf';
             $filenumber++;
             $pdf->Output('/tmp/' . $filename, 'F');
             $this->files[] = $filename;
             $filename = '';
             $pdf = new FPDF('P', 'mm', 'Letter');
             $pdf->SetMargins(6.35, 6.35, 6.35);
             // quarter-inch margins
             $pdf->SetAutoPageBreak(false);
         }
     }
     $filename .= '-End.pdf';
     $pdf->Output('/tmp/' . $filename, 'F');
     $this->files[] = $filename;
     return true;
 }