Ejemplo n.º 1
0
 /**
  * Loads Account page.
  *
  * @access	Private
  * @param	nil
  * @return	void
  */
 function index()
 {
     //Load the package_model
     $this->load->model('package_model');
     //Load Language File
     $this->lang->load('enduser/account', $this->config->item('language_code'));
     $this->lang->load('enduser/viewProject', $this->config->item('language_code'));
     //Load helper file
     $this->load->helper('transaction');
     $this->load->helper('reviews');
     //If Admin try to access this url...redirect him
     /*if(isAdmin() === true)
     		{
     			$this->session->set_flashdata('flash_message', $this->common_model->flash_message('error',$this->lang->line('Dont have rights to access this page')));
     			redirect('info');
     		}
     	    */
     if (!isset($this->loggedInUser->id)) {
         $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You can not access to this page')));
         redirect('info');
     }
     // check Certificate User
     if ($this->loggedInUser) {
         //Get Transaction Information
         $condition_username = '******' . $this->loggedInUser->id;
         $condition_flag = 'subscriptionuser.flag=' . '1';
         $condition = $condition_username . '  AND  ' . $condition_flag;
         $query = 'SELECT * FROM `subscriptionuser` WHERE ' . $condition;
         $result = $this->db->query($query);
         $certificate_user = $result;
         foreach ($certificate_user->result() as $cetificateuser) {
             $user_package = $cetificateuser->package_id;
             $condition1 = 'packages.id =' . $user_package;
             $condition2 = 'packages.end_date>=' . time();
             $condition = $condition1 . ' AND ' . $condition2;
             $query = 'SELECT * FROM packages WHERE ' . $condition;
             $result = $this->db->query($query);
             $packagesList = $result;
             $this->outputData['packagesList'] = $packagesList;
         }
     }
     if ($this->loggedInUser) {
         //Get Transaction Information
         $condition = array('transactions.creator_id' => $this->loggedInUser->id, 'transactions.reciever_id' => $this->loggedInUser->id);
         $transactions = $this->transaction_model->getTransactions($condition);
         $this->outputData['transaction'] = $transactions;
         //pr($transactions->result());
         //Get the review
         $condition2 = array('users.id' => $this->loggedInUser->id);
         $this->outputData['reviewDetails'] = $this->user_model->getUsers($condition2);
     }
     //Load escrow
     if ($this->loggedInUser->role_id == '1') {
         $this->outputData['topBuyers'] = $this->skills_model->getTopBuyers(NULL);
         $creator_condition = array('transactions.creator_id' => $this->loggedInUser->id);
         $transaction_condition = array('transactions.creator_id' => $this->loggedInUser->id, 'type' => 'Escrow Transfer');
         //Get the project messages and mail list
         $condition = array('messages.to_id' => $this->loggedInUser->id, 'messages.notification_status' => '0');
         $this->outputData['mailList'] = $this->messages_model->getProjectMessages($condition);
     }
     if ($this->loggedInUser->role_id == '2') {
         //Get bookmark projects
         $condition_bookmark = array('bookmark.creator_id' => $this->loggedInUser->id);
         $bookMark1 = $this->skills_model->getBookmark($condition_bookmark);
         //$this->outputData['bookMark'] = $bookMark;
         //pagination limit
         $page_rows = $this->config->item('mail_limit');
         $start = $this->uri->segment(3, 0);
         $limit[0] = $page_rows;
         $limit[1] = $start * $page_rows;
         //Get all message trasaction with some limit
         $bookMark = $this->skills_model->getBookmark($condition_bookmark, NULL, NULL, $limit);
         $this->outputData['bookMark'] = $bookMark;
         //Pagination
         $this->load->library('pagination');
         $config['base_url'] = site_url('buyer/bookmarkProjects');
         $config['total_rows'] = $bookMark1->num_rows();
         $config['per_page'] = $page_rows;
         $config['cur_page'] = $start;
         $this->pagination->initialize($config);
         $this->outputData['pagination1'] = $this->pagination->create_links2(false, 'bookmarkProjects');
         //Get all users
         $this->outputData['getUsers'] = $this->user_model->getUsers();
         //Get the Projects details
         $creator_condition = array('transactions.reciever_id' => $this->loggedInUser->id);
         $transaction_condition = array('transactions.reciever_id' => $this->loggedInUser->id, 'type' => 'Escrow Transfer');
         $condition = array('projects.notification_status' => '0');
         $this->outputData['awardProjects'] = $this->skills_model->getProjects($condition);
         $result = $this->skills_model->getTopprogrammers();
         $this->outputData['getProgrammers'] = $result;
         //Get the suers categories
         //Laod bookmark model
         $this->load->model('bookmark_model');
         $condition = array('user_categories.user_id' => $this->loggedInUser->id);
         $projectNotification = $this->bookmark_model->getUserCategories($condition);
         $categoryid = $projectNotification->result();
         //Get the category string value for the id value
         $i = '0';
         if ($categoryid) {
             $categoryid = explode(',', $categoryid[$i]->user_categories);
             //Laod skills_model
             $this->load->model('skills_model');
             $categoryname[$i++] = $this->skills_model->convertCategoryIdsToName($categoryid);
             $this->outputData['categoryname'] = $categoryname;
         }
         //Get the project invitation from the buyer
         $condition = array('project_invitation.receiver_id' => $this->loggedInUser->id, 'project_invitation.notification_status' => '0');
         $this->outputData['projectInvitation'] = $this->user_model->getProgrammerInvitation($condition);
         //Get the project messages and mail list
         $condition = array('messages.to_id' => $this->loggedInUser->id, 'messages.notification_status' => '0');
         $this->outputData['mailList'] = $this->messages_model->getProjectMessages($condition);
     }
     $url = 'account/index';
     $page = $this->uri->segment(3, 0);
     $escrow = loadTransaction($creator_condition, $transaction_condition, $url, $page);
     $page_rows = $this->config->item('listing_limit');
     $max = array($page_rows, ($page - 1) * $page_rows);
     //Get Sorting order
     $field = $this->uri->segment(4, '0');
     $order = $this->uri->segment(5, '0');
     $orderby = array();
     if ($field) {
         $orderby = array($field, $order);
     }
     $this->outputData['order'] = $order;
     $this->outputData['field'] = $field;
     $this->outputData['page'] = $page;
     if (isProgrammer()) {
         $provider_id = $this->loggedInUser->id;
         $conditions = array('projects.programmer_id' => $provider_id, 'projects.project_status !=' => '2');
         $this->outputData['myProjects'] = $this->skills_model->getProjects($conditions, NULL, NULL);
         $created = $this->skills_model->getProjects($conditions);
         $conditions = array('projects.programmer_id' => $provider_id, 'projects.project_status =' => '2');
         $this->outputData['closedProjects'] = $this->skills_model->getProjectsByProvider($conditions);
     } else {
         $buyer_id = $this->loggedInUser->id;
         //Conditions
         $conditions = array('projects.creator_id' => $buyer_id, 'projects.project_status !=' => '2');
         $this->outputData['myProjects'] = $this->skills_model->getProjects($conditions, NULL, NULL);
         $created = $this->skills_model->getProjects($conditions);
         $conditions = array('projects.creator_id' => $buyer_id, 'projects.project_status =' => '2');
         $this->outputData['closedProjects'] = $this->skills_model->getProjectsByProvider($conditions);
         $review_type = $this->outputData['closedProjects']->row();
     }
     $this->outputData['pages'] = $this->common_model->getPages();
     //Pagination
     $this->load->library('pagination');
     $config['base_url'] = site_url('buyer/viewMyProjects/');
     $config['total_rows'] = $created->num_rows();
     $config['per_page'] = $page_rows;
     $config['cur_page'] = $page;
     $this->pagination->initialize($config);
     $this->outputData['pagination'] = $this->pagination->create_links(false, 'project');
     // get user
     $condition = array('users.id' => $this->loggedInUser->id);
     $user_data = $this->user_model->getUsers($condition);
     //$user_data_result = $user_data->result();
     $user_data_row = $user_data->row();
     //pr($user_data_row->refid);
     // load affilate model
     $this->load->model('affiliate_model');
     if (isset($user_data_row->refid)) {
         $condition = array('affiliate_welcome_msg.refid' => $user_data_row->refid, 'referel' => '');
         $affiliate_welcome = $this->affiliate_model->getAffiliateWelcomeMsg($condition);
         $condition1 = array('affiliate_welcome_msg.refid' => $user_data_row->refid, 'referel' => $this->loggedInUser->user_name, 'msg_status' => 1);
         $affiliate_welcome1 = $this->affiliate_model->getAffiliateWelcomeMsg($condition1);
         $welcome_result1 = $affiliate_welcome1->row();
         $welcome_result = $affiliate_welcome->row();
         //pr($welcome_result);
         if (!empty($welcome_result)) {
             if (empty($welcome_result1)) {
                 if ($welcome_result->msg_status == 0 and $welcome_result->referel == '' and $welcome_result->refid != $this->loggedInUser->user_name) {
                     $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $welcome_result->welcome_msg));
                     //Set message Id
                     $updateKey = array('affiliate_welcome_msg.refid' => $user_data_row->refid, 'id' => $welcome_result->id);
                     $updateData = array();
                     $updateData['msg_status '] = 1;
                     $updateData['referel'] = $this->loggedInUser->user_name;
                     //Update Site Settings
                     $this->affiliate_model->updateAffiliateWelcomeMeg($updateKey, $updateData);
                     $insertData1 = array();
                     $insertData1['refid'] = $user_data_row->refid;
                     $insertData1['welcome_msg'] = $welcome_result->welcome_msg;
                     //Add Category
                     $this->affiliate_model->addAffiliateWelcomeMsg($insertData1);
                     redirect('info');
                 }
             }
         }
         //exit;
     }
     // checking the role of the user
     if ($this->loggedInUser->role_name == 'programmer') {
         //Set the user role
         $this->outputData['role'] = '2';
         // pr($this->outputData['transaction']->result());
         //Load Programmer Account View
         $this->load->view('programmer/programmerAccountManage', $this->outputData);
     }
     if ($this->loggedInUser->role_name == 'buyer') {
         //Load Buyer Account View
         $this->load->view('buyer/buyerAccountManage', $this->outputData);
     }
 }
