Example #1
0
 public function index()
 {
     $this->load->helper('multi_pay');
     $this->data['button_confirm'] = $this->language->get('button_confirm');
     // страницу окончания создания заказа свою грузим
     $this->data['action'] = $this->url->link('payment/multi_pay/pay');
     // добавили этот шаблон в общую папку
     $this->template = _tpl('/template/common/payment_confirm.tpl', $this->config->get('config_template'));
     $this->render();
 }
Example #2
0
    public function transfer()
    {
        $this->load->helper('multi_pay');
        $customer_id = $this->customer->isLogged();
        if (!$customer_id) {
            // запомним ссылку для возврата
            $this->session->data['redirect'] = $this->url->link('account/multi_pay/transfer', '', 'SSL');
            $this->redirect($this->url->link('account/login', '', 'SSL'));
        }
        $this->language->load('account/account');
        $this->language->load('account/multi_pay_transf');
        //getTotalAmount
        $total = $this->customer->getBalance();
        $amount = $email = '';
        $post = $this->request->server['REQUEST_METHOD'] == 'POST';
        if ($post) {
            $amount = (double) _g($_POST, 'amount');
            if (empty($amount)) {
                $error = $this->language->get('amount is empty');
            } elseif ($total < $amount) {
                $error = $this->language->get('amount > total');
            }
            $email = _g($_POST, 'email');
            if (empty($email)) {
                $error = $this->language->get('email is empty');
            }
        }
        if ($post and !isset($error)) {
            // найдем клиента
            $this->load->model('account/customer');
            $row = $this->model_account_customer->getCustomer($email);
            if (!$row) {
                $row = $this->model_account_customer->getCustomerByEmail($email);
            }
            if ($row) {
                $to_customer_id = $row['customer_id'];
                if ($to_customer_id == $customer_id) {
                    $error = $this->language->get('self');
                } else {
                    $this->load->model('payment/multi_pay_tools');
                    $this->model_payment_multi_pay_tools->update_deposit($customer_id, -$amount, $this->language->get('transfer to') . ' [' . $email . ']');
                    $this->model_payment_multi_pay_tools->update_deposit($to_customer_id, $amount, $this->language->get('transfer from') . ' [' . $customer_id . ']');
                    $success = $this->currency->format($amount) . ' ' . $this->language->get('transfered to') . ' [' . $email . ']';
                    $total -= $amount;
                }
            } else {
                $error = '[' . $email . '] ' . $this->language->get('not found');
            }
        }
        //$this->data['success'] = $amount . '->'. $email;
        //$this->session->data['success'] = $amount . '->'. $email;
        //$this->data['success'] = $amount . '->'. $email;
        //$this->data['warning'] = $amount . '->'. $email;
        //} else {
        //	unset($this->data['success']);
        //}
        if (isset($error)) {
            $this->session->data['error'] = $error;
        }
        $this->data['breadcrumbs'] = array();
        $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
        $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_account'), 'href' => $this->url->link('account/account', '', 'SSL'), 'separator' => $this->language->get('text_separator'));
        $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_transaction'), 'href' => $this->url->link('account/transaction', '', 'SSL'), 'separator' => $this->language->get('text_separator'));
        $this->children = array('common/content_top', 'common/header');
        $this->data['column_left'] = '';
        $this->data['column_right'] = '';
        $this->data['content_bottom'] = '';
        $this->data['footer'] = '';
        $b = '<h4>' . $this->language->get('text_subtitle') . '</h4>';
        if (isset($this->session->data['note'])) {
            $this->data['note'] = $this->session->data['note'];
        }
        $b .= '
			<h4>' . $this->language->get('Your balance') . ': ' . $this->currency->format($total) . '</h4>
			<form action="' . $this->url->link('account/multi_pay/transfer', '', 'SSL') . '" method="post">
				<label>' . $this->language->get('txt_receiver') . '</label>: 
				<input type="text" name="email" size="20" value="' . $email . '" ><br><br>
				<label>' . $this->language->get('txt_amount') . '</label>: 
				<input type="text" name="amount" value="' . $amount . '"><br><br>
				<input type="submit" class="button">
			</form>&nbsp
			<a href="' . $this->url->link('account/account', '', 'SSL') . '" class="button">' . $this->language->get('Cancel') . '</a>
		';
        if (isset($success)) {
            $b .= '<br><br><div class="success">' . $success . '</div>';
        }
        $this->data['body'] = $b;
        $this->template = _tpl('/template/common/default.tpl', $this->config->get('config_template'));
        $this->document->setTitle($this->language->get('heading_title_transf'));
        $this->data['heading_title'] = $this->language->get('heading_title_transf');
        $this->response->setOutput($this->render());
    }