Наследование: extends AbsCraft
Пример #1
0
 function __construct()
 {
     $model = new Market();
     //header("Content-type:text/xml");
     View::$layout = 'empty';
     View::render('market/list', $model->getList());
 }
Пример #2
0
 public function testBuyStock()
 {
     $market = new Market($this->markets['nasdaq']);
     $this->assertEquals('you purchased GOOG stock', $market->buyStock('GOOG'));
     $market->setGateway($this->markets['spx500']);
     $this->assertEquals('you purchased AMZN stock', $market->buyStock('AMZN'));
 }
Пример #3
0
 function test_save()
 {
     //Arrange
     $title = "Wash the dog";
     $test_market = new Market($title);
     //Act
     $test_market->save();
     //Assert
     $result = Market::getAll();
     $this->assertEquals($test_market, $result[0]);
 }
 /**
  * Do something after content is loaded from DB
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function postContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $marketCheck, $objTemplate, $objMarket, $_CORELANG;
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
             // Market Show Latest
             $marketCheck = $objTemplate->blockExists('marketLatest');
             if ($marketCheck) {
                 $objMarket = new Market('');
                 $objTemplate->setVariable('TXT_MARKET_LATEST', $_CORELANG['TXT_MARKET_LATEST']);
                 $objMarket->getBlockLatest();
             }
             break;
     }
 }
Пример #5
0
    public function getList()
    {
        $start = microtime(true);
        $data = array('list' => array(), 'categories' => array());
        $parentIds = array();
        $sql = '
			SELECT DISTINCT {{catalog}}.*, {{tree}}.* FROM {{catalog}}
			INNER JOIN {{tree}} ON {{catalog}}.tree={{tree}}.id
			WHERE {{catalog}}.market=1 AND {{catalog}}.price>0 AND {{tree}}.visible=1 AND available=1
			ORDER BY num
		';
        //print DB::prefix($sql);
        $catalog = DB::getPagi($sql);
        $fields = Fields::getReserveFieldsByModulePath($tab);
        $k = 1;
        $date_b = explode('.', Funcs::$conf['akcia']['date_begin']);
        $date_e = explode('.', Funcs::$conf['akcia']['date_end']);
        $date_b = mktime(0, 0, 0, $date_b[1], $date_b[0], $date_b[2]);
        $date_e = mktime(23, 59, 59, $date_e[1], $date_e[0], $date_e[2]);
        $today = mktime();
        $yes = 0;
        if ($today >= $date_b && $today <= $date_e) {
            $yes = 1;
        }
        foreach ($catalog as $i => $model) {
            $akcia = '0';
            //if ($yes==1)
            //$akcia=$model['akcia'];
            $data['list'][] = array('id' => $model['id'], 'parent' => $model['parent'], 'fields' => Fields::getFieldsByTree($model['tree'], 'wide'), 'name' => Market::clearInfo($model['name']), 'path' => Catalog::getPathToTree($model['tree']), 'available' => $model['available'], 'bid' => $model['bid'], 'akcia' => $akcia, 'cbid' => $model['cbid'], 'typePrefix' => $model['typePrefix'], 'vendor' => Funcs::$referenceId['vendor'][$model['vendor']]['name'], 'yandex_description' => Market::clearInfo($model['yandex_description']), 'price' => $model['price'], 'local_delivery_cost' => $model['price'] < 4000 ? '200' : '0', 'manufacturer_warranty' => $model['manufacturer_warranty']);
            $parentIds[] = $model['parent'];
            $k++;
            //echo $k.' Время выполнения скрипта '.(microtime(true) - $start).'<br />';
        }
        $parentIds = array_unique($parentIds);
        if (count($parentIds) > 0) {
            $sql = '
				SELECT * FROM {{tree}} WHERE id IN (' . implode(',', $parentIds) . ')
			';
            $list = DB::getAll($sql);
            $parentIds = array();
            foreach ($list as $item) {
                $data['categories'][] = array('id' => $item['id'], 'parent' => $item['parent'], 'name' => $item['name']);
                $parentIds[] = $item['parent'];
            }
            if (count($parentIds) > 0) {
                $sql = '
					SELECT * FROM {{tree}} WHERE id IN (' . implode(',', $parentIds) . ')
				';
                $list = DB::getAll($sql);
                foreach ($list as $item) {
                    $data['categories'][] = array('id' => $item['id'], 'name' => $item['name']);
                }
            }
        }
        return $data;
    }
Пример #6
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();
 }
Пример #7
0
 public function getIndex()
 {
     $loggedIn = $this->loggedIn;
     $title = 'index';
     $markets = Market::orderBy('upvote', 'desc')->get();
     foreach ($markets as $market) {
         $items[$market->id] = $market->items()->orderBy('views', 'desc')->take(2)->get();
     }
     foreach ($items as $itemsSet) {
         foreach ($itemsSet as $item) {
             $users[$item->id] = $item->user;
         }
     }
     return view('environment.home', compact('title', 'items', 'markets', 'users', 'loggedIn'));
 }
Пример #8
0
 public function createAccount()
 {
     $validator = Validator::make($data = Input::all(), User::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $data['role'] = Input::get('user_role');
     $data['country_id'] = Input::get('country');
     $data['password'] = Hash::make($data['password']);
     $data['code'] = str_random(60);
     //Activation code
     $user = User::create($data);
     if ($user) {
         $data['user_id'] = $user->id;
         if ($data['role'] == 'Agent') {
             $data['market_id'] = Market::where('market', 'All Market')->first()->id;
             $role = Role::where('name', $data['role'])->first();
             $user->attachRole($role);
             Agent::create($data);
             Mail::send('emails.auth.signup', array('first_name' => $data['first_name'], 'role' => $data['role']), function ($massage) use($user) {
                 $massage->to($user->email, $user->first_name)->subject('Thank You for Signing Up');
             });
             Mail::send('emails.auth.signup', array('first_name' => $data['first_name'], 'role' => $data['role']), function ($massage) use($user) {
                 $massage->to('*****@*****.**', 'Tharinda')->subject('Thank You for Signing Up');
             });
             Session::flash('global', 'Thank you for signing up with us as an ' . $data['role'] . '. We will contact you within 24 hours');
             return View::make('pages.message');
         }
         if ($data['role'] == 'Hotelier') {
             Mail::send('emails.auth.signup', array('first_name' => $data['first_name'], 'role' => $data['role']), function ($massage) use($user) {
                 $massage->to($user->email, $user->first_name)->subject('Thank You for Signing Up');
             });
             Session::flash('global', 'Thank you for signing up with us as an ' . $data['role'] . '. We will contact you within 24 hours');
             return View::make('pages.message');
         }
         // send email
         Mail::send('emails.auth.activate', array('link' => URL::to('account/activate', $data['code']), 'first_name' => $data['first_name']), function ($massage) use($user) {
             $massage->to($user->email, $user->first_name)->subject('Activate your account');
         });
         Session::flash('global', 'Your account has been created! We have sent you an email to activate your account');
         return View::make('pages.message');
     }
     return 'There was an error';
 }
Пример #9
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;
 }
Пример #10
0
 public function routePage($page = '')
 {
     //echo "<pre>user: "******"</pre>";
     switch ($page) {
         case "fees":
             $market = new Market();
             $wallet = new Wallet();
             $fees_trade = FeeTrade::get()->toArray();
             //echo "<pre>list_buy_orders: "; print_r($list_buy_orders); echo "</pre>";
             $fees_withdraw = FeeWithdraw::leftJoin('wallets', 'fee_withdraw.wallet_id', '=', 'wallets.id')->select('fee_withdraw.*', 'wallets.type', 'wallets.name')->get();
             foreach ($fees_trade as $key => $value) {
                 $wallet_type = $market->getWalletType($value['market_id']);
                 if (!empty($wallet_type)) {
                     $fees_trade[$key]['wallet_from'] = $wallet_type['wallet_from'];
                     $fees_trade[$key]['wallet_to'] = $wallet_type['wallet_to'];
                 }
             }
             $fee['fees_trade'] = $fees_trade;
             $fee['fees_withdraw'] = $fees_withdraw;
             return View::make('fees', $fee);
             break;
         case "voting":
             $setting = new Setting();
             $coinvotes = DB::table('coin_votes')->get();
             try {
                 $wallet = Wallet::where('type', 'BTC')->first();
                 $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port);
                 foreach ($coinvotes as $key => $value) {
                     $num_vote = Vote::where('coinvote_id', '=', $value->id)->count();
                     //echo "<pre>getreceivedbyaccount"; print_r($wallet->getReceivedByAddress($value->btc_address)); echo "</pre>";//$value->label_address
                     $btc_payment = $wallet->getReceivedByAddress($value->btc_address);
                     //'12X9jVe4S8pAqJ7EoKN7B4YwMQpzfgArtX'
                     $amount_btc_per_vote = $setting->getSetting('amount_btc_per_vote', 0.0001);
                     $num_payment = floor($btc_payment / $amount_btc_per_vote);
                     //echo "btc_payment: ".$btc_payment;
                     //echo "<br>num_payment: ".$num_payment;
                     $coinvotes[$key]->num_vote = $num_vote + $num_payment;
                 }
             } catch (Exception $e) {
                 $data['error_message'] = Lang::get('texts.not_connect_wallet');
                 //'Caught exception: '.$e->getMessage()."\n";  //"Not connect to this
             }
             //echo "<pre>coinvotes"; print_r($coinvotes); echo "</pre>";
             $data['coinvotes'] = $coinvotes;
             return View::make('voting', $data);
             break;
         case "security":
             return View::make('security');
             break;
         case "api":
             if (isset($_REQUEST['method'])) {
                 $method = $_REQUEST['method'];
                 $value = $this->api($method);
             } else {
                 $setting = new Setting();
                 $data['pusher_app_key'] = $setting->getSetting('pusher_app_key', '');
                 return View::make('api', $data);
             }
             print_r($value);
             break;
         case "apiprivate":
             $value = $this->apiprivate();
             break;
         case "all-trades":
             if (Auth::guest()) {
                 return Redirect::to('/login');
             }
             $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;
             $trade_history = Trade::leftjoin('market', 'market.id', '=', 'trade_history.market_id')->select('trade_history.*', 'market.wallet_from as from', 'market.wallet_to as to');
             $where = '';
             if (Input::has('market')) {
                 $fil_market = Input::get('market');
                 $trade_history->where("trade_history.market_id", "=", $fil_market);
             }
             if (Input::has('type')) {
                 $fil_type = Input::get('type');
                 $trade_history->where("trade_history.type", "=", $fil_type);
             }
             $total_records = $trade_history->get();
             $data['total_pages'] = ceil(count($total_records) / $record_per_page);
             $trades = $trade_history->skip($offset_start)->take($record_per_page)->orderby("created_at", "desc")->get();
             #echo "<pre>trade_history"; print_r($trades->toArray()); echo "</pre>";
             //echo "<pre>getQueryLog: ".dd(DB::getQueryLog())."</pre>";
             $data['tradehistories'] = $trades;
             $market = new Market();
             $markets = Market::get();
             $market_wallet = array();
             foreach ($markets as $value) {
                 $market_wallet[$value->id] = $market->getWalletType($value->id);
             }
             $data['markets'] = $market_wallet;
             return View::make('alltrades', $data);
             break;
         case "all-news":
             $news = Post::where('type', 'news')->orderby('created_at', 'desc')->get();
             $data['news'] = $news;
             return View::make('allnews', $data);
             break;
         default:
             return View::make('index');
             break;
     }
 }
 public function filtrAction($id)
 {
     $vMarket = new Market($this->context);
     $this->view->setVar('block_filtr_tovar', $vMarket->getFiltr());
     $this->view->setVar('block_cat_comission', $vMarket->getCategoriesCommTreeHTML());
     $this->view->setVar('block_id', $id);
     $this->view->breadcrumbs = array(array('url' => '/', 'title' => 'Главная'), array('url' => '/market/', 'title' => 'Маркет'), array('url' => '../market/comissionka', 'title' => 'Комиссионка'));
     $this->view->generate();
 }
Пример #12
0
<?php

/*
 *  Copyright (c) Codiad & daeks (codiad.com), distributed
 *  as-is and without warranty under the MIT License. See
 *  [root]/license.txt for more. This information must remain intact.
 */
