示例#1
0
 public function getWalletType($market_id)
 {
     //get info market
     $market_default = Market::find($market_id);
     if (isset($market_default->id)) {
         $wallet_from = $market_default->wallet_from;
         $wallet_to = $market_default->wallet_to;
         $wallet = new Wallet();
         $from = $wallet->getType($wallet_from);
         $to = $wallet->getType($wallet_to);
         return array('id' => $market_id, 'wallet_from' => $from, 'wallet_to' => $to);
     }
     return array();
 }
示例#2
0
 public function addTradeHistory($trade_history)
 {
     $this->seller_id = $trade_history['seller_id'];
     $this->buyer_id = $trade_history['buyer_id'];
     $this->amount = $trade_history['amount'];
     $this->price = $trade_history['price'];
     $this->market_id = $trade_history['market_id'];
     $this->type = $trade_history['type'];
     $this->fee_buy = $trade_history['fee_buy'];
     $this->fee_sell = $trade_history['fee_sell'];
     $this->save();
     if ($this->id) {
         require_once app_path() . '/libraries/Pusher.php';
         $setting = new Setting();
         $pusher_app_id = $setting->getSetting('pusher_app_id', '');
         $pusher_app_key = $setting->getSetting('pusher_app_key', '');
         $pusher_app_secret = $setting->getSetting('pusher_app_secret', '');
         if ($pusher_app_id != '' && $pusher_app_key != '' && $pusher_app_secret != '') {
             $pusher = new Pusher($pusher_app_key, $pusher_app_secret, $pusher_app_id);
             $wallet = new Wallet();
             $market = Market::where('id', $this->market_id)->first();
             $from = strtoupper($wallet->getType($market->wallet_from));
             $to = strtoupper($wallet->getType($market->wallet_to));
             $message = array('channel' => 'trade.' . $this->market_id, 'trade' => array('timestamp' => strtotime($this->created_at), 'datetime' => date("Y-m-d H:i:s T", strtotime($this->created_at)), 'marketid' => $this->market_id, 'marketname' => $from . '/' . $to, 'amount' => sprintf("%.8f", $this->amount), 'price' => sprintf("%.8f", $this->price), 'total' => sprintf("%.8f", $this->amount * $this->price), 'type' => $this->type));
             $pusher->trigger('trade.' . $this->market_id, 'message', $message);
         }
         if (!$setting->getSetting('disable_points', 0)) {
             //Cong point cho nguoi mua va nguoi da gioi thieu ho
             $points = new PointsController();
             if ($this->fee_buy > 0) {
                 $points->addPointsTrade($this->buyer_id, $this->fee_buy, $this->id, $market->wallet_to);
             }
             //Cong point cho nguoi ban va nguoi da gioi thieu ho
             if ($this->fee_sell > 0) {
                 $points->addPointsTrade($this->seller_id, $this->fee_sell, $this->id, $market->wallet_to);
             }
         }
     }
     return $this->id;
 }
示例#3
0
 public function triggerPusherTicket($market_id)
 {
     require_once app_path() . '/libraries/Pusher.php';
     $setting = new Setting();
     $pusher_app_id = $setting->getSetting('pusher_app_id', '');
     $pusher_app_key = $setting->getSetting('pusher_app_key', '');
     $pusher_app_secret = $setting->getSetting('pusher_app_secret', '');
     if ($pusher_app_id != '' && $pusher_app_key != '' && $pusher_app_secret != '') {
         $pusher = new Pusher($pusher_app_key, $pusher_app_secret, $pusher_app_id);
         $wallet = new Wallet();
         $market = Market::where('id', $market_id)->first();
         $from = strtoupper($wallet->getType($market->wallet_from));
         $to = strtoupper($wallet->getType($market->wallet_to));
         $order = new Order();
         $buyHighest = $order->getBuyHighest($market_id);
         $sellLowest = $order->getSellLowest($market_id);
         $topsell = array('price' => 0, 'amount' => 0);
         $topbuy = array('price' => 0, 'amount' => 0);
         if (count($sellLowest) > 0) {
             $topsell = array('amount' => sprintf("%.8f", $sellLowest->from_value), 'price' => sprintf("%.8f", $sellLowest->price));
         }
         if (count($buyHighest) > 0) {
             $topbuy = array('amount' => sprintf("%.8f", $buyHighest->from_value), 'price' => sprintf("%.8f", $buyHighest->price));
         }
         $message = array('channel' => 'ticker.' . $market_id, 'trade' => array('timestamp' => time(), 'datetime' => date("Y-m-d H:i:s T", time()), 'marketid' => $market_id, 'marketname' => $from . '/' . $to, 'topsell' => $topsell, 'topbuy' => $topbuy));
         $pusher->trigger('ticker.' . $market_id, 'message', $message);
     }
 }
