예제 #1
1
 public function get_id_pdf_handler()
 {
     global $FANNIE_ROOT;
     if (!class_exists('FPDF')) {
         include $FANNIE_ROOT . 'src/fpdf/fpdf.php';
         define('FPDF_FONTPATH', 'font/');
     }
     $this->get_id_handler();
     // load models
     $loan_info = GumLib::loanSchedule($this->loan);
     $pdf = new FPDF('P', 'mm', 'Letter');
     $pdf->SetMargins(6.35, 6.35, 6.35);
     // quarter-inch margins
     $pdf->SetAutoPageBreak(false);
     $pdf->AddPage();
     $pdf->SetXY(0, 0);
     $pdf->Image('img/letterhead.png', null, null, 203);
     // scale to 8"
     $pdf->SetFont('Arial', '', 8);
     $line_height = 3.5;
     $pdf->SetXY(6.35, 43);
     $text = 'Pursuant to the terms of your Promissory Note with WFC, below please find a check for the principal and, as applicable, compound interest due.   A statement showing the terms of your loan and annual compounding of the interest thereon is provided. If your loan was for more than 0.00% interest, also below is an IRS form 1099-INT to be included with your ' . date('Y') . ' federal tax filing.  If you have questions regarding this payment, please contact Financial Manager Dale Maiers (dmaiers@wholefoods.coop).  Thank you very much for your support.';
     $pdf->Write($line_height, $text);
     $col_width = 40.64;
     $col1 = 6.35 + $col_width;
     $col2 = $col1 + $col_width;
     $col3 = $col2 + $col_width;
     $col4 = $col3 + $col_width;
     $table_y = 60;
     $pdf->SetFont('Arial', 'BU', 8);
     $pdf->SetXY($col1, $table_y);
     $pdf->Cell($col_width, $line_height, 'Ending Period', 0, 0, 'C');
     $pdf->SetXY($col2, $table_y);
     $pdf->Cell($col_width, $line_height, 'Days', 0, 0, 'C');
     $pdf->SetXY($col3, $table_y);
     $pdf->Cell($col_width, $line_height, 'Interest', 0, 0, 'R');
     $pdf->SetXY($col4, $table_y);
     $pdf->Cell($col_width, $line_height, 'Closing Balance', 0, 0, 'R');
     $pdf->SetFont('Arial', '', 8);
     $i = 0;
     for ($i = 0; $i < count($loan_info['schedule']); $i++) {
         $line_y = $table_y + ($i + 1) * $line_height;
         $pdf->SetXY($col1, $line_y);
         $pdf->Cell($col_width, $line_height, $loan_info['schedule'][$i]['end_date'], 0, 0, 'C');
         $pdf->SetXY($col2, $line_y);
         $pdf->Cell($col_width, $line_height, $loan_info['schedule'][$i]['days'], 0, 0, 'C');
         $pdf->SetXY($col3, $line_y);
         $pdf->Cell($col_width, $line_height, number_format($loan_info['schedule'][$i]['interest'], 2), 0, 0, 'R');
         $pdf->SetXY($col4, $line_y);
         $pdf->Cell($col_width, $line_height, number_format($loan_info['schedule'][$i]['balance'], 2), 0, 0, 'R');
     }
     $last_y = $table_y + ($i + 1) * $line_height;
     $pdf->SetFont('Arial', 'B', 8);
     $pdf->SetXY($col1, $last_y);
     $pdf->Cell($col_width, $line_height, 'Total', 0, 0, 'C');
     $pdf->SetXY($col2, $last_y);
     $pdf->Cell($col_width, $line_height, number_format($this->loan->principal(), 2), 0, 0, 'R');
     $pdf->SetXY($col3, $last_y);
     $pdf->Cell($col_width, $line_height, number_format($loan_info['total_interest'], 2), 0, 0, 'R');
     $pdf->SetXY($col4, $last_y);
     $pdf->Cell($col_width, $line_height, number_format($loan_info['balance'], 2), 0, 0, 'R');
     $pdf->SetFont('Arial', '', 8);
     $pdf->SetXY(6.35, $table_y);
     $pdf->SetFont('Arial', 'B', 8);
     $pdf->Cell($col_width, $line_height, 'Loan Amount', 0, 1, 'C');
     $pdf->SetFont('Arial', '', 8);
     $pdf->Cell($col_width, $line_height, number_format($this->loan->principal(), 2), 0, 1, 'C');
     $pdf->SetFont('Arial', 'B', 8);
     $pdf->Cell($col_width, $line_height, 'Term', 0, 1, 'C');
     $pdf->SetFont('Arial', '', 8);
     $pdf->Cell($col_width, $line_height, $this->loan->termInMonths() / 12 . ' Years', 0, 1, 'C');
     $pdf->SetFont('Arial', 'B', 8);
     $pdf->Cell($col_width, $line_height, 'Loan Date', 0, 1, 'C');
     $pdf->SetFont('Arial', '', 8);
     $pdf->Cell($col_width, $line_height, date('m/d/Y', strtotime($this->loan->loanDate())), 0, 1, 'C');
     $pdf->SetFont('Arial', 'B', 8);
     $pdf->Cell($col_width, $line_height, 'Interest Rate', 0, 1, 'C');
     $pdf->SetFont('Arial', '', 8);
     $pdf->Cell($col_width, $line_height, 100 * $this->loan->interestRate() . '%', 0, 1, 'C');
     $pdf->SetFont('Arial', 'B', 8);
     $pdf->Cell($col_width, $line_height, 'Maturity Date', 0, 1, 'C');
     $pdf->SetFont('Arial', '', 8);
     $ld = strtotime($this->loan->loanDate());
     $ed = mktime(0, 0, 0, date('n', $ld) + $this->loan->termInMonths(), date('j', $ld), date('Y', $ld));
     $pdf->Cell($col_width, $line_height, date('m/d/Y', $ed), 0, 1, 'C');
     $pdf->SetDrawColor(0, 0, 0);
     $pdf->Line(6.35, $table_y, 6.35 + $col_width, $table_y);
     $pdf->Line(6.35, $table_y, 6.35, $table_y + 10 * $line_height);
     $pdf->Line(6.35 + $col_width, $table_y, 6.35 + $col_width, $table_y + 10 * $line_height);
     $pdf->Line(6.35, $table_y + 10 * $line_height, 6.35 + $col_width, $table_y + 10 * $line_height);
     for ($i = 2; $i <= 8; $i += 2) {
         $pdf->Line(6.35, $table_y + $i * $line_height, 6.35 + $col_width, $table_y + $i * $line_height);
     }
     $fields = array(1 => $loan_info['total_interest']);
     $this->settings->key('storeStateID');
     if ($this->settings->load()) {
         $fields[12] = $this->settings->value();
     }
     $this->settings->key('storeState');
     if ($this->settings->load()) {
         $fields[11] = $this->settings->value();
     }
     $ssn = 'Unknown';
     if ($this->taxid->load()) {
         $ssn = 'xxx-xx-' . $this->taxid->maskedTaxIdentifier();
     }
     $form = new GumTaxFormTemplate($this->custdata, $this->meminfo, $ssn, date('Y'), $fields, $this->loan->accountNumber());
     $ret .= $form->renderAsPDF($pdf, 105);
     $check = new GumCheckTemplate($this->custdata, $this->meminfo, $loan_info['balance'], 'Loan Repayment', $this->check_info->checkNumber());
     $check->renderAsPDF($pdf);
     $pdf->Output('LoanPayoff.pdf', 'I');
     if (FormLib::get('issued') == '1') {
         $this->check_info->checkIssued(1);
         $this->check_info->issueDate(date('Y-m-d H:i:s'));
         $this->check_info->save();
     }
     return false;
 }