require_once '../../common.php';
require_once 'class.market.php';
//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////
checkSession();
$market = new Market();
//////////////////////////////////////////////////////////////////
// Install
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'install') {
    if (checkAccess()) {
        $market->Install($_GET['type'], $_GET['name'], $_GET['repo']);
    }
}
//////////////////////////////////////////////////////////////////
// Remove
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'remove') {
    if (checkAccess()) {
        $market->Remove($_GET['type'], $_GET['name']);
    }
}
//////////////////////////////////////////////////////////////////
Пример #13
0
 /**
  * Gets the meta data.
  *
  * Returns an object full of business logic/database schema type definitions
  *
  * Returns stdClass
  *    phone_types
  *        {id}
  *            id
  *            name
  *            editable
  *    markets
  *        {id}
  *            id
  *            name
  *            active
  *            currency
  *    email_types
  *        {id}
  *            id
  *            name
  *    address_types
  *        {id}
  *            id
  *            name
  *    states
  *        {id}
  *            id
  *            name
  *            abbrev
  *            country_id
  *    countries
  *        {id}
  *            id
  *            name
  *            can_sell
  *            can_enroll
  *    presenter_status
  *        {id}
  *            id
  *            name
  *    product_credit_types
  *        {id}
  *            id
  *            name
  *            type
  *    product_credit_entry_types
  *        {id}
  *            id
  *            name
  *    product_credit_status_types
  *        {id}
  *            id
  *            name
  *    order_payment_processors
  *        {id}
  *            id
  *            name
  *    languages
  *        {id}
  *            id
  *            name
  *            localize_name
  *            locale
  *
  * @return \stdClass
  */
 private function _getMetaData()
 {
     $results = new stdClass();
     require_once APPLICATION_PATH . MODEL_DIR . '/Phone_type.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Market.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Address_type.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/State.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Country.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Email_type.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Presenter_status.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Product_credit_types.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Product_credit_entry_types.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Product_credit_status_types.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Order_payment_processors.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Secondary_order_status.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Royalty_status.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Language.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Documents.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Presenter_account_types.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Presenter_us_tax_data.php';
     //phone types
     $phone_type = new Phone_type();
     $results->phone_types = $phone_type->getAllData();
     //presenter_us_tax_data
     $presenter_us_tax_data = new Presenter_us_tax_data();
     //$results->presenter_us_tax_data 		= $presenter_us_tax_data->getAllData();
     //markets
     $market = new Market();
     $results->markets = $market->getAllData();
     //email types
     $email_types = new Email_type();
     $results->email_types = $email_types->getAllData();
     //address types
     $address_types = new Address_type();
     $results->address_types = $address_types->getAllData();
     //states
     $states = new State();
     $results->states = $states->getAllData();
     //countries
     $countries = new Country();
     $results->countries = $countries->getAllData();
     //presenter status
     $presenter_status = new Presenter_status();
     $results->presenter_status = $presenter_status->getAllData();
     //order payment processor
     $order_payment_processor = new Order_payment_processor();
     $results->order_payment_processors = $order_payment_processor->getAllData();
     //product_credit_types
     $product_credit_types = new Product_credit_types();
     $results->product_credit_types = $product_credit_types->getAllData();
     //product_credit_entry_types
     $product_credit_entry_types = new Product_credit_entry_types();
     $results->product_credit_entry_types = $product_credit_entry_types->getAllData();
     //product_credit_status_types status
     $product_credit_status_types = new Product_credit_status_types();
     $results->product_credit_status_types = $product_credit_status_types->getAllData();
     //secondary_order_status
     $secondary_order_status = new Secondary_order_status();
     $results->secondary_order_status = $secondary_order_status->getAllData();
     //royalty_status
     $royalty_status = new Royalty_status();
     $results->royalty_status = $royalty_status->getAllData();
     //documents
     $documents = new Documents();
     $results->documents = $documents->getAllData();
     //presenter_account_types
     $presenter_account_types = new Presenter_account_types();
     $results->presenter_account_types = $presenter_account_types->getAllData();
     //language/locale
     $language = new Language();
     //var_export($this->Session->read()); exit;
     $results->language = $language->getAllData(1);
     //index meta data by column so it can be easily referenced in code
     $result = new stdClass();
     foreach ($results as $key => $value) {
         $result->{$key} = $this->_rekeyArray($value);
     }
     return $result;
 }
 /**
  * Give Presenter Sla yCash
  *
  * @param $order_id
  * @param $market_id
  * @param $user_id
  * @param $presenter
  * @param $credit_amount
  * @return mixed
  */
 private function slayCash($order_id, $market_id, $user_id, $presenter, $credit_amount)
 {
     $type_id = ProductCredit::TYPE_SLAYCASH;
     $existing = $this->ProductCredit->checkExists($type_id, $user_id, $order_id);
     if (!$existing) {
         /**
          * Award yCash
          */
         $this->ProductCredit->credit(ProductCredit::METHOD_SYSTEM, $type_id, $market_id, $presenter['Presenter']['id'], $user_id, Money::fromString($credit_amount), "Late Order Shipping", $order_id);
         $market_cash = Market::numberCurrency($market_id, $credit_amount);
         /**
          * Send notifying email
          */
         $this->slayCashEmail($order_id, $market_cash, $user_id, $presenter);
         return true;
     } else {
         // Exists
         return false;
     }
 }
