shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

recurring.php (2408B)


      1 <?php
      2 class ModelAccountRecurring extends Model {
      3 	public function getOrderRecurring($order_recurring_id) {
      4 		$query = $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)$order_recurring_id . "' AND `o`.`customer_id` = '" . (int)$this->customer->getId() . "'");
      5 
      6 		return $query->row;
      7 	}
      8 
      9 	public function getOrderRecurrings($start = 0, $limit = 20) {
     10 		if ($start < 0) {
     11 			$start = 0;
     12 		}
     13 
     14 		if ($limit < 1) {
     15 			$limit = 1;
     16 		}
     17 
     18 		$query = $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);
     19 
     20 		return $query->rows;
     21 	}
     22 	
     23 	public function getOrderRecurringByReference($reference) {
     24 		$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_recurring` WHERE `reference` = '" . $this->db->escape($reference) . "'");
     25 
     26 		return $query->row;
     27 	}
     28 
     29 	public function getOrderRecurringTransactions($order_recurring_id) {
     30 		$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_recurring_transaction` WHERE `order_recurring_id` = '" . (int)$order_recurring_id . "'");
     31 
     32 		return $query->rows;
     33 	}
     34 
     35 	public function getTotalOrderRecurrings() {
     36 		$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() . "'");
     37 
     38 		return $query->row['total'];
     39 	}
     40 	
     41 	public function addOrderRecurringTransaction($order_recurring_id, $type) {
     42 		$this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$order_recurring_id . "', `date_added` = NOW(), `type` = '" . (int)$type . "'");
     43 	}	
     44 	
     45 	public function editOrderRecurringStatus($order_recurring_id, $status) {
     46 		$this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = '" . (int)$status . "' WHERE `order_recurring_id` = '" . (int)$order_recurring_id . "'");
     47 	}	
     48 }