예제 #2
0
 public function get_id_pdf_handler()
 {
     global $FANNIE_ROOT;
     if (!class_exists('FPDF')) {
         include $FANNIE_ROOT . 'src/fpdf/fpdf.php';
         define('FPDF_FONTPATH', 'font/');
     }
     $this->get_id_handler();
     // load models
     $pdf = new FPDF('P', 'mm', 'Letter');
     $pdf->SetMargins(6.35, 6.35, 6.35);
     // quarter-inch margins
     $pdf->SetAutoPageBreak(false);
     $pdf->AddPage();
     $pdf->SetXY(0, 0);
     $pdf->Image('img/letterhead.png', null, null, 203);
     // scale to 8"
     $pdf->SetFont('Arial', '', 10);
     $line_height = 5;
     $pdf->SetXY(6.35, 50);
     $pdf->Write($line_height, 'Based on the terms of Wholefoods Community Coop Class C Stock you Payout Request has been received and approved by our Board of Directors. Please find attached a schedule of your most recent Class C activity as well as a check for the class C payout. Thank you for your continued support.');
     $pdf->Ln();
     $pdf->Ln();
     $y_pos = $pdf->GetY();
     $col_width = 30;
     $col1 = 60;
     $col2 = $col1 + $col_width;
     $col3 = $col2 + $col_width;
     $pdf->SetXY($col1, $y_pos);
     $pdf->Cell($col_width * 3, $line_height, 'Class C Schedule', 0, 0, 'C');
     $y_pos += $line_height;
     $pdf->SetXY($col1, $y_pos);
     $pdf->Cell($col_width, $line_height, 'Date', 0, 0, 'C');
     $pdf->SetXY($col2, $y_pos);
     $pdf->Cell($col_width, $line_height, 'Shares', 0, 0, 'C');
     $pdf->SetXY($col3, $y_pos);
     $pdf->Cell($col_width, $line_height, 'Total', 0, 0, 'C');
     $y_pos += $line_height;
     foreach ($this->all->find('tdate') as $obj) {
         $pdf->SetXY($col1, $y_pos);
         $pdf->Cell($col_width, $line_height, date('m/d/Y', strtotime($obj->tdate())), 0, 0, 'C');
         $pdf->SetXY($col2, $y_pos);
         $pdf->Cell($col_width, $line_height, $obj->shares(), 0, 0, 'C');
         $pdf->SetXY($col3, $y_pos);
         $pdf->Cell($col_width, $line_height, $obj->value(), 0, 0, 'C');
         $y_pos += $line_height;
         if ($obj->gumEquityShareID() == $this->id) {
             break;
         }
     }
     $check = new GumCheckTemplate($this->custdata, $this->meminfo, $this->payoff->value() * -1, 'Class C Payout', $this->check_info->checkNumber());
     $check->renderAsPDF($pdf);
     $pdf->Output('EquityPayoff.pdf', 'I');
     if (FormLib::get('issued') == '1') {
         $this->check_info->checkIssued(1);
         $this->check_info->issueDate(date('Y-m-d H:i:s'));
         $this->check_info->save();
     }
     return false;
 }
예제 #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
 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;
 }