Пример #15
0
<?php

$market = new Market();
$market_name = '';
$market_image = '';
$market_details = '';
if (isset($_GET['markets']) && $_GET['markets'] != '') {
    $market->find_market($_GET['markets']);
    if ($market->market_exists) {
        $market_name = $market->market_name;
        $market_details = $market->market_details;
    }
}
?>

<form action="" method="post" enctype="multipart/form-data">
    
    <table>
        <tr>
            <td>Market Name</td><td><input type="text" name="market_name" value="<?php 
echo $market_name;
?>
"></td>
        </tr>
        <tr>
            <td>Market Details</td><td><textarea name="market_details" ><?php 
echo $market_details;
?>
</textarea></td>
        </tr>
        <tr>
Пример #16
0
 public function addToCart()
 {
     $hot_id = Input::get('hotel_id');
     if (Input::has('room_refer_id')) {
         $room_identity = Input::get('room_refer_id');
         $room_identity_array = explode("_", $room_identity);
         $hotel_id = $room_identity_array[0];
         $room_id = $room_identity_array[1];
         $room_specification_id = $room_identity_array[2];
         $meal_basis_id = $room_identity_array[3];
         $room_count = Session::get('room_count');
         $hotel_name = Hotel::where('id', $hotel_id)->first()->name;
         $hotel_address = Hotel::where('id', $hotel_id)->first()->address;
         $room_name = RoomType::where('id', $room_id)->first()->room_type;
         $room_specification = RoomSpecification::where('id', $room_specification_id)->first()->room_specification;
         $meal_basis = MealBasis::where('id', $meal_basis_id)->first()->meal_basis_name;
         $adult = RoomSpecification::where('id', $room_specification_id)->first()->adults;
         $child = RoomSpecification::where('id', $room_specification_id)->first()->children;
         $nights = Session::get('date_gap');
         $st_date = date('Y-m-d', strtotime(Session::get('st_date')));
         $ed_date = date('Y-m-d', strtotime(Session::get('ed_date')));
         $date_count = Voucher::getNights($st_date, $ed_date)->days;
         //dd($room_id.'/'.$room_specification_id.'/'.$meal_basis_id);
         $room_rate = Rate::lowestRoomRate($hotel_id, $room_id, $room_specification_id, $meal_basis_id, $st_date, $ed_date);
         $room_rate_with_tax = Rate::lowestRoomRateWithTax($hotel_id, $room_id, $room_specification_id, $meal_basis_id, $st_date, $ed_date);
         $room_cost = $room_rate_with_tax * $room_count * $date_count;
         if (Session::has('market')) {
             $market = Session::get('market');
         } else {
             $market = 1;
         }
         $get_market_details = Market::where('id', $market)->first();
         $tax_type = $get_market_details->tax_type;
         $tax = $get_market_details->tax;
         $handling_fee_type = $get_market_details->handling_fee_type;
         $handling_fee = $get_market_details->handling_fee;
         $supplement_rate = Rate::supplementRate($hotel_id, $room_id, $room_specification_id, $meal_basis_id, $st_date, $ed_date);
         if ($market == 1) {
             if ($tax_type == 0) {
                 $total_tax = $room_rate_with_tax / 100 * $tax;
             } else {
                 $total_tax = $tax;
             }
             if ($handling_fee_type == 0) {
                 $total_handling_fee = $room_rate / 100 * $handling_fee;
             } else {
                 $total_handling_fee = $handling_fee;
             }
             $hotel_handling_fee = $total_handling_fee;
             $hotel_tax = $total_tax;
         } else {
             $total_tax = 0;
             if ($handling_fee_type == 0) {
                 $total_handling_fee = $room_rate / 100 * $handling_fee;
             } else {
                 $total_handling_fee = $handling_fee;
             }
             $hotel_tax = $total_tax;
             $hotel_handling_fee = $total_handling_fee;
         }
         $rate_box_details = array('hotel_id' => $hotel_id, 'hotel_name' => $hotel_name, 'hotel_address' => $hotel_address, 'room_name' => $room_name, 'room_type_id' => $room_id, 'room_specification' => $room_specification, 'room_specification_id' => $room_specification_id, 'meal_basis' => $meal_basis, 'meal_basis_id' => $meal_basis_id, 'room_cost' => $room_cost, 'hotel_tax' => $hotel_tax, 'hotel_handling_fee' => $hotel_handling_fee, 'supplement_rate' => $supplement_rate, 'room_count' => $room_count, 'unit_price' => $room_rate_with_tax, 'hotel_room_price' => $room_rate, 'adult' => $adult, 'child' => $child, 'nights' => $nights, 'room_identity' => $room_identity, 'check_in' => $st_date, 'check_out' => $ed_date, 'unit_cost_price' => (double) $hotel_tax + (double) $room_cost);
         if (Session::has('rate_box_details_' . $hotel_id)) {
             $data = Session::get('rate_box_details_' . $hotel_id);
             $data[$room_identity] = $rate_box_details;
         } else {
             $data = [];
             $data[$room_identity] = $rate_box_details;
         }
         Session::put('rate_box_details_' . $hotel_id, $data);
     }
     //dd(Session::get('rate_box_details_'.$hotel_id));
     return Response::json($hotel_id);
 }