Ejemplo n.º 2
0
 /**
  * Loads deposit index page of the site.
  *
  * @access	private
  * @param	nil
  * @return	void
  */
 function index()
 {
     if (!isset($this->loggedInUser->role_id)) {
         $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You can not access to this page')));
         redirect('info');
     }
     if ($this->loggedInUser->suspend_status == 1) {
         $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Suspend Error')));
         redirect('info');
     }
     //Load Language
     $this->lang->load('enduser/depositMoney', $this->config->item('language_code'));
     //Load payment settings
     $this->load->model('payment_model');
     $paymentGateways = $this->payment_model->getPaymentSettings();
     $this->outputData['paymentGateways'] = $paymentGateways;
     if ($this->input->post('amount')) {
         $this->outputData['amount'] = $this->input->post('amount');
     }
     //Check Whether User Logged In Or Not
     if (isLoggedIn() === false) {
         $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Dont have rights to access this page')));
         redirect('info');
     }
     //load validation libraray
     $this->load->library('form_validation');
     //Load Form Helper
     $this->load->helper('form');
     //Intialize values for library and helpers
     $this->form_validation->set_error_delimiters($this->config->item('field_error_start_tag'), $this->config->item('field_error_end_tag'));
     //Check User Balance
     $condition_balance = array('user_balance.user_id' => $this->loggedInUser->id);
     $results = $this->transaction_model->getBalance($condition_balance);
     //Load transfer transaction
     //Load helper file
     $this->load->helper('transaction');
     $creator_condition = array('transactions.creator_id' => $this->loggedInUser->id);
     $transaction_condition = array('transactions.creator_id' => $this->loggedInUser->id, 'type' => 'Deposit');
     $url = 'deposit/index';
     $page = $this->uri->segment(3, 0);
     $escrow = loadTransaction($creator_condition, $transaction_condition, $url, $page);
     //If Record already exists
     if ($results->num_rows() > 0) {
         //get balance detail
         $rowBalance = $results->row();
         //check balance Amount
         $updateKey = array('user_balance.user_id' => $this->loggedInUser->id);
         $updateData = array();
         $this->outputData['userAvailableBalance'] = $rowBalance->amount;
         if ($rowBalance->amount > $this->input->post('total')) {
             $this->outputData['with_balance'] = $this->lang->line('check balance');
         }
     }
     //Get Form Data
     if ($this->input->post('depositMoney')) {
         //Set Validation Rules
         $this->form_validation->set_rules('total', 'lang:total_validation', 'required|trim|integer|xss_clean|abs|is_natural_no_zero');
         $this->form_validation->set_rules('paymentMethod', 'lang:paymentMethod_validation', 'required|trim|xss_clean');
         if ($this->form_validation->run()) {
             //redirect it to appropriate payment method
             $total = $this->input->post('total');
             $this->outputData['total'] = $total;
             if ($this->input->post('paymentMethod') == 'paypal') {
                 $view = 'paypalDeposit';
                 $method = 'Paypal';
             }
             //Load the minimum deposit value
             foreach ($paymentGateways as $res) {
                 $deposit_minimum = $res['deposit_minimum'];
                 $commission = $res['commission'];
                 $this->outputData['commission'] = $commission;
             }
             $total_comm = $total + $total * ($commission / 100);
             $this->outputData['total_with_commission'] = sprintf("%1\$.2f", $total_comm);
             if ($deposit_minimum > $this->input->post('total')) {
                 $this->outputData['min_deposit'] = '0';
                 $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Minimum deposit amount :') . $deposit_minimum . '.00'));
                 redirect('deposit');
             }
             $this->load->model('user_model');
             $this->loggedInUser->id;
             //Conditions
             $conditions = array('users.id' => $this->loggedInUser->id);
             $query = $this->user_model->getUsers($conditions);
             foreach ($query->result() as $row) {
                 $role = $row->role_name;
                 $role_id = $row->role_id;
             }
             //Register Transaction
             $insertData = array();
             $insertData['creator_id'] = $this->loggedInUser->id;
             $insertData['type'] = 'Deposit';
             $insertData['amount'] = $this->outputData['total'];
             $insertData['transaction_time'] = get_est_time();
             $insertData['status'] = 'Pending';
             //Can Be success,failed,pending
             $insertData['description'] = $this->lang->line('Amount Deposited Through') . ' ' . $method;
             $insertData['user_type'] = $role;
             if ($role_id == '1') {
                 $insertData['buyer_id'] = $this->loggedInUser->id;
             }
             if ($role_id == '2') {
                 $insertData['provider_id'] = $this->loggedInUser->id;
             }
             $this->load->model('transaction_model');
             $res = $this->transaction_model->addTransaction($insertData);
             //Get Transaction id and set this in to transactions custom field
             $this->outputData['transactionId'] = $this->db->insert_id();
             //echo $this->outputData['total'];exit;
             //Load Corresponding View Based On Payment Method
             $this->load->view('transaction/' . $view, $this->outputData);
         } else {
             $this->load->view('transaction/depositMoney', $this->outputData);
         }
         //If Check For Validation
     } else {
         $this->load->view('transaction/depositMoney', $this->outputData);
     }
     //If End - Check For Form Submission
 }
