public function index() { $data = array(); $data['systemMessageType'] = SYS_MSG_ADD_CREDIT; $data = array_merge($data, $this->parameters); $addCreditRequests = Messaging::getSystemMessages($data); // $this->log->write(print_r($addCreditRequests, true)); $this->data['customersToFilterBy'] = $this->getCustomers(); $this->data['requests'] = array(); foreach ($addCreditRequests as $addCreditRequest) { $customer = CustomerDAO::getInstance()->getCustomer($addCreditRequest['senderId']); $actions = array(); if ($addCreditRequest['data']->status == ADD_CREDIT_STATUS_PENDING) { $actions['accept'] = array('text' => $this->language->get('ACCEPT'), 'onclick' => 'acceptRequest(' . $addCreditRequest['messageId'] . ', this)'); $actions['reject'] = array('text' => $this->language->get('REJECT'), 'onclick' => 'rejectRequest(' . $addCreditRequest['messageId'] . ', this)'); } $this->data['requests'][] = array('requestId' => $addCreditRequest['messageId'], 'actions' => $actions, 'amount' => $addCreditRequest['data']->amount, 'comment' => $addCreditRequest['data']->comment, 'currency' => $addCreditRequest['data']->currency, 'customerName' => $customer['lastname'] . ' ' . $customer['firstname'] . ' / ' . $customer['nickname'], 'customerUrl' => $this->url->link('sale/customer/update', 'token=' . $this->session->data['token'] . '&customer_id=' . $addCreditRequest['senderId'], 'SSL'), 'status' => $this->load->model('localisation/requestStatus')->getStatus($addCreditRequest['data']->status), 'statusId' => $addCreditRequest['data']->status, 'timeAdded' => $addCreditRequest['timeAdded']); } $this->data = array_merge($this->data, $this->parameters); /// Initialize interface $this->setBreadcrumps(); $this->data['textActions'] = $this->language->get('ACTIONS'); $this->data['textAmount'] = $this->language->get('AMOUNT'); $this->data['textComment'] = $this->language->get('COMMENT'); $this->data['textCustomer'] = $this->language->get('CUSTOMER'); $this->data['textFilter'] = $this->language->get('FILTER'); $this->data['textPaymentMethod'] = $this->language->get('PAYMENT_METHOD'); $this->data['textRequestId'] = $this->language->get('REQUEST_ID'); $this->data['textStatus'] = $this->language->get('STATUS'); $this->data['textTimeAdded'] = $this->language->get('TIME_ADDED'); $this->data['urlSelf'] = $this->url->link($this->selfRoute, 'token=' . $this->parameters['token'], 'SSL'); $this->template = 'sale/creditManagement.tpl'; $this->children = array('common/footer', 'common/header'); $this->getResponse()->setOutput($this->render()); }
public function getList() { $addCreditRequests = Messaging::getSystemMessages(array('systemMessageType' => SYS_MSG_ADD_CREDIT, 'filterCustomerId' => array($this->customer->getId()))); // $this->log->write(print_r($addCreditRequests, true)); foreach ($addCreditRequests as $addCreditRequest) { // if ($addCreditRequest['senderId'] != $this->customer->getId()) // continue; $this->data['requests'][] = array('requestId' => $addCreditRequest['messageId'], 'amount' => $addCreditRequest['data']->amount, 'comment' => $addCreditRequest['data']->comment, 'currency' => $addCreditRequest['data']->currency, 'status' => Status::getStatus($addCreditRequest['data']->status, $this->config->get('language_id'), true), 'statusId' => $addCreditRequest['data']->status, 'timeAdded' => $addCreditRequest['timeAdded']); } /// Initialize interface $this->setBreadcrumps(); $this->data['textAmount'] = $this->language->get('AMOUNT'); $this->data['textComment'] = $this->language->get('COMMENT'); $this->data['textRequestId'] = $this->language->get('REQUEST_ID'); $this->data['textStatus'] = $this->language->get('STATUS'); $this->data['textTimeAdded'] = $this->language->get('TIME_ADDED'); $templateName = '/template/account/creditHistory.tpl'; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . $templateName)) { $this->template = $this->config->get('config_template') . $templateName; } else { $this->template = 'default' . $templateName; } $this->children = array('common/footer', 'common/header', 'common/column_right', 'common/column_left', 'common/content_top', 'common/content_bottom'); $this->getResponse()->setOutput($this->render()); }
private function getCreditRequests($customer) { $this->getLoader()->library('Messaging'); $this->getLoader()->library('Status'); $addCreditRequests = Messaging::getSystemMessages(array('systemMessageType' => SYS_MSG_ADD_CREDIT, 'filterCustomerId' => array($customer['customer_id']), 'start' => ($this->parameters['creditRequestsPage'] - 1) * 10, 'limit' => 10)); // $this->log->write(print_r($addCreditRequests, true)); foreach ($addCreditRequests as $addCreditRequest) { $this->data['requests'][] = array('requestId' => $addCreditRequest['messageId'], 'amount' => $addCreditRequest['data']->amount, 'comment' => $addCreditRequest['data']->comment, 'currency' => $addCreditRequest['data']->currency, 'status' => Status::getStatus($addCreditRequest['data']->status, $this->config->get('language_id'), true), 'statusId' => $addCreditRequest['data']->status, 'timeAdded' => $addCreditRequest['timeAdded']); } /// Initialize interface $this->data['textAmount'] = $this->language->get('AMOUNT'); $this->data['textComment'] = $this->language->get('COMMENT'); $this->data['textRequestId'] = $this->language->get('REQUEST_ID'); $this->data['textStatus'] = $this->language->get('STATUS'); $this->data['textTimeAdded'] = $this->language->get('TIME_ADDED'); $pagination = new Pagination(); $pagination->total = Messaging::getSystemMessagesCount(SYS_MSG_ADD_CREDIT, $customer['customer_id']); $pagination->page = $this->parameters['creditRequestsPage']; $pagination->limit = 10; $pagination->text = $this->language->get('text_pagination'); $pagination->url = $this->url->link('sale/customer/transaction', 'creditRequestsPage={page}&transactionsPage=' . $this->parameters['transactionsPage'] . '&token=' . $this->parameters['token'] . '&customerId=' . $this->parameters['customerId'], 'SSL'); $this->data['creditRequestsPagination'] = $pagination->render(); }