Пример #17
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);
 }
Пример #18
0
<?php

require 'stocksmarket.php';
$markets = array('nasdaq' => new NasdaqGateway(), 'spx500' => new SPX500Gateway());
$market = new Market($markets['nasdaq']);
echo $market->buyStock('GOOG');
echo '<br>';
$market->setGateway($markets['spx500']);
echo $market->buyStock('AMZN');
Пример #19
0
<?php

$market = new Market();
$market->callAPI();
Пример #20
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);
     }
 }
Пример #21
0
 public static function supplementRate($hotel_id, $room_type_id, $specification_id, $meal_basis_id, $st_date, $ed_date)
 {
     $x = 0;
     $y = 0;
     $supplement_rates = 0;
     if (Session::has('market')) {
         $market = Session::get('market');
     } else {
         $market = 1;
     }
     $get_market_details = Market::where('id', $market)->first();
     $from_date = date('Y-m-d', strtotime(str_replace('-', '/', $st_date)));
     $to_date = date('Y-m-d', strtotime(str_replace('-', '/', $ed_date)));
     $dates = (strtotime($ed_date) - strtotime($st_date)) / 86400;
     //      dd($market.'/'.$hotel_id.'/'.$room_type_id.'/'.$specification_id.'/'.$meal_basis_id.'/'.$st_date.'/'.$ed_date);
     for ($x = 1; $x <= $dates; $x++) {
         $supplement_rate = 0;
         $get_supplement_rates = SupplementRate::where('hotel_id', $hotel_id)->where('room_type_id', $room_type_id)->where('room_specification_id', $specification_id)->where('meal_basis_id', $meal_basis_id)->where('from', '<=', $from_date)->where('to', '>', $from_date)->where('market_id', $market)->get();
         foreach ($get_supplement_rates as $get_supplement_rate) {
             $supplement_rate = $get_supplement_rate->rate;
             if ($supplement_rate > 0) {
                 $y = $y + 1;
             }
         }
         $from_date = date('Y-m-d', strtotime($from_date . ' + 1 days'));
         if ($supplement_rate > 0) {
             $supplement_rates = $supplement_rates + $supplement_rate;
         }
     }
     $room_supplement_rate = number_format($supplement_rates, 2);
     return $room_supplement_rate;
 }
