public function __construct($custdata, $meminfo, $tax_id, $tax_year, $fields, $account_number = '') { global $FANNIE_PLUGIN_SETTINGS; $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']); $settings = new GumSettingsModel($dbc); $this->tax_id = $tax_id; $this->tax_year = $tax_year; $this->fields = $fields; $this->account_number = $account_number; $this->their_address[] = $custdata->FirstName() . ' ' . $custdata->LastName(); $this->their_address[] = $meminfo->street(); $this->their_address[] = $meminfo->city() . ', ' . $meminfo->state() . ' ' . $meminfo->zip(); $settings->key('storeFederalID'); if ($settings->load()) { $this->my_federal_id = $settings->value(); } $settings->key('storeStateID'); if ($settings->load()) { $this->my_state_id = $settings->value(); } $this->my_address[0] = 'Name of Co-op'; $settings->key('storeName'); if ($settings->load()) { $this->my_address[0] = $settings->value(); } $this->my_address[1] = 'Street Address'; $settings->key('storeAddress'); if ($settings->load()) { $this->my_address[1] = $settings->value(); } $this->my_address[2] = ''; $settings->key('storeCity'); if ($settings->load()) { $this->my_address[2] .= $settings->value() . ', '; } else { $this->my_address[2] .= 'City, '; } $settings->key('storeState'); if ($settings->load()) { $this->my_address[2] .= $settings->value() . ' '; } else { $this->my_address[2] .= 'XX '; } $settings->key('storeZip'); if ($settings->load()) { $this->my_address[2] .= $settings->value(); } else { $this->my_address[2] .= '12345'; } $this->my_address[3] = '555-867-5309'; $settings->key('storePhone'); if ($settings->load()) { $this->my_address[3] = $settings->value(); } }
public function post_keys_values_handler() { global $FANNIE_PLUGIN_SETTINGS; $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']); $model = new GumSettingsModel($dbc); for ($i = 0; $i < count($this->keys); $i++) { if (!isset($this->values[$i])) { continue; } $model->key($this->keys[$i]); $model->value($this->values[$i]); $model->save(); } header('Location: GumSettingsPage.php'); return false; }
/** Get value for a given setting @param $key [string] setting key @param $default [string] value to use if setting is missing @return [string] setting value or $default */ public static function getSetting($key, $default = '') { global $FANNIE_PLUGIN_SETTINGS; $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']); $s = new GumSettingsModel($dbc); $s->key($key); if ($s->load()) { return $s->value(); } else { return $default; } }
public function __construct($custdata, $meminfo, $amount, $memo = '', $check_number = false, $date = false) { global $FANNIE_PLUGIN_SETTINGS; $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']); $settings = new GumSettingsModel($dbc); if (!$date) { $this->check_date = date('m/d/Y'); } else { $this->check_date = $date; } $this->memo = $memo; $this->check_number = $check_number; $this->amount = $amount; $dollars = floor($amount); $cents = round(($amount - $dollars) * 100); $nf = new NumberFormatter('en_US', NumberFormatter::SPELLOUT); $this->amount_as_words = ucwords($nf->format($dollars)) . ' And ' . str_pad($cents, 2, '0', STR_PAD_LEFT) . '/100'; $this->their_address[] = $custdata->FirstName() . ' ' . $custdata->LastName(); if (strstr($meminfo->street(), "\n")) { foreach (explode("\n", $meminfo->street()) as $line) { $this->their_address[] = $line; } } else { $this->their_address[] = $meminfo->street(); } $this->their_address[] = $meminfo->city() . ', ' . $meminfo->state() . ' ' . $meminfo->zip(); $settings->key('routingNo'); if ($settings->load()) { $this->routing_no = $settings->value(); } $settings->key('checkingNo'); if ($settings->load()) { $this->checking_no = $settings->value(); } $this->my_address[0] = 'Name of Co-op'; $settings->key('storeName'); if ($settings->load()) { $this->my_address[0] = $settings->value(); } $this->my_address[1] = 'Street Address'; $settings->key('storeAddress'); if ($settings->load()) { $this->my_address[1] = $settings->value(); } $this->my_address[2] = ''; $settings->key('storeCity'); if ($settings->load()) { $this->my_address[2] .= $settings->value() . ', '; } else { $this->my_address[2] .= 'City, '; } $settings->key('storeState'); if ($settings->load()) { $this->my_address[2] .= $settings->value() . ' '; } else { $this->my_address[2] .= 'XX '; } $settings->key('storeZip'); if ($settings->load()) { $this->my_address[2] .= $settings->value(); } else { $this->my_address[2] .= '12345'; } $this->my_address[3] = 'Tel: 555-867-5309'; $settings->key('storePhone'); if ($settings->load()) { $this->my_address[3] = 'Tel: ' . $settings->value(); } }
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; }
public function settingChange() { global $FANNIE_ROOT, $FANNIE_PLUGIN_SETTINGS; $db_name = $FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']; if (empty($db_name)) { return; } $dbc = FannieDB::get($db_name); $tables = array('GumEquityShares', 'GumLoanAccounts', 'GumLoanDefaultInterestRates', 'GumLoanLedger', 'GumLoanValidTerms', 'GumSettings', 'GumTaxIdentifiers', 'GumPayoffs', 'GumEquityPayoffMap', 'GumLoanPayoffMap', 'GumEmailLog', 'GumDividends', 'GumDividendPayoffMap'); foreach ($tables as $t) { $model_class = $t . 'Model'; if (!class_exists($model_class)) { include_once dirname(__FILE__) . '/models/' . $model_class . '.php'; } if (!$dbc->tableExists($t)) { $instance = new $model_class($dbc); $instance->create(); } } $settings = new GumSettingsModel($dbc); /** Employee # used for writing any POS transactions */ $settings->key('emp_no'); if (!$settings->load()) { $settings->value(1001); $settings->save(); } /** Register # used for writing any POS transactions */ $settings->reset(); $settings->key('register_no'); if (!$settings->load()) { $settings->value(99); $settings->save(); } /** $ value of one equity share */ $settings->reset(); $settings->key('equityShareSize'); if (!$settings->load()) { $settings->value(500.0); $settings->save(); } /** Department # for equity-related POS transactions */ $settings->reset(); $settings->key('equityPosDept'); if (!$settings->load()) { $settings->value(993); $settings->save(); } /** Department description for equity-related POS transactions (could probably be pulled from department table instead; guaranteeing a description even if the department doesn't exist may make debugging easier if the department # is misconfigured). */ $settings->reset(); $settings->key('equityDescription'); if (!$settings->load()) { $settings->value('Class C Stock'); $settings->save(); } /** Department # for equity-related POS transactions */ $settings->reset(); $settings->key('loanPosDept'); if (!$settings->load()) { $settings->value(998); $settings->save(); } /** Department description for loan-related POS transactions See equityDescription for justification. */ $settings->reset(); $settings->key('loanDescription'); if (!$settings->load()) { $settings->value('Member Loan'); $settings->save(); } /** Department # for balancing transactions Transactions are written as: $X.XX to loan/equity department -$X.XX to offset department This ensures transactions net to zero. It also allows tender to occur at a different time/place without leaving any transaction half-complete. The tender transaction would (probably) be: $X.XX to offset department -$X.XX tender type */ $settings->reset(); $settings->key('offsetPosDept'); if (!$settings->load()) { $settings->value(800); $settings->save(); } /** Month the fiscal year ends (typically 6 or 12) */ $settings->reset(); $settings->key('FYendMonth'); if (!$settings->load()) { $settings->value(6); $settings->save(); } /** Day the fiscal year ends (typically 30 or 31) */ $settings->reset(); $settings->key('FYendDay'); if (!$settings->load()) { $settings->value(30); $settings->save(); } /** The store's federal tax identification number. Only needed for tax forms. */ $settings->reset(); $settings->key('storeFederalID'); if (!$settings->load()) { $settings->value('12-1234567'); $settings->save(); } /** The store's state tax identification number. Only needed for tax forms. */ $settings->reset(); $settings->key('storeStateID'); if (!$settings->load()) { $settings->value('1234567'); $settings->save(); } /** The store's name (or DBA name) Used for address blocks */ $settings->reset(); $settings->key('storeName'); if (!$settings->load()) { $settings->value('Name of Co-op / DBA'); $settings->save(); } /** The store's street address Multi-line street address is not permitted because vertical spacing is often tight. Some tax forms also *require* a single line street address. Use comma separation as needed. Used for address blocks */ $settings->reset(); $settings->key('storeAddress'); if (!$settings->load()) { $settings->value('Street Address'); $settings->save(); } /** The store's city Used for address blocks */ $settings->reset(); $settings->key('storeCity'); if (!$settings->load()) { $settings->value('Anytown'); $settings->save(); } /** The store's state (or equivalent) Used for address blocks */ $settings->reset(); $settings->key('storeState'); if (!$settings->load()) { $settings->value('XX'); $settings->save(); } /** The store's zip code (or equivalent) Used for address blocks */ $settings->reset(); $settings->key('storeZip'); if (!$settings->load()) { $settings->value('12345'); $settings->save(); } /** The store's phone number Used for [some] address blocks */ $settings->reset(); $settings->key('storePhone'); if (!$settings->load()) { $settings->value('555-867-5309'); $settings->save(); } /** The store's checking account routing # Used for creating checks */ $settings->reset(); $settings->key('routingNo'); if (!$settings->load()) { $settings->value('123456789'); $settings->save(); } /** The store's checking account # Used for creating checks */ $settings->reset(); $settings->key('checkingNo'); if (!$settings->load()) { $settings->value('987654321987'); $settings->save(); } /** The first check number to use when creating checks. The plugin will use check numbers sequentially starting from this value */ $settings->reset(); $settings->key('firstCheckNumber'); if (!$settings->load()) { $settings->value('1'); $settings->save(); } /** Zero-pad check numbers to this many digits. Six is the default. */ $settings->reset(); $settings->key('checkNumberPadding'); if (!$settings->load()) { $settings->value('6'); $settings->save(); } /** POS interaction interface */ $settings->reset(); $settings->key('posLayer'); if (!$settings->load()) { $settings->value('GumCoreLayer'); $settings->save(); } }