Esempio n. 1
0
 /**
  * @author: lmkhang - skype
  * @date: 2016-01-15
  * Member detail
  */
 public function detail($user_id)
 {
     //set Title for PAGE
     $this->_page_title = 'Members';
     //check user id existed
     $user_get = new \App\User();
     $user = $user_get->getAccount($user_id);
     if (!$user) {
         //set Flash Message
         $this->setFlash('message', 'The user is not existed!');
         return Redirect::intended($this->_page_url)->with('message', 'The user is not existed!');
     }
     //Get income-expenditure list
     $user_in_ex_get = new \App\UserIncomeExpenditure();
     $number_pagination = \App\Config::where(['prefix' => 'site', 'name' => 'pagination', 'del_flg' => 1])->get()[0]['value'];
     $user_in_ex = $user_in_ex_get->getAllPaging(['user_income_expenditure.user_id' => $user_id, 'user_income_expenditure.status' => 1], $number_pagination);
     return view('admin.members.detail', ['admin' => $this->_admin, 'name' => $user['full_name'] ? $user['full_name'] : $user['first_name'] . ' ' . $user['last_name'], 'page_title' => $this->_page_title, 'active' => $this->_active, 'number_pagination' => $number_pagination, 'user' => $user, 'user_in_ex' => $user_in_ex, 'in_expen_type' => config('constant.in_expen_type'), 'in_exp_action' => config('constant.in_exp_action')]);
 }
Esempio n. 2
0
 /**
  * @author: lmkhang - skype
  * @date: 2016-01-09
  * DASHBOARD HOME
  */
 public function index()
 {
     //Check Status
     if ($this->_stop) {
         return Redirect::intended(url($this->_redirectTo));
     }
     //set Title for PAGE
     $this->_page_title = 'Home';
     //Get income-expenditure list
     $user_in_ex_get = new \App\UserIncomeExpenditure();
     $number_pagination = \App\Config::where(['prefix' => 'site', 'name' => 'pagination', 'del_flg' => 1])->get()[0]['value'];
     $user_in_ex = $user_in_ex_get->getAllPaging(['user_id' => $this->_user_id, 'status' => 1], $number_pagination);
     //get money
     $user_stats_get = new \App\UserStats();
     $user_stats = $user_stats_get->getAccount($this->_user_id);
     //min PAY
     $minpay = \App\Config::where(['prefix' => 'payment', 'name' => 'minpay', 'del_flg' => 1])->get()[0]['value'];
     return view('dashboard.home.index', ['user' => $this->_user, 'name' => $this->getName(), 'page_title' => $this->_page_title, 'active' => $this->_active, 'user_stats' => $user_stats, 'number_pagination' => $number_pagination, 'user_in_ex' => $user_in_ex, 'in_expen_type' => config('constant.in_expen_type'), 'in_exp_action' => config('constant.in_exp_action'), 'minpay' => $minpay]);
 }
Esempio n. 3
0
 /**
  * @author: lmkhang - skype
  * @date: 2016-02-15
  *
  */
 public function detail(Request $request)
 {
     //set Title for PAGE
     $this->_page_title = 'Receipts and Expenses';
     //get
     $gets = $request->all();
     $gets = $this->trim_all($gets);
     $filter = isset($gets['filter']) ? $gets['filter'] : [];
     //unset if dont choose
     $filter_temp = $filter;
     foreach ($filter_temp as $k => $v) {
         if (!$v) {
             unset($filter[$k]);
         }
     }
     //get user list
     $user_get = new \App\User();
     $users = $user_get->getAllPaging(['status' => 1, 'del_flg' => 1, 'sign_contract' => 1]);
     //get all receipts and expenses
     $number_pagination = \App\Config::where(['prefix' => 'site', 'name' => 'pagination', 'del_flg' => 1])->get()[0]['value'];
     $receipt_expense_get = new \App\UserIncomeExpenditure();
     $receipt_expense = $receipt_expense_get->getAllPaging($filter, $number_pagination);
     return view('admin.stats.detail', ['admin' => $this->_admin, 'name' => $this->getName(), 'page_title' => $this->_page_title, 'active' => $this->_active, 'users' => $users, 'filter' => $filter, 'number_pagination' => $number_pagination, 'receipt_expense' => $receipt_expense, 'in_expen_type' => config('constant.in_expen_type'), 'in_expen_status' => config('constant.in_expen_status'), 'in_exp_action' => config('constant.in_exp_action')]);
 }