Ejemplo n.º 3
0
 /**
  * Loads deposit page of the site.
  *
  * @access	public
  * @param	nil
  * @return	void
  */
 function index()
 {
     if (!isset($this->loggedInUser->id)) {
         $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You can not access to this page')));
         redirect('info');
     }
     if ($this->loggedInUser->suspend_status == 1) {
         $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Suspend Error')));
         redirect('info');
     }
     //Check Whether User Logged In Or Not
     if (isLoggedIn() === false) {
         $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Dont have rights to access this page')));
         redirect('info');
     }
     $condition = array('projects.project_status' => '2');
     $projectList = $this->skills_model->getUsersproject($condition);
     $this->outputData['projectList_tranferamount'] = $projectList->result();
     //load validation libraray
     $this->load->library('form_validation');
     //Load Form Helper
     $this->load->helper('form');
     //Load escrow transaction
     //Load helper file
     $this->load->helper('transaction');
     $creator_condition = array('transactions.creator_id' => $this->loggedInUser->id);
     $transaction_condition = array('transactions.creator_id' => $this->loggedInUser->id, 'type' => 'Transfer');
     $url = 'transfer/index';
     $page = $this->uri->segment(3, 0);
     $escrow = loadTransaction($creator_condition, $transaction_condition, $url, $page);
     //Intialize values for library and helpers
     $this->form_validation->set_error_delimiters($this->config->item('field_error_start_tag'), $this->config->item('field_error_end_tag'));
     //Check User Balance
     $this->load->model('transaction_model');
     $condition_balance = array('user_balance.user_id' => $this->loggedInUser->id);
     $results = $this->transaction_model->getBalance($condition_balance);
     if ($results->num_rows() > 0) {
         //get balance detail
         $rowBalance = $results->row();
         $this->outputData['userAvailableBalance'] = $rowBalance->amount;
         $avail_balance = $rowBalance->amount;
     }
     //Get Form Data
     if ($this->input->post('transferMoney')) {
         //Set Validation Rules
         $this->form_validation->set_rules('total', 'lang:total_validation', 'required|trim|integer|xss_clean|abs');
         $this->form_validation->set_rules('type_id', 'lang:buyer_id_validation', 'required|trim|xss_clean|abs');
         if ($this->form_validation->run() and $this->input->post('type_id') != '0') {
             //redirect it to appropriate payment method
             if ($this->input->post('total') <= '0') {
                 //echo $this->input->post('amount');
                 $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Transfer Amount should not be empty')));
                 redirect('transfer');
             }
             //Get the Minimum Balance amount
             $this->load->model('settings_model');
             $paymentSettings = $this->settings_model->getSiteSettings();
             $paymentSettings['PAYMENT_SETTINGS'];
             $bal_amount = $avail_balance - ($paymentSettings['PAYMENT_SETTINGS'] + $this->input->post('total'));
             if ($bal_amount < 0) {
                 $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You are not having Sufficient Balance to Transfer')));
                 redirect('transfer');
             } else {
                 if ($this->input->post('paymentMethod') == 'paypal') {
                     $view = 'paypalDeposit';
                     $method = 'Paypal';
                 }
                 $method = 'Paypal';
                 $this->outputData['amount'] = $this->input->post('total');
                 //Register Transaction
                 $insertData = array();
                 $insertData['creator_id'] = $this->loggedInUser->id;
                 $insertData['reciever_id'] = $this->input->post('users_load');
                 $insertData['project_id'] = $this->input->post('type_id');
                 $insertData['type'] = 'Transfer';
                 $insertData['amount'] = $this->input->post('total');
                 $insertData['transaction_time'] = get_est_time();
                 $insertData['status'] = 'Completed';
                 //Can Be success,failed,pending
                 $insertData['description'] = 'Transfer Amount for';
                 //Check User Balance
                 $condition_balance = array('user_balance.user_id' => $this->loggedInUser->id);
                 $results = $this->transaction_model->getBalance($condition_balance);
                 if (getSuspendStatus($this->input->post('users_load'))) {
                     $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('The user you are trying to Transfer is currently Suspended')));
                     redirect('transfer');
                 }
                 //If Record already exists
                 if ($results->num_rows() > 0) {
                     //get balance detail
                     $rowBalance = $results->row();
                     //Update Amount
                     $updateKey = array('user_balance.user_id' => $this->loggedInUser->id);
                     $updateData = array();
                     $updateData['amount'] = $rowBalance->amount - $this->input->post('total');
                     $results1 = $this->transaction_model->updateBalance($updateKey, $updateData);
                     $condition = array('users.id' => $insertData['reciever_id']);
                     $registerusers = $this->user_model->getUsers($condition);
                     $registerusers = $registerusers->row();
                     //Update Amount to the receiver id
                     $updateKey = array('user_balance.user_id' => $insertData['reciever_id']);
                     $updateData = array();
                     // Getting the account balance of the receiver ---->stat
                     $condition_balance_receiver = array('user_balance.user_id' => $insertData['reciever_id']);
                     $results_receiver = $this->transaction_model->getBalance($condition_balance_receiver);
                     if ($results_receiver->num_rows() > 0) {
                         $rowBalance_receiver = $results_receiver->row();
                         $updateData['amount'] = $rowBalance_receiver->amount + $this->input->post('total');
                         $results1 = $this->transaction_model->updateBalance($updateKey, $updateData);
                     }
                     //  Getting the account balance of the receiver -->End
                     //  $updateData['amount'] = $rowBalance->amount   +   $this->input->post('total');
                     //  $results1 			  = $this->transaction_model->updateBalance($updateKey,$updateData);
                     $projects_condition = array('projects.id' => $insertData['project_id']);
                     $projects = $this->skills_model->getUsersproject($projects_condition);
                     $projects = $projects->row();
                     //Send email to the user after registration
                     $this->load->model('email_model');
                     $conditionUserMail = array('email_templates.type' => 'transaction');
                     $result = $this->email_model->getEmailSettings($conditionUserMail);
                     $rowUserMailConent = $result->row();
                     $splVars = array("!site_name" => $this->config->item('site_title'), "!username" => $this->loggedInUser->user_name, "!siteurl" => site_url(), "!amount" => $insertData['amount'], "!type" => 'Transfer', "!others" => 'Receiver Name   :' . $registerusers->user_name, "!others1" => 'Project Name   :' . $projects->project_name, "!contact_url" => site_url('contact'));
                     $mailSubject = strtr($rowUserMailConent->mail_subject, $splVars);
                     $mailContent = strtr($rowUserMailConent->mail_body, $splVars);
                     $toEmail = $this->loggedInUser->email;
                     $fromEmail = $this->config->item('site_admin_mail');
                     $this->email_model->sendHtmlMail($toEmail, $fromEmail, $mailSubject, $mailContent);
                 }
                 $this->load->model('transaction_model');
                 $res = $this->transaction_model->addTransaction($insertData);
                 $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('Your Transaction successfully Completed')));
                 redirect('account');
             }
         }
         //Validation Failed
     }
     //If End - Check For Form Submission
     $this->load->view('transaction/transferMoney', $this->outputData);
 }
