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; }