示例#4
0
 public function index($market_id = '')
 {
     $setting = new Setting();
     $wallet = new Wallet();
     $m = Market::where('active', 1)->orderBy('id')->first();
     if ($market_id == '') {
         $market_id = $setting->getSetting('default_market', $m->id);
     }
     Session::put('market_id', $market_id);
     $market_default = Market::find($market_id);
     if (!isset($market_default->active) || $market_default->active == 0) {
         //$setting->setSetting('default_market',$m->id);
         return Redirect::to('market/' . $m->id);
     }
     $wallet_from = $market_default->wallet_from;
     $wallet_to = $market_default->wallet_to;
     $from = strtoupper($wallet->getType($wallet_from));
     $to = strtoupper($wallet->getType($wallet_to));
     //get limit amount
     $limit_day = WalletTimeLimitTrade::select('limit_amount')->where('wallet_id', $wallet_to)->where('time_limit', 'per day')->first();
     if (isset($limit_day)) {
         $data['limit_day'] = $limit_day->limit_amount;
     } else {
         $data['limit_day'] = 1000;
     }
     $limit_week = WalletTimeLimitTrade::select('limit_amount')->where('wallet_id', $wallet_to)->where('time_limit', 'per week')->first();
     if (isset($limit_week)) {
         $data['limit_week'] = $limit_week->limit_amount;
     } else {
         $data['limit_week'] = 1000;
     }
     //get amount : day
     $user = Confide::user();
     if (isset($user)) {
         $uid = $user->id;
         $select = "SELECT sum(t.to_value) as sumamount from orders t, market m where m.id=t.market_id and m.wallet_to=" . $wallet_to . " and t.user_id=" . $uid . " and t.created_at='" . date("Y-m-d") . "'";
         $selectsum = DB::select($select);
         $sumamount = $selectsum[0]->sumamount;
         $data['amount_sum_day'] = $sumamount;
     }
     if (!isset($data['amount_sum_day'])) {
         $data['amount_sum_day'] = 0;
     }
     //echo 'aaaaaaaaaaa:'; print_r($data['amount_sum_day']);
     //get name of wallet
     $wallet1 = Wallet::where('id', $wallet_from)->first();
     $wallet2 = Wallet::where('id', $wallet_to)->first();
     $data['market_from'] = $wallet1->name;
     $data['market_to'] = $wallet2->name;
     $data['coinmain'] = $from;
     $data['coinsecond'] = $to;
     //get balance
     $balance = new Balance();
     $data['balance_coinmain'] = sprintf('%.8f', $balance->getBalance($wallet_from, 0));
     $data['balance_coinsecond'] = sprintf('%.8f', $balance->getBalance($wallet_to, 0));
     //get Sell Lowest
     $data['sell_lowest'] = sprintf('%.8f', 0);
     $data['buy_highest'] = sprintf('%.8f', 0);
     $order = new Order();
     $sell_lowest = $order->getSellLowest($market_id);
     $buy_highest = $order->getBuyHighest($market_id);
     if (isset($sell_lowest->price)) {
         $data['sell_lowest'] = sprintf('%.8f', $sell_lowest->price);
     }
     if (isset($buy_highest->price)) {
         $data['buy_highest'] = sprintf('%.8f', $buy_highest->price);
     }
     //fee_buy, fee_sell
     $fee_trade = new FeeTrade();
     $fee = $fee_trade->getFeeTrade($market_id);
     $data['fee_buy'] = $fee['fee_buy'];
     $data['fee_sell'] = $fee['fee_sell'];
     //get list orders
     $num_transaction_display = $setting->getSetting('num_transaction_display', 0);
     $list_sell_orders = $order->getOrders($market_id, 'sell', $num_transaction_display);
     $list_buy_orders = $order->getOrders($market_id, 'buy', $num_transaction_display);
     $data['sell_orders'] = $list_sell_orders;
     $data['buy_orders'] = $list_buy_orders;
     //get all history
     $trade_history = Trade::where('market_id', '=', $market_id)->orderBy('created_at', 'desc')->take($num_transaction_display)->get();
     $data['trade_history'] = $trade_history;
     $data['market_id'] = $market_id;
     $current_orders_user = $order->getCurrentOrdersUser($market_id);
     if ($current_orders_user) {
         $data['current_orders_user'] = $current_orders_user;
     }
     $trade = new Trade();
     $datachart = $trade->getDatasChart($market_id, '6 hour');
     $news = Post::where('type', 'news')->take(5)->orderby('created_at', 'desc')->get();
     $data['news'] = $news;
     //price
     $data_price = $trade->getBlockPrice($market_id);
     $data["get_prices"] = $data_price['get_prices'];
     $data['lastest_price'] = $data_price['lastest_price'];
     //limit trade amount
     $limit_trade = WalletLimitTrade::where('wallet_id', $wallet_from)->first();
     if ($limit_trade) {
         $data['limit_trade'] = $limit_trade->toArray();
     } else {
         $data['limit_trade'] = array('min_amount' => 0.0001, 'max_amount' => 1000);
     }
     //get data for block statistic
     $btc_wallet = Wallet::where('type', 'BTC')->first();
     $ltc_wallet = Wallet::where('type', 'LTC')->first();
     $btc_markets = array();
     $ltc_markets = array();
     //btc market on sidebar left
     $all_market_btc = array();
     if (isset($btc_wallet->id)) {
         $btc_markets = Market::leftJoin('wallets', 'market.wallet_from', '=', 'wallets.id')->select('market.*', 'wallets.name', 'wallets.type')->where('wallet_to', $btc_wallet->id)->orderby('wallets.type')->get();
         $btc_datainfo = array();
         foreach ($btc_markets as $value) {
             $all_market_btc[] = $value->id;
             $btc_datainfo[$value->id] = Trade::where('market_id', $value->id)->orderby('created_at', 'desc')->take(2)->get()->toArray();
             //      	$total_btc = DB::table('trade_history')->select(DB::raw('SUM( amount * price ) AS total'))
             //                  ->where('market_id', '=', $value->id)->first();
             //              //echo "<pre>total_btc: "; print_r($total_btc); echo "</pre>";
             //              //echo "<pre>getQueryLog: ".dd(DB::getQueryLog())."</pre>";
             // if(isset($total_btc->total))
             // 	$ltc_datainfo[$value->id]['total'] = $total_btc->total;
             $select = "SELECT SUM( amount * price ) AS total FROM trade_history Where `market_id`='" . $value->id . "' GROUP BY market_id";
             $total_btc = DB::select($select);
             if (isset($total_btc[0])) {
                 $btc_datainfo[$value->id]['total'] = $total_btc[0]->total;
             } else {
                 $btc_datainfo[$value->id]['total'] = 0;
             }
         }
         $data['btc_datainfo'] = $btc_datainfo;
     }
     //ltc market on sidebar left
     $all_market_ltc = array();
     if (isset($ltc_wallet->id)) {
         $ltc_markets = Market::leftJoin('wallets', 'market.wallet_from', '=', 'wallets.id')->select('market.*', 'wallets.name', 'wallets.type')->where('wallet_to', $ltc_wallet->id)->orderby('wallets.type')->get();
         $ltc_datainfo = array();
         foreach ($ltc_markets as $value) {
             $all_market_ltc[] = $value->id;
             $ltc_datainfo[$value->id] = Trade::where('market_id', $value->id)->orderby('created_at', 'desc')->take(2)->get()->toArray();
             // $total_ltc = DB::table('trade_history')->select(DB::raw('SUM( amount * price ) AS total'))
             //                  ->where('market_id', '=', $value->id)->first();
             // if(isset($total_ltc->total))
             // 	$ltc_datainfo[$value->id]['total'] = $total_ltc->total;
             $select = "SELECT SUM( amount * price ) AS total FROM trade_history Where `market_id`='" . $value->id . "' GROUP BY market_id";
             $total_ltc = DB::select($select);
             if (isset($total_ltc[0])) {
                 $ltc_datainfo[$value->id]['total'] = $total_ltc[0]->total;
             } else {
                 $ltc_datainfo[$value->id]['total'] = 0;
             }
         }
         $data['ltc_datainfo'] = $ltc_datainfo;
     }
     $data['btc_markets'] = $btc_markets;
     $data['ltc_markets'] = $ltc_markets;
     $date = date("Y-m-d H:i:s", strtotime(" -24 hour"));
     //echo "+24 hours: ".$date;
     if (!empty($all_market_btc)) {
         $data['statistic_btc'] = DB::table('trade_history')->select(DB::raw('COUNT(*) as number_trade,SUM( amount * price ) AS total'))->where('created_at', '>=', $date)->whereIn('market_id', $all_market_btc)->first();
     }
     if (!empty($all_market_ltc)) {
         $data['statistic_ltc'] = DB::table('trade_history')->select(DB::raw('COUNT(*) as number_trade,SUM( amount * price ) AS total'))->where('created_at', '>=', $date)->whereIn('market_id', $all_market_ltc)->first();
     }
     $data['wallets'] = Wallet::orderby('type')->get();
     return View::make('home', $data);
 }
