Ejemplo n.º 1
0
 public function handleUpdate($messageId)
 {
     //        AddCreditRequest::$instance->log->write('Starting');
     $request = Messaging::getSystemMessage($messageId);
     //        AddCreditRequest::$instance->log->write(print_r($request, true));
     if ($request['data']->status == ADD_CREDIT_STATUS_ACCEPTED) {
         $this->load->library("Transaction");
         Transaction::addCredit($request['senderId'], $request['data']->amount, $request['data']->currency, $this->registry, $request['data']->comment);
     }
 }
Ejemplo n.º 2
0
 public function approvePhotos($photo_ids, $credits, $desc)
 {
     $today = date("Y-m-d");
     $query = "UPDATE gallery_photo SET approved_at ='" . $today . "' WHERE photo_id IN (" . implode(",", $photo_ids) . ")";
     $this->db->query($query);
     $query = "SELECT DISTINCT customer_id FROM gallery_photo WHERE photo_id IN (" . implode(",", $photo_ids) . ")";
     $result = $this->db->query($query);
     if ($credits > 0) {
         $this->load->library('Transaction');
         foreach ($result->rows as $row) {
             //$this->log->write("------------------------------------------------------>" . $credits);
             Transaction::addCredit($row['customer_id'], $credits, 'WON', $this->registry, $desc);
         }
     }
 }
Ejemplo n.º 3
0
 public function transaction()
 {
     $this->getLoader()->library('Transaction');
     $customer = CustomerDAO::getInstance()->getCustomer($this->parameters['customerId']);
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         if ($this->user->hasPermission('modify', 'sale/customer')) {
             if ($this->request->post['action'] == 'add') {
                 if ($this->request->post['amount'] < 0) {
                     Transaction::addCredit($this->parameters['customerId'], -$this->request->post['amount'], $customer['base_currency_code'], $this->registry, $this->request->post['description']);
                     $this->data['success'] = $this->language->get('SUCCESS_CREDIT_ADDED');
                 } elseif ($this->request->post['amount'] > 0) {
                     Transaction::addTransaction(0, $this->parameters['customerId'], $this->request->post['amount'], $customer['base_currency_code'], $this->request->post['description']);
                     $this->data['success'] = $this->language->get('SUCCESS_PAYMENT_ADDED');
                 }
             } elseif ($this->request->post['action'] == 'delete') {
                 $modelSaleTransaction = $this->getLoader()->model('sale/transaction');
                 $transaction = $modelSaleTransaction->getTransaction($this->request->post['transactionId']);
                 if ($transaction['invoice_id'] != 0) {
                     $this->data['error_warning'] = $this->language->get('ERROR_RELATED_INVOICE_EXISTS');
                 } elseif ($transaction['currency_code'] != $customer['base_currency_code']) {
                     $this->data['error_warning'] = $this->language->get('ERROR_TRANSACTION_AND_CUSTOMER_CURRENCY_DONT_MATCH');
                 } else {
                     Transaction::deleteTransaction($this->request->post['transactionId']);
                     $this->data['success'] = sprintf($this->language->get('SUCCESS_TRANSACTION_DELETED'), $this->request->post['transactionId']);
                 }
             }
             $customer = CustomerDAO::getInstance()->getCustomer($this->parameters['customerId']);
         } else {
             $this->data['error_warning'] = $this->language->get('error_permission');
         }
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && !$this->user->hasPermission('modify', 'sale/customer')) {
         $this->data['error_warning'] = $this->language->get('error_permission');
     }
     $this->data['text_no_results'] = $this->language->get('text_no_results');
     $this->data['text_balance'] = $this->language->get('text_balance');
     $this->data['column_date_added'] = $this->language->get('column_date_added');
     $this->data['column_description'] = $this->language->get('column_description');
     $this->data['column_amount'] = $this->language->get('column_amount');
     $this->data['textAction'] = $this->language->get('ACTIONS');
     $this->data['textInvoiceId'] = $this->language->get('INVOICE_ID');
     $this->data['textTransactionId'] = $this->language->get('TRANSACTION_ID');
     $this->getTransactions($customer);
     $this->getCreditRequests($customer);
     $this->getResponse()->setOutput($this->render('sale/customerTransaction.tpl.php'));
     return;
     if (isset($_REQUEST['page'])) {
         $page = $_REQUEST['page'];
     } else {
         $page = 1;
     }
     $this->data['transactions'] = array();
     $results = CustomerDAO::getInstance()->getTransactions($_REQUEST['customer_id'], ($page - 1) * 10, 10);
     foreach ($results as $result) {
         $actions = array();
         $actions[] = array('text' => $this->language->get('DELETE'), 'onclick' => "deleteTransaction(" . $result['customer_transaction_id'] . ");");
         $this->data['transactions'][] = array('transactionId' => $result['customer_transaction_id'], 'actions' => $actions, 'amount' => $this->currency->format($result['amount'], $result['currency_code'], 1), 'description' => $result['description'], 'date_added' => $result['date_added'], 'invoiceId' => $result['invoice_id'] ? $result['invoice_id'] : '', 'invoiceUrl' => $this->url->link('sale/invoice/showForm', 'invoiceId=' . $result['invoice_id'] . '&token=' . $this->session->data['token'], 'SSL'));
     }
     $this->data['balance'] = $this->currency->format(CustomerDAO::getInstance()->getCustomerBalance($_REQUEST['customer_id']), $customer['base_currency_code'], 1);
     $transaction_total = CustomerDAO::getInstance()->getTotalTransactions($_REQUEST['customer_id']);
     $pagination = new Pagination();
     $pagination->total = $transaction_total;
     $pagination->page = $page;
     $pagination->limit = 10;
     $pagination->text = $this->language->get('text_pagination');
     $pagination->url = $this->url->link('sale/customer/transaction', 'token=' . $this->session->data['token'] . '&customer_id=' . $_REQUEST['customer_id'] . '&page={page}', 'SSL');
     $this->data['pagination'] = $pagination->render();
     $this->template = 'sale/customer_transaction.tpl';
     $this->getResponse()->setOutput($this->render());
 }