public function fetch_report_data() { global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB; $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']); $dt = FormLib::get('endDate', date('Y-m-d')); $dividends = new GumDividendsModel($dbc); $dividends->yearEndDate($dt); $map = new GumDividendPayoffMapModel($dbc); $check = new GumPayoffsModel($dbc); $data = array(); foreach ($dividends->find('card_no') as $dividend) { $record = array($dividend->card_no(), sprintf('%.2f', $dividend->equityAmount()), $dividend->daysHeld(), sprintf('%.2f%%', $dividend->dividendRate() * 100), sprintf('%.2f', $dividend->dividendAmount())); $checkID = false; $map->reset(); $map->gumDividendID($dividend->gumDividendID()); foreach ($map->find('gumPayoffID', true) as $obj) { $checkID = $obj->gumPayoffID(); } if (!$checkID) { $record[] = '?'; } else { $check->gumPayoffID($checkID); $check->load(); $record[] = $check->checkNumber(); } $data[] = $record; } return $data; }
public function get_id_dreceipt_did_handler() { global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB; $bridge = GumLib::getSetting('posLayer'); $this->custdata = $bridge::getCustdata($this->id); $this->meminfo = $bridge::getMeminfo($this->id); $uid = FannieAuth::getUID($this->current_user); // bridge may change selected database $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']); $model = new GumDividendsModel($dbc); $model->gumDividendID($this->did); $model->load(); $msg = 'Dear ' . $this->custdata->FirstName() . ' ' . $this->custdata->LastName() . ',' . "\n"; $msg .= "\n"; $msg .= 'Attached is a 1099 for the Class C dividend issued ' . date('Y-m-d', strtotime($model->yearEndDate())) . "\n"; $msg .= wordwrap('Whole Foods Co-op recognizes and thanks you for your support and purchase of Class C Stock. It is important that we maintain your current contact information so that we can deliver any dividends you may earn. Please reply to this email or to finance@wholefoods.coop with any questions or concerns. Or you may also call 218-728-0884, ask for Finance, and we will gladly assist you.') . "\n"; $msg .= "\n"; $msg .= 'Dale Maiers' . "\n"; $msg .= 'Finance Manager' . "\n"; $subject = 'SAMPLE WFC Owner Financing: Class C Stock Dividend'; $to = $this->meminfo->email_1(); $mail = new PHPMailer(); $mail->From = '*****@*****.**'; $mail->FromName = 'Whole Foods Co-op'; $mail->AddAddress('*****@*****.**'); $mail->AddAddress('*****@*****.**'); $mail->Subject = $subject; $mail->Body = $msg; $year = date('Y', strtotime($model->yearEndDate())); $taxID = new GumTaxIdentifiersModel($dbc); $taxID->card_no($this->id); $taxID->load(); $ssn = 'n/a'; if ($taxID->maskedTaxIdentifier() != '') { $ssn = 'xxx-xx-' . $taxID->maskedTaxIdentifier(); } $amount = array(1 => $model->dividendAmount()); $pdf = new FPDF('P', 'mm', 'Letter'); $pdf->AddPage(); $form = new GumTaxFormTemplate($this->custdata, $this->meminfo, $ssn, $year, $amount); $form->renderAsPDF($pdf, 15); $raw_pdf = $pdf->Output('wfc.pdf', 'S'); $mail->AddStringAttachment($raw_pdf, 'wfc.pdf', 'base64', 'application/pdf'); if ($mail->Send()) { header('Location: GumEmailPage.php?id=' . $this->id); } else { echo $mail->ErrorInfo; } return false; }
function post_confirmEndDate_confirmRate_handler() { global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB; $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']); $num_days = $this->fyLength($this->confirmEndDate); $info = $this->calculateHoldings($this->confirmEndDate); $model = new GumDividendsModel($dbc); foreach ($info as $cn => $shares) { foreach ($shares as $days => $value) { $model->reset(); $model->card_no($cn); $model->yearEndDate($this->confirmEndDate); $model->equityAmount($value); $model->daysHeld($days); $model->dividendRate($this->confirmRate / 100.0); $dividend = $value * ($this->confirmRate / 100.0) * ($days / (double) $num_days); $model->dividendAmount($dividend); $model->save(); } } header('Location: GumIssueDividendPage.php?done=1'); return false; }