public function get_id_creceipt_cid_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']); $msg = 'Dear ' . $this->custdata->FirstName() . ' ' . $this->custdata->LastName() . ',' . "\n"; $msg .= "\n"; $msg .= 'Class C Stock Purchase Receipt:' . "\n"; $msg .= "\n"; $model = new GumEquitySharesModel($dbc); $model->gumEquityShareID($this->cid); $model->load(); $spacer = str_repeat(' ', 6); $msg .= $spacer . 'Owner Number: ' . $this->id . "\n"; $msg .= $spacer . 'Date/Time: ' . $model->tdate() . "\n"; $msg .= $spacer . 'No. of Shares: ' . $model->shares() . "\n"; $msg .= $spacer . 'Purchase Amount: $' . number_format($model->value(), 2) . "\n"; $msg .= "\n"; $model->reset(); $model->card_no($this->id); $shares = 0; $value = 0; $purchases = 0; foreach ($model->find() as $obj) { $shares += $obj->shares(); $value += $obj->value(); if ($shares > 0) { $purchases++; } } if ($purchases > 1) { $msg .= 'Total Class C Stock Owned:' . "\n"; $msg .= $spacer . 'No. of Shares: ' . $shares . "\n"; $msg .= $spacer . 'Value of Shares: $' . number_format($value, 2) . "\n"; $msg .= "\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 = 'WFC Owner Financing: Class C Stock Receipt'; $to = $this->meminfo->email_1(); $headers = 'From: Whole Foods Co-op <*****@*****.**>' . "\r\n" . 'Reply-To: finance@wholefoods.coop' . "\r\n"; $log = new GumEmailLogModel($dbc); $log->card_no($this->id); $log->tdate(date('Y-m-d H:i:s')); $log->uid($uid); $log->messageType('Equity Receipt (' . $this->cid . ')'); if (FormLib::get('sendAs') == 'print') { echo '<pre>' . $msg . '</pre>'; return false; } else { if (mail($to, $subject, $msg, $headers)) { $log->save(); header('Location: GumEmailPage.php?id=' . $this->id); } else { echo 'Error: unable to send email. Notify IT'; } } return false; }
public function post_id_shares_type_handler() { global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB, $FANNIE_URL; $bridge = GumLib::getSetting('posLayer'); $meminfo = $bridge::getMeminfo($this->id); $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']); $settings = new GumSettingsModel($dbc); $settings->key('equityShareSize'); $settings->load(); if ($this->shares != 0) { $model = new GumEquitySharesModel($dbc); $model->card_no($this->id); $bal = 0.0; foreach ($model->find() as $obj) { $bal += $obj->value(); } if (strtolower($this->type) == 'payoff') { $this->shares *= -1; } $model->shares($this->shares); $model->value($this->shares * $settings->value()); $model->tdate(date('Y-m-d H:i:s')); // payoff cannot exceed balance if ($model->value() > 0 || $model->value() < 0 && abs($model->value()) <= $bal) { $newid = $model->save(); // share purchase & email exists // use curl to call email page's request handler if ($this->shares > 0 && $meminfo->email_1() != '') { $url = 'http://localhost' . $FANNIE_URL . 'modules/plugins2.0/GiveUsMoneyPlugin/GumEmailPage.php?id=' . $this->id . '&creceipt=1&cid=' . $newid; $handle = curl_init($url); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($handle); curl_close($handle); } $model->gumEquityShareID($newid); $model->load(); $emp = GumLib::getSetting('emp_no', 1001); $reg = GumLib::getSetting('register_no', 30); $dept = GumLib::getSetting('equityPosDept', 993); $desc = GumLib::getSetting('equityDescription', 'Class C Stock'); $offset = GumLib::getSetting('offsetPosDept', 800); $bridge = GumLib::getSetting('posLayer', 'GumCoreLayer'); if (class_exists($bridge)) { $line1 = array('department' => $dept, 'description' => $desc, 'amount' => $model->value(), 'card_no' => $model->card_no()); $line2 = array('department' => $offset, 'description' => 'OFFSET ' . $desc, 'amount' => -1 * $model->value(), 'card_no' => $model->card_no()); $trans_identifier = $bridge::writeTransaction($emp, $reg, array($line1, $line2)); if ($trans_identifier !== true && $trans_identifier !== false) { $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']); $model->trans_num($trans_identifier); $model->save(); } } } } header('Location: GumMainPage.php?id=' . $this->id); return false; }