예제 #1
0
 public function membershipFormAction()
 {
     $this->view->order_info = Model_Membership::get(JO_Session::get('membership_id'));
     if (!$this->view->order_info) {
         return;
     }
     $this->view->currency = WM_Currency::getCurrency();
     if (JO_Registry::forceGet('paypal_sandbox_mode')) {
         $this->view->url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
     } else {
         $this->view->url = 'https://www.paypal.com/cgi-bin/webscr';
     }
     $this->view->paypal_email = JO_Registry::forceGet('paypal_email');
     $this->view->return = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=success_membership');
     $this->view->notify_url = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=payments_paypal&action=callback_membership');
     $this->view->cancel_return = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=membership');
     $this->view->email = JO_Session::get('email');
     $this->view->first_name = JO_Session::get('firstname');
     $this->view->last_name = JO_Session::get('lastname');
 }
예제 #2
0
 public function faqAction()
 {
     $request = $this->getRequest();
     $this->view->currency = WM_Currency::getCurrency();
     $itemID = $request->getRequest('faq');
     $item = Model_Items::get($itemID);
     if (!is_array($item) || $item['status'] == 'deleted' || JO_Session::get('username') && $item['status'] == 'unapproved' && $item['user_id'] != $_SESSION['user']['user_id'] || $item['status'] == 'queue' || $item['status'] == 'extended_buy') {
         return $this->forward('error', 'error404');
     }
     $this->view->item_link = WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     $faqs_data = Model_Faq::getAll($itemID);
     if (JO_Session::get('user_id') == $item['user_id'] || $faqs_data) {
         $this->view->faq_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=faq&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     }
     if (JO_Session::get('user_id') == $item['user_id']) {
         $this->view->edit_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=edit&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
         $this->view->delete_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=delete&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     }
     $this->view->comment_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=comments&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     JO_Session::set('redirect', $this->view->comment_link);
     if (JO_Session::get('msg_success')) {
         $this->view->msg_success = JO_Session::get('msg_success');
         JO_Session::clear('msg_success');
     }
     if (JO_Session::get('msg_error')) {
         $this->view->msg_error = JO_Session::get('msg_error');
         JO_Session::clear('msg_error');
     }
     $user = $item['user'] = Model_Users::getUser($item['user_id']);
     $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Portfolio'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']))), array('name' => $item['name'], 'href' => $this->view->item_link), array('name' => $this->translate('FAQ')));
     $filter = '';
     if ((int) $request->getRequest('filter')) {
         $filter = ' AND items_comments.id = ' . (int) $request->getRequest('filter');
     }
     $link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=comments&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     $this->view->faq = array();
     if ($faqs_data) {
         foreach ($faqs_data as $f) {
             $f['question'] = nl2br($f['question']);
             $f['answer'] = html_entity_decode($f['answer']);
             $f['delete'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=delete_faq&item_id=' . $item['id'] . '&del=' . $f['id']);
             $f['update'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=update_faq&item_id=' . $item['id'] . '&faq=' . $f['id']);
             $this->view->faq[] = $f;
         }
     }
     $this->view->add_faq_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=add_faq&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     $this->getLayout()->meta_title = $item['name'];
     $this->getLayout()->meta_description = substr(strip_tags(html_entity_decode($item['description'], ENT_QUOTES, 'utf-8')), 0, 255);
     $this->view->item = $item;
     $this->view->user = $user;
     $this->view->children = array();
     $this->view->children['rightside'] = 'items/rightside';
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
예제 #3
0
파일: Orders.php 프로젝트: noikiy/PD
 public function buy($item, $price, $extended = 'false')
 {
     $you = Model_Users::getUser(JO_Session::get('user_id'));
     $deposit = 0;
     $earning = 0;
     if ($you['deposit'] > $price) {
         $deposit = $price;
     } else {
         $deposit = $you['deposit'];
         $earning = floatval($price) - floatval($you['deposit']);
     }
     $db = JO_Db::getDefaultAdapter();
     $db->update(Model_Users::getPrefixDB() . 'users', array('deposit' => new JO_Db_Expr('deposit - ' . floatval($deposit)), 'earning' => new JO_Db_Expr('earning - ' . floatval($earning)), 'total' => new JO_Db_Expr('total - ' . floatval($price))), array('user_id =?' => $you['user_id']));
     JO_Session::set('deposit', floatval(JO_Session::get('deposit')) - floatval($deposit));
     JO_Session::set('earning', floatval(JO_Session::get('earning')) - floatval($earning));
     JO_Session::set('total', floatval(JO_Session::get('total')) - floatval($price));
     #ADD PRICE TO OWNER USER
     $user = Model_Users::getUser($item['user_id']);
     $percent = Model_Percentes::getPercentRow($user);
     $percent = $percent['percent'];
     $receiveMoney = floatval($price) * floatval($percent) / 100;
     $db->update(Model_Users::getPrefixDB() . 'users', array('earning' => new JO_Db_Expr('earning+' . floatval($receiveMoney)), 'total' => new JO_Db_Expr('total + ' . floatval($receiveMoney)), 'sold' => new JO_Db_Expr('sold + ' . floatval($price)), 'sales' => new JO_Db_Expr('sales+1')), array('user_id =?' => $user['user_id']));
     #ADD ORDER
     $currency = WM_Currency::getCurrency();
     $db->insert('orders', array('user_id' => (int) JO_Session::get('user_id'), 'owner_id' => (int) $item['user_id'], 'item_id' => (int) $item['id'], 'item_name' => $item['name'], 'price' => (double) $price, 'datetime' => new JO_Db_Expr('NOW()'), 'receive' => $receiveMoney, 'paid' => 'true', 'paid_datetime' => new JO_Db_Expr('NOW()'), 'extended' => $extended, 'type' => 'buy', 'currency_code' => $currency['code'], 'currency_value' => $currency['value'], 'module' => $item['module']));
     $order_id = $db->lastInsertId();
     if ($order_id && $you['referal_id'] != '0') {
         self::referalMoney(array('order_id' => $order_id, 'price' => $price, 'user_id' => JO_Session::get('user_id'), 'owner_id' => $item['user_id'], 'item_id' => $item['id'], 'item_name' => $item['name'], 'currency_code' => $currency['code'], 'currency_value' => $currency['value']), $you);
     }
     $db->update(Model_Users::getPrefixDB() . 'users', array('buy' => new JO_Db_Expr('buy+1')), array('user_id =?' => JO_Session::get('user_id')));
     #UPDATE ITEM
     $toadd = array('sales' => new JO_Db_Expr('sales+1'), 'earning' => new JO_Db_Expr('earning+' . $price));
     if ($extended == 'true') {
         $toadd['status'] = 'extended_buy';
     }
     $db->update('items', $toadd, array('id = ?' => $item['id']));
     return true;
 }
예제 #4
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $this->view->base_url = $request->getBaseUrl();
     #LINKS FOR HEAD PARTS IN BOX
     $this->view->finance_href = $request->getModule() . '/reports/';
     $this->view->sales_href = $request->getModule() . '/orders/';
     $this->view->users_href = $request->getModule() . '/users/';
     $this->view->approval_href = $request->getModule() . '/queueitems/';
     $this->view->queue_href = $request->getModule() . '/queueupdateditems/';
     $this->view->contacts_href = $request->getModule() . '/contacts/';
     $this->view->gainpayingup_href = $request->getModule() . '/gainpayingup/';
     $this->view->tags_href = $request->getModule() . '/tags/?filter_visible=false';
     #LOAD ORDERS COUNT
     $this->view->total = Model_Orders::getSalesStatus();
     if ($this->view->total) {
         $this->view->total['total_f'] = WM_Currency::format($this->view->total['total']);
     }
     $ref = Model_Orders::getSalesStatus(" AND `datetime` > '" . date('Y-m') . "-01 00:00:00' ", 'referal');
     $sales = Model_Orders::getSalesStatus(" AND `datetime` > '" . date('Y-m') . "-01 00:00:00' ");
     if ($sales) {
         if ($ref) {
             $sales['referal'] = $ref['receive'];
         } else {
             $sales['referal'] = 0;
         }
         $sales['win'] = floatval($sales['total']) - floatval($sales['receive']) - floatval($sales['referal']);
         $sales['total_f'] = WM_Currency::format($sales['total']);
         $sales['receive_f'] = WM_Currency::format($sales['receive']);
         $sales['referal_f'] = WM_Currency::format($sales['referal']);
         $sales['win_f'] = WM_Currency::format($sales['win']);
     }
     $this->view->sales = $sales;
     unset($ref);
     $ref = Model_Orders::getSalesStatus("", 'referal');
     $sales = Model_Orders::getSalesStatus("");
     if ($sales) {
         if ($ref) {
             $sales['referal'] = $ref['receive'];
         } else {
             $sales['referal'] = 0;
         }
         $sales['win'] = floatval($sales['total']) - floatval($sales['receive']) - floatval($sales['referal']);
         $sales['total_f'] = WM_Currency::format($sales['total']);
         $sales['receive_f'] = WM_Currency::format($sales['receive']);
         $sales['referal_f'] = WM_Currency::format($sales['referal']);
         $sales['win_f'] = WM_Currency::format($sales['win']);
     }
     $this->view->sales2 = $sales;
     unset($ref);
     #LOAD USERS COUNT
     $this->view->users = array();
     $this->view->users['month'] = Model_Users::getUsersCount(" `register_datetime` > '" . date('Y-m') . "-01 00:00:00' AND `status` = 'activate' ");
     $this->view->users['total'] = Model_Users::getUsersCount(" `status` = 'activate' ");
     $this->view->topAuthors = array();
     $topAuthors = Model_Users::getAll(0, 5, " `status` = 'activate' ", "`sales` DESC");
     if ($topAuthors) {
         $percentsClass = new Model_Percents();
         foreach ($topAuthors as $user) {
             $user['deposit'] = WM_Currency::format($user['deposit']);
             $user['earning'] = WM_Currency::format($user['earning']);
             $user['total'] = WM_Currency::format($user['total']);
             $user['sold'] = WM_Currency::format($user['sold']);
             $user['referal_money'] = WM_Currency::format($user['referal_money']);
             $comision = $percentsClass->getPercentRow($user['user_id']);
             $user['commission'] = round($comision['percent']);
             $user['sum'] = Model_Balance::getTotalUserBalanceByType($user['user_id']);
             $user['web_profit'] = WM_Currency::format($user['web_profit']);
             $user['web_profit2'] = WM_Currency::format($user['web_profit2']);
             $user['has_referral_sum'] = $user['referral_sum'];
             $user['referral_sum'] = WM_Currency::format($user['referral_sum']);
             $user['edit_href'] = $request->getModule() . '/users/edite/?id=' . $user['user_id'];
             $user['balance_href'] = $request->getModule() . '/users/balance/?id=' . $user['user_id'];
             $this->view->topAuthors[] = $user;
         }
     }
     #LOAD WITHDRAW
     $this->view->withdraw = array();
     $this->view->withdraw['no'] = Model_Deposit::getWithdrawCount(" `paid` = 'false' AND `datetime` > '" . date('Y-m') . "-01 00:00:00' ");
     if ($this->view->withdraw['no']) {
         $this->view->withdraw['no']['total_f'] = WM_Currency::format($this->view->withdraw['no']['total']);
     }
     $this->view->withdraw['paid'] = Model_Deposit::getWithdrawCount(" `paid` = 'true' AND `paid_datetime` > '" . date('Y-m') . "-01 00:00:00' ");
     if ($this->view->withdraw['paid']) {
         $this->view->withdraw['paid']['total_f'] = WM_Currency::format($this->view->withdraw['paid']['total']);
     }
     #LOAD THEMES
     $this->view->items = Model_Items::getItems(array('filter_status' => 'queue', 'start' => 0, 'limit' => 5));
     $this->view->updated_items = Model_Items::getItems(array('filter_update' => true, 'start' => 0, 'limit' => 5));
     #LOAD LAST REQUEST
     $this->view->contacts = array();
     $contacts = Model_Contacts::getContacts(array('filter_answer_datetime' => '0000-00-00', 'start' => 0, 'limit' => 5));
     if ($contacts) {
         foreach ($contacts as $contact) {
             $data = new JO_Date($contact['datetime'], 'dd MM yy');
             $contact['datetime'] = $data->toString();
             $contact['has_response'] = $contact['answer_datetime'] != '0000-00-00 00:00:00';
             if ($contact['answer_datetime'] != '0000-00-00 00:00:00') {
                 $data = new JO_Date($contact['answer_datetime'], 'dd MM yy');
                 $contact['answer_datetime'] = $data->toString();
             } else {
                 $contact['answer_datetime'] = '';
             }
             $this->view->contacts[] = $contact;
         }
     }
     #Withdrawals
     $this->view->withdraws = array();
     $withdraws = Model_Users::getWithdraws(array('start' => 0, 'limit' => 5));
     if ($withdraws) {
         foreach ($withdraws as $withdraw) {
             $withdraw['earning'] = WM_Currency::format($withdraw['earning']);
             $date = new JO_Date($withdraw['datetime'], 'dd MM yy');
             $withdraw['datetime'] = $date->toString();
             if ($withdraw['paid'] == 'true') {
                 $date = new JO_Date($withdraw['paid_datetime'], 'dd MM yy');
                 $withdraw['paid_datetime'] = $date->toString();
             } else {
                 $withdraw['paid_datetime'] = '';
             }
             $withdraw['amount'] = WM_Currency::format($withdraw['amount']);
             $this->view->withdraws[] = $withdraw;
         }
     }
     #TAGS NO ACTIVE
     $this->view->tags = Model_Tags::getTags(array('filter_visible' => 'false', 'start' => 0, 'limit' => 20));
     #DRAW GRAPHCS
     $referal_sum = Model_Orders::getSalesStatusByDay(" AND `datetime` > '" . date('Y-m') . "-01 00:00:00' ", 'referal');
     $sales_sum = Model_Orders::getSalesStatusByDay(" AND `datetime` > '" . date('Y-m') . "-01 00:00:00' ");
     $referal_money = array();
     $sales_money = array();
     $user_money = array();
     $win_money = array();
     $sales_num = array();
     $referal_num = array();
     $days = array();
     //		for($i=1; $i<= date('t'); $i++) {
     //			if(isset($referal_sum[date("Y-m-") . sprintf('%02d', $i)])) {
     //				$referal_money[] = number_format($referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'], 2, '.', '');
     //			} else {
     //				$referal_money[] = 0;
     //			}
     //			if(isset($sales_sum[date("Y-m-") . sprintf('%02d', $i)])) {
     //				$sales_money[] = number_format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['total'], 2, '.', '');
     //				$user_money[] = number_format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'], 2, '.', '');
     //				if(isset($referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'])) {
     //					$sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'] = $referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'];
     //				}
     //				if(!isset($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'])) {
     //					$sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'] = 0;
     //				}
     //				$sales_num[] = $sales_sum[date("Y-m-") . sprintf('%02d', $i)]['num'];
     //				$win_money[] = number_format( floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['total']) - floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['receive']) - floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal']), 2, '.', '');
     //			} else {
     //				$sales_money[] = 0;
     //				$user_money[] = 0;
     //				$win_money[] = 0;
     //				$sales_num[] = 0;
     //			}
     //			$days[] = $i;
     //		}
     for ($i = 1; $i <= date('t'); $i++) {
         if (isset($referal_sum[date("Y-m-") . sprintf('%02d', $i)])) {
             $referal_money[] = array(WM_Currency::format($referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive']), (double) WM_Currency::format($referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'], '', '', false));
         } else {
             $referal_money[] = array(WM_Currency::format(0), 0);
         }
         if (isset($referal_sum[date("Y-m-") . sprintf('%02d', $i)]['num'])) {
             $referal_num[] = array($i, $referal_sum[date("Y-m-") . sprintf('%02d', $i)]['num']);
         } else {
             $referal_num[] = array($i, 0);
         }
         if (isset($sales_sum[date("Y-m-") . sprintf('%02d', $i)])) {
             $sales_money[] = array(WM_Currency::format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['total']), (double) WM_Currency::format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['total'], '', '', false));
             $user_money[] = array(WM_Currency::format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['receive']), (double) WM_Currency::format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'], '', '', false));
             if (isset($referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'])) {
                 $sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'] = $referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'];
             }
             if (!isset($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'])) {
                 $sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'] = 0;
             }
             $sales_num[] = array($i, $sales_sum[date("Y-m-") . sprintf('%02d', $i)]['num']);
             $win_money[] = array(WM_Currency::format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['total'] - floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['receive']) - floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'])), (double) WM_Currency::format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['total'] - floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['receive']) - floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal']), '', '', false));
         } else {
             $sales_money[] = array(WM_Currency::format(0), 0);
             $user_money[] = array(WM_Currency::format(0), 0);
             $win_money[] = array(WM_Currency::format(0), 0);
             $sales_num[] = array($i, 0);
         }
         $days[] = $i;
     }
     $new_array = array();
     $new_array[] = array('name' => $this->translate('Total'), 'data' => $sales_money);
     $new_array[] = array('name' => $this->translate('User\'s profit'), 'data' => $user_money);
     $new_array[] = array('name' => $this->translate('Net total'), 'data' => $win_money);
     $new_array[] = array('name' => $this->translate('Referent'), 'data' => $referal_money);
     $new_array2 = array();
     $new_array2[] = array('name' => $this->translate('Referent'), 'data' => $referal_num);
     $new_array2[] = array('name' => $this->translate('Sales'), 'data' => $sales_num);
     $this->view->finance_array = JO_Json::encode($new_array);
     $this->view->sales_array = JO_Json::encode($new_array2);
     $this->view->days = JO_Json::encode($days);
     $this->view->currency = WM_Currency::getCurrency();
 }