Initial import: Carteasy Shop (Dev-Stand)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
class backordered_items {
|
||||
|
||||
private $layout_object;
|
||||
|
||||
function __construct() {
|
||||
$this->layout_object = Registry::get('layout_object');
|
||||
}
|
||||
|
||||
function run() {
|
||||
$backordered_items = OrderHelper::get_items_on_backorder();
|
||||
$this->layout_object->assign('backordered_items', $backordered_items);
|
||||
|
||||
return $this->layout_object->fetch('widgets/backordered_items.tpl');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
class inventory_manager {
|
||||
|
||||
private $base_object;
|
||||
private $layout_object;
|
||||
private $db;
|
||||
|
||||
function __construct() {
|
||||
$this->base_object = Registry::get('base');
|
||||
$this->layout_object = Registry::get('layout_object');
|
||||
$this->db = $this->base_object->db;
|
||||
}
|
||||
|
||||
function run() {
|
||||
if (isset($_POST['action'])) {
|
||||
$action = $_POST['action'];
|
||||
} elseif (isset($_GET['action'])) {
|
||||
$action = $_GET['action'];
|
||||
} else {
|
||||
$action = false;
|
||||
}
|
||||
|
||||
if ($action == "get_item_by_search_string") {
|
||||
$this->get_item_by_search_string();
|
||||
} elseif ($action == "get_item_for_inventory") {
|
||||
$this->get_item_for_inventory();
|
||||
} elseif ($action == "save_item_for_inventory") {
|
||||
$this->save_item_for_inventory();
|
||||
}
|
||||
|
||||
return $this->draw();
|
||||
}
|
||||
|
||||
private function draw() {
|
||||
return $this->layout_object->fetch('widgets/inventory_manager.tpl');
|
||||
}
|
||||
|
||||
private function get_item_by_search_string() {
|
||||
if (isset($_POST['data'])) {
|
||||
$data = $_POST['data'];
|
||||
} elseif (isset($_GET['data'])) {
|
||||
$data = $_GET['data'];
|
||||
} else {
|
||||
$data = false;
|
||||
}
|
||||
|
||||
if ($data) {
|
||||
$safe_data = $this->db->real_escape_string($data);
|
||||
|
||||
$sql = "SELECT id, name FROM items WHERE number LIKE '%" . $safe_data . "%' OR ean_code like '%" . $safe_data . "%'";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
$items = array();
|
||||
if ($result->num_rows > 0) {
|
||||
while ($obj = $result->fetch_object()) {
|
||||
$items[] = $obj;
|
||||
}
|
||||
}
|
||||
|
||||
$return_data = array('items' => $items);
|
||||
} else {
|
||||
$return_data = array('items' => array());
|
||||
}
|
||||
|
||||
echo json_encode($return_data);
|
||||
exit();
|
||||
}
|
||||
|
||||
private function get_item_for_inventory() {
|
||||
if (isset($_POST['id'])) {
|
||||
$id = $_POST['id'];
|
||||
} elseif (isset($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
} else {
|
||||
$id = false;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$sql = "SELECT * FROM items WHERE id=" . $this->db->real_escape_string($id);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
$item = false;
|
||||
if ($result->num_rows > 0) {
|
||||
$item = $result->fetch_object();
|
||||
}
|
||||
|
||||
if ($item) {
|
||||
$return_data = array('status' => 'success', 'item' => $item);
|
||||
} else {
|
||||
$return_data = array('status' => 'error', 'message' => 'no result');
|
||||
}
|
||||
} else {
|
||||
$return_data = array('status' => 'error', 'message' => 'no id');
|
||||
}
|
||||
|
||||
echo json_encode($return_data);
|
||||
exit();
|
||||
|
||||
}
|
||||
|
||||
private function save_item_for_inventory() {
|
||||
if (isset($_POST['id']) && $_POST['id'] != '') {
|
||||
$id = $_POST['id'];
|
||||
} else {
|
||||
$id = false;
|
||||
}
|
||||
|
||||
if (isset($_POST['inventory_min']) && $_POST['inventory_min'] != '') {
|
||||
$inventory_min = $_POST['inventory_min'];
|
||||
} else {
|
||||
$inventory_min = 0;
|
||||
}
|
||||
|
||||
if (isset($_POST['inventory']) && $_POST['inventory'] != '') {
|
||||
$inventory = $_POST['inventory'];
|
||||
} else {
|
||||
$inventory = 0;
|
||||
}
|
||||
|
||||
if (isset($_POST['inventory_add']) && $_POST['inventory_add'] != '') {
|
||||
$inventory_add = $_POST['inventory_add'];
|
||||
} else {
|
||||
$inventory_add = 0;
|
||||
}
|
||||
|
||||
if (isset($_POST['inventory_sub']) && $_POST['inventory_sub'] != '') {
|
||||
$inventory_sub = $_POST['inventory_sub'];
|
||||
} else {
|
||||
$inventory_sub = 0;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$inventory = $inventory + $inventory_add - $inventory_sub;
|
||||
$date = getdate();
|
||||
$today = $date['year'] . '-' . $date['mon'] . '-' . $date['mday'];
|
||||
|
||||
$sql = "UPDATE items SET";
|
||||
$sql .= " inventory_min=" . $this->db->real_escape_string($inventory_min);
|
||||
$sql .= ", inventory=" . $this->db->real_escape_string($inventory);
|
||||
$sql .= ", last_update='" . $this->db->real_escape_string($today) . "'";
|
||||
$sql .= " WHERE id=" . $this->db->real_escape_string($id);
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
$return_data = array('status' => 'success', 'inventory' => $inventory, 'sql' => $sql);
|
||||
} else {
|
||||
$return_data = array('status' => 'error', 'message' => 'no result', 'sql' => $sql);
|
||||
}
|
||||
} else {
|
||||
$return_data = array('status' => 'error', 'message' => 'no id');
|
||||
}
|
||||
|
||||
echo json_encode($return_data);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
// TODO: two variables
|
||||
// number of new customers
|
||||
// new customer list
|
||||
// link to full list
|
||||
class new_customers {
|
||||
|
||||
private $layout_object;
|
||||
|
||||
function __construct() {
|
||||
$this->layout_object = Registry::get('layout_object');
|
||||
}
|
||||
|
||||
function run() {
|
||||
$customer_object = new Customer(Registry::get('base'));
|
||||
|
||||
$new_customer_count = $customer_object->new_customer_count();
|
||||
$new_customers = $customer_object->get_new(10);
|
||||
|
||||
$this->layout_object->assign('new_customer_count', $new_customer_count);
|
||||
$this->layout_object->assign('new_customers', $new_customers);
|
||||
|
||||
return $this->layout_object->fetch('widgets/new_customers.tpl');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
class new_messages {
|
||||
|
||||
private $layout_object;
|
||||
|
||||
function __construct() {
|
||||
$this->layout_object = Registry::get('layout_object');
|
||||
$this->base_object = Registry::get('base');
|
||||
}
|
||||
|
||||
function run() {
|
||||
$ticket_object = new Cs_ticket($this->base_object);
|
||||
$ticket_list = $ticket_object->get_new_messages();
|
||||
$cs_ticket_message_object = new Cs_ticket_message($this->base_object);
|
||||
foreach($ticket_list as $ticket) {
|
||||
// get customer
|
||||
if($ticket->customer_id) {
|
||||
$this->base_object->customer->customer_id = $ticket->customer_id;
|
||||
$ticket->customer = $this->base_object->customer->get_data();
|
||||
}
|
||||
// get first message
|
||||
$ticket->first_message = $cs_ticket_message_object->get_first_message($ticket->id);
|
||||
$data[] = $ticket;
|
||||
}
|
||||
$this->layout_object->assign('ticket_list', $data);
|
||||
|
||||
return $this->layout_object->fetch('widgets/new_messages.tpl');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
class new_orders {
|
||||
|
||||
private $layout_object;
|
||||
|
||||
function __construct() {
|
||||
$this->layout_object = Registry::get('layout_object');
|
||||
}
|
||||
|
||||
function run() {
|
||||
$limit = 10;
|
||||
$under_min = OrderHelper::get_open_orders($limit);
|
||||
$this->layout_object->assign('open_orders', $under_min);
|
||||
|
||||
return $this->layout_object->fetch('widgets/new_orders.tpl');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
class paypal_money_back {
|
||||
|
||||
private $layout_object;
|
||||
|
||||
function __construct() {
|
||||
$this->layout_object = Registry::get('layout_object');
|
||||
}
|
||||
|
||||
function run() {
|
||||
$data = OrderHelper::get_all_orders_with_money_back();
|
||||
$this->layout_object->assign('money_back_orderes', $data);
|
||||
|
||||
return $this->layout_object->fetch('widgets/paypal_money_back.tpl');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
class warehouse_inventory {
|
||||
|
||||
private $layout_object;
|
||||
|
||||
function __construct() {
|
||||
$this->layout_object = Registry::get('layout_object');
|
||||
}
|
||||
|
||||
function run() {
|
||||
$item_object = new Item(Registry::get('base'));
|
||||
|
||||
$under_min = $item_object->get_sold_out();
|
||||
$this->layout_object->assign('low_inventory', $under_min);
|
||||
|
||||
return $this->layout_object->fetch('widgets/warehouse_inventory.tpl');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user