Initial import: Carteasy Shop (Dev-Stand)
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
class CancellationRequests {
|
||||
|
||||
// generic
|
||||
private $base_object;
|
||||
private $id;
|
||||
private $db;
|
||||
private $error;
|
||||
|
||||
function __construct($base_object) {
|
||||
$this->base_object = $base_object;
|
||||
$this->db = $base_object->db;
|
||||
$this->id = $id;
|
||||
$this->error = '';
|
||||
} // end constructor
|
||||
|
||||
public function get_error() {
|
||||
return $this->error;
|
||||
} // end get_error
|
||||
|
||||
public function get_all_paginated($items, $page) {
|
||||
$page = ($page - 1) * $items;
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
orders
|
||||
WHERE
|
||||
order_status != 6
|
||||
AND
|
||||
cancellation_status = 1
|
||||
LIMIT $items OFFSET $page";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
while ($obj = $result->fetch_object()) {
|
||||
$return_data[] = $obj;
|
||||
}
|
||||
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
return false;
|
||||
} // end get_all_paginated
|
||||
|
||||
public function get_number_of_pages($items) {
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
orders
|
||||
WHERE
|
||||
cancellation_status=1";
|
||||
|
||||
$num = $this->db->query($sql)->num_rows;
|
||||
|
||||
return (int)ceil($num / $items);
|
||||
} // end get_number_of_pages
|
||||
|
||||
public function get_pagination_array($items, $page) {
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
orders
|
||||
WHERE
|
||||
cancellation_status=1";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
$num = $result->num_rows;
|
||||
$pages = (int)ceil($num / $items);
|
||||
|
||||
$i = 0;
|
||||
while ($i < $pages) {
|
||||
$data[] = ++$i;
|
||||
}
|
||||
|
||||
if ($pages > 10) {
|
||||
if ($page <= 5) {
|
||||
$data = array_slice($result, 0, 10);
|
||||
} else if ($page > ($pages - 4)) {
|
||||
$data = array_slice($result, $pages-10, 10);
|
||||
} else {
|
||||
|
||||
$data = array_slice($result, $page -5, 10);
|
||||
}
|
||||
}
|
||||
|
||||
if ($pages == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $data;
|
||||
} // end get_pagination_array
|
||||
}
|
||||
Reference in New Issue
Block a user