private function getAccountForSubclass(Subclass $subclass, $operation) { $priorities = array(Account::PRIORITY_TRADITIONAL_IRA => 1, Account::PRIORITY_ROTH_IRA => 2, Account::PRIORITY_TAXABLE => 3); $factor = count($priorities); if ($subclass->isRothIraAccountType()) { $priorities[Account::PRIORITY_ROTH_IRA] -= $factor; } elseif ($subclass->isTraditionalIraAccountType()) { $priorities[Account::PRIORITY_TRADITIONAL_IRA] -= $factor; } elseif ($subclass->isTaxableAccountType()) { $priorities[Account::PRIORITY_TAXABLE] -= $factor; } $iterator = $this->getIterator(); $iterator->uasort(function ($a, $b) use($operation, $priorities) { $aPriority = $priorities[$a->getPriority()]; $bPriority = $priorities[$b->getPriority()]; if ($operation === 'sell') { return $aPriority > $bPriority ? -1 : 1; } else { return $aPriority < $bPriority ? -1 : 1; } }); $result = null; // If buy - get the first sorted by priority account if ($operation === 'buy') { $iterator->rewind(); /** @var Account $result */ $result = $iterator->current(); // If sell - get the sorted by priority account which contains subclass } elseif ($operation === 'sell') { $security = $subclass->getSecurity(); /** @var Account $account */ foreach ($iterator as $account) { if ($account->getSecurities()->containsKey($security->getId())) { $result = $account; break; } } } return $result; }
function batchDelete($p, $ids) { $c = new Subclass($this->db_conn); $i = 0; for ($i = 0; $i < count($ids); $i++) { $c->getData($ids[$i]); $c->delete(); } $this->gotoURL("subclass.php?action=list"); //$this->browse($p); }
function selects($vars) { $vars = $_GET; $s_array = array(); $c = new Subclass($this->db_conn); $p['cat_id'] = $vars['id']; $sublists = $c->getListArray($p); $result = count($sublists); $s_array[0]['id'] = ""; $s_array[0]['name_cht'] = "[請選擇]"; for ($i = 0; $i < $result; $i++) { //$s_array['id'] = $sublists[$i]['id']; //$s_array['name_cht'] = $sublists[$i]['name_cht']; $s_array[$i + 1]['id'] = $sublists[$i]['id']; $s_array[$i + 1]['name_cht'] = $sublists[$i]['name_cht']; //echo json_encode($s_array); } //$data = array("data"=>$s_array); //print_r($sublists[$i]['id']);return; echo json_encode($s_array); }
} if ($language == "") { $language = "tw"; } if ($template == "") { $template = "default"; } $id = $_GET['id']; $cat_id = $_GET['cat_id']; $sub_id = $_GET['sub_id']; /*--------------------------------左列表-------------------------------------*/ $category = new Category(); $p1 = array(); $cat_lists = $category->getListArray($p1); //all category content $subclass = new Subclass(); foreach ($cat_lists as $value) { $pp['cat_id'] = $value['id']; $subcontent[$pp['cat_id']] = $subclass->getListArray($pp); //include cat_id all subclass content //print_r($subcontent[0]['name_cht']); return; } #print_r($subcontent['44']); /*---------------------------------------------------------------------------*/ /*$b = new Category(); $p = array(); $clists = $b->getListArray($p); $s = new Subclass(); $p = array(); $p['cat_id'] = '37';