Esempio n. 4
0
 /**
  * @author: lmkhang - skype
  * @date: 2016-02-01
  * $type: 1=> Plus; 2=> Minus
  * $action: 1=> System; 2=>People; $valid_type: 1=> valid, 2=> invalid
  */
 protected function historyInExp($user_id, $amount, $reason = '', $type = 1, $action = 1, $post = [], $valid_type = 1)
 {
     $rs = true;
     $process_amount = ['currency_string' => '$', 'original_amount' => $amount, 'amount' => $amount];
     //get some info
     //min PAY
     $minpay = \App\Config::where(['prefix' => 'payment', 'name' => 'minpay', 'del_flg' => 1])->get()[0]['value'];
     //initial USERSTATS
     $user_stats_get = new \App\UserStats();
     $user_stats = $user_stats_get->getAccount($user_id);
     //if choose payment
     if (count($post) > 0 && isset($post['is_payment']) && $post['is_payment'] == 1 && $type == 2) {
         if ($user_stats->total < $minpay || $post['amount'] < $minpay) {
             $rs = false;
             return $rs;
         }
         //no payment information
         $payment_user_get = new \App\Payment();
         $user_payment = $payment_user_get->getPaymentInfomation($user_id);
         if (!$user_payment) {
             $rs = false;
             return $rs;
         }
         $process_amount = $this->payment_amount($amount, $user_payment['payment_method']);
     }
     //without payment, only withdraw
     if ($type == 2 && $user_stats->total < $post['amount']) {
         $rs = false;
         return $rs;
     }
     //if choose import from csv
     if (count($post) > 0 && isset($post['is_import']) && $post['is_import'] == 1 && $type == 1) {
         $process_amount = $this->net_amount($amount);
     }
     $date = isset($post['date']) ? date('Y-m-d H:i:s', strtotime($post['date'])) : date('Y-m-d H:i:s');
     //insert history
     $user_history = new \App\UserIncomeExpenditure();
     $user_history->user_id = $user_id;
     $user_history->tax_from_daily = isset($process_amount['tax_from_daily']) ? $process_amount['tax_from_daily'] : '';
     $user_history->commission = isset($process_amount['commission']) ? $process_amount['commission'] : '';
     $user_history->currency = isset($process_amount['currency']) ? $process_amount['currency'] : '';
     $user_history->tax_pay_bank = isset($process_amount['tax_pay_bank']) ? $process_amount['tax_pay_bank'] : '';
     $user_history->payment_method = isset($process_amount['payment_method']) ? $process_amount['payment_method'] : '';
     $user_history->original_amount = isset($process_amount['original_amount']) ? $process_amount['original_amount'] : '';
     $user_history->currency_string = isset($process_amount['currency_string']) ? $process_amount['currency_string'] : '';
     $user_history->status = $valid_type;
     $user_history->type = $type;
     $user_history->date = $date;
     $user_history->action = $action;
     $user_history->reason = str_replace(array('{mm-YYYY}'), array(date('F Y', strtotime($date))), $reason);
     if ($type == 1) {
         //increase
         $user_history->amount = $process_amount['amount'];
         if ($valid_type == 1) {
             $user_stats->total = floatval($user_stats->total + $process_amount['amount']);
         } else {
             if ($valid_type == 2) {
                 $user_stats->loss_total = floatval($user_stats->loss_total + $process_amount['amount']);
             }
         }
     } else {
         if ($type == 2) {
             //withdraw, payment
             $_amount = $process_amount['original_amount'];
             $user_history->amount = $_amount;
             if ($valid_type == 1) {
                 $user_stats->total = floatval($user_stats->total - $_amount);
             }
             //if choose payment
             if (count($post) > 0 && isset($post['is_payment']) && $post['is_payment'] == 1 && $type == 2) {
                 $user_history->is_payment = 1;
                 $this->sendmailPayment($user_id, $process_amount['string_amount'], $process_amount['string_original_amount'], $process_amount['net_amount_word_info'], $date, $reason);
             }
         }
     }
     $user_history->save();
     $user_stats->save();
     return $rs;
 }