Пример #22
0
/**
 * Delete market post and pictures
 *
 * @param Market $post
 * @return array
 */
function market_delete_image($post = NULL, $imagenum)
{
    if (!$post || !$imagenum) {
        return false;
    }
    $filenum = $imagenum;
    if ($imagenum == 1) {
        $filenum = '';
    }
    $owner = get_entity($post->getOwner());
    $owner_guid = $owner->guid;
    $prefix = "market/{$post->guid}";
    $names = array("{$prefix}small{$filenum}.jpg", "{$prefix}medium{$filenum}.jpg", "{$prefix}large{$filenum}.jpg", "{$prefix}master{$filenum}.jpg");
    foreach ($names as $name) {
        $delfile = new ElggFile();
        $delfile->owner_guid = $owner_guid;
        $delfile->setFilename($name);
        $delfile->delete();
    }
    $images = unserialize($post->images);
    $new_array = array();
    foreach ($images as $key => $value) {
        if ($key == $imagenum) {
            $value = 0;
        }
        $new_array[$key] = $value;
    }
    $post->images = serialize($new_array);
    $post->save();
    return true;
}
Пример #23
0
<?php

$market = new Market();
$market_name = '';
$market_image = '';
$market_details = '';
if (isset($_GET['markets']) && $_GET['markets'] != '') {
    $market->find_market($_GET['markets']);
    if ($market->market_exists) {
        $market_name = $market->market_name;
        $market_details = $market->market_details;
        if (isset($_POST['market_name'])) {
            $market->update_market();
            header('location:index.php?marketskjjknjkn=' . $market->market_id);
        }
    }
}
if (isset($_POST['market_name'])) {
    $market->market_id = $market->add_market();
    header('location:index.php?markets=' . $market->market_id);
}
?>

<?php 
$collection = new Market();
$collection = $collection->getCollection();
foreach ($collection as $market) {
    ?>
<div width="200" style="display: block;width:100%; height:50px ">
<a href="index.php?markets=<?php 
    echo $market->market_id;
 public function disableMarket()
 {
     $status = Input::get('status');
     $market_id = Input::get('market_id');
     $market = Market::find($market_id);
     if (isset($market->id)) {
         Market::where('id', $market_id)->update(array('active' => $status));
         $message = Lang::get('admin_messages.disable_success');
         if (Input::get('isAjax')) {
             echo json_encode(array('status' => 'success', 'message' => $message));
             exit;
         } else {
             return Redirect::to('admin/manage/markets')->with('success', $message);
         }
     } else {
         $message = Lang::get('admin_messages.market_not_exist');
         if (Input::get('isAjax')) {
             echo json_encode(array('status' => 'error', 'message' => $message));
             exit;
         } else {
             return Redirect::to('admin/manage/markets')->with('error', $message);
         }
     }
 }