Вход Регистрация
Файл: upload-2031-rs1/catalog/model/account/recurring.php
Строк: 102
<?php
class ModelAccountRecurring extends Model {
    private 
$recurring_status = array(
        
=> 'Inactive',
        
=> 'Active',
        
=> 'Suspended',
        
=> 'Cancelled',
        
=> 'Expired / Complete'
    
);

    private 
$transaction_type = array(
        
=> 'Created',
        
=> 'Payment',
        
=> 'Outstanding payment',
        
=> 'Payment skipped',
        
=> 'Payment failed',
        
=> 'Cancelled',
        
=> 'Suspended',
        
=> 'Suspended from failed payment',
        
=> 'Outstanding payment failed',
        
=> 'Expired'
    
);

    public function 
getProfile($id) {
        
$result $this->db->query("SELECT `or`.*,`o`.`payment_method`,`o`.`payment_code`,`o`.`currency_code` FROM `" DB_PREFIX "order_recurring` `or` LEFT JOIN `" DB_PREFIX "order` `o` ON `or`.`order_id` = `o`.`order_id` WHERE `or`.`order_recurring_id` = '" . (int)$id "' AND `o`.`customer_id` = '" . (int)$this->customer->getId() . "' LIMIT 1");

        if (
$result->num_rows 0) {
            
$recurring $result->row;

            return 
$recurring;
        } else {
            return 
false;
        }
    }

    public function 
getProfileByRef($ref) {
        
$recurring $this->db->query("SELECT * FROM `" DB_PREFIX "order_recurring` WHERE `reference` = '" $this->db->escape($ref) . "' LIMIT 1");

        if (
$recurring->num_rows 0) {
            return 
$recurring->row;
        } else {
            return 
false;
        }
    }

    public function 
getProfileTransactions($id) {
        
$recurring $this->getProfile($id);

        
$results $this->db->query("SELECT * FROM `" DB_PREFIX "order_recurring_transaction` WHERE `order_recurring_id` = '" . (int)$id "'");

        if (
$results->num_rows 0) {
            
$transactions = array();

            foreach (
$results->rows as $transaction) {

                
$transaction['amount'] = $this->currency->format($transaction['amount'], $recurring['currency_code'], 1);

                
$transactions[] = $transaction;
            }

            return 
$transactions;
        } else {
            return 
false;
        }
    }

    public function 
getAllProfiles($start 0$limit 20) {
        if (
$start 0) {
            
$start 0;
        }

        if (
$limit 1) {
            
$limit 1;
        }

        
$result $this->db->query("SELECT `or`.*,`o`.`payment_method`,`o`.`currency_id`,`o`.`currency_value` FROM `" DB_PREFIX "order_recurring` `or` LEFT JOIN `" DB_PREFIX "order` `o` ON `or`.`order_id` = `o`.`order_id` WHERE `o`.`customer_id` = '" . (int)$this->customer->getId() . "' ORDER BY `o`.`order_id` DESC LIMIT " . (int)$start "," . (int)$limit);

        if (
$result->num_rows 0) {
            
$recurrings = array();

            foreach (
$result->rows as $recurring) {
                
$recurrings[] = $recurring;
            }

            return 
$recurrings;
        } else {
            return 
false;
        }
    }

    public function 
getTotalRecurring() {
        
$query $this->db->query("SELECT COUNT(*) AS total FROM `" DB_PREFIX "order_recurring` `or` LEFT JOIN `" DB_PREFIX "order` `o` ON `or`.`order_id` = `o`.`order_id` WHERE `o`.`customer_id` = '" . (int)$this->customer->getId() . "'");

        return 
$query->row['total'];
    }
}
Онлайн: 0
Реклама