static public function retrieveByClient($status, $client_id = null) { //echo $status; $types= array('all','sell','purchase','switch'); $statuses= array('all','pending','completed','cancelled'); if(!in_array($status,$statuses)) if(!in_array($status,$types)) die('Wrong status when getting transfer collection!'); $IsTypeOriented = in_array($status,$statuses) ? false: true; if(!$client_id) die('Should add case for all clients!'); $transactions= array(); if($IsTypeOriented) $addition = ($status!= 'all') ? " AND types = '$status'" : ""; else $addition = ($status!= 'all') ? " AND status = '$status'" : ""; $query = " SELECT t.id, t.created_at, t.comment, a.name aname, i.fund_name name, i.ISIN code, t.status, t.types, t.amount, t.trade_date, t.settlement_date FROM transfers t, custody_ac a, fund i WHERE t.id_client = '$client_id' AND a.id = t.id_custody1 AND i.id = t.id_isin $addition "; $qres=mysql_query($query) or die(mysql_error()); while($row=mysql_fetch_assoc($qres)) { $transfer = new Transfer(); $transfer->setId($row['id']); $transfer->setStatus($row['status']); $transfer->setType($row['types']); $transfer->setComment($row['comment']); $transfer->setSecurity($row['name']); $transfer->setAmount($row['amount']); $transfer->setIsin($row['code']); $transfer->setTradeDate($row['trade_date']); $transfer->setSettlementDate($row['settlement_date']); $transfer->setAccount($row['aname']); $transfer->setCreatedAt($row['created_at']); $transfers[] = $transfer; } return $transfers; }