Initial import: Carteasy Shop (Dev-Stand)
This commit is contained in:
Vendored
+88
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/*
|
||||
* @version $Id: index.php 10381 2008-06-01 03:35:53Z $
|
||||
* @package Carteasy
|
||||
* @copyright Copyright (C) 2005 - 2011 Wlanium
|
||||
* @license proprietary
|
||||
* @author Thomas Bartelt
|
||||
* Carteasy is a web shop system
|
||||
*/
|
||||
|
||||
include_once './core/base/edit.class.php';
|
||||
|
||||
class Vendors_Edit extends Base_Edit {
|
||||
|
||||
public function __construct($base_object, $id = false) {
|
||||
parent::__construct($base_object, $id);
|
||||
} // end __construct
|
||||
|
||||
public function get_data($id = false) {
|
||||
if ($id) {
|
||||
$this->set_id($id);
|
||||
}
|
||||
|
||||
return $this->select_one('herstellerinformationen');
|
||||
} // end get_data
|
||||
|
||||
public function delete_data($id = false) {
|
||||
if ($id) {
|
||||
$this->set_id($id);
|
||||
}
|
||||
|
||||
return $this->delete_one('herstellerinformationen');
|
||||
} // end delete
|
||||
|
||||
public function create($data) {
|
||||
return $this->create_one('herstellerinformationen', $data);
|
||||
} // end create
|
||||
|
||||
public function update($data, $id = false) {
|
||||
if ($id) {
|
||||
$this->set_id($id);
|
||||
}
|
||||
|
||||
return $this->update_one('herstellerinformationen', $data);
|
||||
} // end update
|
||||
|
||||
public function get_all() {
|
||||
$result = $this->db->query("SELECT id, marke_name, hersteller_name FROM herstellerinformationen ORDER BY hersteller_name");
|
||||
|
||||
$data = array();
|
||||
while ($row = $result->fetch_object()) {
|
||||
$vendor = new stdClass();
|
||||
$vendor->id = intval($row->id);
|
||||
$vendor->name = $row->marke_name . ' - ' . $row->hersteller_name;
|
||||
$vendor->value = intval($row->id);
|
||||
$vendor->hersteller_id = intval($row->id);
|
||||
$data[] = $vendor;
|
||||
}
|
||||
|
||||
return $data;
|
||||
} // end get_all
|
||||
|
||||
public function get_dropdown_data() {
|
||||
return $this->get_all();
|
||||
} // end get_dropdown_data
|
||||
|
||||
protected function select_one($table) {
|
||||
if ($this->id) {
|
||||
// Debug-Ausgabe
|
||||
error_log("Vendor select_one - Suche nach ID: " . $this->id);
|
||||
|
||||
$sql = "SELECT * FROM herstellerinformationen WHERE id = " . intval($this->id);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
// Debug-Ausgabe
|
||||
error_log("Vendor select_one - SQL: " . $sql);
|
||||
|
||||
if ($result && $result->num_rows > 0) {
|
||||
return $result->fetch_object();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}// end ItemTypeDefinition_Edit
|
||||
|
||||
/* EOF */
|
||||
Vendored
+78
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*
|
||||
* @version $Id: index.php 10381 2008-06-01 03:35:53Z $
|
||||
* @package Carteasy
|
||||
* @copyright Copyright (C) 2005 - 2011 Wlanium
|
||||
* @license proprietary
|
||||
* @author Thomas Bartelt
|
||||
* Carteasy is a web shop system
|
||||
*/
|
||||
|
||||
class Vendors_List {
|
||||
|
||||
private $base_object;
|
||||
private $db;
|
||||
|
||||
public function __construct($base_object) {
|
||||
$this->base_object = $base_object;
|
||||
$this->db = $base_object->db;
|
||||
} // end __construct
|
||||
|
||||
public function get_number_of_pages($items, $filter = false) {
|
||||
$sql = 'SELECT * FROM herstellerinformationen';
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
return (int)ceil($result->num_rows / $items);
|
||||
} // end get_number_of_pages
|
||||
|
||||
public function get_pagination_array($items, $page, $filter = false) {
|
||||
$sql = 'SELECT * FROM herstellerinformationen';
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
$num = $result->num_rows;
|
||||
|
||||
$pages = (int)ceil($num / $items);
|
||||
|
||||
while ($i < $pages) {
|
||||
$data[] = ++$i;
|
||||
}
|
||||
|
||||
if ($pages > 10) {
|
||||
if ($page <= 5) {
|
||||
$data = array_slice($data, 0, 10);
|
||||
} else if ($page > ($pages - 4)) {
|
||||
$data = array_slice($data, $pages-10, 10);
|
||||
} else {
|
||||
$data = array_slice($data, $page -5, 10);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
} // end get_pagination_array
|
||||
|
||||
public function get_all_paginated($items, $page, $sortation, $sortation_direction, $filter = false) {
|
||||
$sql = 'SELECT * FROM herstellerinformationen';
|
||||
|
||||
if ($sortation) {
|
||||
$sql .= ' ORDER BY ' . $sortation . ' ' . $sortation_direction;
|
||||
} else {
|
||||
$sql .= ' ORDER BY hersteller_name ASC';
|
||||
}
|
||||
|
||||
$sql .= ' LIMIT ' . ($page - 1) * $items . ', ' . $items;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
$data = array();
|
||||
while ($row = $result->fetch_object()) {
|
||||
$data[$row->hersteller_id] = $row;
|
||||
}
|
||||
|
||||
return $data;
|
||||
} // end get_all_paginated
|
||||
|
||||
} // end Vendors_List
|
||||
|
||||
/* EOF */
|
||||
Reference in New Issue
Block a user