示例#5
0
 public function viewprofile($page = '', $filter = '')
 {
     $user = Confide::user();
     $user_id = $user->id;
     $data = array();
     $data['user_id'] = $user_id;
     $data['user'] = $user;
     if ($user_id > 0) {
         $profile = User::leftJoin('users_roles', 'users.id', '=', 'users_roles.user_id')->join('roles', 'roles.id', '=', 'users_roles.role_id')->select('users.*', 'roles.name as rolename')->where('users.id', '=', $user_id)->get();
         if ($profile) {
             $data['profile'] = $profile->first()->toArray();
         }
     }
     $data['page'] = $page;
     $data['filter'] = $filter;
     $balance = new Balance();
     $order = new Order();
     $market = new Market();
     $wallet = new Wallet();
     $setting = new Setting();
     $data['disable_points'] = $setting->getSetting('disable_points', 0);
     switch ($page) {
         case 'balances':
             $wallets = Wallet::orderBy('name')->get()->toArray();
             foreach ($wallets as $key => $value) {
                 $wallet_id = $value['id'];
                 //get balance
                 $balance_amount = $balance->getBalance($wallet_id);
                 $wallets[$key]['balance'] = sprintf('%.8f', $balance_amount);
                 //get PENDING DEPOSITS
                 $deposit_pendding = Deposit::where('user_id', '=', $user_id)->where('wallet_id', '=', $wallet_id)->where('paid', '=', 0)->sum('amount');
                 $wallets[$key]['deposit_pendding'] = sprintf('%.8f', $deposit_pendding);
                 //get PENDING WITHDRAWALS
                 $withdraw_pendding = Withdraw::where('user_id', '=', $user_id)->where('wallet_id', '=', $wallet_id)->where('status', '=', 0)->sum('amount');
                 $wallets[$key]['withdraw_pendding'] = sprintf('%.8f', $withdraw_pendding);
                 //get HELD FOR ORDERS
                 //giao dich ban se giam tien cua wallet hien tai, doi voi btc/ltc (dong tien trao doi) thi giao dich mua se giam tien no
                 //vi vay can xac dinh dau la btc/ltc, bang cach dua vao market, wallet_to trong market chinh la dong tien chinh de trao doi
                 $wallets_to = Market::select("market.wallet_to")->distinct()->get();
                 $wal_to = array();
                 foreach ($wallets_to as $value) {
                     $wal_to[] = $value->wallet_to;
                 }
                 //$wallets_to = array_column($market, 'wallet_to');
                 $status_active = $order->getStatusActive();
                 /*if(in_array($wallet_id,$wal_to)){
                       $held_order = Order::leftJoin('market', 'orders.market_id', '=', 'market.id')
                                   ->where('market.wallet_to','=',$wallet_id)
                                   ->where('orders.user_id','=',$user_id)
                                   ->whereIn('status', $status_active)
                                   ->sum('to_value');
                   }else{*/
                 $held_order = Order::leftJoin('market', 'orders.market_id', '=', 'market.id')->where('market.wallet_from', '=', $wallet_id)->where('orders.user_id', '=', $user_id)->where('type', '=', 'sell')->whereIn('status', $status_active)->sum('from_value');
                 //}
                 $wallets[$key]['held_order'] = sprintf('%.8f', $held_order);
             }
             //echo "<pre>ggg?: "; print_r($wallets); echo "</pre>";
             $data['balances'] = $wallets;
             break;
         case 'orders':
             $record_per_page = 15;
             if (empty($_GET['pager_page'])) {
                 $pager_page = 1;
             } else {
                 $pager_page = $_GET['pager_page'];
             }
             $data['cur_page'] = $pager_page;
             $offset_start = ($pager_page - 1) * $record_per_page;
             $select = "select a.*, b.wallet_from as `from`, b.wallet_to as `to` from orders a left join market b on a.market_id=b.id where a.user_id='" . $user_id . "' ";
             if ($filter != '') {
                 $data['current_coin'] = $wallet->getType($filter);
                 $select .= " AND (b.wallet_to='" . $filter . "' OR b.wallet_from='" . $filter . "') ";
             }
             if (isset($_GET['do_filter'])) {
                 if (!empty($_GET['market'])) {
                     $select .= " AND a.market_id='" . $_GET['market'] . "'";
                 }
                 if ($_GET['status'] != '') {
                     $select .= " AND a.status='" . $_GET['status'] . "'";
                 }
                 if ($_GET['type'] != '') {
                     $select .= " AND a.type='" . $_GET['type'] . "'";
                 }
             }
             $select_count = $select;
             $total_records = DB::select($select_count);
             $data['total_pages'] = ceil(count($total_records) / $record_per_page);
             $select .= " order by `created_at` desc limit " . $offset_start . "," . $record_per_page;
             $ordershistory = DB::select($select);
             //echo "<pre>ordershistory: "; print_r($ordershistory); echo "</pre>";
             //echo "<pre>".dd(DB::getQueryLog())."</pre>";
             $data['ordershistories'] = $ordershistory;
             $markets = Market::get();
             $market_wallet = array();
             foreach ($markets as $value) {
                 $market_wallet[$value->id] = $market->getWalletType($value->id);
             }
             $data['markets'] = $market_wallet;
             break;
         case 'trade-history':
             $record_per_page = 15;
             if (empty($_GET['pager_page'])) {
                 $pager_page = 1;
             } else {
                 $pager_page = $_GET['pager_page'];
             }
             $data['cur_page'] = $pager_page;
             $offset_start = ($pager_page - 1) * $record_per_page;
             $select = "select a.*, b.wallet_from as `from`, b.wallet_to as `to` from trade_history a left join market b on a.market_id=b.id where (a.seller_id='" . $user_id . "' OR a.buyer_id ='" . $user_id . "') ";
             if ($filter != '') {
                 $data['current_coin'] = $wallet->getType($filter);
                 $select .= " AND (b.wallet_to='" . $filter . "' OR b.wallet_from='" . $filter . "') ";
             }
             if (isset($_GET['do_filter'])) {
                 if (!empty($_GET['market'])) {
                     $select .= " AND a.market_id='" . $_GET['market'] . "'";
                 }
                 if (!empty($_GET['type'])) {
                     $select .= " AND a.type='" . $_GET['type'] . "'";
                 }
             }
             $select_count = $select;
             $total_records = DB::select($select_count);
             //echo "<pre>total_records: "; print_r($total_records); echo "</pre>"; exit;
             $data['total_pages'] = ceil(count($total_records) / $record_per_page);
             $select .= " order by `created_at` desc limit " . $offset_start . "," . $record_per_page;
             $trades = DB::select($select);
             $data['tradehistories'] = $trades;
             $markets = Market::get();
             $market_wallet = array();
             foreach ($markets as $value) {
                 $market_wallet[$value->id] = $market->getWalletType($value->id);
             }
             $data['markets'] = $market_wallet;
             break;
         case 'deposits':
             $deposits = Deposit::leftJoin('wallets', 'deposits.wallet_id', '=', 'wallets.id')->select('deposits.*', 'wallets.name', 'wallets.type')->where('user_id', '=', $user_id);
             if ($filter != '') {
                 $data['current_coin'] = $wallet->getType($filter);
                 $deposits = $deposits->where('deposits.wallet_id', '=', $filter);
             }
             if (isset($_POST['do_filter'])) {
                 if (isset($_POST['wallet']) && $_POST['wallet'] != '') {
                     $deposits = $deposits->where('wallet_id', '=', $_POST['wallet']);
                 }
                 if ($_POST['status'] != '') {
                     $deposits = $deposits->where('paid', '=', $_POST['status']);
                 }
             }
             $deposits = $deposits->orderBy('created_at', 'desc')->get();
             //echo "<pre>_POST: "; print_r($_POST); echo "</pre>";
             //echo "<pre>"; echo dd(DB::getQueryLog()); echo "</pre>";
             $data['deposits'] = $deposits;
             $wallets = Wallet::select('id', 'type', 'name')->get();
             $data['wallets'] = $wallets;
             break;
         case 'withdrawals':
             $withdrawals = Withdraw::leftJoin('wallets', 'withdraws.wallet_id', '=', 'wallets.id')->select('withdraws.*', 'wallets.name', 'wallets.type')->where('user_id', '=', $user_id);
             if ($filter != '') {
                 $data['current_coin'] = $wallet->getType($filter);
                 $withdrawals = $withdrawals->where('withdraws.wallet_id', '=', $filter);
             }
             if (isset($_POST['do_filter'])) {
                 if ($_POST['wallet'] != '') {
                     $withdrawals = $withdrawals->where('wallet_id', '=', $_POST['wallet']);
                 }
                 if ($_POST['status'] != '') {
                     $withdrawals = $withdrawals->where('status', '=', $_POST['status']);
                 }
             }
             $withdrawals = $withdrawals->orderBy('created_at', 'desc')->get();
             //echo "<pre>_POST: "; print_r($_POST); echo "</pre>";
             //echo "<pre>"; echo dd(DB::getQueryLog()); echo "</pre>";
             $data['withdrawals'] = $withdrawals;
             $wallets = Wallet::select('id', 'type', 'name')->get();
             $data['wallets'] = $wallets;
             break;
         case 'viewtranferin':
             $record_per_page = 15;
             if (empty($_GET['pager_page'])) {
                 $pager_page = 1;
             } else {
                 $pager_page = $_GET['pager_page'];
             }
             $data['cur_page'] = $pager_page;
             $offset_start = ($pager_page - 1) * $record_per_page;
             //$offset_end = ($pager_page*$record_per_page)-1;
             $select = "select a.*, b.type, b.name , c.username from transfer_history a left join wallets b on a.wallet_id=b.id left join users c on a.receiver=c.id where a.receiver='" . $user_id . "'";
             $select_count = "select count(*) as total from transfer_history a where a.receiver='" . $user_id . "'";
             if ($filter != '') {
                 $data['current_coin'] = $wallet->getType($filter);
                 $select .= " AND a.wallet_id='" . $filter . "'";
             }
             $where = '';
             if (isset($_GET['do_filter'])) {
                 if ($where == '') {
                     if (!empty($_GET['wallet'])) {
                         $where = $where . " AND a.wallet_id='" . $_GET['wallet'] . "'";
                     }
                 }
             }
             $select_count = $select_count . " " . $where . " order by `created_at` desc";
             $total_records = DB::select($select_count);
             //echo "<pre>total_records: "; print_r($total_records); echo "</pre>"; exit;
             $data['total_pages'] = ceil($total_records[0]->total / $record_per_page);
             $select .= " " . $where . " order by `created_at` desc limit " . $offset_start . "," . $record_per_page;
             $transferins = DB::select($select);
             $data['transferins'] = $transferins;
             $wallets_temp = Wallet::get();
             $wallets = array();
             foreach ($wallets_temp as $wallet) {
                 $wallets[$wallet->id] = $wallet;
             }
             $data['wallets'] = $wallets;
             break;
         case 'viewtranferout':
             $record_per_page = 2;
             if (empty($_GET['pager_page'])) {
                 $pager_page = 1;
             } else {
                 $pager_page = $_GET['pager_page'];
             }
             $data['cur_page'] = $pager_page;
             $offset_start = ($pager_page - 1) * $record_per_page;
             //$offset_end = ($pager_page*$record_per_page)-1;
             $select = "select a.*, b.type, b.name , c.username from transfer_history a left join wallets b on a.wallet_id=b.id left join users c on a.sender=c.id where a.sender='" . $user_id . "'";
             $select_count = "select count(*) as total from transfer_history a where a.sender='" . $user_id . "'";
             if ($filter != '') {
                 $data['current_coin'] = $wallet->getType($filter);
                 $select .= " AND a.wallet_id='" . $filter . "'";
             }
             $where = '';
             if (isset($_GET['do_filter'])) {
                 if ($where == '') {
                     if (!empty($_GET['wallet'])) {
                         $where = $where . " AND a.wallet_id='" . $_GET['wallet'] . "'";
                     }
                 }
             }
             $select_count = $select_count . " " . $where . " order by `created_at` desc";
             $total_records = DB::select($select_count);
             //echo "<pre>total_records: "; print_r($total_records); echo "</pre>";
             $data['total_pages'] = ceil($total_records[0]->total / $record_per_page);
             $select .= " " . $where . " order by `created_at` desc limit " . $offset_start . "," . $record_per_page;
             $transferouts = DB::select($select);
             $data['transferouts'] = $transferouts;
             $wallets_temp = Wallet::get();
             $wallets = array();
             foreach ($wallets_temp as $wallet) {
                 $wallets[$wallet->id] = $wallet;
             }
             $data['wallets'] = $wallets;
             break;
         case 'dashboard':
             $total_trades = Trade::where('seller_id', $user_id)->orwhere('buyer_id', $user_id)->get()->toArray();
             $data['total_trades'] = count($total_trades);
             $order = new Order();
             $total_openordes = Order::where('user_id', $user_id)->whereIn('status', $order->getStatusActive())->get()->toArray();
             $data['total_openordes'] = count($total_openordes);
             $twentyfourhours = date('Y-m-d H:i:s', strtotime('-24 hour'));
             $deposit_twentyfourhours = Deposit::where('user_id', $user_id)->where('created_at', ">=", $twentyfourhours)->get()->toArray();
             $data['deposit_twentyfourhours'] = count($deposit_twentyfourhours);
             $withdraw_twentyfourhours = Withdraw::where('user_id', $user_id)->where('created_at', ">=", $twentyfourhours)->get()->toArray();
             $data['withdraw_twentyfourhours'] = count($withdraw_twentyfourhours);
             $deposit_pendings = Deposit::where('user_id', $user_id)->where('paid', 0)->get()->toArray();
             $data['deposit_pendings'] = count($deposit_pendings);
             $total_referred = User::where('referral', $user->username)->get()->toArray();
             $data['total_referred'] = count($total_referred);
             //echo "<pre>total_referred: "; print_r($total_referred); echo "</pre>";
             break;
         case "ecoinstraderpoint":
             $setting = new Setting();
             $data['point_per_btc'] = $setting->getSetting('point_per_btc', 1);
             $data['percent_point_reward_trade'] = $setting->getSetting('percent_point_reward_trade', 0);
             $data['percent_point_reward_referred_trade'] = $setting->getSetting('percent_point_reward_referred_trade', 0);
             break;
         case "verify":
             $userinfo = UserInformation::where('user_id', $user_id)->first();
             //echo "<pre>userinfo: "; print_r($userinfo); echo "</pre>";
             $data['userinfo'] = $userinfo;
             break;
     }
     return View::make('user.profile', $data);
 }
 public function doUpdateTakeMoneyWithdraw()
 {
     $username = Input::get('username');
     $amount = Input::get('amount');
     $transaction_id = Input::get('transaction_id');
     $take_money = Input::get('take_money');
     if (empty($take_money)) {
         $take_money = 0;
     }
     $withdraw_id = Input::get('withdraw_id');
     $redirect = Input::get('redirect');
     $fee = Input::get('fee');
     $receive_amount = $amount - $fee;
     $user = User::where('username', $username)->first();
     //echo "<pre>Input: "; print_r(Input::all()); echo "</pre>"; exit;
     if (!isset($user->id)) {
         return Redirect::to($redirect)->with('error', Lang::get('admin_messages.user_not_exist'));
     } else {
         $withdraw = Withdraw::find($withdraw_id);
         if (isset($withdraw->id)) {
             $withdraw->amount = $amount;
             $withdraw->transaction_id = $transaction_id;
             $withdraw->status = $take_money;
             $withdraw->save();
             $message = '';
             if ($take_money) {
                 $balance = new Balance();
                 $wallet = new Wallet();
                 $balance->takeMoney($amount, $withdraw->wallet_id, $user->id);
                 $message = ". " . Lang::get('admin_messages.take_money_user', array('amount' => $amount, 'coin' => $wallet->getType($withdraw->wallet_id), 'username' => $user->username));
             }
             return Redirect::to($redirect)->with('success', Lang::get('admin_messages.update_success') . $message);
         } else {
             return Redirect::to($redirect)->with('error', Lang::get('admin_messages.withdraw_not_exist'));
         }
     }
 }