Initial import: Carteasy Shop (Dev-Stand)

This commit is contained in:
Thomas Bartelt
2026-04-20 01:03:43 +02:00
commit d504f8a05d
3845 changed files with 761050 additions and 0 deletions
+288
View File
@@ -0,0 +1,288 @@
<?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/main.class.php';
class Country extends Main {
protected $db;
protected $base_object;
public $list_table_config = array (
'title' => 'Länder',
'db_table' => 'countries',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Land',
'sortable' => 1
),
array( 'db_field' => 'iso_code_2',
'name' => 'ISO 3166 ALPHA-2',
'sortable' => 1
),
array( 'db_field' => 'iso_code_3',
'name' => 'ISO 3166 ALPHA-3',
'sortable' => 1
),
array(
'db_field' => 'shipping_area_id',
'name' => 'Lieferzone',
'rewrite_function' => 'shipping_areas',
'sortable' => 1
)
),
'search_fields' => array('name', 'iso_code_2'),
'db_id_field' => 'id',
'edit_link' => 'index.php?admin_modul=admin_country_editor&id=',
'toolbar' => array(
'delete' => 1,
'new' => 'index.php?admin_modul=admin_country_editor',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
)
);
private $object_fields = array(
'name' => 'text',
'shipping_area_id' => 'integer',
'rang' => 'integer',
'iso_code_2' => 'text',
'iso_code_3' => 'text',
'customer_ust_id_required' => 'integer'
);
public $id;
function __construct($base_object) {
$this->base_object = $base_object;
$this->db = $base_object->db;
$this->id = false;
} // end __construct
function shipping_areas() {
include_once './core/shipping_area.class.php';
$shipping_area_object = New Shipping_area($this->base_object);
return $shipping_area_object->get_all_names();
}
public function get_all($filter = false) {
$sql = "SELECT * FROM countries";
if ($filter['isset_shipping_area'] && $filter['isset_shipping_area'] == 1) {
$sql .= ' WHERE shipping_area_id > 0';
}
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[$obj->id] = $obj;
}
return $data;
} // end get_all
public function get_all_names() {
$sql = "SELECT id, name FROM countries";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[$obj->id] = $obj->name;
}
return $data;
} // end get_all
public function set_id($id) {
$this->id = $id;
}
public function get_id() {
return $this->id;
}
public function get_data() {
if ($this->id) {
$sql = "SELECT *
FROM countries
WHERE id = ".$this->id;
$result = $this->db->query($sql);
$obj = $result->fetch_object();
if ($obj) {
$obj->customer_group_shipping_area = array();
$sql = "SELECT *
FROM country_customergroup_shippingarea
WHERE country_id = ".$this->id;
$result = $this->db->query($sql);
while ($obj2 = $result->fetch_object()) {
$obj->customer_group_shipping_area[$obj2->customer_group_id] = $obj2->shipping_area_id;
}
return $obj;
}
}
return false;
} // end get_data
public function delete() {
$sql = "DELETE FROM countries
WHERE id=".$this->id;
$this->db->query($sql);
return;
}// end delete
public function data_filter($request) {
$data = array();
foreach ($this->object_fields as $field_name => $var_type) {
if (isset($request[$field_name])) {
if ($var_type == 'text') {
$data[$field_name] = $request[$field_name];
} else {
$data[$field_name] = (int)$request[$field_name];
}
}
}
return $data;
} // end data_filter
public function create($data) {
if ($data) {
$sql = "INSERT INTO countries
SET ";
foreach ($data as $var_name => $value) {
$value = $this->db->real_escape_string($value);
if ($this->object_fields[$var_name] == 'integer') {
$sql .= $var_name.' = '.$value.', ';
} else {
$sql .= $var_name.' = "'.$value.'", ';
}
}
$sql = substr($sql, 0, -2);
$this->db->query($sql);
$this->id = $this->db->insert_id;
}
return;
} // end create
public function update($data) {
if ($data) {
$sql = "UPDATE countries
SET ";
foreach ($data as $var_name => $value) {
$value = $this->db->real_escape_string($value);
if ($this->object_fields[$var_name] == 'integer') {
$sql .= $var_name.'='.$value.', ';
} else {
$sql .= $var_name.'="'.$value.'", ';
}
}
$sql = substr($sql, 0, -2);
$sql .= ' WHERE id='.$this->id;
$this->db->query($sql);
}
return;
} // end update
public function save_customer_group_shipping_areas($country_id, $data) {
// delete old discounts
$sql = "DELETE FROM country_customergroup_shippingarea WHERE country_id=".$this->db->real_escape_string($country_id);
$result = $this->db->query($sql);
if ($data) {
// set new shipping areas
$sql = "
INSERT INTO country_customergroup_shippingarea (
country_id,
shipping_area_id,
customer_group_id
) VALUES
";
foreach ($data as $customer_group_id => $shipping_area_id) {
$sql .= "(
".$this->db->real_escape_string($country_id).",
".$this->db->real_escape_string($shipping_area_id).",
".$this->db->real_escape_string($customer_group_id)."), ";
}
$sql = substr($sql, 0, -2);
$result = $this->db->query($sql);
}
return;
}
public function delete_by_id($id) {
$rs = $this->db->query("DELETE FROM countries WHERE id=$id;");
} // end delete_by_id
public static function get_name_by_id($id) {
$db = Registry::get('base')->db;
$sql = "SELECT
name
FROM
countries
WHERE id = $id";
$result = $db->query($sql);
if ($result->num_rows > 0) {
$return = $result->fetch_object();
return $return->name;
}
return false;
} // end get_name_by_id
public static function getShippingAreaById($countryId, $customer_group_id = false) {
$db = Registry::get('base')->db;
$sql = "SELECT shipping_area_id
FROM countries
WHERE id = $countryId";
$result = $db->query($sql);
$shipping_area_id = false;
if ($result->num_rows > 0) {
$shipping_area_id = $result->fetch_object()->shipping_area_id;
}
if ($customer_group_id) {
$sql = "SELECT * FROM country_customergroup_shippingarea
WHERE country_id = $countryId AND customer_group_id = $customer_group_id";
$result = $db->query($sql);
if ($result->num_rows > 0) {
$shipping_area_id = $result->fetch_object()->shipping_area_id;
}
}
return $shipping_area_id;
}
} // end Country
?>
+66
View File
@@ -0,0 +1,66 @@
<?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/delivererhelper.class.php';
include_once './core/paymenthelper.class.php';
class CountryHelper {
//=========================================
//
// THIS CLASS IS STATIC ONLY
//
//=========================================
private function __construct() {}
private function __clone() {}
//=========================================
//
// THE PUBLIC INTERFACE
//
//=========================================
public static function get_delivery_and_shipping_info_for_all_countries() {
$db = Registry::get('base')->db;
$deliverer_array = DelivererHelper::get_deliverers_by_shipping_area_array();
$payment_array = PaymentHelper::get_payment_methods_by_shipping_area_array();
$sql = "SELECT * FROM countries";
$result = $db->query($sql);
if ($result->num_rows > 0 && $deliverer_array && $payment_array) {
while ($obj = $result->fetch_object()) {
$country_array[] = array('name' => $obj->name, 'id' => $obj->id, 'delivery_methods' => $deliverer_array[$obj->shipping_area_id], 'payment_methods' => $payment_array[$obj->shipping_area_id]);
}
return $country_array;
}
return false;
}
public static function get_shipping_area_by_country_id($country_id) {
$db = Registry::get('base')->db;
$sql = "SELECT * FROM countries WHERE id=".$country_id;
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object()->shipping_area_id;
}
return false;
}
}
?>
File diff suppressed because it is too large Load Diff
+473
View File
@@ -0,0 +1,473 @@
<?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/database.class.php';
class CustomerAddress {
// table fields
private $table_fields = array(
'customer_id' => array('required' => true, 'type' => 'int'),
'company' => array('required' => false, 'type' => 'text'),
'honorific' => array('required' => true, 'type' => 'int'),
'firstname' => array('required' => false, 'type' => 'text'),
'surname' => array('required' => false, 'type' => 'text'),
'street' => array('required' => true, 'type' => 'text'),
'house_number' => array('required' => false, 'type' => 'text'),
'zip_code' => array('required' => true, 'type' => 'text'),
'city' => array('required' => true, 'type' => 'text'),
'country' => array('required' => true, 'type' => 'int'),
'orders' => array('required' => false, 'type' => 'int')
);
// generic
private $base_object;
private $db;
private $address_id;
private $customer_id;
private $error;
private $validation_errors;
public function __construct($base_object, $address_id = false, $customer_id = false) {
$this->base_object = $base_object;
$this->db = $base_object->db;
$this->address_id = $address_id;
$this->customer_id = $customer_id;
$this->error = '';
$this->validation_errors = array();
} // end constructor
public function set_address_id($address_id) {
$this->address_id = $address_id;
} // end set_id
public function get_id() {
return $this->address_id;
} // end get_id
public function set_customer_id($customer_id) {
$this->customer_id = $customer_id;
} // end set_customer_id
public function get_customer_id() {
return $this->customer_id();
} // end get_customer_id
public function get_customer_id_by_address_id($address_id = false) {
$sql = "SELECT customer_id FROM customer_addresses";
if ($address_id) {
$sql .= " WHERE id=".$this->db->real_escape_string($address_id);
$this->address_id = $address_id;
} else if ($this->address_id) {
$sql .= " WHERE id=".$this->db->real_escape_string($this->address_id);
} else {
$this->error = "no address id";
return false;
}
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object()->customer_id;
}
$this->error = "no result";
return false;
} // end get_customer_id_by_address_id
public function get_error() {
return $this->error;
} // end get_error
public function get_validation_errors() {
return $this->validation_errors;
} // end get_validation_errors
public function get_all($filter = false, $customer_id = false) {
$sql = "SELECT * FROM customer_addresses WHERE";
if ($customer_id) {
$sql .= " customer_id=".$this->db->real_escape_string($customer_id);
$this->customer_id = $customer_id;
} else if ($this->customer_id) {
$sql .= " customer_id=".$this->db->real_escape_string($this->customer_id);
} else {
$this->error = "no customer id";
return false;
}
// TODO: I need filter object, here for coutnries
if ($filter) {
if ($filter == 'WHATEVER') {
$sql .= 'WHERE something';
} else {
$this->error = "unknown filter";
return false;
}
}
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
$return_data = array();
while ($obj = $result->fetch_object()) {
$return_data[$obj->id] = $this->enrich($obj);
}
return $return_data;
}
$this->error = "no result";
return false;
} // end get_all
public function get_data_by_address_id($address_id = false) {
$sql = "SELECT * FROM customer_addresses";
if ($address_id) {
$sql .= " WHERE id=".$this->db->real_escape_string($address_id);
$this->address_id = $address_id;
} else if ($this->address_id) {
$sql .= " WHERE id=".$this->db->real_escape_string($this->address_id);
} else {
$this->error = "no address id";
return false;
}
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $this->enrich($result->fetch_object());
}
$this->error = "no result";
return false;
} // end get_data_by_address_id
public function get_data_by_customer_id($customer_id = false) {
$sql = "SELECT * FROM customer_addresses";
if ($customer_id) {
$sql .= " WHERE customer_id=".$this->db->real_escape_string($customer_id);
$this->customer_id = $customer_id;
} else if ($this->customer_id) {
$sql .= " WHERE customer_id=".$this->db->real_escape_string($customer_id);
} else {
$this->error = "no customer id";
return false;
}
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
$return_data = array();
while ($obj = $result->fetch_object()) {
$return_data[$obj->id] = $this->enrich($obj);
}
return $return_data;
}
$this->error = "no result";
return false;
} // end get_data_by_customer_id
public function delete_by_address_id($address_id = false) {
$sql = "DELETE FROM customer_addresses";
if ($address_id) {
$sql .= " WHERE id=".$this->db->real_escape_string($address_id);
$this->address_id = $address_id;
} else if ($this->address_id) {
$sql .= " WHERE id=".$this->db->real_escape_string($this->address_id);
} else {
$this->error = "no address id";
return false;
}
$result = $this->db->query($sql);
if ($result) {
$this->address_id = false;
return true;
}
$this->error = "can't delete";
return false;
} // end delete_by_address_id
public function delete_by_customer_id($customer_id = false) {
$sql = "DELETE FROM customer_addresses";
if ($customer_id) {
$sql .= " WHERE customer_id=".$this->db->real_escape_string($customer_id);
$this->customer_id = $customer_id;
} else if ($this->customer_id) {
$sql .= " WHERE customer_id=".$this->db->real_escape_string($this->customer_id);
} else {
$this->error = "no customer id";
return false;
}
$result = $this->db->query($sql);
if ($result) {
$this->address_id = false;
$this->customer_id = false;
return true;
}
$this->error = "can't delte";
return false;
} // end delte_by_customer_id
public function create($data, $customer_id = false) {
if ($data) {
$is_valid = $this->validate($data);
if ($is_valid) {
if (!isset($data['customer_id'])) {
if ($customer_id) {
$data['customer_id'] = $customer_id;
$this->customer_id = $customer_id;
} else if ($this->customer_id) {
$data['customer_id'] = $this->customer_id;
} else {
$this->error = "no customer id";
return false;
}
}
$sql = "INSERT INTO customer_addresses ";
$data_line = "";
$insert_line = "";
$first = true;
foreach ($data as $key => $value) {
if ($first) {
$first = false;
} else {
$data_line .= ", ";
$value_line .= ", ";
}
$data_line .= $key;
$value_line .= "'".$this->db->real_escape_string($value)."'";
}
$sql .= "(".$data_line.") ";
$sql .= " VALUES (".$value_line.")";
$result = $this->db->query($sql);
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/customeraddress.php->create()', $this->db->error.', sql:'.$sql);
}
if ($result) {
$this->address_id = $this->db->insert_id;
return $this->address_id;
}
$this->error = "create failed";
return false;
}
$this->error = "invalid data";
return false;
}
$this->error = "no data";
return false;
} // end create
public function update($data, $address_id = false) {
if ($data) {
$is_valid = $this->validate($data);
if ($is_valid) {
if (isset($data['address'])) {
$this->address_id = $data['address'];
unset($data['address']);
}
$sql = "UPDATE customer_addresses SET ";
$size = count($data);
$i = 1;
foreach ($data as $key => $value) {
$sql .= $key."='".$this->db->real_escape_string($value)."'";
if ($i < $size) {
$sql .= ", ";
$i++;
}
}
if ($address_id) {
$sql .= " WHERE id=".$this->db->real_escape_string($address_id);
$this->address_id = $address_id;
} else if ($this->address_id) {
$sql .= " WHERE id=".$this->db->real_escape_string($this->address_id);
} else {
$this->error = "no address id";
return false;
}
$result = $this->db->query($sql);
if ($result) {
return $this->address_id;
}
$this->error = "update failed";
return false;
}
$this->error = "invalid data";
return false;
}
$this->error = "no data";
return false;
} // end update
public function enrich($obj) {
if ($obj->honorific == '0') {
$obj->honorific_text = 'Herr';
} else if ($obj->honorific == '1') {
$obj->honorific_text = 'Frau';
} else if ($obj->honorific == '2') {
$obj->honorific_text = 'Firma';
} else {
$obj->honorific_text = '';
}
return $obj;
} // end enrich
public function validate($data) {
$is_valid = true;
foreach ($this->table_fields as $field => $setting) {
if ($setting['required'] == true && (!isset($data[$field]) || $data[$field] == '')) {
$this->validation_errors[$field] = 'not_set';
$is_valid = false;
}
}
return $is_valid;
} // end validate
public function set_field_to($field, $value, $address_id = false) {
if (isset($this->table_fields[$field])) {
$sql = $sql = "UPDATE customer_addresses SET ".$field."'".$this->db->real_escape_string($value);
if ($address_id) {
$sql = " WHERE id=".$this->db->real_escape_string($address_id);
$this->address_id = $address_id;
} else if ($this->address_id) {
$sql = " WHERE id=".$this->db->real_escape_string($this->address_id);
} else {
$this->error = "no address id";
return false;
}
$result = $this->db->query($sql);
if ($result) {
return $this->address_id;
}
$this->error = 'no result';
return false;
}
$this->error = 'unknown field';
return false;
} // end validate
public function check_data_diff($data, $address_id) {
// get old customer data
unset($data['customer_id']);
$address_data_old = $this->get_data_by_address_id($address_id);
include_once './core/main.class.php';
$country_object = new Country($this->base_object);
$countries = $country_object->get_all_names();
$field_data = array(
'company' => array('name' => 'Firma', 'values' => false),
'honorific' => array(
'name' => 'Anrede',
'values' => array(
'0' => 'Herr',
'1' => 'Frau',
'2' => 'Firma'
)
),
'firstname' => array('name' => 'Vorname', 'values' => false),
'surname' => array('name' => 'Nachname', 'values' => false),
'street' => array('name' => 'Strasse', 'values' => false),
'house_number' => array('name' => 'Hausnummer', 'values' => false),
'zip_code' => array('name' => 'PLZ', 'type' => false),
'city' => array('name' => 'Ort', 'values' => false),
'country' => array('name' => 'Land', 'values' => $countries)
);
// check new data
$diff_data = array();
foreach ($data as $key => $value) {
$value_old = $address_data_old->{$key};
if ($key != 'pass' && $value != $value_old) {
if ($field_data[$key]['values']) {
$diff_data[$field_data[$key]['name']] = array(
'old' => $field_data[$key]['values'][$value_old],
'new' => $field_data[$key]['values'][$value]
);
} else {
$diff_data[$field_data[$key]['name']] = array(
'old' => $value_old,
'new' => $value
);
}
//$log_object = Logger::get_instance();
//$log_object->info($key, $value.'---'.$value_old);
}
}
return $diff_data;
}
function make_diff_table($data) {
$html = '<table border="0" cellpadding="2" cellspacing="2">';
$html .= '<tr><th colspan="3">Adressenänderung</hd></tr><tr><th>Feld</th><th>Alter Wert</th><th>Neuer Wert</th></tr>';
foreach ($data as $key => $val) {
$html .= '<tr><td>'.$key.'</td><td>'.$val['old'].'</td><td>'.$val['new'].'</td></tr>';
}
$html .= '</table>';
return $html;
}
}
?>
+117
View File
@@ -0,0 +1,117 @@
<?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 Database {
protected function __construct() {}
private function __clone() {}
public static function update($table, $data, $where) {
$set_line = "";
if (is_array($data)) {
$size = count($data);
} else {
$size = count($data);
}
$i = 1;
foreach ($data as $key => $value) {
$set_line .= $key;
$set_line .= "=";
if (is_numeric($value)) {
$set_line .= $value;
} else {
$set_line .= "'".$value."'";
}
if ($i < $size) {
$set_line .= ", ";
$i++;
}
}
$sql = "UPDATE $table ";
$sql .= "SET ".$set_line." ";
if ($where) {
$sql .= " ".$where;
}
return $sql;
} // end update
public static function insert($table, $data) {
$db = Registry::get('base')->db;
$data_line = "";
$value_line = "";
if (is_array($data)) {
$size = count($data);
} else {
$size = count((array)$data);
}
$i = 1;
foreach ($data as $key => $value) {
$data_line .= $key;
$value_line .= "'".$db->real_escape_string($value)."'";
if ($i < $size) {
$data_line .= ", ";
$value_line .= ", ";
$i++;
}
}
$sql = "INSERT INTO $table(".$data_line.") ";
$sql .= "VALUES (".$value_line.");";
return $sql;
} // end insert
public function delete() {
} // end delete
public static function clean($data) {
foreach ($data as $key => $value) {
if ($value == '') {
if (is_array($data)) {
unset($data[$key]);
} else {
unset($data->$key);
}
}
}
return $data;
} // end clan_data
// replaces clean, clean must die
public static function validate($data, $schema) {
} // end validate
public static function where($text, $clause) {
if ($text == '') {
$text .= ' WHERE '.$clause;
} else {
$text .= ' AND '.$clause;
}
return $text;
} // end where
} // end Database
?>
+365
View File
@@ -0,0 +1,365 @@
<?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 Deliverer extends Main {
protected $base_object;
public $list_table_config = array (
'title' => 'Zusteller',
'db_table' => 'deliverers',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Zusteller',
'sortable' => 1
),
array(
'db_field' => 'active',
'name' => 'Status',
'rewrite_function' => 'state_values',
'sortable' => 1
)
),
'search_fields' => array('subject'),
'db_id_field' => 'id',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=Deliverer&object_id=',
'toolbar' => array(
'delete' => 'index.php?admin_modul=admin_object_edit&object=Deliverer&object_id=',
'new' => 'index.php?admin_modul=admin_object_edit&object=Deliverer',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
),
'edit_title' => 'Newsletter',
'edit_fields' => array (
array(
'name' => 'Stammdaten',
'type' => 'form_title'
),
array(
'db_field' => 'name',
'name' => 'Name',
'type' => 'text'
),
array(
'db_field' => 'tacking_url',
'name' => 'Tracking Link',
'type' => 'text',
'info' => 'Plazhalter für den Trackingcode: [trackingcode]'
),
array(
'db_field' => 'active',
'name' => 'Status',
'values' => 'state_values',
'type' => 'int'
)
),
'edit_js_file' => 'admin_newsletter_edit.js',
'edit_mandatory_fields' => array('firstname', 'surename', 'email'),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_list&object=Newsletter',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'send' => 0,
'delete' => 1
),
);
function __construct($base_object, $id = false) {
$this->base_object = $base_object;
$this->db = $base_object->db;
$this->id = $id;
$this->error = '';
} // end constructor
function state_values() {
return array(
'0' => 'inaktiv',
'1' => 'aktiv'
);
}
function set_id($id) {
$this->id = $id;
} // set_id
function get_id() {
return $this->id;
} // end get_id
function get_error() {
return $this->error;
} // end get_error
// TODO: add filters
public function get_all($active_only = false) {
$sql = "SELECT * FROM deliverers";
if ($active_only) {
$sql .= ' WHERE active=1';
}
$result = $this->db->query($sql);
if ($result->num_rows) {
$data = array();
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
}
return false;
} // end get_all
public function get_data($id = false) {
$sql = "SELECT * FROM deliverers WHERE id=";
if ($id) {
$sql .= $this->db->real_escape_string($id);
$this->id = $id;
} else if ($this->id) {
$sql .= $this->db->real_escape_string($this->id);
} else {
return false;
}
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
return false;
} // end get_data
public function delete($id = false) {
$sql = "DELETE FROM deliverers WHERE id=";
if ($id) {
$sql .= $this->db->real_escape_string($id);
$this->id = $id;
} else if ($this->id) {
$sql .= $this->db->real_escape_string($this->id);
} else {
return false;
}
$result = $this->db->query($sql);
if ($result) {
$this->id = false;
return true;
}
return false;
} // end delete
// TODO: rename to verify
public function data_filter($request) {
$data = array();
foreach ($this->object_fields as $field_name => $var_type) {
if (isset($request[$field_name])) {
if ($var_type == 'text') {
$data[$field_name] = $request[$field_name];
} else {
$data[$field_name] = (int) $request[$field_name];
}
}
}
return $data;
}
public function create($data) {
if ($data) {
$sql = "INSERT INTO deliverers SET ";
foreach ($data as $var_name => $value) {
$value = $this->db->real_escape_string($value);
if ($this->object_fields[$var_name] == 'integer') {
$sql .= $var_name.' = '.$value.', ';
} else {
$sql .= $var_name.' = "'.$value.'", ';
}
}
$sql = substr($sql, 0, -2);
$result = $this->db->query($sql);
if ($result) {
$this->id = $this->db->insert_id;
return $this->id;
}
$this->error = "Speicher fehlgeschlagen";
return false;
}
$this->error = "Keine Daten";
return false;
} // end create
public function update($data, $id = false) {
if ($data) {
$sql = "UPDATE deliverers SET ";
foreach ($data as $var_name => $value) {
$value = $this->db->real_escape_string($value);
if ($this->object_fields[$var_name] == 'integer') {
$sql .= $var_name.'='.$value.', ';
} else {
$sql .= $var_name.'="'.$value.'", ';
}
}
$sql = substr($sql, 0, -2);
if ($id) {
$sql .= ' WHERE id='.$id;
$this->id = $id;
} else if ($this->id) {
$sql .= ' WHERE id='.$this->id;
} else {
$this->error = "Keine ID";
return false;
}
$result = $this->db->query($sql);
if ($result) {
return $this->id;
}
$this->error = "Speicher fehlgeschlagen";
return false;
}
$this->error = "Keine Daten";
return false;
} // end update
// TODO: remove this and use delete
public function delete_by_id($id) {
$rs = $this->db->query("DELETE FROM deliverers
WHERE id=$id;");
}
// TODO: remove this and add filters to get_all
public function getAllActive($shippingArea = false, $standard_shipping_items = 1, $bulk_goods_price_add = false, $goods_weight = false, $good_price_sum_net = 0) {
if (!$shippingArea) {
$shippingArea = 7;
}
$query = "
SELECT
sd.*,
d.name, d.id
FROM
shipping_area_deliverers sd
LEFT JOIN
deliverers d
ON
d.id = sd.deliverer_id
WHERE
sd.shipping_area_id = ".$shippingArea."
AND
sd.active = 1
AND
d.active = 1
";
$rs = $this->db->query($query);
$deliverers = array();
while ($D = $rs->fetch_object()) {
// goods weight shipping price
if ($D->deliverer_cost_type == 1) {
if (!$goods_weight) {
$goods_weight = 0;
}
if ($goods_weight > 0) {
$last_price = 0;
$found = 0;
for ($i=1;$i<=10;$i++) {
if ($D->{'weight_'.$i} > 0) {
$last_price = $D->{'weight_'.$i.'_price'};
}
if ($D->{'weight_'.$i} >= $goods_weight && ($i == 1 || $D->{'weight_'.($i - 1)} < $goods_weight)) {
$D->price_add = $D->{'weight_'.$i.'_price'};
$found = 1;
}
}
if ($found == 0) {
$D->price_add = $last_price;
}
}
else {
$D->price_add = $D->{'weight_1_price'};
}
}
// shipping free price
if ($D->shipping_free_price > 0 && $good_price_sum_net > $D->shipping_free_price) {
$D->price_add = 0;
$D->bulk_goods_price_add = 0;
}
if ($bulk_goods_price_add) {
$D->price_add += $D->bulk_goods_price_add;
} else {
$D->bulk_goods_price_add = 0;
}
if ($standard_shipping_items == 0) {
$D->price_add = 0;
}
$D->price_add_net = $D->price_add / (100 + $this->base_object->config->shopConfiguration['default_vat_value']) * 100;
$D->price_add_vat = $D->price_add - $D->price_add_net;
$D->bulk_goods_price_add_net = $D->bulk_goods_price_add / (100 + $this->base_object->config->shopConfiguration['default_vat_value']) * 100;
$D->bulk_goods_price_add_vat = $D->bulk_goods_price_add - $D->bulk_goods_price_add_net;
if ($this->base_object->customer_group->show_tax) {
$D->price_add_shown = $D->price_add;
$D->bulk_goods_price_add_shown = $D->bulk_goods_price_add;
} else {
$D->price_add_shown = $D->price_add_net;
$D->bulk_goods_price_add_shown = $D->bulk_goods_price_add_net;
}
$deliverers[$D->id] = $D;
}
return $deliverers;
}
// TODO: WHERE IS THIS USED AND FOR WHAT
public function checkShipping($shippingId, $shippingArea = 7) {
$shippings = $this->getAllActive($shippingArea);
if (isset($shippings[$shippingId])) {
return $shippings;
}
return false;
}
}
?>
+139
View File
@@ -0,0 +1,139 @@
<?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/main.class.php';
class Domain extends Main {
protected $base_object;
protected $db;
public $list_table_config = array (
'title' => 'Domain',
'db_table' => 'domains',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Domain',
'sortable' => 1
),
array(
'db_field' => 'google_site_verification',
'name' => 'Google-Site-Verification',
'sortable' => 1
),
array(
'db_field' => 'google_analytics_code',
'name' => 'Google-Analytics-Code',
'sortable' => 1
),
array(
'db_field' => 'standard_theme_id',
'name' => 'Standard-Theme',
'rewrite_function' => 'theme_values',
'sortable' => 1
),
array(
'db_field' => 'standard_language_id',
'name' => 'Standardsprache',
'rewrite_function' => 'language_values',
'sortable' => 1
)
),
'search_fields' => array('name', 'google_site_verification'),
'db_id_field' => 'id',
'db_selectable_field' => 'name',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=Domain&object_id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_object_edit&object=Domain',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
),
'edit_title' => 'Domain',
'edit_fields' => array (
array(
'name' => 'Allgemein',
'type' => 'form_title'
),
array(
'db_field' => 'name',
'name' => 'Domain',
'type' => 'text'
),
array(
'db_field' => 'google_site_verification',
'name' => 'Google-Site-Verification',
'type' => 'text'
),
array(
'db_field' => 'google_analytics_code',
'name' => 'Google-Analytics-Code',
'type' => 'text'
),
array(
'db_field' => 'standard_theme_id',
'name' => 'Standard-Theme',
'values' => 'theme_values',
'type' => 'int'
),
array(
'db_field' => 'standard_language_id',
'name' => 'Standardsprache',
'values' => 'language_values',
'type' => 'int'
)
),
'edit_mandatory_fields' => array('name', 'iso'),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_list&object=Domain',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'send' => 0,
'delete' => 1
),
);
function __construct($base_object) {
$this->db = $base_object->db;
$this->base_object = $base_object;
}
public function theme_values() {
include_once './core/shop_theme.class.php';
$theme_object = new Shop_theme($this->base_object);
$data = $theme_object->get_all_selectable();
return $data;
}
public function language_values() {
include_once './core/language.class.php';
$language_object = new Language($this->base_object);
$data = $language_object->get_all_selectable();
return $data;
}
public function get_domain_config($domain_name) {
$sql = "SELECT * FROM domains WHERE name='".$this->db->real_escape_string($domain_name)."'";
$result = $this->db->query($sql);
if ($result && $obj = $result->fetch_object()) {
return $obj;
}
return false;
}
}
?>
+79
View File
@@ -0,0 +1,79 @@
<?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/main.class.php';
class Email_template extends Main {
public $list_table_config = array (
'title' => 'E-Mail Vorlagen',
'db_table' => 'email_templates',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Bezeichnung',
'sortable' => 1
),
array(
'db_field' => 'subject',
'name' => 'Betreff',
'sortable' => 1
)
),
'search_fields' => array('firstname', 'surname', 'email'),
'db_id_field' => 'id',
'db_selectable_field' => 'name',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=Email_template&object_id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_object_edit&object=Email_template',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
),
'edit_title' => 'Newsletter Abonnent',
'edit_fields' => array (
array(
'name' => 'Stammdaten',
'type' => 'form_title'
),
array(
'db_field' => 'name',
'name' => 'Bezeichnung',
'type' => 'text'
),
array(
'db_field' => 'subject',
'name' => 'Betreff',
'type' => 'text'
),
array(
'db_field' => 'body',
'name' => 'Nachrichtentext',
'type' => 'multitext'
)
),
'edit_mandatory_fields' => array('name', 'subject', 'body'),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_list&object=Email_template',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'delete' => 1
),
);
}
?>
+287
View File
@@ -0,0 +1,287 @@
<?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 'main.class.php';
include_once 'item.class.php';
class Export extends Main {
public $list_table_config = array (
'title' => 'Preissuchmaschinen',
'db_table' => 'export',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Name',
'sortable' => 1
),
array(
'db_field' => 'count_exported_items',
'name' => 'Exportierte Artikel',
'sortable' => 1
),
array(
'db_field' => 'last_export_date',
'name' => 'Letzter Export',
'sortable' => 1
)
),
'search_fields' => array('name'),
'db_id_field' => 'id',
'edit_link' => 'index.php?admin_modul=admin_price_search_engine_editor&id=',
'toolbar' => array(
'delete' => '0',
'new' => '',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
)
);
private $object_fields = array(
'name' => 'text',
'customer_group_id' =>'integer',
'all_item_groups' => 'integer',
'export_filter' => 'text',
'count_exported_items' => 'integer'
);
protected $base_object;
protected $db;
private $customer_number;
private $seperator;
function __construct($base_object) {
parent::__construct($base_object);
$this->db = $base_object->db;
$this->base_object = $base_object;
$this->customer_number = '';
$this->seperator = "|";
} // end __construct
public function set_customer_number($customer_number) {
$this->customer_number = $customer_number;
} // end set_customer_number
public function set_seperator($seperator) {
$this->seperator = $seperator;
} // end set_seperator
public function get_all() {
$sql = "SELECT * FROM export";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[$obj->id] = $obj;
}
return $data;
} // end get_all
public function get_data() {
if ($this->id) {
$sql = "SELECT * FROM export_item_groups WHERE export_id = ".$this->id;
$result = $this->db->query($sql);
$structure_ids = array();
while ($obj = $result->fetch_object()) {
$structure_ids[$obj->structure_id] = 1;
}
$sql = "SELECT * FROM export WHERE id = ".$this->id;
$result = $this->db->query($sql);
$obj = $result->fetch_object();
$obj->structure_ids = $structure_ids;
return $obj;
}
return false;
} // end get_data
public function delete() {
$sql = "DELETE FROM export WHERE id=".$this->id;
$this->db->query($sql);
return;
}// end delete
public function data_filter($request) {
$data = array();
foreach ($this->object_fields as $field_name => $var_type) {
if (isset($request[$field_name])) {
if ($var_type == 'text') {
$data[$field_name] = $request[$field_name];
} else {
$data[$field_name] = (int)$request[$field_name];
}
}
}
return $data;
} // end data_filter
public function create($data) {
if ($data) {
$sql = "INSERT INTO export SET ";
foreach ($data as $var_name => $value) {
$value = $this->db->real_escape_string($value);
if ($this->object_fields[$var_name] == 'integer') {
$sql .= $var_name.' = '.$value.', ';
} else {
$sql .= $var_name.' = "'.$value.'", ';
}
}
$sql = substr($sql, 0, -2);
$this->db->query($sql);
$this->id = $this->db->insert_id;
}
return;
} // end create
public function update($data) {
if ($data) {
$sql = "UPDATE export SET ";
foreach ($data as $var_name => $value) {
$value = $this->db->real_escape_string($value);
if ($this->object_fields[$var_name] == 'integer') {
$sql .= $var_name.'='.$value.', ';
} else {
$sql .= $var_name.'="'.$value.'", ';
}
}
$sql = substr($sql, 0, -2);
$sql .= ' WHERE id='.$this->id;
$this->db->query($sql);
}
return;
} // end update
public function update_selected_structure($data) {
$sql = "DELETE FROM export_item_groups WHERE export_id=".$this->id;
$this->db->query($sql);
if ($data) {
foreach ($data as $value) {
$sql = "INSERT INTO export_item_groups SET ";
$value = $this->db->real_escape_string($value);
$sql .= 'export_id="'.$this->id.'", ';
$sql .= 'structure_id="'.$value.'"';
$this->db->query($sql);
}
}
return;
} // end update
public function get_all_paginated($items , $page, $order = false) {
$page = ($page - 1) * $items;
$sql = "SELECT * FROM export LIMIT $items OFFSET $page";
$result = $this->db->query($sql);
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
} // end get_all_paginated
public function delete_by_id($id) {
$rs = $this->db->query("DELETE FROM export
WHERE id=$id;");
} // end delete_by_id
public static function get_name_by_id($id) {
$db = Registry::get('base')->db;
$sql = "SELECT
name
FROM
export
WHERE id = $id";
$result = $db->query($sql);
if ($result->num_rows > 0) {
$return = $result->fetch_object();
return $return->name;
}
return false;
} // end get_name_by_id
public function get_export_csv($export_name) {
$sql = "SELECT * FROM export WHERE name = '".$this->db->real_escape_string($export_name)."'";
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
$obj = $result->fetch_object();
// get items
$item_count = 0;
if ($obj->set_customer_group_id) {
$this->base_object->customer_group->id = $obj->customer_group_id;
}
$item_object = new Item($this->base_object);
if ($obj->id == 5) {
$items = $item_object->get_flat_items();
} else {
$items = $item_object->get_all_items_list();
}
$data_array = array();
// load filter
include_once './core/export_filter/'.$obj->export_filter;
// make csv file
$csv = '';
foreach ($data_array as $row) {
//$csv .= implode(";",$row)."\r\n";
$csv .= implode($this->seperator,$row)."\r\n";
//$csv .= implode("|",$row)."<br>";
$item_count++;
}
// update
$sql = "
UPDATE export
SET last_export_date = current_timestamp,
count_exported_items = $item_count
WHERE id = ".$obj->id."
";
$this->db->query($sql);
return $csv;
}
return false;
}
} // end Export
?>
+248
View File
@@ -0,0 +1,248 @@
<?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/main.class.php';
class Gift_certificate extends Main {
public $list_table_config = array (
'title' => 'Gutscheine',
'db_table' => 'gift_certificates',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Bezeichnung',
'sortable' => 1
),
array(
'db_field' => 'code',
'name' => 'Freischaltcode',
'sortable' => 1
),
array(
'db_field' => 'account',
'name' => 'Wert',
'sortable' => 1
),
array(
'db_field' => 'available_until',
'name' => 'G&uuml;ltigkeit',
'sortable' => 1
),
array(
'db_field' => 'active',
'name' => 'Status',
'rewrite_function' => 'state_text',
'sortable' => 1
)
),
'search_fields' => array('name', 'description'),
'db_id_field' => 'id',
'edit_link' => 'index.php?admin_modul=admin_gift_certificate_editor&id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_gift_certificate_editor',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
)
);
private $object_fields = array(
'name' => 'text',
'code' => 'text',
'description' => 'text',
'active' => 'integer',
'available_from' => 'text',
'available_until' => 'text',
'customer_valid_type' => 'integer',
'customer_id' => 'integer',
'customer_group_id' => 'integer',
'account' => 'text',
'account_type' => 'integer',
'min_order_sum' => 'float',
);
protected $base_object;
protected $db;
public $id;
function __construct($base_object) {
parent::__construct($base_object);
$this->id = false;
$this->db = $base_object->db;
$this->base_object = $base_object;
} // end __construct
public function state_text() {
return array (
'1' => 'aktiv',
'0' => 'inaktiv'
);
}
public function set_id($id) {
$this->id = $id;
}
public function get_id() {
return $this->id;
}
public function get_all() {
$sql = "SELECT * FROM countries";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[$obj->id] = $obj;
}
return $data;
} // end get_all
public function get_data($id = false) {
$sql = "SELECT * FROM gift_certificates WHERE id=";
if ($id) {
$sql .= $this->db->real_escape_string($id);
} else if ($this->id) {
$sql .= $this->db->real_escape_string($this->id);
} else {
return false;
}
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
return false;
} // end get_data
public function delete() {
$sql = "DELETE FROM gift_certificates WHERE id=".$this->id;
$this->db->query($sql);
return;
}// end delete
public function data_filter($request) {
$data = array();
foreach ($this->object_fields as $field_name => $var_type) {
if (isset($request[$field_name])) {
if ($var_type == 'text') {
$data[$field_name] = $request[$field_name];
} else {
$data[$field_name] = (int)$request[$field_name];
}
}
}
return $data;
} // end data_filter
public function create($data) {
if ($data) {
$sql = "INSERT INTO gift_certificates SET ";
foreach ($data as $var_name => $value) {
$value = $this->db->real_escape_string($value);
if ($this->object_fields[$var_name] == 'integer') {
$sql .= $var_name.' = '.$value.', ';
} else if ($this->object_fields[$var_name] == 'float') {
$sql .= $var_name.' = '.number_format($value,4,'.','').', ';
}
else {
$sql .= $var_name.' = "'.$value.'", ';
}
}
$sql = substr($sql, 0, -2);
$this->db->query($sql);
$this->id = $this->db->insert_id;
}
return;
} // end create
public function update($data) {
if ($data) {
$sql = "UPDATE gift_certificates SET ";
foreach ($data as $var_name => $value) {
$value = $this->db->real_escape_string($value);
if ($this->object_fields[$var_name] == 'integer') {
$sql .= $var_name.'='.$value.', ';
} else {
$sql .= $var_name.'="'.$value.'", ';
}
}
$sql = substr($sql, 0, -2);
$sql .= ' WHERE id='.$this->id;
$this->db->query($sql);
}
return;
} // end update
public function get_all_paginated($items , $page, $order = false) {
$page = ($page - 1) * $items;
$sql = "SELECT * FROM gift_certificates LIMIT $items OFFSET $page";
$result = $this->db->query($sql);
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
} // end get_all_paginated
public function get_number_of_pages($items) {
$sql = "SELECT COUNT(id) FROM gift_certificates";
return parent::get_number_of_pages($items, $sql);
} // end get_number_of_pages
public function get_pagination_array($items, $page) {
$sql = "SELECT COUNT(id) FROM gift_certificates";
return parent::get_pagination_array($items, $page, $sql);
} // end get_pagination_array
public function delete_by_id($id) {
$rs = $this->db->query("DELETE FROM gift_certificates WHERE id=$id;");
} // end delete_by_id
public static function get_name_by_id($id) {
$db = Registry::get('base')->db;
$sql = "SELECT name FROM gift_certificates WHERE id = $id";
$result = $db->query($sql);
if ($result->num_rows > 0) {
$return = $result->fetch_object();
return $return->name;
}
return false;
} // end get_name_by_id
}
?>
+211
View File
@@ -0,0 +1,211 @@
<?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/customerhelper.class.php';
include_once './core/customer_group.class.php';
include_once './core/customergroups.class.php';
class GiftCertificateHelper {
private static $certificate_error_number = 0;
private static $certificate_error_array = array(
1 => array('en' => 'Certificate is not active', 'de' => 'Dieser Gutschein ist nicht g&uuml;ltig.'),
2 => array('en' => 'Certificate not active yet, too early', 'de' => 'Dieser Gutschein ist nicht Aktiv.'),
3 => array('en' => 'Certificate expired, too late', 'de' => 'Dieser Gutschein ist abgelaufen.'),
4 => array('en' => 'Order amount to small for certificate', 'de' => 'Die Kaufsumme ist zu gering f&uuml;r diesen Gutschein.'),
5 => array('en' => 'Group is not eligible', 'de' => 'Dieser Gutschein ist nicht f&uuml;r Ihre Gruppe g&uuml;ltig.'),
6 => array('en' => 'Certificate was already used', 'de' => 'Dieser Gutschein wurde schon eingel&ouml;st.'),
7 => array('en' => 'Certificate does not exist', 'de' => 'Dieser Gutschein existiert nicht.')
);
public static function get_cetificate_type($id) {
$db = Registry::get('base')->db;
$sql = "SELECT * FROM gift_certificates WHERE id=".$db->real_escape_string($id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object()->account_type;
}
return false;
}
public static function get_certificate_id_by_code($code) {
$db = Registry::get('base')->db;
$sql = "SELECT id FROM gift_certificates WHERE code='".$db->real_escape_string($code)."'";
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object()->id;
}
return false;
}
public static function get_certificate_value($code, $total, $group_id) {
$base = Registry::get('base');
$customer_groups = new CustomerGroups($base);
$show_taxes = $customer_groups->get_data($group_id)->show_tax;
$gift = GiftCertificateHelper::get_certificate_by_code($code);
$gift_cert = new stdClass();
if ($gift->account_type == '1') {
$gift_cert->with_vat = number_format($gift->account, 2);
} else if ($gift->account_type == '2') {
$gift_cert->with_vat = (float)($total * $gift->account) / 100;
}
$gift_cert->without_vat = round($gift_cert->with_vat / (100 + $base->config->shopConfiguration['default_vat_value']) * 100, 2);
$gift_cert->vat = $gift_cert->with_vat - $gift_cert->without_vat;
if ($show_taxes) {
$gift_cert->show = $gift_cert->with_vat;
} else {
$gift_cert->show = $gift_cert->without_vat;
}
return $gift_cert;
}
public static function code_is_valide($customer_id, $code, $total) {
$certificate = GiftCertificateHelper::get_certificate_by_code($code);
if ($certificate) {
GiftCertificateHelper::$certificate_error_number = 0;
GiftCertificateHelper::certificate_is_active($customer_id, $certificate, $total);
if (GiftCertificateHelper::$certificate_error_number) {
return false;
}
return true;
} else {
GiftCertificateHelper::$certificate_error_number = 7;
}
return false;
}
public static function get_error_text($lang = false) {
if (!$lang) {
$lang = 'de';
}
return GiftCertificateHelper::$certificate_error_array[GiftCertificateHelper::$certificate_error_number][$lang];
}
public static function get_certificate_by_code($code) {
$db = Registry::get('base')->db;
$sql = "SELECT * FROM gift_certificates WHERE code='".$db->real_escape_string($code)."'";
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
return false;
}
public static function certificate_is_active($customer_id, $certificate, $total) {
if ($certificate == '0') {
GiftCertificateHelper::$certificate_error_number = 1;
return false;
}
$today = getdate();
$today = strtotime($today['year'].'-'.$today['mon'].'-'.$today['mday']);
$startDate = strtotime($certificate->available_from);
$stopDate = strtotime($certificate->available_until);
if (!($startDate <= $today && $today <= $stopDate)) {
if ($today < $startDate) {
GiftCertificateHelper::$certificate_error_number = 2;
}
if ($stopDate < $today) {
GiftCertificateHelper::$certificate_error_number = 3;
}
return false;
}
if (is_numeric($certificate->min_order_sum)) {
$min_order = (double)$certificate->min_order_sum;
if ($min_order > $total) {
GiftCertificateHelper::$certificate_error_number = 4;
return false;
}
}
// checks customer group
if (!(GiftCertificateHelper::customer_group_is_eligable($customer_id, $certificate))) {
GiftCertificateHelper::$certificate_error_number = 5;
return false;
}
if ($certificate->customer_valid_type == '1') {
$certificatWasUsed = GiftCertificateHelper::customer_used_certificate($customer_id, $certificate);
if ($certificatWasUsed) {
GiftCertificateHelper::$certificate_error_number = 6;
return false;
}
}
return true;
}
public static function customer_group_is_eligable($customer, $certificate) {
if ($certificate->customer_group_id == 0) {
return true;
} else {
$customer_group_id = CustomerHelper::get_customer_group_id_by_customer_id($customer);
if ($customer_group_id == $certificate->customer_group_id) {
return true;
}
}
return false;
}
public static function customer_used_certificate($customer, $certificate) {
$db = Registry::get('base')->db;
$sql = "SELECT * FROM orders
WHERE
customer_id=".$db->real_escape_string($customer)."
AND
gift_certificate_id=".$db->real_escape_string($certificate->id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
return true;
}
return false;
}
}
?>
+22
View File
@@ -0,0 +1,22 @@
<?php
class Honorific {
protected function __construct() {}
private function __clone() {}
public static function get_honorific($number) {
if ($number == 0) {
return "Herr";
}
if ($number == 1) {
return "Frau";
}
if ($number == 2) {
return "Firma";
}
}
}
+49
View File
@@ -0,0 +1,49 @@
<?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 i18n {
public $language = 'de';
public $shopadmin_translation = array();
public $admin_language_code_iso639 = array(
'en' => 'English',
'de' => 'Deutsch'
);
public $standard_admin_language = 'de';
public function __construct() {
$this->language = $this->standard_admin_language;
}
public function convert_time($time) {
return $time;
}
public function convert_date($date) {
$date = mktime(0,0,0,substr($date,5,2),substr($date,8,2),substr($date,0,4));
return date($this->shopadmin_translation['system_date_format'], $date);
}
public function convert_price($price) {
return $price.' '.$this->currency;
}
public function get_shopadmin_text($lang = false) {
if ($lang) {
$this->language = $lang;
}
include('./scripts/i18n/shopadmin_translation_'.$this->language.'.php');
$this->shopadmin_translation = $shopadmin_translation;
return;
}
}
?>
+114
View File
@@ -0,0 +1,114 @@
<?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/main.class.php';
class Import extends Main {
public $list_table_config = array (
'title' => 'Import',
'db_table' => 'import',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Name',
'sortable' => 1
),
array(
'db_field' => 'count_imported_items',
'name' => 'Importierte Datensätze',
'sortable' => 1
),
array(
'db_field' => 'last_import_date',
'name' => 'Letzter Import',
'sortable' => 1
)
),
'search_fields' => array('name'),
'db_id_field' => 'id',
'edit_link' => 'index.php?admin_modul=admin_import_editor&id=',
'toolbar' => array(
'delete' => '0',
'new' => '',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
)
);
private $object_fields = array(
'name' => 'text',
'customer_group_id' =>'integer',
'all_item_groups' => 'integer',
'export_filter' => 'text',
'count_exported_items' => 'integer'
);
protected $base_object;
protected $db;
function __construct($base_object) {
parent::__construct($base_object);
$this->db = $base_object->db;
$this->base_object = $base_object;
} // end __construct
public function get_all() {
$sql = "SELECT * FROM export";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[$obj->id] = $obj;
}
return $data;
} // end get_all
public function get_data() {
if ($this->id) {
$sql = "SELECT * FROM import WHERE id = ".$this->id;
$result = $this->db->query($sql);
$obj = $result->fetch_object();
return $obj;
}
return false;
} // end get_data
public function save_file($id, $element_name) {
// get import modul data
$this->id=$id;
$data = $this->get_data();
$import_modul = $data->import_filter;
// save file
if (move_uploaded_file($_FILES['Filedata']['tmp_name'], ROOT_DIR.'tmp/import/'.basename($_FILES['Filedata']['name']))) {
$log_object = Logger::get_instance();
// load import modul
include_once './core/import_filter/'.$import_modul;
//return
return true;
} else {
return false;
}
}
} // end Export
?>
+439
View File
@@ -0,0 +1,439 @@
<?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/main.class.php';
class Incomming_goods extends Main {
public $list_table_config = array (
'title' => 'Wareneingang',
'db_table' => 'incomming_goods',
'list_fields' => array(
array(
'db_field' => 'number',
'name' => 'Nummber',
'sortable' => 1
),
array(
'db_field' => 'date',
'name' => 'Datum',
'format' => 'date_format',
'sortable' => 1
),
array(
'db_field' => 'vendor_id',
'name' => 'Lieferant',
'rewrite_function' => 'vendor_names',
'sortable' => 1
)
),
'default_sort_item' => 'date',
'default_sort_direction' => 'down',
'search_fields' => array('number'),
'db_id_field' => 'id',
'edit_link' => 'index.php?admin_modul=admin_incomming_goods_editor&id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_incomming_goods_editor',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 1,
'search' => 1
),
'list_filter' => array(
array (
'db_field' => 'vendor_id',
'relational_operator' => '=',
'name' => 'Lieferant',
'values' => 'vendor_names'
)
),
);
private $theme_fields = array(
'name' => 'text',
'description' => 'text',
'modul' => 'text',
'number' => 'text',
'date' => 'text',
'conversion_price' => 'text',
'currency' => 'text',
'vendor_id' => 'integer',
'settings' => 'text'
);
public $id;
protected $db;
protected $base_object;
private $config;
private $path;
private $error;
public function __construct($base_object) {
global $config_object;
$this->base_object = $base_object;
$this->config = $base_object->config;
$this->db = $base_object->db;
$this->id = false;
$this->url = './web/'.SHOP_SYSTEM.'/documents/incomming_goods_bill/';
$this->error = '';
} // end __construct
public function date_format($string) {
return substr($string,8,2).'.'.substr($string,5,2).'.'.substr($string,0,4);
}
public function vendor_names() {
include_once './core/vendor.class.php';
$vendor_object = new Vendor($this->base_object);
return $vendor_object->get_all_names();
}
public function set_id($id) {
$this->id = $id;
}
public function get_id() {
return $this->id;
}
public function get_error() {
return $this->error;
}
public function get_all() {
$sql = "SELECT * FROM incomming_goods ORDER BY name";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
} // end get_all
public function create_new() {
$sql = "INSERT INTO incomming_goods (number) VALUES ('')";
$this->db->query($sql);
$id = $this->db->insert_id;
return $id;
} // end get_by_id
public function get_by_id($id) {
$sql = "SELECT * FROM incomming_goods WHERE id = $id";
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
$data = $result->fetch_object();
// get items
include_once './core/item_inventory.class.php';
$item_inventory_object = new ItemInventory($this->base_object);
$data->item_list = $item_inventory_object->get_by_object_id($id, 2);
$data->price_sum_netto = 0;
// calc tax
$data->tax_7_sum = 0;
$data->tax_19_sum = 0;
foreach ($data->item_list as $item) {
$data->price_sum_netto += $item->price_sum * $item->amount;
if ($item->item_tax == 7.00) {
$data->tax_7_sum += $item->price_sum * $item->amount;
} else if ($item->item_tax == 19) {
$data->tax_19_sum += $item->price_sum * $item->amount;
}
}
$data->shipping_cost_tax = $data->cost_sum * 0.19;
$data->tax_19 = ($data->tax_19_sum * 0.19) + $data->shipping_cost_tax;
$data->tax_7 = $data->tax_7_sum * 0.07;
$data->tax_sum = $data->tax_19 + $data->tax_7;
$data->price_sum_brutto = $data->price_sum_netto + $data->tax_19 + $data->tax_7;
$data->skonto_sum = ($data->skonto / 100) * $data->price_sum_brutto;
$data->cash_sum = $data->price_sum_brutto - $data->skonto_sum + $data->cost_sum;
// calc article shipping costs
$items = array();
foreach ($data->item_list as $item) {
$item->price_sum_netto = $item->price_sum * $item->amount;
$item->item_beschaffungskosten = $data->cost_sum / $data->price_sum_netto * $item->price_sum;
$item->item_price_ek = ($item->price_sum + $item->item_beschaffungskosten) * (1 - ($data->skonto / 100));
$items[] = $item;
}
$data->item_list = $items;
// formated date
$data->formated_date = substr($data->date,8,2).'.'.substr($data->date,5,2).'.'.substr($data->date,0,4);
return $data;
}
return false;
} // end get_by_id
public function delete_by_id($id) {
$sql = "DELETE FROM incomming_goods WHERE id=".id;
return $this->db->query($sql);
} // end delete_by_id
public function get_where_name_like($name) {
$sql = "SELECT id FROM incomming_goods WHERE name LIKE '%".$name."%'";
$result = $this->db->query($sql);
while ($row = $result->fetch_object()) {
$data[] = $row;
}
return $data;
} // end get_where_name_like
public function get_data($id = false) {
$sql = "SELECT * FROM incomming_goods";
if ($id) {
$sql .= " WHERE id=".$this->db->real_escape_string($id);
} else if ($this->id) {
$sql .= " WHERE id=".$this->db->real_escape_string($this->id);
} else {
$this->error = 'no id';
return false;
}
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
$this->error = 'no data';
return false;
} // end get_data
public function create($data) {
if ($data) {
$data['short_uri'] = $this->short_uri($data['short_uri'], $data['name']);
$sql = "INSERT INTO incomming_goods SET ";
foreach ($data as $var_name => $value) {
$value = $this->db->real_escape_string($value);
if ($this->theme_fields[$var_name] == 'integer') {
$sql .= $var_name.' = '.$value.', ';
} else {
$sql .= $var_name.' = "'.$value.'", ';
}
}
$sql = substr($sql, 0, -2);
$this->db->query($sql);
$this->id = $this->db->insert_id;
}
return;
} // end create
public function update($data) {
if ($data) {
// get items for updating sum values
include_once './core/item_inventory.class.php';
$item_inventory_object = new ItemInventory($this->base_object);
// update items
$create_date = $data['date'].' 00:00:00';
if (isset($data['items'])) {
foreach ($data['items'] as $item_inventory) {
$item_inventory_object->id = $item_inventory['item_id'];
$item_inventory['created'] = $create_date;
unset($item_inventory['item_id']);
$item_inventory_object->update($item_inventory);
}
unset($data['items']);
}
// get item list
$item_list = $item_inventory_object->get_by_object_id($this->id, 2);
//$data['short_uri'] = $this->short_uri($data['short_uri'], $data['name'], $this->id);
$sql = "UPDATE incomming_goods SET ";
foreach ($data as $var_name => $value) {
$value = $this->db->real_escape_string($value);
if ($this->theme_fields[$var_name] == 'integer') {
$sql .= $var_name.'='.$value.', ';
} else {
$sql .= $var_name.'="'.$value.'", ';
}
}
$sql = substr($sql, 0, -2);
$sql .= ' WHERE id='.$this->id;
$this->db->query($sql);
}
return 1;
} // end update
public function delete($id) {
$sql = "DELETE FROM incomming_goods WHERE id=".$id;
return $this->db->query($sql);
} // end delete
public function data_filter($request) {
$data = array();
foreach ($this->theme_fields as $field_name => $var_type) {
if (isset($request[$field_name])) {
if ($var_type == 'text') {
$data[$field_name] = $request[$field_name];
} else {
$data[$field_name] = (int)$request[$field_name];
}
}
}
return $data;
} // end data_filter
public function add_item($data) {
if ($data) {
$data['inventory_object_type_id'] = 2;
$data['inventory_object_id'] = $data['inventory_object_id'];
// get retail sale data
$sale_date = $this->get_data()->date;
$data['create_time'] = $sale_date.' 12:00:00';
// get items for updating sum values
include_once './core/item_inventory.class.php';
$item_inventory_object = new ItemInventory($this->base_object);
$item_inventory_object->add($data);
// updated
$this->update(array('tax_sum' => 0));
}
return 1;
} // end update
public function delete_item($item_id) {
if ($item_id) {
// get items for updating sum values
include_once './core/item_inventory.class.php';
$item_inventory_object = new ItemInventory($this->base_object);
$item_inventory_object->delete($item_id);
// updated
$this->update(array('tax_sum' => 0));
}
return 1;
} // end update
public function get_all_paginated($items , $page, $order = false) {
$page = ($page - 1) * $items;
$sql = "SELECT * FROM incomming_goods ORDER BY date DESC LIMIT $items OFFSET $page";
$result = $this->db->query($sql);
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
} // end get_all
public function get_number_of_pages($items) {
$sql = "SELECT COUNT(id) FROM incomming_goods";
return parent::get_number_of_pages($items, $sql);
} // end get_number_of_pages
public function get_pagination_array($items, $page) {
$sql = "SELECT COUNT(id) FROM incomming_goods";
return parent::get_pagination_array($items, $page, $sql);
} // end get_pagination_array
public function save($data) {
if (isset($data['id'])) {
$id = $data['id'];
unset($data['id']);
$sql = Database::update('incomming_goods', $data, 'WHERE id='.$id);
} else {
$id = false;
$sql = Database::insert('incomming_goods', $data);
}
$return = $this->db->query($sql);
if ($return) {
if ($id) {
return $id;
} else {
return $this->db->insert_id;
}
}
return false;
} // end save
public function save_bill($id, $name) {
$file_name = 'Rechnung_'.$id.'.pdf';
if (move_uploaded_file($_FILES['Filedata']['tmp_name'], $this->url.$file_name)) {
// save filename to db
$sql = "UPDATE incomming_goods SET bill_file='$file_name' WHERE id=$id";
//return $sql;
$this->db->query($sql);
//return
return $this->url.$file_name;
} else {
return false;
}
}
public function delete_bill_file($id) {
$file_name = 'Rechnung_'.$id.'.pdf';
if (unlink($this->url.$file_name)) {
// save filename to db
$sql = "UPDATE incomming_goods
SET bill_file=''
WHERE id=$id";
//return $sql;
$this->db->query($sql);
//return
return $this->url.$file_name;
} else {
return false;
}
}
}
?>
+69
View File
@@ -0,0 +1,69 @@
<?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 InvoiceStatus {
protected function __construct() {}
private function __clone() {}
public static function get_all() {
$db = Registry::get('base')->db;
$sql = "SELECT *
FROM invoice_status";
$result = $db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$return[] = $obj;
}
return $return;
}
return false;
}
public static function get_name($id) {
$db = Registry::get('base')->db;
if (empty($id)) return false;
$sql = "SELECT name FROM invoice_status WHERE id=$id";
$result = $db->query($sql);
if ($result->num_rows > 0) {
$obj = $result->fetch_object();
return $obj->name;
}
return false;
} // end get_name
public static function get_data($id) {
$db = Registry::get('base')->db;
$sql = "SELECT * FROM invoice_status WHERE id=$id";
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
return false;
} // end get_data
}
?>
File diff suppressed because it is too large Load Diff
+290
View File
@@ -0,0 +1,290 @@
<?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 ItemInventory {
private $item_id;
private $db;
private $error;
function __construct() {
$this->base_object = Registry::get('base');
$this->db = Registry::get('base')->db;
$this->error = '';
} // end constructor
public function get_type_name($type_id) {
$name = '';
switch ($type_id) {
case 1:
$name = 'Ladenverkauf';
break;
case 2:
$name = 'Wareneingang';
break;
case 3:
$name = 'Verlust';
break;
case 4:
$name = 'Eigenverbrauch';
break;
case 5:
$name = 'Onlineverkauf';
break;
}
return $name;
}
public function get_by_id($id) {
$sql = "SELECT *
FROM item_inventory
WHERE id = $id";
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
$data = $result->fetch_object();
return $data;
}
return false;
} // end get_by_id
// object id description:
// 1: Ladenverkauf
// 2: Wareneingang
// 3: Verlust
// 4: Eigenverbrauch
// 5: Onlineverkauf
public function get_by_object_id($object_id, $type_id) {
$sql = "SELECT *
FROM item_inventory
WHERE inventory_object_id = $object_id AND inventory_object_type_id = $type_id";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
//$obj->item_tax_sum = $obj->price_sum * $obj->item_tax / 100;
$obj->item_tax_sum = $obj->price_sum / (100 + $obj->item_tax) * $obj->item_tax;
$data[] = $obj;
}
return $data;
} // end get_by_id
public function get_all_item_inventory($item_id) {
$sql = "SELECT *
FROM item_inventory
WHERE item_id = $item_id ORDER BY created DESC
";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
if ($obj->inventory_object_type_id == 2) {
// get costs with shipping costs
include_once './core/incomming_goods.class.php';
$incomming_goods_object = new Incomming_goods($this->base_object);
$incomming_data = $incomming_goods_object->get_by_id($obj->inventory_object_id);
foreach ($incomming_data->item_list as $incomming_item) {
if ($incomming_item->id == $obj->id) {
$obj->price_sum = $incomming_item->item_price_ek;
}
}
$obj->price_sum *= $obj->amount;
}
//$obj->item_tax_sum = $obj->price_sum * $obj->item_tax / 100;
$obj->item_tax_sum = $obj->price_sum / (100 + $obj->item_tax) * $obj->item_tax;
if ($obj->inventory_object_type_id != 2) {
$obj->price_sum = $obj->price_sum - $obj->item_tax_sum;
}
$obj->type_name = $this->get_type_name($obj->inventory_object_type_id);
$data[] = $obj;
}
return $data;
} // end get_by_id
public function add($data) {
// get item data
include_once './core/item.class.php';
$item_object = new Item($this->base_object);
$item_object->id = $data['item_id'];
$item = $item_object->get_data();
if (!isset($data['inventory_object_id'])) {
$data['inventory_object_id'] = 0;
}
if (!isset($data['price_sum'])) {
$data['price_sum'] = 0;
}
if (!isset($data['create_time'])) {
$data['create_time'] = 'CURRENT_TIMESTAMP';
} else {
$data['create_time'] = "'".$this->db->real_escape_string($data['create_time'])."'";
}
// clear old inventory
if (isset($data['update']) && $data['update'] == 1) {
$sql = "
DELETE FROM item_inventory
WHERE item_id=".$this->db->real_escape_string($item->id)."
AND inventory_object_type_id=".$this->db->real_escape_string($data['inventory_object_type_id'])."
AND inventory_object_id=".$this->db->real_escape_string($data['inventory_object_id']);
$this->db->query($sql);
}
$sql = "INSERT INTO item_inventory
(
item_id,
item_number,
item_name,
item_tax,
inventory_object_type_id,
inventory_object_id,
amount,
price_sum,
created
) VALUES (
'".$this->db->real_escape_string($item->id)."',
'".$this->db->real_escape_string($item->number)."',
'".$this->db->real_escape_string($item->name)."',
'".$this->db->real_escape_string($item->tax)."',
'".$this->db->real_escape_string($data['inventory_object_type_id'])."',
'".$this->db->real_escape_string($data['inventory_object_id'])."',
'".$this->db->real_escape_string($data['amount'])."',
'".$this->db->real_escape_string($data['price_sum'])."',
".$data['create_time']."
)
";
$this->db->query($sql);
// update item inventory amount
$count = $this->get_item_inventory_count($item->id);
$item_object->set_inventory($count);
return 1;
}
public function remove($data) {
// get item data
include_once './core/item.class.php';
$item_object = new Item($this->base_object);
$item_object->id = $data['item_id'];
$item = $item_object->get_data();
if (!isset($data['inventory_object_id'])) {
$data['inventory_object_id'] = 0;
}
// clear old inventory
if (isset($data['update']) && $data['update'] == 1) {
$sql = "
DELETE FROM item_inventory
WHERE item_id=".$this->db->real_escape_string($item->id)."
AND inventory_object_type_id=".$this->db->real_escape_string($data['inventory_object_type_id'])."
AND inventory_object_id=".$this->db->real_escape_string($data['inventory_object_id']);
$this->db->query($sql);
}
// update item inventory amount
$count = $this->get_item_inventory_count($item->id);
$item_object->set_inventory($count);
return 1;
}
public function get_item_inventory_count($item_id) {
$count = 0;
$sql = "SELECT amount, inventory_object_type_id
FROM item_inventory
WHERE item_id = ".$this->db->real_escape_string($item_id);
$result = $this->db->query($sql);
$data = array();
if ($result) {
while ($obj = $result->fetch_object()) {
if ($obj->inventory_object_type_id == 2) {
// wareneingang
$count += $obj->amount;
} else {
// warenausgang
$count -= $obj->amount;
}
}
}
return $count;
}
public function update($data) {
$sql = "UPDATE item_inventory
SET ";
foreach ($data as $var_name => $value) {
$value = $this->db->real_escape_string($value);
if ($this->theme_fields[$var_name] == 'integer') {
$sql .= $var_name.'='.$value.', ';
} else {
$sql .= $var_name.'="'.$value.'", ';
}
}
$sql = substr($sql, 0, -2);
$sql .= ' WHERE id='.$this->id;
$this->db->query($sql);
// update item inventory count
$item_id = $this->get_item_id($this->id);
include_once './core/item.class.php';
$item_object = new Item($this->base_object);
$item_object->id = $item_id;
$count = $this->get_item_inventory_count($item_id);
$item_object->set_inventory($count);
return 1;
}
public function delete($id) {
// get item id for item update befor item inventory deleted
$item_id = $this->get_item_id($id);
// delete
$sql = "DELETE FROM item_inventory WHERE id = ".$this->db->real_escape_string($id);
$this->db->query($sql);
// update item inventory count
include_once './core/item.class.php';
$item_object = new Item($this->base_object);
$item_object->id = $item_id;
$count = $this->get_item_inventory_count($item_id);
$item_object->set_inventory($count);
return 1;
}
public function get_item_id($inventory_id) {
$sql = "SELECT item_id
FROM item_inventory
WHERE id = ".$this->db->real_escape_string($inventory_id);
$result = $this->db->query($sql);
if ($result) {
$obj = $result->fetch_object();
return $obj->item_id;
} else {
return 0;
}
}
}
+260
View File
@@ -0,0 +1,260 @@
<?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/item.class.php';
include_once './core/itemschema.class.php';
class ItemHelper {
//=========================================
//
// THIS CLASS IS STATIC ONLY
//
//=========================================
private function __construct() {}
private function __clone() {}
//=========================================
//
// THE PUBLIC INTERFACE
//
//=========================================
public static function get_number_of_items_by_manufacturer($id, $active_only = false) {
$db = Registry::get('base')->db;
$sql = "SELECT
COUNT(id) AS num
FROM
items
WHERE
manufacturer_id=".$db->real_escape_string($id);
// TODO: active is a hell of a lot more complicated with availability now, active still exists but nobody uses it
/*if ($active_only) {
$sql .= " AND
active=1";
}*/
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object()->num;
}
return false;
}
// TODO: SQL QUERY IN LOOP OVER ITEM OBJECT
// TO FIX THIS ITEM CLASS NEEDS TO BE REDESIGNED
public static function get_best_selling_items($num = 3, $structure_id = 0) {
$items = ItemHelper::get_best_selling_items_objects($num, $structure_id);
$item_object = new Item(Registry::get('base'));
foreach ($items as $item) {
$item_object->set_id($item->id);
$return_data[] = $item_object->get_data();
}
return $return_data;
}
public static function get_item_attributes($item, $with_variants = false) {
$item_schema_object = new ItemSchema(Registry::get('base'));
$schema_data = $item_schema_object->get_data($item->schema_id, true);
$return_data = array();
foreach ($schema_data->attributes as $value) {
if ($value->name != '') {
$attribute_value = $item->{"attribute_".$value->number};
$tmp = new stdClass();
if ($value->number != $schema_data->selectable_attribute_1 && $value->number != $schema_data->selectable_attribute_2) {
if ($attribute_value != '') {
$tmp->name = $value->name;
$tmp->value = $attribute_value;
$return_data[] = $tmp;
}
} else {
if ($value->name != '') {
$tmp->name = $value->name;
if ($value->number == $schema_data->selectable_attribute_1) {
$tmp->value = $item->variant1;
$tmp->variant = 1;
} else if ($value->number == $schema_data->selectable_attribute_2) {
$tmp->value = $item->variant2;
$tmp->variant = 2;
}
$return_data[] = $tmp;
}
}
}
}
return $return_data;
} // end get_item_attributes
public static function get_best_selling_items_objects($num, $structure_id) {
$db = Registry::get('base')->db;
$sql = "SELECT
oi.item_id AS id,
COUNT(oi.id) AS num
FROM
order_item oi
RIGHT JOIN
items i
ON
i.id = oi.item_id
WHERE
oi.item_id is not null
AND
i.active=1
AND
i.structure_id > 0";
if ($structure_id > 0) {
$sql .= "
AND (
i.structure_id = ".$db->real_escape_string($structure_id)."
OR
i.structure_id_2 = ".$db->real_escape_string($structure_id)."
OR
i.structure_id_3 = ".$db->real_escape_string($structure_id)."
OR
i.structure_id_4 = ".$db->real_escape_string($structure_id)."
OR
i.structure_id_5 = ".$db->real_escape_string($structure_id)."
OR
i.structure_id_6 = ".$db->real_escape_string($structure_id)."
OR
i.structure_id_7 = ".$db->real_escape_string($structure_id)."
OR
i.structure_id_8 = ".$db->real_escape_string($structure_id)."
OR
i.structure_id_9 = ".$db->real_escape_string($structure_id)."
OR
i.structure_id_10 = ".$db->real_escape_string($structure_id)."
)
";
}
$sql .= "
GROUP BY oi.item_id
ORDER BY num DESC
LIMIT 0, ".$db->real_escape_string($num);
$result = $db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$return_data[] = $obj;
}
return $return_data;
}
return false;
}
// TODO: where is that default taxrate
public static function get_item_taxrate($item_id) {
$db = Registry::get('base')->db;
$sql = "SELECT
t.steuersatz
FROM
tax t
RIGHT JOIN
items i
ON
i.tax_id = t.id
WHERE
i.id=".$db->real_escape_string($item_id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object()->steuersatz;
}
return false;
}
public static function get_item_variant_prices($item_id, $group_id, $taxrate = 19) {
$item_object = new Item(Registry::get('base'));
$item_object->set_id($item_id);
$data = $item_object->getVariantPricesForCustomerGroup($group_id, false, false, $taxrate);
return $data;
}
public static function get_item_variant_image($item_id, $attribute_1, $attribute_2) {
$db = Registry::get('base')->db;
$sql = "SELECT
*
FROM
item_files
WHERE
item_id='".$db->real_escape_string($item_id)."'
AND
attribut1='".$db->real_escape_string($attribute_1)."'
AND
attribut2='".$db->real_escape_string($attribute_2)."'
LIMIT
1";
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object()->file_name;
}
return false;
}
public static function get_additional_item_images($item_id) {
$db = Registry::get('base')->db;
$sql = "
SELECT
file_name
FROM
item_files
WHERE
item_id = '".$db->real_escape_string($item_id)."'
AND
type = 0
ORDER BY
rang
";
$result = $db->query($sql);
if ($result->num_rows > 0) {
$images = array();
$pos = 0;
while ($I = $result->fetch_object()) {
$images[++$pos] = $I->file_name;
}
return $images;
}
return false;
}
}
+268
View File
@@ -0,0 +1,268 @@
<?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/main.class.php';
class ItemSchema extends Main {
public $list_table_config = array (
'title' => 'Artikelattribute',
'db_table' => 'item_schema',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Bezeichnung',
'sortable' => 1
),
array(
'db_field' => 'description',
'name' => 'Beschreibung',
'sortable' => 1
),
array(
'db_field' => 'active',
'name' => 'Status',
'rewrite_function' => 'state_text',
'sortable' => 1
)
),
'search_fields' => array('name', 'description'),
'db_id_field' => 'id',
'edit_link' => 'index.php?admin_modul=admin_item_schema_editor&id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_item_schema_editor',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
)
);
protected $base_object;
protected $db;
// db fields
private $fields = array(
);
// generic
private $id;
private $error;
public function __construct($base_object, $id = false) {
$this->base_object = $base_object;
$this->db = $base_object->db;
$this->id = $id;
$this->error = '';
} // end constructor
public function state_text() {
return array (
'1' => 'aktiv',
'0' => 'inaktiv'
);
}
public function set_id($id) {
$this->id = $id;
} // end set_id
public function get_id() {
return $this->id;
} // end get_id
public function get_error() {
return $this->error;
} // end get_error
public function get_all($filter = false, $with_attributes = false) {
$sql = "SELECT * FROM item_schema";
if ($filter) {
if ($filter == ' ') {
$sql .= " ";
} else {
$this->error = 'unknown filter';
return false;
}
}
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
$return_data = array();
while ($obj = $result->fetch_object()) {
$return_data[$obj->id] = $obj;
}
if ($with_attributes) {
$sql = "SELECT * FROM item_schema_attributes";
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
if (isset($return_data[$obj->schema_id])) {
$return_data[$obj->schema_id]->attributes[$obj->rang] = $obj;
}
}
}
}
return $return_data;
}
$this->error = 'no result';
return false;
} // end get_all
public function get_data($id = false, $with_attributes = false) {
$sql = "SELECT * FROM item_schema";
if ($id) {
$sql .= " WHERE id=".$this->db->real_escape_string($id);
$this->id = $id;
} else if ($this->id) {
$sql .= " WHERE id=".$this->db->real_escape_string($this->id);
} else {
$this->error = 'no id';
return false;
}
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
if ($with_attributes) {
$structure = $result->fetch_object();
$sql = "SELECT * FROM item_schema_attributes WHERE schema_id=".$this->db->real_escape_string($this->id);
$result = $this->db->query($sql);
$attributes = array();
while ($obj = $result->fetch_object()) {
if ($obj->name != '') {
$attributes[] = $obj;
}
}
$structure->attributes = $attributes;
return $structure;
}
return $result->fetch_object();
}
$this->error = 'no result';
return false;
} // end get_data
public function delete($id = false) {
$sql = "DELETE FROM item_schema ";
if ($id) {
$sql .= "WHERE id=".$this->db->real_escape_string($id);
} else if ($this->id) {
$sql .= "WHERE id=".$this->db->real_escape_string($this->id);
} else {
return false;
}
return $this->db->query($sql);
} // end delete
public function create($data) {
echo "implement create in itemschema"; exit();
} // end create
public function update($data, $id = false) {
echo "implement update in itemschema"; exit();
} // end update
public function validate($data) {
// TODO: implement this
return true;
} // end data_filter
public function get_all_paginated($items , $page) {
$page = ($page - 1) * $items;
$sql = "SELECT * FROM item_schema 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 COUNT(id) FROM item_schema";
$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 COUNT(id) FROM item_schema";
$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
public function delete_by_id($id) {
$sql = "DELETE FROM item_schema_attributes
WHERE schema_id=".$id;
$this->db->query($sql);
$sql = "DELETE FROM item_schema
WHERE id=".$id;
$this->db->query($sql);
return;
}
}
+150
View File
@@ -0,0 +1,150 @@
<?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/main.class.php';
class ItemType extends Main {
public $list_table_config = array (
'title' => 'Artikeltypen',
'db_table' => 'item_type_definitions',
'list_fields' => array(
array(
'db_field' => 'item_type_definition_name',
'name' => 'Bezeichnung',
'sortable' => 1
),
array(
'db_field' => 'item_type_definition_text',
'name' => 'Beschreibung',
'sortable' => 1
),
array(
'db_field' => 'item_type_definition_is_active',
'name' => 'Status',
'rewrite_function' => 'state_text',
'sortable' => 1
)
),
'search_fields' => array('item_type_definition_name', 'item_type_definition_text'),
'db_id_field' => 'item_type_definition_id',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=ItemType&object_id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_object_edit&object=ItemType',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
),
'edit_title' => 'Artikeltyp',
'edit_fields' => array (
array(
'name' => 'Stammdaten',
'type' => 'form_title'
),
array(
'db_field' => 'item_type_definition_name',
'name' => 'Name',
'type' => 'text'
),
array(
'db_field' => 'item_type_definition_text',
'name' => 'Text',
'type' => 'text'
),
array(
'db_field' => 'item_type_definition_is_active',
'name' => 'Status',
'values' => 'state_text',
'type' => 'int'
),
array(
'db_field' => 'item_type_definition_type',
'name' => 'Aktion',
'values' => 'item_action_text',
'type' => 'int'
)
),
'edit_mandatory_fields' => array('name', 'text'),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_list&object=ItemType',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'delete' => 1
),
);
protected $base_object;
protected $db;
// db fields
private $fields = array(
);
// generic
private $id;
private $error;
public function __construct($base_object, $id = false) {
$this->base_object = $base_object;
$this->db = $base_object->db;
$this->id = $id;
$this->error = '';
} // end constructor
public function state_text() {
return array (
'1' => 'aktiv',
'0' => 'inaktiv'
);
}
public function item_action_text() {
return array (
'0' => '-',
'1' => 'Angebotspreis - Zeitraum definierbar'
);
}
public function set_id($id) {
$this->id = $id;
} // end set_id
public function get_id() {
return $this->id;
} // end get_id
public function get_error() {
return $this->error;
} // end get_error
public function get_item_type_definitions() {
$sql = 'SELECT * FROM item_type_definitions';
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
$data = array();
while ($obj = $result->fetch_object()) {
$data[$obj->item_type_definition_id] = $obj->item_type_definition_name;
}
return $data;
}
return false;
} // end get_item_type_definitions
}
+120
View File
@@ -0,0 +1,120 @@
<?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/main.class.php';
include_once './core/database.class.php';
class Language extends Main {
public $list_table_config = array (
'title' => 'Sprachen',
'db_table' => 'languages',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Sprache',
'sortable' => 1
),
array(
'db_field' => 'iso_639_1',
'name' => 'ISO 631-1',
'sortable' => 1
),
array(
'db_field' => 'active',
'name' => 'Status',
'rewrite_function' => 'state_text',
'sortable' => 1
)
),
'search_fields' => array('name', 'iso_639_1'),
'db_id_field' => 'id',
'db_selectable_field' => 'name',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=Language&object_id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_object_edit&object=Language',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
),
'edit_title' => 'Sprache bearbeiten',
'edit_fields' => array (
array(
'name' => 'Stammdaten',
'type' => 'form_title'
),
array(
'db_field' => 'name',
'name' => 'Sprache',
'type' => 'text'
),
array(
'db_field' => 'iso_639_1',
'name' => 'ISO 631-1',
'type' => 'text'
),
array(
'db_field' => 'price_format',
'name' => 'Price format',
'type' => 'text'
),
array(
'db_field' => 'date_format',
'name' => 'Date format',
'type' => 'text'
),
array(
'db_field' => 'active',
'name' => 'Status',
'values' => 'state_text',
'type' => 'int'
)
),
'edit_mandatory_fields' => array('name', 'iso_639_1'),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_list&object=Language',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'delete' => 1
),
);
public function state_text() {
return array (
'1' => 'aktiv',
'0' => 'inaktiv'
);
}
public function get_all_active() {
$sql = "SELECT * FROM languages WHERE active=1";
$result = $this->db->query($sql);
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/language_class.php->get_all_active()', $this->db->error.', sql:'.$sql);
}
$data = array();
if ($result) {
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
}
return $data;
}
}
?>