Ejemplo n.º 4
0
 /**
  * Loads Withdraw page lauput
  *
  * @access	private
  * @param	nil
  * @return	void
  */
 function index()
 {
     if (!isset($this->loggedInUser->id)) {
         $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You can not access to this page')));
         redirect('info');
     }
     if ($this->loggedInUser->suspend_status == 1) {
         $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Suspend Error')));
         redirect('info');
     }
     //Load payment model
     $this->load->model('payment_model');
     //Load payment settings
     $this->load->model('payment_model');
     $paymentGateways = $this->payment_model->getPaymentSettings();
     $this->outputData['paymentGateways'] = $paymentGateways;
     //Check Whether User Logged In Or Not
     if (isLoggedIn() === false) {
         $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Dont have rights to access this page')));
         redirect('info');
     }
     /*Load payment settings
     		$this->load->model('payment_model');
     		$paymentGateways = $this->payment_model->getPaymentSettings();
     		$this->outputData['paymentGateways']	= $paymentGateways;	
     		$conditions=array('payments.id'=>1);
     		$payamount = $this->payment_model->getPayment($conditions); 
     		foreach($payamount->result() as $res)
     		{
     	    $this->outputData['paypal_commission']=$res->commission;
     		$this->outputData['paypal_withdraw_description']=$res->withdraw_description;
     		}
     		$conditions=array('payments.id'=>3);
     		$payamount = $this->payment_model->getPayment($conditions); 
     	
     		foreach($payamount->result() as $res)
     		{
     		
     	   $this->outputData['mb_commission']=$res->commission;
     	   $this->outputData['mb_withdraw_description']=$res->withdraw_description;
     		}*/
     //Check User Balance
     $condition_balance = array('user_balance.user_id' => $this->loggedInUser->id);
     $results = $this->transaction_model->getBalance($condition_balance);
     //If Record already exists
     if ($results->num_rows() > 0) {
         //get balance detail
         $rowBalance = $results->row();
         $this->outputData['userAvailableBalance'] = $rowBalance->amount;
     }
     //Load escrow transaction
     //Load helper file
     $this->load->helper('transaction');
     $creator_condition = array('transactions.creator_id' => $this->loggedInUser->id);
     $transaction_condition = array('transactions.creator_id' => $this->loggedInUser->id, 'type' => 'Withdraw');
     $url = 'withdraw/index';
     $page = $this->uri->segment(3, 0);
     $escrow = loadTransaction($creator_condition, $transaction_condition, $url, $page);
     //Get Form Data
     if ($this->input->post('withdrawMoney')) {
         //Set Validation Rules for amount
         $this->form_validation->set_rules('total', 'lang:total_validation', 'required|trim|integer|xss_clean|abs');
         $this->form_validation->set_rules('paymentMethod', 'lang:paymentMethod_validation', 'required|trim|xss_clean');
         if ($this->form_validation->run()) {
             //get the minimum withdraw value
             if (isset($paymentGateways)) {
                 foreach ($paymentGateways as $res) {
                     $withdraw_minimum = $res['withdraw_minimum'];
                     $this->outputData['withdraw_minimum'] = $withdraw_minimum;
                 }
                 //check the balance amount for withdraw
                 if ($rowBalance->amount < $this->input->post('total')) {
                     $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('your not having sufficient balance')));
                     redirect('withdraw');
                 }
             }
             //check the minimum withdraw amount
             if ($withdraw_minimum > $this->input->post('total')) {
                 $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Minimum withdraw amount :') . $withdraw_minimum . '.00'));
                 redirect('withdraw');
             }
             $paymentSettings = $this->settings_model->getSiteSettings();
             $withdrawvalue = $rowBalance->amount - ($this->input->post('total') + $paymentSettings['PAYMENT_SETTINGS']);
             if ($withdrawvalue < 0) {
                 $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('your not having sufficient balance') . $withdraw_minimum . '.00'));
                 redirect('withdraw');
             }
             //redirect it to appropriate payment method
             $this->outputData['total'] = $this->input->post('total');
             $this->outputData['creator_id'] = $this->loggedInUser->id;
             if ($this->input->post('paymentMethod') == 'paypal') {
                 $view = 'paypalWithdraw';
                 $method = 'Paypal';
                 $this->outputData['paymentMethod'] = $method;
             }
             /*  if($this->input->post('paymentMethod')=='mb')
             
             				 {
             
             				   $view	=  'moneybookerWithdraw';
             
             				   $method  =  'mb';
             				   $this->outputData['paymentMethod']  = $method;	
             
             				 }	*/
             //Load Corresponding View Based On Payment Method
             $this->load->view('transaction/' . $view, $this->outputData);
         } else {
             $this->load->view('transaction/withdrawMoney', $this->outputData);
         }
         //If Check For Validation
     } else {
         $this->load->view('transaction/withdrawMoney', $this->outputData);
     }
     //If End - Check For Form Submission
 }