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

49
.gitignore vendored Normal file
View File

@ -0,0 +1,49 @@
# Secrets & Config
config.inc.php
# Logs
error_log.txt
error_log*
*.log
# User-Daten (Bilder, Uploads, Kundendateien)
/media/
/upload/
/logs/
/web/intelectra_shop/media/
/web/intelectra_shop/documents/article/
/web/intelectra_shop/themes/*/media/images/
# Smarty Cache/Compile
/tmp/smarty_compile/
/tmp/smarty_cache/
/tmp/log.csv
/web/*/tmp/
/web/*/themes/*/templates_c/
smarty_compile
# Backups / Altlasten
*.bak
*.bak2
*.bak3
*.broken
*.old
*.oold
*.backup_*
*.SAFE_BACKUP_*
*.live_backup_*
*.fix[0-9]*
*.orig
*~
# IDE / OS
.idea/
.vscode/
.DS_Store
Thumbs.db
# Claude / AI
.claude/
# Node
node_modules/

80
.htaccess Normal file
View File

@ -0,0 +1,80 @@
RewriteEngine On
Options +SymLinksIfOwnerMatch
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
### Error-Docs
ErrorDocument 404 /error_404/
### go to backend
RewriteRule ^easywayshop(/)?$ index.php?admin_modul=admin_dashboard [R=301]
### Logout
RewriteRule ^LogOff/$ index.php?logout=1 [L,NC,QSA]
### Lightingrod
RewriteRule ^LightingRod/$ index.php?lightningrod=1 [L,NC,QSA]
### items.csv
RewriteRule ^Kundencenter/(items).(csv)$ index.php?structure_suri=Kundencenter&action=get_item_export [L,NC,QSA]
### get google shopping csv
#RewriteRule ^google_de.csv?$ index.php?website_modul=website_export&id=google_de [L,NC,QSA]
### Language selection
RewriteRule ^lang/([a-zA-Z0-9-_,]+)/$ index.php?lang=$1 [L,NC,QSA]
### Manufacturer views
## Manufacturer only
RewriteRule ^Kaufen/([a-zA-Z0-9-_,]+)/$ index.php?seo_manufacturer_suri=$1 [L,NC,QSA]
## Manufacturer and structure group
RewriteRule ^Kaufen/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/$ index.php?seo_manufacturer_suri=$1&structureSuri=$2 [L,NC,QSA]
### Item category navigation and pages
RewriteRule ^([a-zA-Z0-9-_,]+)(/Seite-([0-9]+))?/$ index.php?structure_suri=$1&page=$3 [L,NC,QSA]
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)(/Seite-([0-9]+))?/$ index.php?structure_suri=$2&structure_suri2=$1&page=$4 [L,NC,QSA]
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)(/Seite-([0-9]+))?/$ index.php?structure_suri=$3&structure_suri1=$2&structure_suri2=$1&page=$5 [L,NC,QSA]
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)(/Seite-([0-9]+))?/$ index.php?structure_suri=$4&structure_suri1=$3&structure_suri2=$2&structure_suri3=$1&page=$6 [L,NC,QSA]
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)(/Seite-([0-9]+))?/$ index.php?structure_suri=$5&structure_suri1=$4&structure_suri2=$3&structure_suri3=$2&structure_suri4=$1&page=$7 [L,NC,QSA]
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)(/Seite-([0-9]+))?/$ index.php?structure_suri=$6&structure_suri1=$5&structure_suri2=$4&structure_suri3=$3&structure_suri4=$2&structure_suri5=$1&page=$8 [L,NC,QSA]
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)(/Seite-([0-9]+))?/$ index.php?structure_suri=$7&structure_suri1=$6&structure_suri2=$5&structure_suri3=$4&structure_suri4=$3&structure_suri5=$2&structure_suri6=$1&page=$9 [L,NC,QSA]
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)(/Seite-([0-9]+))?/$ index.php?structure_suri=$8&structure_suri1=$7&structure_suri2=$6&structure_suri3=$5&structure_suri4=$4&structure_suri5=$3&structure_suri6=$2&structure_suri7=$1&page=$10 [L,NC,QSA]
### Item views
## 7. Level / 5. Manufacturer
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([aA-zZ0-9-_,]+)/([aA-zZ0-9-_,]+)/([aA-zZ0-9-_,]+)/([aA-zZ0-9-_,]+)/([aA-zZ0-9-_,]+).(html)$ index.php?structure_suri3=$1&structure_suri2=$2&structure_suri=$3&structure_suri=$4&structure_suri=$5&structure_suri=$6&structure_suri=$7&item_suri=$8 [L,NC,QSA]
## 6. Level / 4. Manufacturer
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([aA-zZ0-9-_,]+)/([aA-zZ0-9-_,]+)/([aA-zZ0-9-_,]+)/([aA-zZ0-9-_,]+).(html)$ index.php?structure_suri3=$1&structure_suri2=$2&structure_suri=$3&structure_suri=$4&structure_suri=$5&structure_suri=$6&item_suri=$7 [L,NC,QSA]
## 5. Level / 3. Manufacturer
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([aA-zZ0-9-_,]+)/([aA-zZ0-9-_,]+)/([aA-zZ0-9-_,]+).(html)$ index.php?structure_suri3=$1&structure_suri2=$2&structure_suri=$3&structure_suri=$4&structure_suri=$5&item_suri=$6 [L,NC,QSA]
## 4. Level / 2. Manufacturer
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([aA-zZ0-9-_,]+)/([aA-zZ0-9-_,]+).(html)$ index.php?structure_suri3=$1&structure_suri2=$2&structure_suri=$3&structure_suri=$4&item_suri=$5 [L,NC,QSA]
## 3. Level / 1. Manufacturer
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([aA-zZ0-9-_,]+).(html)$ index.php?structure_suri3=$1&structure_suri2=$2&structure_suri=$3&item_suri=$4 [L,NC,QSA]
## 2. Level
RewriteRule ^([a-zA-Z0-9-_,]+)/([a-zA-Z0-9-_,]+)/([aA-zZ0-9-_,]+).(html)$ index.php?structure_suri2=$1&structure_suri=$2&item_suri=$3 [L,NC,QSA]
## 1. Level
RewriteRule ^([a-zA-Z0-9-_,]+)/([aA-zZ0-9-_,]+).(html)$ index.php?structure_suri=$1&item_suri=$2 [L,NC,QSA]
## Direct
RewriteRule ^([aA-zZ0-9-_,]+).(html)$ index.php?item_suri=$1 [L,NC,QSA]
### google xml sitemap
RewriteRule ^(sitemap).(xml)$ index.php?website_modul=website_sitemap&action=get_xml [L,NC,QSA]
### export files to search engines
RewriteRule ^export/([a-zA-Z0-9-_,]+).(csv)$ index.php?website_modul=website_export&id=$1 [L,NC,QSA]

1
.php-ini Normal file
View File

@ -0,0 +1 @@
/var/www/vhosts/system/intelectra-shop.de/etc/php.ini

1
.php-version Normal file
View File

@ -0,0 +1 @@
8.2

114
core/admin_object_list.php Normal file
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
*/
class admin_object_list {
private $base_object;
private $config;
private $object_name;
private $object = false;
private $action = false;
private $max_list_items = 20;
private $sort_direction = 'up';
private $sort_item = false;
private $actual_page = 1;
private $count_pages = 1;
private $list_filter = false;
private $search_string = '';
private $output = false;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
// get vars
foreach (array('action', 'max_list_items', 'actual_page', 'sort_item', 'sort_direction', 'search_string', 'list_filter', 'output', 'object') as $field) {
if (isset($_GET[$field])) {
$this->{$field} = $_GET[$field];
} else if (isset($_POST[$field])) {
$this->{$field} = $_POST[$field];
}
}
// init object
$this->object_name = $this->object;
include_once(ROOT_DIR.'./core/'.strtolower($this->object_name).'.class.php');
$this->object = new $this->object_name($this->base_object);
if ($this->action == 'get_list_items') {
return $this->get_list_items();
} else {
return $this->get_initial_object_table();
}
}
private function get_list_items() {
// get row data
if ($this->output && $this->output == 'csv') {
$setting = $this->get_list_setting();
$setting['data_format'] = 0;
$list_data = $this->object->get_list_items($setting);
$list_data['list_table_config'] = $this->object->list_table_config;
// make csv file
$csv_header = array();
foreach ($list_data['list_table_config']['list_fields'] as $list_field) {
$csv_header[] = $list_field['name'];
}
$csv = implode(';',$csv_header)."\r\n";
foreach ($list_data['list_items'] as $row) {
array_shift($row);
$csv .= implode(';',$row)."\r\n";
}
$csv = html_entity_decode(strip_tags($csv),ENT_NOQUOTES,'UTF-8');
//echo $csv;exit();
header( "Content-Type: text/csv" );
header( "Content-Disposition: attachment; filename=export.csv");
header( "Content-Description: csv File" );
header( "Pragma: no-cache" );
header( "Expires: 0" );
echo utf8_decode($csv);
exit();
} else {
$list_data = $this->object->get_list_items($this->get_list_setting());
$list_data['list_table_config'] = $this->object->list_table_config;
$this->layout_object->assign('list_data', $list_data);
return $this->layout_object->fetch('admin_object_list_items.tpl');
}
}
private function get_initial_object_table() {
// get table funktions (delete, edit, search, filter, sort...) and titlerows:
$table_data = $this->object->list_table_config;
$table_data['list_setting'] = $this->get_list_setting();
$table_data['list_filter'] = $this->object->get_filter();
$table_data['list_actions'] = $this->object->get_actions();
$table_data['object_name'] = $this->object_name;
$this->layout_object->assign('table_data', $table_data);
return $this->layout_object->fetch('admin_object_table.tpl');
}
private function get_list_setting() {
// get list setting
return array (
'max_list_items' => $this->max_list_items,
'sort_direction' => $this->sort_direction,
'sort_item' => $this->sort_item,
'actual_page' => $this->actual_page,
'count_pages' => $this->count_pages,
'list_filter' => $this->list_filter,
'data_format' => 1,
'search_string' => $this->search_string
);
}
}

210
core/admin_role.class.php Normal file
View File

@ -0,0 +1,210 @@
<?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 Admin_role extends Main {
public $list_table_config = array (
'title' => 'Verwaltungs Rollen',
'db_table' => 'admin_roles',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Rollenname',
'sortable' => 1
),
array(
'db_field' => 'description',
'name' => 'Beschreibung',
'sortable' => 1
)
),
'search_fields' => array('name', 'description'),
'db_id_field' => 'id',
'edit_link' => 'index.php?admin_modul=admin_admin_role_editor&id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_admin_role_editor',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
)
);
private $object_fields = array(
'name' => 'text',
'acl_show' => 'text',
'description' => 'text'
);
protected $db;
protected $base;
private $config;
public function __construct($base_object) {
parent::__construct($base_object);
$this->config_object = $base_object->config;
$this->db = $base_object->db;
$this->base = $base_object;
}
public function get_data() {
$sql = "SELECT * FROM admin_roles WHERE id = ".$this->id;
$result = $this->db->query($sql);
$obj = $result->fetch_object();
$acl_show_string = $obj->acl_show;
$acl_show = explode(';', $acl_show_string);
$acl_permission = array();
foreach ($acl_show as $modul) {
$acl_permission[$modul] = 1;
}
$obj->acl_show = $acl_permission;
return $obj;
} // end get_data
public function get_all() {
// get all groups from database
$sql = "
SELECT
*
FROM
admin_roles
";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
}
public function delete() {
$sql = "
DELETE FROM
admin_roles
WHERE id=".$this->id;
$this->db->query($sql);
return;
}
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 admin_roles 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;
}
public function update($data) {
if ($data) {
$sql = "
UPDATE
admin_roles
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;
}
public function get_all_paginated($items , $page, $order = false) {
$page = ($page - 1) * $items;
$sql = "SELECT *
FROM admin_roles
LIMIT $items OFFSET $page";
return parent::get_all_paginated($items, $page, $sql);
} // end get_all_paginated
public function get_number_of_pages($items) {
$sql = "SELECT COUNT(id) FROM admin_roles";
return parent::get_number_of_pages($items, $sql);
}
public function get_pagination_array($items, $page) {
$sql = "SELECT COUNT(id) FROM admin_roles";
return parent::get_pagination_array($items, $page, $sql);
}
public function delete_by_id($id) {
$rs = $this->db->query("DELETE FROM admin_roles WHERE id=$id;");
}
public function get_all_admin_modules() {
include('./core/system_registration.inc.php');
return $admin_modul_registration;
}
public function acl_2_string($acl_array) {
include('./core/system_registration.inc.php');
$acl = array();
foreach ($admin_modul_registration as $modul) {
if (isset($acl_array[$modul['modul']]) && $acl_array[$modul['modul']] == 1) {
$acl[] = $modul['modul'];
}
}
return implode(';', $acl);
}
function get_all_names() {
$data = array();
$result = $this->db->query('SELECT id, name FROM admin_roles');
if ($result) {
while ($obj = $result->fetch_object()) {
$data[$obj->id] = $obj->name;
}
}
return $data;
}
}
?>

View File

@ -0,0 +1,213 @@
<?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 article_group {
function get($id) {
return;
} // end get
public function load_discounts($fetch_article_ids = false, $discount_group = false, $customer_id = false) {
$discounts = array();
if (is_numeric($fetch_article_ids)) {
$article_ids = array($fetch_article_ids);
} else if (is_array($fetch_article_ids)) {
$article_ids = $fetch_article_ids;
} else {
$article_ids = array();
}
if (count($article_ids) > 0 && is_numeric($discount_group) && $discount_group > 0) {
// Group discounts
$rs = mysql_query("
SELECT
MAX(d.rg_".$discount_group.") AS discount,
p.id
FROM
easyshop_rabattgruppen d
RIGHT JOIN
easyshop_zuweisungen a
ON
a.wg_id = d.wg_id
LEFT JOIN
easyshop_artikel p
ON
a.a_id = p.id
WHERE
a.a_id IN (".implode(',', $article_ids).")
AND
d.hersteller_id = p.hersteller_id
GROUP BY
p.id,
d.hersteller_id
HAVING
discount > 0
");
while ($D = mysql_fetch_object($rs)) {
$discounts[$D->id] = $D->discount;
}
if (is_numeric($customer_id)) {
// Customer discounts
$rs = mysql_query("
SELECT
MAX(d.rabatt) AS discount,
p.id
FROM
easyshop_rabattkunden d
RIGHT JOIN
easyshop_zuweisungen a
ON
a.wg_id = d.wg_id
LEFT JOIN
easyshop_artikel p
ON
a.a_id = p.id
WHERE
a.a_id IN (".implode(',', $article_ids).")
AND
d.hersteller_id = p.hersteller_id
AND
d.kunden_id = ".$customer_id."
GROUP BY
p.id,
d.hersteller_id
HAVING
discount > 0
");
while ($D = mysql_fetch_object($rs)) {
$discounts[$D->id] = max(array($D->discount, $discounts[$D->id]));
}
}
// Product discounts
$rs = mysql_query("
SELECT
rg_".$discount_group." AS discount,
artikel_id
FROM
easyshop_rabattartikel
WHERE
artikel_id IN (".implode(',', $article_ids).")
AND
rg_".$discount_group." > 0
");
while ($D = mysql_fetch_object($rs)) {
$discounts[$D->artikel_id] = max(array($D->discount, $discounts[$D->artikel_id]));
}
}
return $discounts;
}// end load_discounts
//speziell fuer article export
public function load_discounts_export($fetch_article_ids = false, $discount_group = false, $customer_id = false) {
$discounts = array();
if (is_numeric($fetch_article_ids)) {
$article_ids = array($fetch_article_ids);
} else if (is_array($fetch_article_ids)) {
$article_ids = $fetch_article_ids;
} else {
$article_ids = array();
}
if (is_numeric($discount_group) && $discount_group > 0) {
// Group discounts
$rs = mysql_query("
SELECT
MAX(d.rg_".$discount_group.") AS discount,
p.id
FROM
easyshop_rabattgruppen d
RIGHT JOIN
easyshop_zuweisungen a
ON
a.wg_id = d.wg_id
LEFT JOIN
easyshop_artikel p
ON
a.a_id = p.id
AND
d.hersteller_id = p.hersteller_id
GROUP BY
p.id,
d.hersteller_id
HAVING
discount > 0
");
while ($D = mysql_fetch_object($rs)) {
$discounts[$D->id] = $D->discount;
}
if (is_numeric($customer_id) && $article_ids) {
// Customer discounts
$rs = mysql_query("
SELECT
MAX(d.rabatt) AS discount,
p.id
FROM
easyshop_rabattkunden d
RIGHT JOIN
easyshop_zuweisungen a
ON
a.wg_id = d.wg_id
LEFT JOIN
easyshop_artikel p
ON
a.a_id = p.id
WHERE
a.a_id IN (".implode(',', $article_ids).")
AND
d.hersteller_id = p.hersteller_id
AND
d.kunden_id = ".$customer_id."
GROUP BY
p.id,
d.hersteller_id
HAVING
discount > 0
");
while ($D = mysql_fetch_object($rs)) {
$discounts[$D->id] = max(array($D->discount, $discounts[$D->id]));
}
}
if ($article_ids) {
// Product discounts
$rs = mysql_query("
SELECT
rg_".$discount_group." AS discount,
artikel_id
FROM
easyshop_rabattartikel
WHERE
artikel_id IN (".implode(',', $article_ids).")
AND
rg_".$discount_group." > 0
");
while ($D = mysql_fetch_object($rs)) {
$discounts[$D->artikel_id] = max(array($D->discount, $discounts[$D->artikel_id]));
}
}
}
return $discounts;
} // end load_discounts_export
}

96
core/base.class.php Normal file
View File

@ -0,0 +1,96 @@
<?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
*/
// including libs
include_once './core/logger.class.php';
include_once './core/config.class.php';
include_once './core/i18n.class.php';
include_once './core/customer.class.php';
include_once './core/customer_group.class.php';
include_once './core/admin_role.class.php';
class base {
public $logger;
public $config;
public $i18n;
public $db;
public $customer;
public $customer_group;
public $admin_role;
private $document_dir;
public function __construct() {
// load config settings
$confFilePath = './config.inc.php';
if (file_exists($confFilePath)) {
include_once($confFilePath);
} else {
die('<h3>easyway shop wird gerade aktualisiert.</h3>');
}
// needed global vars
define('SHOP_SYSTEM', $config_shop_system['SHOP_SYSTEM']);
define('ROOT_DIR', $config_shop_system['ROOT_DIR']);
define('STANDARD_DIR', $config_shop_system['STANDARD_DIR']);
define('MAIN_URL', $config_shop_system['MAIN_URL']);
// system logger
$this->logger = Logger::get_instance();
// new database object
$this->db = new mysqli(
$config_shop_system['db_host'],
$config_shop_system['db_user'],
$config_shop_system['db_password'],
$config_shop_system['db_name']
);
// set database default charset
$this->db->query("SET NAMES 'utf8'");
// other important objects
$this->config = new config($this);
$this->customer = new customer($this);
$this->i18n = new i18n($this);
$this->customer_group = new Customer_group($this);
$this->admin_role = new Admin_role($this);
$this->document_dir = $config_shop_system['ROOT_DIR'].'web/'.$config_shop_system['SHOP_SYSTEM'].'/documents/';
}
protected function setup_info() {
$info = (object)"";
$info->base_url = MAIN_URL;
$info->my_url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$info->module_name = $this->module_name;
$info->images = MAIN_URL.'web/'.SHOP_SYSTEM.'/documents/files/';
$this->layout_object->assign('info', $info);
} // end setup_info
public function is_customer_logged_in() {
if ($this->customer->customer_id) {
return true;
}
return false;
}
function __destruct() {
$this->db->close();
}
function get_document_dir() {
return $this->document_dir;
}
}
?>

107
core/base/edit.class.php Normal file
View File

@ -0,0 +1,107 @@
<?php
class Base_Edit {
protected $base_object;
protected $db;
protected $error;
protected $id;
public function __construct($base_object, $id = false) {
$this->base_object = $base_object;
$this->db = $base_object->db;
$this->error = false;
$this->id = $id;
} // end __construct
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
protected function select_one($table) {
if ($this->id) {
$sql = 'SELECT * FROM '.$table;
$sql .= ' WHERE '.$this->get_id_name($table);
$sql .= '='.$this->db->real_escape_string($this->id);
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $this->enrich($result->fetch_object());
}
}
return false;
} // end select_one
protected function delete_one($table) {
$sql = 'DELETE FROM '.$table;
$sql .= ' WHERE '.$this->get_id_name($table);
$sql .= '='.$this->db->real_escape_string($this->id);
return $this->db->query($sql);
} // end delete_one
private function set_string($data) {
$sql = ' SET';
$first = true;
foreach ($data as $key => $value) {
if ($first) {
$first = false;
} else {
$sql .= ',';
}
$sql .= ' '.$this->db->real_escape_string($key);
$sql .= "='".$this->db->real_escape_string($value)."'";
}
return $sql;
} // end set_string
private function save_data($sql) {
$result = $this->db->query($sql);
if ($result) {
return $this->db->insert_id;
}
return false;
} // end save_data
protected function create_one($table, $data) {
$sql = 'INSERT INTO '.$table;
$sql .= $this->set_string($data);
return $this->save_data($sql);
} // end create_one
protected function update_one($table, $data) {
$sql = 'UPDATE '.$table;
$sql .= $this->set_string($data);
$sql .= ' WHERE '.$this->get_id_name($table);
$sql .= '='.$this->db->real_escape_string($this->id);
$this->save_data($sql);
return $this->id;
} // end update_one
private function get_id_name($table) {
return substr($table, 0, -1).'_id';
} // end get_id_name
protected function enrich($object) {
return $object;
} // end enrich
}

109
core/bill.class.php Normal file
View File

@ -0,0 +1,109 @@
<?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 Bill extends Main {
public $list_table_config = array (
'title' => 'Rechnungen',
'db_table' => 'bills',
'list_fields' => array(
array(
'db_field' => 'state_id',
'name' => 'Status',
'sortable' => 1
),
array(
'db_field' => 'number',
'name' => 'Nummmer',
'sortable' => 1
),
array(
'db_field' => 'bill_date',
'name' => 'Datum',
'sortable' => 1
),
array(
'db_field' => 'payment_date',
'name' => 'Fällig am',
'sortable' => 1
),
array(
'db_field' => 'customer',
'name' => 'Kunde',
'sortable' => 1
),
array(
'db_field' => 'payment_state',
'name' => 'Zahlungsstatus',
'sortable' => 1
),
array(
'db_field' => 'amount_brutto',
'name' => 'Summe brutto',
'sortable' => 1
),
array(
'db_field' => 'open_amount',
'name' => 'Offener Betrag',
'sortable' => 1
)
),
'search_fields' => array('number', 'customer'),
'db_id_field' => 'id',
'db_selectable_field' => 'name',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=Bill&object_id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_object_edit&object=Bill',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
),
'edit_title' => 'Rechnung',
'edit_fields' => array (
array(
'name' => 'Stammdaten',
'type' => 'form_title'
),
array(
'db_field' => 'number',
'name' => 'Nummer',
'type' => 'text'
),
array(
'db_field' => 'bill_date',
'name' => 'Datum',
'type' => 'text'
),
array(
'db_field' => 'customer',
'name' => 'Kunde',
'type' => 'text'
)
),
'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
),
);
}
?>

145
core/billing.class.php Normal file
View File

@ -0,0 +1,145 @@
<?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/pageable.class.php';
class Billing extends Pageable {
public function __construct($base_object) {
parent::__construct($base_object);
$this->config_object = $base_object->config;
$this->base_object = $base_object;
} // end constructor
private function get_order_statuses() {
$sql = "
SELECT
id
FROM
order_status
WHERE
in_billing = 1";
$result = $this->db->query($sql);
if ($result->num_rows) {
while ($obj = $result->fetch_object()) {
$return[] = $obj->id;
}
return $return;
} else {
return false;
}
throw new Exception("Es wurde noch kein Bestellstatus den Rechnungen zugewiesen.");
} // end get_order_statuses
private function get_billing_statuses() {
$sql = "
SELECT
id
FROM
billing_status
WHERE
in_billing = 1";
$result = $this->db->query($sql);
if ($result->num_rows) {
while ($obj = $result->fetch_object()) {
$return[] = $obj->id;
}
return $return;
} else {
return false;
}
throw new Exception("Es wurde noch kein Rechnungsstatus den Rechnungen zugewiesen.");
} // end get_billing_statuses
private function get_where_clause() {
$order_where = '';
$order_statuses = $this->get_order_statuses();
foreach ($order_statuses as $order_status) {
if ($order_where == '') {
$order_where .= "WHERE order_status = $order_status ";
} else {
$order_where .= "OR order_status = $order_status ";
}
}
$billing_where = '';
$billing_statuses = $this->get_billing_statuses();
foreach ($billing_statuses as $billing_status) {
if ($billing_where == '') {
$billing_where .= "AND billing_status = $billing_status ";
} else {
$billing_where .= "OR billing_status = $billing_status ";
}
}
return $order_where.$billing_where;
} // end get_where_clause
public function get_number_of_pages($items) {
$sql = "
SELECT
COUNT(id)
FROM
orders ";
$sql .= $this->get_where_clause();
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
orders ";
$sql .= $this->get_where_clause();
return parent::get_pagination_array($items, $page, $sql);
} // end get_pagination_array
public function get_all_paginated($items, $page, $order = false) {
$page = ($page - 1) * $items;
$sql = "
SELECT
*
FROM
orders ";
$sql .= $this->get_where_clause();
$sql .= ' '."
ORDER BY
order_date DESC
LIMIT $items OFFSET $page";
return parent::get_all_paginated($items, $page, $sql);
} // end get_all_paginated
}

74
core/cache.class.php Normal file
View File

@ -0,0 +1,74 @@
<?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 Cache {
private $object_fields = array(
'id' => 'text',
'timestamp' => 'text',
'data' => 'text'
);
private $base_object;
function __construct($base_object) {
$this->base_object = $base_object;
$this->db = $base_object->db;
} // end __construct
public function get_data($id) {
if ($this->id) {
$sql = "SELECT *
FROM cache
WHERE id='".$this->db->real_escape_string($id)."'";
$result = $this->db->query($sql);
$obj = $result->fetch_object();
if ($obj) {
return $obj;
}
}
return false;
} // end get_data
public function delete($id) {
$sql = "DELETE FROM cache
WHERE id='".$this->db->real_escape_string($id)."'";
$this->db->query($sql);
return;
}// end delete
public function set($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
} // end Country

View File

@ -0,0 +1,364 @@
<?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 CancellationReasons extends Main {
public $list_table_config = array (
'title' => 'Stornierungsgr&uuml;nde',
'db_table' => 'cancellation_reasons',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Stornierungsgrund',
'sortable' => 1
),
array(
'db_field' => 'type',
'name' => 'Initiator',
'rewrite_function' => 'type_values',
'sortable' => 1
),
array(
'db_field' => 'active',
'name' => 'Status',
'rewrite_function' => 'state_text',
'sortable' => 1
)
),
'search_fields' => array('name'),
'db_id_field' => 'id',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=CancellationReasons&object_id=',
'toolbar' => array(
'delete' => 1,
'new' => 'index.php?admin_modul=admin_object_edit&object=CancellationReasons',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
),
'edit_title' => 'Stornierungsgrund',
'edit_fields' => array (
array(
'name' => 'Stammdaten',
'type' => 'form_title'
),
array(
'db_field' => 'name',
'name' => 'Stornierungsgrund',
'type' => 'text'
),
array(
'db_field' => 'type',
'name' => 'Initiator',
'values' => 'type_values',
'type' => 'text'
),
array(
'db_field' => 'active',
'name' => 'Status',
'values' => 'state_text',
'type' => 'int'
)
),
'edit_mandatory_fields' => array('name'),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_list&object=CancellationReasons',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'delete' => 1
),
);
// db fields
private $fields = array(
'name' => 'text',
'type' => 'int',
'active' => 'int'
);
// generic
private $id;
private $error;
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 type_values() {
return array (
'1' => 'Shop Storno',
'0' => 'Kunden Storno'
);
}
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) {
$sql = "SELECT * FROM cancellation_reasons";
if ($filter) {
if ($filter == 'customer-active') {
$sql .= " WHERE type='0' AND active='1'";
} else if ($filter = 'active') {
$sql .= " WHERE active='1'";
} 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;
}
return $return_data;
}
$this->erro = 'no result';
return false;
} // end get_all
public function get_data($id = false) {
$sql = "SELECT * FROM cancellation_reasons ";
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 results';
return false;
} // end get_data
public function delete($id = false) {
$sql = "DELETE FROM cancellation_reasons ";
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) {
if ($data) {
$valid = $this->validate($data);
$size = count($data);
if ($valid) {
$sql = "INSERT INTO cancellation_reasons ";
$data_line = "";
$value_line = "";
$i = 1;
foreach ($data as $key => $value) {
$data_line .= $key;
$value_line .= "'".$this->db->real_escape_string($value)."'";
if ($i < $size) {
$data_line .= ", ";
$value_line .= ", ";
$i++;
}
}
$sql .= "(".$data_line.") ";
$sql .= " VALUES (".$value_line.")";
$result = $this->db->query($sql);
if ($result) {
return $this->db->insert_id;
}
$this->error = "insert failed";
return false;
}
$this->error = "invalid data";
return false;
}
$this->error = "no data";
return false;
} // end create
public function update($data, $id = false) {
if ($data) {
$valid = $this->validate($data);
$size = count($data);
if ($valid) {
$sql = "UPDATE cancellation_reasons SET ";
$i = 1;
foreach ($data as $key => $value) {
$sql .= $key."='".$this->db->real_escape_string($value)."'";
if ($i < $size) {
$sql .= ", ";
$i++;
}
}
if ($id) {
$sql .= " WHERE id=".$this->db->real_escape_string($id);
$id = $this->db->real_escape_string($id);
} else if ($this->id) {
$sql .= " WHERE id=".$this->db->real_escape_string($this->id);
$id = $this->db->real_escape_string($this->id);
} else {
$this->error = "no id";
return false;
}
$result = $this->db->query($sql);
if ($result) {
return $id;
}
$this->error = 'update failed';
return false;
}
$this->error = "invalid data";
return false;
}
$this->error = "no data";
return false;
} // 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
cancellation_reasons
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 cancellation_reasons";
$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 cancellation_reasons";
$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
}

View File

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

View File

@ -0,0 +1,61 @@
<?php
class CancellationRequestsHelper {
//=========================================
//
// THIS CLASS IS STATIC ONLY
//
//=========================================
private function __construct() {
}
private function __clone() {
}
//=========================================
//
// THE PUBLIC INTERFACE
//
//=========================================
public static function get_cancellation_request_status_by_order_id($order_id) {
$db = Registry::get('base')->db;
$sql = "SELECT
cancellation_status
FROM
orders
WHERE
id=".$db->real_escape_string($order_id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object()->status;
}
return false;
}
public static function set_status($id, $status) {
$db = Registry::get('base')->db;
$sql = "UPDATE orders
SET cancellation_status=".$db->real_escape_string($status)."
WHERE id=".$db->real_escape_string($id);
return $db->query($sql);
}
public static function set_statuses($ids, $status) {
$db = Registry::get('base')->db;
$sql = "UPDATE orders
SET cancellation_status=".$db->real_escape_string($status)."
WHERE id IN (".$db->real_escape_string($ids).")";
return $db->query($sql);
}
}

View File

@ -0,0 +1,246 @@
<?php
/**
* Cart Session Manager - PayPal v1 Session Fix
*
* Eliminates session dependency during PayPal redirects by storing
* cart data in database with PayPal token as key.
*
* Compatible with existing Legacy System and future PayPal v2 integration.
*
* @author PFC Claude
* @version 1.0
* @date 2025
*/
class CartSessionManager {
private $db;
private $base_object;
private $log_file;
public function __construct($base_object) {
$this->base_object = $base_object;
$this->db = $base_object->db;
// Dedicated PayPal log file - easier than Plesk chaos!
$this->log_file = $_SERVER['DOCUMENT_ROOT'] . '/logs/paypal_session_fix.log';
// Ensure log directory exists
$log_dir = dirname($this->log_file);
if (!file_exists($log_dir)) {
mkdir($log_dir, 0755, true);
}
}
/**
* Store cart data in database before PayPal redirect
*
* @param string $session_key - PayPal token or session_id
* @param array $cart_data - Complete cart contents
* @param string $payment_provider - 'paypal', 'stripe', etc.
* @return bool Success/failure
*/
public function storeCartSession($session_key, $cart_data, $payment_provider = 'paypal') {
$session_key_clean = $this->db->real_escape_string($session_key);
$cart_json = $this->db->real_escape_string(json_encode($cart_data));
$provider_clean = $this->db->real_escape_string($payment_provider);
$user_agent = $this->db->real_escape_string($_SERVER['HTTP_USER_AGENT'] ?? '');
$ip_address = $this->db->real_escape_string($_SERVER['REMOTE_ADDR'] ?? '');
$query = "
INSERT INTO cart_sessions (
session_key,
cart_data,
payment_provider,
status,
user_agent,
ip_address
) VALUES (
'{$session_key_clean}',
'{$cart_json}',
'{$provider_clean}',
'active',
'{$user_agent}',
'{$ip_address}'
) ON DUPLICATE KEY UPDATE
cart_data = VALUES(cart_data),
updated_at = CURRENT_TIMESTAMP,
status = 'active'
";
$result = $this->db->query($query);
if ($this->db->error) {
$this->writePayPalLog("STORE_ERROR", "Database error: " . $this->db->error);
return false;
}
// Dedicated PayPal logging - no more Plesk chaos!
$this->writePayPalLog("STORE_SUCCESS", "Cart stored for token: {$session_key}", array(
'cart_items' => count($cart_data['shoppingcart'] ?? []),
'order_id' => $cart_data['order_id'] ?? 'unknown'
));
return $result ? true : false;
}
/**
* Retrieve cart data from database after PayPal return
*
* @param string $session_key - PayPal token or session_id
* @return array|null Cart data or null if not found
*/
public function retrieveCartSession($session_key) {
$session_key_clean = $this->db->real_escape_string($session_key);
$query = "
SELECT
cart_data,
payment_provider,
status,
created_at,
updated_at
FROM cart_sessions
WHERE session_key = '{$session_key_clean}'
AND expires_at > NOW()
LIMIT 1
";
$result = $this->db->query($query);
if ($this->db->error) {
$this->writePayPalLog("RETRIEVE_ERROR", "Database error: " . $this->db->error);
return null;
}
if ($result && $result->num_rows > 0) {
$row = $result->fetch_object();
$cart_data = json_decode($row->cart_data, true);
// Success logging
$this->writePayPalLog("RETRIEVE_SUCCESS", "Cart retrieved for key: {$session_key}", array(
'cart_items' => count($cart_data['shoppingcart'] ?? []),
'status' => $row->status
));
return array(
'cart_data' => $cart_data,
'payment_provider' => $row->payment_provider,
'status' => $row->status,
'created_at' => $row->created_at,
'updated_at' => $row->updated_at
);
}
$this->writePayPalLog("RETRIEVE_FAILED", "No cart found for key: {$session_key}");
return null;
}
/**
* Dedicated PayPal logging system - no more Plesk chaos!
*
* @param string $type - LOG_TYPE (STORE_SUCCESS, RETRIEVE_SUCCESS, ERROR, etc.)
* @param string $message - Human readable message
* @param array $context - Additional context data
*/
private function writePayPalLog($type, $message, $context = array()) {
$timestamp = date('Y-m-d H:i:s');
$ip = $_SERVER['REMOTE_ADDR'] ?? 'unknown';
$user_agent = substr($_SERVER['HTTP_USER_AGENT'] ?? '', 0, 100);
$log_entry = sprintf(
"[%s] %s | %s | IP:%s | %s | Context:%s\n",
$timestamp,
$type,
$message,
$ip,
$user_agent,
json_encode($context)
);
// Write to dedicated PayPal log file
file_put_contents($this->log_file, $log_entry, FILE_APPEND | LOCK_EX);
// Also write to error_log as fallback
error_log("PayPal Session Fix [{$type}]: {$message}");
}
/**
* Update cart session status (processing, completed, abandoned)
*
* @param string $session_key
* @param string $status - 'processing', 'completed', 'abandoned'
* @return bool Success/failure
*/
public function updateCartStatus($session_key, $status) {
$session_key_clean = $this->db->real_escape_string($session_key);
$status_clean = $this->db->real_escape_string($status);
$query = "
UPDATE cart_sessions
SET status = '{$status_clean}',
updated_at = CURRENT_TIMESTAMP
WHERE session_key = '{$session_key_clean}'
";
$result = $this->db->query($query);
if ($this->db->error) {
$this->writePayPalLog("STATUS_ERROR", "Database error: " . $this->db->error);
return false;
}
$this->writePayPalLog("STATUS_UPDATE", "Updated {$session_key} to {$status}");
return $result ? true : false;
}
/**
* Clean up expired or completed cart sessions
* Should be called via cron job
*
* @param int $older_than_hours - Delete sessions older than X hours
* @return int Number of deleted records
*/
public function cleanupExpiredSessions($older_than_hours = 24) {
$query = "
DELETE FROM cart_sessions
WHERE expires_at < NOW()
OR (status = 'completed' AND updated_at < (NOW() - INTERVAL {$older_than_hours} HOUR))
OR (status = 'abandoned' AND updated_at < (NOW() - INTERVAL {$older_than_hours} HOUR))
";
$result = $this->db->query($query);
$deleted_count = $this->db->affected_rows;
if ($this->db->error) {
$this->writePayPalLog("CLEANUP_ERROR", "Database error: " . $this->db->error);
return 0;
}
$this->writePayPalLog("CLEANUP_SUCCESS", "Deleted {$deleted_count} expired sessions");
return $deleted_count;
}
/**
* Debug helper - get cart session info
*/
public function getCartSessionInfo($session_key) {
$session_key_clean = $this->db->real_escape_string($session_key);
$query = "
SELECT * FROM cart_sessions
WHERE session_key = '{$session_key_clean}'
LIMIT 1
";
$result = $this->db->query($query);
if ($result && $result->num_rows > 0) {
return $result->fetch_object();
}
return null;
}
}
?>

428
core/config.class.php Normal file
View File

@ -0,0 +1,428 @@
<?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/logger.class.php';
include_once './core/main.class.php';
class Config extends Main {
protected $base_object;
protected $db;
public $list_table_config = array (
'title' => 'Systemeinstellungen',
'db_table' => 'configuration',
'list_fields' => array(
array(
'db_field' => 'group_id',
'name' => 'Einstellungen',
'sortable' => 1
)
),
'list_group_by' => 'group_id',
'permanent_filter' => array(
array(
'db_field' => 'group_id',
'value' => '',
'relational_operator' => '!='
)
),
'search_fields' => array('group_id', 'name', 'text'),
'db_id_field' => 'group_id',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=Config&object_id=',
'toolbar' => array(
'delete' => 0,
'new' => 0,
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
),
'edit_title' => 'Systemeinstellung',
'edit_fields' => array (),
'edit_mandatory_fields' => array(),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_list&object=Config',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'delete' => 0
)
);
/*$resulttba = $mysqli->query("SELECT * FROM configuration", MYSQLI_USE_RESULT);
$pdo = new PDO('mysql:host=newmail.intelectra.de;dbname=webshop-sql2022', 'webshopadm', 'Je=53qi2Jey53qi2');
$statement = $pdo->query("SELECT * FROM configuration");
$row = $statement->fetch(PDO::FETCH_ASSOC);
echo htmlentities($row['configuration']);
print $resulttba;*/
function __construct($base_object) {
$this->db = $base_object->db;
$this->config = $base_object->config;
// Config
$sql = "SELECT * FROM configuration";
$result = $this->db->query($sql);
$text_values = array();
while ($obj = $result->fetch_object()) {
if ($obj->text == 'formated' || $obj->text == 'multi') {
$text_values[] = $obj;
} else if ($obj->type == 2) {
$data = array();
eval($obj->setting);
$this->shopConfiguration[$obj->name] = $data;
} else {
$this->shopConfiguration[$obj->name] = $obj->setting;
}
}
foreach ($text_values as $obj) {
$this->shopConfiguration[$obj->name] = str_replace('{$THEME_DIR}', STANDARD_DIR.'web/'.SHOP_SYSTEM.'/themes/'.$this->shopConfiguration['THEME'], $obj->setting);
}
// VAT
$result = $this->db->query("
SELECT id, steuersatz FROM tax WHERE standard = '1'
");
$obj = $result->fetch_object();
$this->shopConfiguration['commonVAT'] = $obj->steuersatz;
$this->shopConfiguration['commonVAT_Id'] = $obj->id;
$this->shopConfiguration['SHOP_SYSTEM'] = SHOP_SYSTEM;
// Countries
$result = $this->db->query("SELECT * FROM countries ORDER BY name ASC");
while ($obj = $result->fetch_object()) {
$countries[$obj->id] = $obj;
}
$this->shopConfiguration['countries'] = $countries;
$this->setup_config();
} // end __construct
public function init_edit_fields($object_id) {
// include config file
if (file_exists('./core/config/'.$object_id.'.inc.php')) {
include './core/config/'.$object_id.'.inc.php';
foreach ($config_group_settings['edit_fields'] as $setting) {
$this->list_table_config['edit_fields'][] = $setting;
}
}
else {
// get edit fields
$sql = "
SELECT *
FROM configuration
WHERE group_id='".$this->db->real_escape_string($object_id)."'
";
$result = $this->db->query($sql);
while ($obj = $result->fetch_object()) {
$type = 'text';
if ($obj->text == 'multi' ) {
$type = 'multitext';
}
else if ($obj->text == 'formated') {
$type = 'formatedtext';
}
$this->list_table_config['edit_fields'][] = array(
'db_field' => $obj->name,
'name' => $obj->description,
'type' => $type
);
}
}
return;
}
public function load($object_id) {
$sql = "
SELECT *
FROM configuration
WHERE group_id='".$this->db->real_escape_string($object_id)."'
";
$result = $this->db->query($sql);
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/main_class.php->load()', $this->db->error.', sql:'.$sql);
return false;
}
$data = array();
while ($obj = $result->fetch_object()) {
$data[$obj->name] = $obj->setting;
}
return $data;
}
private function setup_config() {
include_once './web/'.SHOP_SYSTEM.'/config/theme_widget.inc.php';
if (isset($parent_theme)) {
$this->shopConfiguration['parent_theme'] = $parent_theme;
}
if (isset($customized_templates)) {
$this->shopConfiguration['customized_templates'] = $customized_templates;
}
$this->shopConfiguration['images'] = array();
// there is already code for this and there might be a better way to do this
//$this->shopConfiguration['images'][] = array('', $default_image_size);
$default_image_size = $this->shopConfiguration['item_image_size_zoom'];
$default_generatable_images = array(
'overview_' => $this->shopConfiguration['item_image_size_overview'],
'thumb_' => $this->shopConfiguration['item_image_size_thumb'],
'details_' => $this->shopConfiguration['item_image_size_details'],
'detaildefault_' => $this->shopConfiguration['item_image_size_detaildefault'],
);
if (isset($default_generatable_images)) {
foreach ($default_generatable_images as $key => $value) {
$this->shopConfiguration['images'][] = array($key, $value);
}
}
if (isset($widget_regions)) {
$this->shopConfiguration['widget_regions'] = $widget_regions;
foreach ($widget_regions as $region) {
$this->shopConfiguration['default_widget_list_'.$region] = ${'default_widget_list_'.$region};
}
}
}
public function set_config_item($item_key, $item_value) {
if (is_array($item_value)) {
$type = 2;
$value = '$data = '.$this->php_2_string($item_value).';';
} else {
$type = 1;
$value = $item_value;
}
if (isset($this->shopConfiguration[$item_key])) {
$sql = '
UPDATE
configuration
SET
type = '.$type.',
setting = "'.$this->db->real_escape_string($value).'"
WHERE
name = "'.$this->db->real_escape_string($item_key).'"';
} else {
$sql = '
INSERT INTO configuration (
type,
setting,
name
) values (
'.$type.',
"'.$this->db->real_escape_string($value).'",
"'.$this->db->real_escape_string($item_key).'"
)';
}
$this->db->query($sql);
if ($this->db->error) {
$log = Logger::get_instance();
$log->error(__FILE__, $mysqli->error);
}
$this->shopConfiguration[$item_key] = $item_value;
return;
}
private function php_2_string($data) {
$string = '';
if (is_array($data)) {
$string .= 'array(';
foreach ($data as $key => $value) {
if (is_array($value)) {
$string .= "'$key' => ".$this->php_2_string($value).", ";
} else {
$string .= "'$key' => '$value', ";
}
}
$string .= ")";
} else {
$string .= "'".$data."'";
};
return $string;
}
function get_config_elements($group_id) {
$sql = "
SELECT *
FROM configuration
WHERE group_id='".$group_id."'
";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
}
public function save($data, $object_id = false) {
if ($data && $object_id) {
$this->update($object_id, $data);
// already saved
return true;
}
else {
// no data to save
$log_object = Logger::get_instance();
$log_object->info('Error in /core/config_class.php->save()', 'No data to save!');
return false;
}
}
public function update($group_id, $form_data) {
$config_elemente = $this->get_config_elements($group_id);
foreach ($config_elemente as $config_element) {
$sql = "
UPDATE configuration
SET setting='".$form_data[$config_element->name]."'
WHERE name='".$config_element->name."'
";
$this->db->query($sql);
}
return;
} // end update
public function update_config_element($name, $setting) {
$sql = "
UPDATE configuration
SET setting='".$this->db->real_escape_string($setting)."'
WHERE name='".$this->db->real_escape_string($name)."'
";
$this->db->query($sql);
return;
} // end update
public static function has_key($key) {
$db = Registry::get('base')->db;
$sql = "SELECT *
FROM configuration
WHERE name = '$key'";
$result = $db->query($sql);
if ($result->num_rows > 0) {
return true;
}
return false;
} // end has_key
public static function is_set($key) {
$db = Registry::get('base')->db;
$sql = "SELECT *
FROM configuration
WHERE name = '$key'";
$result = $db->query($sql);
if ($result->num_rows > 0) {
$return = $result->fetch_object();
if ($return->setting != '') {
return true;
}
}
return false;
} // end has_key
public static function get_value($key) {
$db = Registry::get('base')->db;
$sql = "SELECT setting
FROM configuration
WHERE name = '$key'";
$result = $db->query($sql);
if ($result->num_rows > 0) {
$return = $result->fetch_object();
return $return->setting;
}
return false;
} // end get_key
public static function set_key($key, $value) {
$db = Registry::get('base')->db;
if (is_array($value)) {
$type = 2;
$value = '$data = '.$this->php_2_string($value).';';
} else {
$type = 1;
$value = $value;
}
if (Config::has_key($key)) {
$sql = '
UPDATE
configuration
SET
type = '.$type.',
setting = "'.$db->real_escape_string($value).'"
WHERE
name = "'.$db->real_escape_string($key).'"';
} else {
$sql = '
INSERT INTO configuration (
type,
setting,
name
) values (
'.$type.',
"'.$db->real_escape_string($value).'",
"'.$db->real_escape_string($key).'"
)';
}
$db->query($sql);
if ($db->error) {
$log = Logger::get_instance();
$log->error(__FILE__, $mysqli->error);
}
return;
}
}
?>

143
core/config/company.inc.php Normal file
View File

@ -0,0 +1,143 @@
<?php
$config_group_settings = array(
'edit_fields' => array (
array(
'name' => 'Stammdaten',
'type' => 'form_title'
),
array(
'db_field' => 'company_name',
'name' => 'Firmenname',
'type' => 'text'
),
array(
'db_field' => 'company_legal_form',
'name' => 'Rechtsform',
'type' => 'text'
),
array(
'db_field' => 'company_ustid',
'name' => 'USt-IdNr.',
'type' => 'text'
),
array(
'db_field' => 'company_jurisdiction',
'name' => 'Gerichtsstand',
'type' => 'text'
),
array(
'db_field' => 'company_management',
'name' => 'Geschäftführung',
'type' => 'text'
),
array(
'db_field' => 'company_director',
'name' => 'Vorstand',
'type' => 'text'
),
array(
'db_field' => 'company_directorat',
'name' => 'Aufsichtsratsvorsitz',
'type' => 'text'
),
array(
'db_field' => 'company_register_court',
'name' => 'Sitz, Registergericht, Registernummer',
'type' => 'text'
),
array(
'db_field' => 'company_data_protection_officer',
'name' => 'Datenschutzbeauftragte',
'type' => 'text'
),
array(
'db_field' => 'company_youth_protection_officer',
'name' => 'Jugendschutzbeauftragte',
'type' => 'text'
),
array(
'name' => 'Anschrift',
'type' => 'form_title'
),
array(
'db_field' => 'company_country',
'name' => 'Land',
'type' => 'text'
),
array(
'db_field' => 'company_street',
'name' => 'Geschäftführung',
'type' => 'text'
),
array(
'db_field' => 'company_zip_code',
'name' => 'PLZ',
'type' => 'text'
),
array(
'db_field' => 'company_city',
'name' => 'Ort',
'type' => 'text'
),
array(
'name' => 'Kontakt',
'type' => 'form_title'
),
array(
'db_field' => 'company_email',
'name' => 'E-Mail',
'type' => 'text'
),
array(
'db_field' => 'company_phone',
'name' => 'Telefon',
'type' => 'text'
),
array(
'db_field' => 'company_fax',
'name' => 'Fax',
'type' => 'text'
),
array(
'db_field' => 'company_website',
'name' => 'Webseite',
'type' => 'text'
),
array(
'name' => 'Bankdaten',
'type' => 'form_title'
),
array(
'db_field' => 'company_bank',
'name' => 'Bank',
'type' => 'text'
),
array(
'db_field' => 'company_bank_number',
'name' => 'BLZ',
'type' => 'text'
),
array(
'db_field' => 'company_account_number',
'name' => 'Kto-Nr.',
'type' => 'text'
),
array(
'db_field' => 'company_iban',
'name' => 'IBAN',
'type' => 'text'
),
array(
'db_field' => 'company_swift_bic',
'name' => 'SWIFT / BIC',
'type' => 'text'
)
)
);
?>

View File

@ -0,0 +1,50 @@
<?php
/**
* Carteasy Revocation / Widerruf (EU-RL 2026/2673 "Widerrufsbutton")
*
* Zentrale Feature-Flags und Konstanten. Bis zum Go-Live Mitte Mai 2026
* bleibt REVOCATION_ENABLED = false (Silent-Modus).
*
* @copyright Wlanium / Thomas Bartelt
* @since 2026-04-19
*/
if (defined('REVOCATION_CONFIG_LOADED')) {
return;
}
define('REVOCATION_CONFIG_LOADED', true);
// ===== Master-Schalter =====
// wenn false: Token werden weder erzeugt noch Mails verschickt,
// Landingpage liefert "Widerruf zurzeit nicht verfügbar".
define('REVOCATION_ENABLED', false);
// wenn false: Token wird trotzdem in DB angelegt (für spätere Aktivierung),
// aber die Info-Mail an den Kunden geht NICHT raus.
define('REVOCATION_INFO_MAIL_ENABLED', false);
// ===== Einordnung B2C / B2B =====
define('REVOCATION_B2C_GROUP_IDS', serialize([1, 103])); // Endverbraucher, Gast
define('REVOCATION_B2B_GROUP_IDS', serialize([101])); // Händler (ausgenommen)
define('REVOCATION_GUEST_GROUP_ID', 103);
// ===== Token / Gültigkeit =====
define('REVOCATION_TOKEN_VALIDITY_DAYS', 20); // 14 Tage Pflicht + 6 Puffer
define('REVOCATION_TOKEN_BYTES', 32); // 32 Bytes = 64 Hex-Chars
// ===== Adressen / URLs =====
define('REVOCATION_OWNER_EMAIL', 'intelectra-ersatzteile@t-online.de');
define('REVOCATION_LANDING_PATH', '/widerruf.php'); // Pfad auf dem Shop-Host
define('REVOCATION_RETURN_COMPANY','Intelectra GmbH');
define('REVOCATION_RETURN_STREET', 'Sachsenring 20');
define('REVOCATION_RETURN_CITY', '94315 Straubing');
define('REVOCATION_RETURN_COSTS_NOTE',
'Die regelmäßigen Kosten der Rücksendung tragen Sie.');
// ===== UI-Texte =====
define('REVOCATION_BUTTON_LABEL', 'Vertrag hier widerrufen');

288
core/country.class.php Normal file
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 (isset($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
?>

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;
}
}
?>

731
core/cs_ticket.class.php Normal file
View File

@ -0,0 +1,731 @@
<?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/cs_ticket_message.class.php';
include_once './core/order.class.php';
include_once './core/standard_message.class.php';
include_once './core/customer.class.php';
include_once './core/mail.class.php';
include_once './core/site_content.class.php';
class Cs_ticket extends Main {
protected $base_object;
public $list_table_config = array (
'title' => 'E-Mail Tickets',
'db_table' => 'tickets',
'list_fields' => array(
array(
'db_field' => 'number',
'name' => 'Nummer',
'sortable' => 1
),
array(
'db_field' => 'subject',
'name' => 'Betreff',
'ref_db_table' => 'ticket_messages',
'ref_db1_field' => 'id',
'ref_db2_field' => 'ticket_id',
'sortable' => 1
),
array(
'db_field' => 'firstname',
'name' => 'Vorname',
'ref_db_table' => 'customers',
'ref_db1_field' => 'customer_id',
'ref_db2_field' => 'id',
'sortable' => 1
),
array(
'db_field' => 'surname',
'name' => 'Nachname',
'ref_db_table' => 'customers',
'ref_db1_field' => 'customer_id',
'ref_db2_field' => 'id',
'sortable' => 1
),
array(
'db_field' => 'create_time',
'name' => 'Erstellt',
'sortable' => 1
),
array(
'db_field' => 'state_id',
'rewrite_function' => 'state_values',
'name' => 'Status',
'sortable' => 1
)
),
'list_actions' => array(
array (
'db_field' => 'state_id',
'name' => 'Neuer Status',
'values' => 'filter_state_values'
)
),
'list_filter' => array(
array (
'db_field' => 'state_id',
'relational_operator' => '=',
'name' => 'Status',
'values' => 'filter_state_values'
)
),
'permanent_filter' => array(
array(
'db_field' => 'state_id',
'relational_operator' => '!=',
'value' => '4'
)
),
'quick_filter' => 0,
'list_css_selector' => 'state_id',
'default_sort_item' => 'number',
'default_sort_direction' => 'down',
'search_fields' => array('tickets.number', 'customers.firstname', 'customers.surname', 'orders.order_number'),
'db_id_field' => 'id',
'list_group_by' => 'number',
'edit_link' => 'index.php?admin_modul=admin_cs_ticket_editor&id=',
'toolbar' => array(
'delete' => 1,
'new' => 'index.php?admin_modul=admin_cs_ticket_editor',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 1,
'filter' => 1,
'search' => 1
),
'edit_fields' => array (
array(
'db_field' => 'state_id',
'name' => 'Status',
'type' => 'int'
)
)
);
private $object_fields = array(
'number' => 'text',
'customer_id' => 'integer',
'state_id' => 'integer',
'order_id' => 'integer'
);
function __construct($base_object) {
$this->base_object = $base_object;
$this->db = $base_object->db;
}
public function state_values() {
return array(
'1' => 'Neu',
'2' => 'Offen',
'3' => 'Geschlossen',
'4' => 'Intern'
);
}
public function filter_state_values() {
return array(
'1' => 'Neu',
'2' => 'Offen',
'3' => 'Geschlossen'
);
}
public function get_all() {
$sql = "SELECT * FROM tickets";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
}
public function get_all_customer_tickets($customer_id) {
$sql = "SELECT * FROM tickets WHERE customer_id=".$this->db->real_escape_string($customer_id);
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
}
public function get_all_order_tickets($order_id) {
$sql = "SELECT * FROM tickets WHERE order_id=".$this->db->real_escape_string($order_id);
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
}
public function get_data() {
$sql = "SELECT * FROM tickets WHERE id = ".$this->id;
$result = $this->db->query($sql);
$obj = $result->fetch_object();
// get ticket messages
$ticket_message_object = new Cs_ticket_message($this->base_object);
$ticket_messages = $ticket_message_object->get_all_ticket_messages($this->id);
$obj->ticket_messages = $ticket_messages['messages'];
$obj->last_message_number = $ticket_messages['last_message_number'];
return $obj;
} // end get_data
public function get_id_by_number($ticket_number) {
$sql = "SELECT * FROM tickets WHERE number = '#CS".$ticket_number."'";
$result = $this->db->query($sql);
if ($result) {
$obj = $result->fetch_object();
return $obj->id;
}
return false;
}
public function delete() {
$sql = "DELETE FROM tickets WHERE id=".$this->id;
$this->db->query($sql);
return;
}
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) {
// create new ticket
$order = '';
if (isset($data['order_id']) && $data['order_id']) {
$order = "order_id=".$data['order_id'].", ";
}
$sql = "INSERT INTO tickets SET
customer_id = ".$data['customer_id'].",".$order."
state_id=".$data['state_id'].",
create_time = current_timestamp
";
$this->db->query($sql);
$this->id = $this->db->insert_id;
// create new ticket number
$this->ticket_number = $ticket_number = '#CS'.(100000 + $this->id);
// set ticket number
$sql = "
UPDATE tickets
SET number='".$ticket_number."'
WHERE id=".$this->id;
$this->db->query($sql);
// create new message
//$data['subject'] = '['.$ticket_number.'] '.$data['subject'];
$data['subject'] = $data['subject'].' ['.$ticket_number.']';
$ticket_message_object = new Cs_ticket_message($this->base_object);
$data['ticket_id'] = $this->id;
if (!isset($data['create_type'])) {
$data['create_type'] = 2;
}
$form_data = $ticket_message_object->data_filter($data);
$attachments = (isset($data['attachments'])) ? $data['attachments'] : false;
$ticket_message_object->create($form_data, $attachments);
// set state
if (isset($data['state_id'])) {
$this->set_state($data['state_id']);
}
if ($data['create_type'] == 2) {
// send message
$mailer = new mail_tools($this->base_object);
$res = $mailer->send_mail($form_data['subject'], $form_data['message'], $form_data['m_to'], 'extern', false, false, false, false, $attachments);
}
return $ticket_message_object->id;
}
public function get_response($data) {
// create new message
$ticket_number = '#CS'.(100000 + $this->id);
//$data['subject'] = '['.$ticket_number.'] '.$data['subject'];
$data['subject'] = $data['subject'].' ['.$ticket_number.'] ';
$ticket_message_object = new Cs_ticket_message($this->base_object);
$data['ticket_id'] = $this->id;
if (!isset($data['create_type'])) {
$data['create_type'] = 1;
}
$form_data = $ticket_message_object->data_filter($data);
$ticket_message_object->create($form_data);
// set state
if (isset($data['state_id'])) {
$this->set_state($data['state_id']);
}
$attachments = false;
if ($data['create_type'] == 2) {
// send message
$mailer = new mail_tools($this->base_object);
$mailer->send_mail($form_data['subject'], $form_data['message'], $form_data['m_to'], 'extern', false, false, false, false, $attachments);
}
return $ticket_message_object->id;
}
private function search_order_ticket($search_options) {
$sql = "SELECT * FROM tickets
WHERE customer_id=".$search_options['customer_id']."
AND order_id=".$search_options['order_id']."
LIMIT 1
";
$result = $this->db->query($sql);
if ($result) {
$obj = $result->fetch_object();
return $obj->id;
} else {
return 0;
}
}
public function event($event_type, $customer_id, $order_id, $data = false) {
$tracking_url='';
$ticket_data = array(
'customer_id' => $customer_id,
'state_id' => 1,
'order_id' => $order_id
);
// get ticket id - if exists
if (!empty($ticket_data['order_id'])) {
$this->id = $this->search_order_ticket($ticket_data);
}
// get customer data
$customer_object = new Customer($this->base_object);
$customer_object->customer_id = $customer_id;
$customer_data = $customer_object->get_data();
// get standard message
$standard_message_object = new Standard_message($this->base_object);
$standard_messages = $standard_message_object->get_messages_by_event($event_type);
// get agbs
$var_data = array();
//if ($event_type == 3) {
// customer data place holder
$var_data['[#customer_id]'] = $customer_id;
$var_data['[#customer_number]'] = $customer_data->number;
if ($customer_data->honorific == 0) {
$var_data['[#customer_salutation]'] = 'Herr';
$var_data['[#full_salutation]'] = 'Herr '.$customer_data->firstname.' '.$customer_data->surname;
}
else if ($customer_data->honorific == 1) {
$var_data['[#customer_salutation]'] = 'Frau';
$var_data['[#full_salutation]'] = 'Frau '.$customer_data->firstname.' '.$customer_data->surname;
}
else if ($customer_data->honorific == 2) {
$var_data['[#customer_salutation]'] = 'Firma';
$var_data['[#full_salutation]'] = 'Sehr geehrte Damen und Herren';
}
$var_data['[#customer_company]'] = $customer_data->company;
$var_data['[#customer_name]'] = $customer_data->firstname.' '.$customer_data->surname;
$var_data['[#customer_firstname]'] = $customer_data->firstname;
$var_data['[#customer_email]'] = $customer_data->email;
$var_data['[#customer_surename]'] = $customer_data->surname;
$var_data['[#customer_address]'] = '';
if ($customer_data->default_address_company) {
$var_data['[#customer_address]'] .= $customer_data->default_address_company.'<br />';
}
if ($customer_data->default_address_surname) {
$var_data['[#customer_address]'] .= $customer_data->default_address_firstname.' '.$customer_data->default_address_surname.'<br />';
}
$var_data['[#customer_address]'] .= $customer_data->default_address_street.' '.$customer_data->default_address_house_number.'<br />';
$var_data['[#customer_address]'] .= $customer_data->default_address_zip_code.' '.$customer_data->default_address_city.'<br />';
$var_data['[#customer_address]'] .= $customer_data->default_address_countryname.'<br />';
$var_data['[#customer_skonto]'] = $customer_data->skonto;
$var_data['[#customer_freetext1]'] = $customer_data->freetextfield1;
$var_data['[#customer_freetext2]'] = $customer_data->freetextfield2;
$var_data['[#customer_freetext3]'] = $customer_data->freetextfield3;
$var_data['[#customer_freetext4]'] = $customer_data->freetextfield4;
$var_data['[#customer_freetext5]'] = $customer_data->freetextfield5;
$var_data['[#customer_freetext6]'] = $customer_data->freetextfield6;
$var_data['[#customer_birthday]'] = $customer_data->burth_date;
$var_data['[#customer_phone]'] = $customer_data->phone;
$var_data['[#customer_fax]'] = $customer_data->fax;
$var_data['[#customer_mobile]'] = $customer_data->mobile;
$var_data['[#customer_website]'] = $customer_data->website;
$var_data['[#customer_bank]'] = $customer_data->bank;
$var_data['[#customer_bank_number]'] = $customer_data->bank_number;
$var_data['[#customer_account_number]'] = $customer_data->account_number;
$var_data['[#customer_iban]'] = $customer_data->iban;
$var_data['[#customer_bic]'] = $customer_data->swift_bic;
$var_data['[#customer_account_holder]'] = $customer_data->account_holder;
$var_data['[#customer_tax_id]'] = $customer_data->tax_id;
$var_data['[#customer_tax_number]'] = $customer_data->tax_number;
$var_data['[#customer_da_zip_code]'] = $customer_data->default_address_zip_code;
$var_data['[#customer_da_city]'] = $customer_data->default_address_city;
$var_data['[#customer_da_street]'] = $customer_data->default_address_street;
$var_data['[#customer_da_house_number]'] = $customer_data->default_address_house_number;
$var_data['[#customer_da_countryname]'] = $customer_data->default_address_countryname;
$var_data['[#customer_da_company]'] = $customer_data->default_address_company;
$var_data['[#customer_da_firstname]'] = $customer_data->default_address_firstname;
$var_data['[#customer_da_surname]'] = $customer_data->default_address_surname;
// get agb's ...
$site_content_object = new SiteContent($this->base_object);
$var_data['[#datenschutz]'] = $site_content_object->get_textbox_data_by_id(55);
$var_data['[#agb]'] = $site_content_object->get_textbox_data_by_id(56);
$var_data['[#agb_b2b]'] = $site_content_object->get_textbox_data_by_id(10632);
$var_data['[#widerruf]'] = $site_content_object->get_textbox_data_by_id(60);
//}
// get order data
if ($order_id) {
$var_data['[#order]'] = OrderHelper::get_order_items_html($order_id);
$order_object = new Order($this->base_object);
$order_object->id = $order_id;
$order_data = $order_object->get_data();
$var_data['[#order_number]'] = $order_data->order_number;
$var_data['[#order_date]'] = $order_data->order_date;
$var_data['[#order_customer_text]'] = $order_data->customer_info;
// get country data
include_once './core/country.class.php';
$country_object = new Country($this->base_object);
$countries = $country_object->get_all();
// order billing address
$var_data['[#order_address]'] = '';
if ($order_data->billing_company) {
$var_data['[#order_address]'] .= $order_data->billing_company.'<br />';
}
if ($order_data->billing_surname) {
$var_data['[#order_address]'] .= $order_data->billing_firstname.' '.$order_data->billing_surname.'<br />';
}
$var_data['[#order_address]'] .= $order_data->billing_street.' '.$order_data->billing_house_number.'<br />';
$var_data['[#order_address]'] .= $order_data->billing_zip_code.' '.$order_data->billing_city.'<br />';
$var_data['[#order_address]'] .= $countries[$order_data->billing_country]->name.'<br />';
// order shipping address
$var_data['[#shipping_address]'] = '';
if ($order_data->shipping_company) {
$var_data['[#shipping_address]'] .= $order_data->shipping_company.'<br />';
}
if ($order_data->shipping_surname) {
$var_data['[#shipping_address]'] .= $order_data->shipping_firstname.' '.$order_data->shipping_surname.'<br />';
}
$var_data['[#shipping_address]'] .= $order_data->shipping_street.' '.$order_data->shipping_house_number.'<br />';
$var_data['[#shipping_address]'] .= $order_data->shipping_zip_code.' '.$order_data->shipping_city.'<br />';
$var_data['[#shipping_address]'] .= $countries[$order_data->shipping_country]->name.'<br />';
// get payment method
if ($order_data->payment_method) {
$sql = " SELECT name, order_email_text FROM payment_methods WHERE id = ".$order_data->payment_method;
$result = $this->db->query($sql);
$payment = $result->fetch_object();
$var_data['[#payment_method]'] = $payment->name;
$var_data['[#payment_text]'] = $payment->order_email_text;
}
}
if ($event_type == 6 && $order_data->trackingcode && $order_data->shipping_method) { // versandt
$sql = " SELECT tacking_url FROM deliverers WHERE id = '".$order_data->shipping_method."' ";
$result = $this->db->query($sql);
$deliever = $result->fetch_object();
$tracking_url=$deliever->tacking_url;
if ($tracking_url) {
$tracking_url=str_replace(array('[trackingcode]'), array($order_data->trackingcode), $tracking_url);
}
}
if ($data) {
foreach ($data as $key => $value) {
$var_data['[#'.$key.']'] = $value;
}
}
if ($standard_messages) {
foreach ($standard_messages as $standard_message) {
if ($standard_message->active == 1 && ($standard_message->customer_group_id == 0 || $standard_message->customer_group_id == $customer_data->group_id)) {
// create ticket
$ticket_data['subject'] = strtr($standard_message->title,$var_data);
$ticket_data['message'] = strtr($standard_message->message,$var_data);
if ($tracking_url) {
$ticket_data['message']=str_replace(array('[trackingcode]'), array($tracking_url), $ticket_data['message']);
}
if ($standard_message->recipient == 1) {
$ticket_data['m_to'] = $customer_data->email;
} else {
$ticket_data['m_to'] = $this->base_object->config->shopConfiguration['mailRecipients'];
}
$ticket_data['m_from'] = $this->base_object->config->shopConfiguration['system_email'];
// get attachments
$standard_message_object->id = $standard_message->id;
$ticket_data['attachments'] = $standard_message_object->get_file_list();
if (isset($data['attachments'])) {
$ticket_data['attachments'] = array_merge($ticket_data['attachments'], $data['attachments']);
}
if ($this->id) {
//$ticket = $this->get_data();
//$ticket_number = $ticket->number;
$ticket_number = $this->ticket_number;
$ticket_data['subject'] = $ticket_data['subject'].' ['.$ticket_number.']';
$response_id = $this->send_response($ticket_data);
} else {
$this->id = $this->create($ticket_data);
}
}
}
}
return $this->id;
}
public function send_response($data) {
// create new message
$ticket_message_object = new Cs_ticket_message($this->base_object);
$data['ticket_id'] = $this->id;
$data['create_type'] = 2;
$form_data = $ticket_message_object->data_filter($data);
$attachments = (isset($data['attachments'])) ? $data['attachments'] : false;
$ticket_message_object->create($form_data, $attachments);
// set state
if (isset($data['state_id'])) {
$this->set_state($data['state_id']);
}
// todo send message
$mailer = new mail_tools($this->base_object);
$mailer->send_mail($form_data['subject'], $form_data['message'], $form_data['m_to'], 'extern', false, false, false, false, $attachments);
return $ticket_message_object->id;
}
public function set_state($state_id) {
$sql = "
UPDATE tickets
SET state_id=".$state_id."
WHERE id=".$this->id;
$this->db->query($sql);
return;
}
public function delete_by_id($id) {
$rs = $this->db->query("DELETE FROM tickets WHERE id=$id;");
}
public function fetch_email() {
// mail connection data
/*$mbox = imap_open("{pop3.web.de:110/pop3/novalidate-cert}", "richard_kammermayer", "azce74BU");
if ($hdr = imap_check($mbox)) {
$overview = imap_fetch_overview($mbox, '1:'.$hdr->Nmsgs, 0);
if (is_array($overview)) {
$curMsgNo = 0;
foreach ($overview as $msgId => $message_data) {
++$curMsgNo;
// get body data
$body = imap_body($mbox, $curMsgNo);
// set ticket message data
$ticket_data = array();
$ticket_data['subject'] = $message_data->subject;
$ticket_data['message'] = $body;
$ticket_data['m_to'] = $message_data->to;
$ticket_data['m_from'] = $message_data->from;
$ticket_data['state_id'] = 1;
// create new ticket
$ticket_data['customer_id'] = 0;
$ticket_data['create_type'] = 1;
$this->ticket_id = false;
if (preg_match("@\[\#CS([0-9]+)\]@si", $message_data->subject)) {
$ticket_number = preg_replace("@(.*)?(\[\#CS)([0-9]+)(\])(.*)?@si", "$3", $message_data->subject);
$this->id = $this->get_id_by_number($ticket_number);
}
if ($this->id) {
$this->get_response($ticket_data);
} else {
$this->id = $this->create($ticket_data);
}
}
}
}*/
/*imap_expunge($mbox);
imap_delete($mbox, '1:*'); // to clear out an entire mailbox.
imap_expunge($mbox);
imap_close($mbox);*/
return;
}
function get_part($mime_type, $structure = false, $part_number = false) {
if (!$structure) {
$structure = imap_fetchstructure($this->stream, $this->msgId);
}
if ($structure) {
if ($mime_type == $this->get_mime_type($structure)) {
if (!$part_number) {
$part_number = 1;
}
$text = imap_fetchbody($this->stream, $this->msgId, $part_number);
if ($structure->encoding == 3) {
return imap_base64($text);
} else if ($structure->encoding == 4) {
return imap_qprint($text);
} else {
return $text;
}
}
if ($structure->type == 1) {
$prefix = '';
foreach ($structure->parts as $part) {
list($index, $sub_structure) = $part;
if ($part_number) {
$prefix = $part_number.'.';
}
$data = $this->get_part($mime_type, $sub_structure, $prefix.($index + 1));
if ($data) {
return $data;
}
}
}
}
return false;
}
function get_mime_type(&$structure) {
$primary_mime_type = array("TEXT", "MULTIPART", "MESSAGE", "APPLICATION", "AUDIO", "IMAGE", "VIDEO", "OTHER");
if ($structure->subtype) {
return $primary_mime_type[(int) $structure->type].'/'.$structure->subtype;
}
return "TEXT/PLAIN";
}
function get_tickets_by_type() {
$types = array('1' => 'Posteingang', '2' => 'Postausgang', '3' => 'geschlossen');
$data = array(array(
'id' => 0,
'name' => 'Alle',
'count' => $this->get_count_all(),
));
foreach ($types as $type_id => $type_name) {
$data[] = array (
'id' => $type_id,
'name' => $type_name,
'count' => $this->get_count_by_type($type_id),
);
}
return $data;
}
function get_count_by_type($type_id) {
$count = 0;
$sql = "SELECT count(id) AS ticket_count
FROM tickets
WHERE state_id=".$this->db->real_escape_string($type_id);
$result = $this->db->query($sql);
if ($obj = $result->fetch_object()) {
$count = $obj->ticket_count;
}
return $count;
}
function get_count_all() {
$count = 0;
$sql = "SELECT count(id) AS ticket_count FROM tickets";
$result = $this->db->query($sql);
if ($obj = $result->fetch_object()) {
$count = $obj->ticket_count;
}
return $count;
}
function get_new_messages() {
$sql = "SELECT * FROM tickets WHERE state_id=1 LIMIT 10";
$result = $this->db->query($sql);
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
}
function set_ticket_state($state_id, $ticket_id = false) {
if ($ticket_id) {
$id = $ticket_id;
} else if ($this->id) {
$id = $this->id;
}
if ($id) {
$sql = "
UPDATE tickets
SET state_id='".$this->db->real_escape_string($state_id)."'
WHERE id=".$this->db->real_escape_string($id);
$this->db->query($sql);
return 1;
} else {
return 0;
}
}
}
?>

View File

@ -0,0 +1,221 @@
<?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 Cs_ticket_message {
private $object_fields = array(
'ticket_id' => 'integer',
'm_from' => 'text',
'm_to' => 'text',
'cc' => 'text',
'subject' => 'text',
'message' => 'text',
'create_type' => 'integer'
);
private $base_object;
function __construct($base_object) {
$this->base_object = $base_object;
$this->db = $base_object->db;
}
public function get_all_ticket_messages($ticket_id) {
$sql = "SELECT
*
FROM
ticket_messages
WHERE
ticket_id=".$this->db->real_escape_string($ticket_id);
$result = $this->db->query($sql);
$data = array();
$z = 1;
while ($obj = $result->fetch_object()) {
$obj->message_number = $z;
$this->id = $obj->id;
$obj->attachments = $this->get_file_list();
$data['messages'][$z] = $obj;
$z++;
}
$data['last_message_number'] = $z - 1;
return $data;
}
public function get_first_message($ticket_id) {
$sql = "SELECT
*
FROM
ticket_messages
WHERE
ticket_id=".$this->db->real_escape_string($ticket_id).
" ORDER
BY id ASC
LIMIT
1";
$result = $this->db->query($sql);
while ($obj = $result->fetch_object()) {
$data = $obj;
$this->id = $obj->id;
$obj->attachments = $this->get_file_list();
}
return $data;
}
public function get_data() {
$sql = "SELECT
*
FROM
ticket_messages
WHERE
id=".$this->db->real_escape_string($this->id);
$result = $this->db->query($sql);
$obj = $result->fetch_object();
$obj->attachments = $this->get_file_list();
return $obj;
} // end get_data
public function delete() {
$sql = "DELETE FROM
ticket_messages
WHERE
id=".$this->db->real_escape_string($this->id);
$this->db->query($sql);
return;
}
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;
}
// TODO : real_escape_string this ?
public function create($data, $attachments = false) {
if ($data) {
$sql = "INSERT INTO
ticket_messages
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 .= 'create_time = current_timestamp';
$this->db->query($sql);
$this->id = $this->db->insert_id;
if ($attachments) {
foreach ($attachments as $attachment) {
$this->add_file(array (
'file_name' => $attachment->file_name,
'mime_type' => $attachment->mime_type,
'content' => $attachment->content
));
}
}
}
return;
}
// TODO : real_escape_string this ?
public function update($data) {
if ($data) {
$sql = "UPDATE
ticket_messages
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->db->real_escape_string($this->id);
$this->db->query($sql);
}
return;
}
public function delete_by_id($id) {
$sql = "DELETE FROM
ticket_messages
WHERE
id=".$this->db->real_escape_string($id);
$rs = $this->db->query($sql);
}
public function add_file($data) {
if ($data) {
$sql = "
INSERT INTO
ticket_message_attachments
(ticket_message_id, file_name, mime_type, content) VALUES
(".$this->id.", '".$data['file_name']."', '".$data['mime_type']."','".base64_encode($data['content'])."')" ;
$this->db->query($sql);
}
return;
}
public function get_file_list() {
$sql = "SELECT * FROM ticket_message_attachments WHERE ticket_message_id=".$this->id;
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$obj->content = base64_decode($obj->content);
$data[] = $obj;
}
return $data;
}
public function get_file($file_id) {
$sql = "SELECT * FROM ticket_message_attachments WHERE id=".$file_id;
$result = $this->db->query($sql);
$obj = $result->fetch_object();
$obj->content = base64_decode($obj->content);
return $obj;
}
public function delete_file($file_id) {
$sql = "
DELETE FROM ticket_message_attachments
WHERE id=".$this->db->real_escape_string($file_id)."
";
$result = $this->db->query($sql);
return;
}
}
?>

44
core/cstickethelper.php Normal file
View File

@ -0,0 +1,44 @@
<?php
class CSTicketHelper {
//=========================================
//
// THIS CLASS IS STATIC ONLY
//
//=========================================
private function __construct() {}
private function __clone() {}
//=========================================
//
// THE PUBLIC INTERFACE
//
//=========================================
public static function get_tickets_by_ids($ids) {
$db = Registry::get('base')->db;
$sql = "SELECT
*
FROM
tickets
WHERE
order_id
IN
(".$db->real_escape_string($ids).")";
$result = $db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$return[] = $obj;
}
return $return;
}
return false;
}
}

83
core/currency.class.php Normal file
View File

@ -0,0 +1,83 @@
<?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 Currency extends Main {
protected $base_object;
protected $db;
public $list_table_config = array (
'title' => 'Währung',
'db_table' => 'currency',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Name',
'sortable' => 1
),
array(
'db_field' => 'iso',
'name' => 'ISO',
'sortable' => 1
)
),
'search_fields' => array('name', 'iso'),
'db_id_field' => 'id',
'db_selectable_field' => 'name',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=Currency&object_id=',
'toolbar' => array(
'delete' => '0',
'new' => 'index.php?admin_modul=admin_object_edit&object=Currency',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
),
'edit_title' => 'Währung',
'edit_fields' => array (
array(
'name' => 'Allgemein',
'type' => 'form_title'
),
array(
'db_field' => 'name',
'name' => 'Name',
'type' => 'text'
),
array(
'db_field' => 'iso',
'name' => 'ISO',
'type' => 'text'
)
),
'edit_mandatory_fields' => array('name', 'iso'),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_list&object=Currency',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'send' => 0,
'delete' => 0
),
);
function __construct($base_object) {
$this->base_object = $base_object;
$this->db = Registry::get('base')->db;
}
}
?>

1657
core/customer.class.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,370 @@
<?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 Customer_group extends Main {
protected $base_object;
protected $db;
public $list_table_config = array (
'title' => 'Kundengruppen',
'db_table' => 'customer_groups',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Bezeichnung',
'sortable' => 1
),
array(
'db_field' => 'description',
'name' => 'Beschreibung',
'sortable' => 1
),
array(
'db_field' => 'adaptPricesFromId',
'name' => 'Preise',
'rewrite_function' => 'show_price_source',
'sortable' => 1
),
array(
'db_field' => 'show_tax',
'name' => 'MwSt',
'rewrite_function' => 'show_tax_state',
'sortable' => 1
)
),
'search_fields' => array('name', 'description'),
'db_id_field' => 'id',
'db_selectable_field' => 'name',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=Customer_group&object_id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_object_edit&object=Customer_group',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
),
'edit_title' => 'Kundengruppe',
'edit_fields' => array (
array(
'name' => 'Allgemein',
'type' => 'form_title'
),
array(
'db_field' => 'name',
'name' => 'Name',
'type' => 'text'
),
array(
'db_field' => 'description',
'name' => 'Beschreibung',
'type' => 'text'
),
array(
'name' => 'Einstellungen',
'type' => 'form_title'
),
array(
'db_field' => 'show_tax',
'name' => 'MwSt zeigen',
'type' => 'int',
'values' => 'show_tax_values'
),
array(
'db_field' => 'price_tax_text',
'name' => 'MwSt Preistext',
'type' => 'text'
),
array(
'db_field' => 'price_tax_text_free_shipping',
'name' => 'MwSt Preistext - Versandkostenfrei',
'type' => 'text'
),
array(
'name' => 'Preise übernehmen von Gruppe',
'type' => 'int',
'db_field' => 'adaptPricesFromId',
'values' => 'show_price_source'
),
array(
'name' => 'Status nach Kundenregistrierung',
'type' => 'int',
'db_field' => 'state_after_registration',
'values' => 'first_state_values'
),
array(
'name' => 'Kundennummer überschreibbar',
'type' => 'int',
'db_field' => 'customer_number_edit',
'values' => 'customer_number_values'
)
),
'edit_mandatory_fields' => array('firstname', 'surename', 'email'),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_list&object=Customer_group',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'send' => 0,
'delete' => 1
),
);
private $object_fields = array(
'name' => 'text',
'description' => 'text',
'show_tax' => 'integer',
'price_tax_text' => 'text',
'state_after_registration' => 'integer',
'adaptPricesFromId' => 'integer'
);
public $structure_id = 0;
private $config;
public function __construct($base_object) {
parent::__construct($base_object);
$this->config_object = $base_object->config;
$this->db = $base_object->db;
}
public function show_tax_state() {
return array (
'0' => 'ohne',
'1' => 'mit'
);
}
public function customer_number_values() {
return array (
'1' => 'Ja',
'0' => 'Nein'
);
}
public function show_tax_values() {
return array (
'1' => 'Ja',
'0' => 'Nein'
);
}
public function first_state_values() {
return array (
'2' => 'Aktiv und eingeloggt',
'1' => 'Aktiv',
'0' => 'gesperrt'
);
}
public function show_price_source() {
$data = array(
'0' => 'Eigene Preise',
);
$sql = "SELECT id, name FROM customer_groups";
$result = $this->db->query($sql);
while ($obj = $result->fetch_object()) {
$data[$obj->id] = 'von '.$obj->name;
}
return $data;
}
public function get_id() {
return $this->id;
}
public function set_id($id) {
if ($id) {
$this->id = $id;
}
return $id;
}
public function get_all_groups() {
// get all groups from database
$sql = "SELECT * FROM customer_groups ORDER BY isLocked DESC, name";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[$obj->id] = $obj;
}
return $data;
}
public function get_all_price_groups() {
// get all groups from database
$sql = "SELECT * FROM customer_groups WHERE adaptPricesFromId=0 ORDER BY isLocked DESC, name";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[$obj->id] = $obj;
}
return $data;
}
// TODO: standard interface for all classes
public function get_all() {
return $this->get_all_groups();
}
public function get_data($id = false) {
$sql = "SELECT * FROM customer_groups 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 get_group_price_id($id = false) {
$sql = "SELECT * FROM customer_groups 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);
$obj = $result->fetch_object();
if ($obj->adaptPricesFromId) {
return $obj->adaptPricesFromId;
} else {
return $obj->id;
}
return false;
}// end get_data
public function load_data() {
$sql = "SELECT * FROM customer_groups WHERE id = ".$this->id;
$result = $this->db->query($sql);
$obj = $result->fetch_object();
foreach ($obj as $key => $value) {
if ($obj->adaptPricesFromId == 0) {
$obj->price_group_id = $obj->id;
} else {
$obj->price_group_id = $obj->adaptPricesFromId;
}
$this->{$key} = $value;
}
return;
}
// end get_data
public function delete() {
$sql = "DELETE FROM
customer_groups
WHERE
isLocked = 0
AND
id=".$this->id;
$this->db->query($sql);
return;
}
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 customer_groups 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;
}
public function update($data) {
if ($data) {
$sql = "UPDATE customer_groups 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;
}
public function delete_by_id($id) {
$rs = $this->db->query("DELETE FROM customer_groups WHERE isLocked = 0 AND id=$id;");
}
public static function get_taxation_type($id) {
$db = Registry::get('base')->db;
$tax_obj = $db->query("
SELECT
show_tax
FROM
customer_groups
WHERE
id = ".$id."
")->fetch_object();
return $tax_obj->show_tax;
}
}
?>

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 = "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;
}
}
?>

View File

@ -0,0 +1,90 @@
<?php
class CustomerGroupPMConf {
private $_db;
private $_pm;
private $_sa;
function __construct($pm, $sa) {
$this->_db = Registry::get('base')->db;
$this->_pm = $pm;
$this->_sa = $sa;
}
public function get_all() {
$sql = "SELECT cgpmc.group_id, cgpmc.payment_method_id, cgpmc.shipping_area_id, cgpmc.active, cg.name
FROM customer_group_payment_method_configuration cgpmc
JOIN customer_groups cg
WHERE cg.id = cgpmc.group_id
AND cgpmc.payment_method_id=".$this->_db->real_escape_string($this->_pm).
" AND cgpmc.shipping_area_id=".$this->_db->real_escape_string($this->_sa);
$result = $this->_db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$return[] = $obj;
}
return $return;
}
return false;
}
private function has_conf($group) {
$sql = "SELECT *
FROM customer_group_payment_method_configuration
WHERE group_id=".$this->_db->real_escape_string($group).
" AND shipping_area_id=".$this->_db->real_escape_string($this->_sa).
" AND payment_method_id=".$this->_db->real_escape_string($this->_pm);
$result = $this->_db->query($sql);
if ($result->num_rows > 0) {
return true;
}
return false;
}
public function update($data) {
$sql = "UPDATE customer_group_payment_method_configuration
SET active=".$this->_db->real_escape_string($data['active']).
" WHERE group_id=".$this->_db->real_escape_string($data['group']).
" AND shipping_area_id=".$this->_db->real_escape_string($this->_sa).
" AND payment_method_id=".$this->_db->real_escape_string($this->_pm);
$this->_db->query($sql);
}
public function create($data) {
$sql = "INSERT INTO
customer_group_payment_method_configuration (group_id, payment_method_id, shipping_area_id, active)
VALUES (".$this->_db->real_escape_string($data['group']).
" , ".$this->_db->real_escape_string($this->_pm).
" , ".$this->_db->real_escape_string($this->_sa).
" , ".$this->_db->real_escape_string($data['active']).
" )";
$this->_db->query($sql);
}
public function delete() {
}
public function save($data) {
if ($this->has_conf($data['group'])) {
$this->update($data);
} else {
$this->create($data);
}
}
public function save_array($data) {
foreach ($data as $point) {
$this->save($point);
}
}
}

View File

@ -0,0 +1,245 @@
<?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 CustomerGroups {
private $table_fields = array(
'name' => 'text',
'description' => 'text',
'show_tax' => 'integer',
'price_tax_text' => 'text',
'state_after_registration' => 'integer',
'adaptPricesFromId' => 'integer'
);
private $db;
private $id;
private $user_id;
private $error;
public function __construct($base_object = false, $id = false) {
if ($base_object) {
$this->db = $base_object->db;
} else {
$this->db = Registry::get('base')->db;
}
$this->id = $id;
$this->user_id = false;
$this->structure_id = 0;
$this->error = '';
} // end cunstructor
public function get_id() {
return id;
} // end get_id
public function set_id($id) {
$this->id = $id;
} // end set_id
public function get_user_id() {
return $this->user_id;
} // end get_user_id
public function set_user_id($id) {
$this->user_id = $id;
} // end set_user_id
public function get_error() {
return $this->error;
} // end get_error
function get_all_names() {
$data = array();
$result = $this->db->query('SELECT id, name FROM customer_groups');
if ($result) {
while ($obj = $result->fetch_object()) {
$data[$obj->id] = $obj->name;
}
}
return $data;
}
public function get_all($filter = false) {
$sql = "SELECT * FROM customer_groups";
if ($filter) {
if ($filter == 'registrable') {
$sql .= " WHERE registrable = 1";
} else if ($filter == 'default') {
$sql .= " WHERE is_default = 1";
} else {
$this->error = 'no valid filter';
return false;
}
}
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$return[$obj->id] = $obj;
}
return $return;
}
return false;
}
public function get_data($id = false) {
$sql = "SELECT * FROM customer_groups";
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($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 result';
return false;
} // end get_data
public function get_by_user_id($user_id = false) {
$sql = "SELECT cg.* FROM customers c JOIN customer_groups cg ON cg.id = c.group_id";
if ($user_id) {
$sql .= " WHERE c.id=".$this->db->real_escape_string($user_id);
$this->user_id = $user_id;
} else if ($this->user_id) {
$sql .= " WHERE c.id=".$this->db->real_escape_string($this->user_id);
} else {
$this->error = "no user id";
return false;
}
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
$this->error = "no result";
return false;
} // end get_by_user_id
public function create($data) {
if ($data) {
$sql = "INSERT INTO customer_groups 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() {
if ($data) {
$sql = "UPDATE customer_groups 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 delete() {
$sql = "DELETE FROM customer_groups WHERE isLocked = 0 AND id=".$this->id;
$this->db->query($sql);
return;
} // end delete
public function get_all_paginated($items, $page, $order = false) {
$page = ($page - 1) * $items;
$sql = "SELECT * FROM customer_groups ORDER BY isLocked DESC, name 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 customer_groups";
return get_number_of_pages($items, $sql);
} // end get_number_of_pages
public function get_pagination_array($items, $page) {
$sql = "SELECT COUNT(id) FROM customer_groups";
return get_pagination_array($items, $page, $sql);
} // end get_pagination_array
// DEPRECATED
public function get_by_user($id = false) {
if ($id) {
$sql = "SELECT cg.* FROM customers c JOIN customer_groups cg ON cg.id = c.group_id
WHERE c.id=".$this->db->real_escape_string($id);
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
}
return false;
}
public function get($id = false) {
if ($id) {
$sql = "SELECT * FROM customer_groups WHERE id=".$this->db->real_escape_string($id);
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
}
return false;
}
}
?>

View File

@ -0,0 +1,454 @@
<?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/orderstatus.class.php';
class CustomerHelper {
//=========================================
//
// THIS CLASS IS STATIC ONLY
//
//=========================================
private function __construct() {}
private function __clone() {}
//=========================================
//
// THE PUBLIC INTERFACE
//
//=========================================
public static function get_customer_email($customer_id) {
$db = Registry::get('base')->db;
$sql = "SELECT email FROM customers WHERE id=".$db->real_escape_string($customer_id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object()->email;
}
return false;
}
public static function getCustomerBankingAccount($customer_id) {
$db = Registry::get('base')->db;
$sql = "SELECT
bank, bank_number, account_holder, account_number, iban, swift_bic
FROM
customers
WHERE
id=".$db->real_escape_string($customer_id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
return false;
}
public static function get_default_address_country($customer_id) {
$db = Registry::get('base')->db;
$sql = "SELECT ca.country FROM customer_addresses ca JOIN customers c ON ca.id=c.default_address
WHERE c.id=".$db->real_escape_string($customer_id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
$obj = $result->fetch_object();
return $obj->country;
}
$sql = "SELECT country FROM customer_addresses WHERE customer_id=".$db->real_escape_string($customer_id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
$obj = $result->fetch_object();
return $obj->country;
}
return false;
}
public static function create_customer_address($data) {
$db = Registry::get('base')->db;
$data_line = "";
$value_line = "";
$size = count($data);
$i = 1;
foreach ($data as $key => $value) {
if (is_numeric($value)) {
$data_line .= $key;
$value_line .= $value;
} else {
$data_line .= $key;
$value_line .= "'".$value."'";
}
if ($i < $size) {
$data_line .= ", ";
$value_line .= ", ";
$i++;
}
}
$sql = "INSERT INTO customer_addresses(".$data_line.") ";
$sql .= "VALUES (".$value_line.");";
if ($db->query($sql)) {
return $db->insert_id;
}
return false;
}
public static function update_customer_address($data, $id) {
$db = Registry::get('base')->db;
$set_line = "";
$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 customer_addresses ";
$sql .= "SET ".$set_line." WHERE id=".$db->real_escape_string($id);
if ($db->query($sql)) {
return $id;
}
return false;
}
public static function get_customer_country($customer_id) {
$db = Registry::get('base')->db;
$sql = "SELECT ca.country FROM customer_addresses ca JOIN customers c ON ca.id = c.default_address
WHERE c.id=".$db->real_escape_string($customer_id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object()->country;
}
return false;
}
public static function get_customer_address($address_id) {
$db = Registry::get('base')->db;
$sql = "SELECT * FROM customer_addresses WHERE id=".$db->real_escape_string($address_id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
else return false;
}
public static function get_revisor_data($id) {
$db = Registry::get('base')->db;
$sql = "SELECT * FROM customers WHERE id = ".$db->real_escape_string($id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
$customer = $result->fetch_object();
$return = $customer->firstname.' '.$customer->surname;
if ($customer->admin_role_id == 0) {
$return = ' (Kunde)';
}
return $return;
}
return false;
} // end get_revisor_data
public function email_exists($email) {
$db = Registry::get('base')->db;
$sql = "SELECT *
FROM customers
WHERE email='".$db->real_escape_string($email)."'";
$result = $db->query($sql);
if ($result->num_rows > 0) {
return true;
}
return false;
} // end email_exists
public function email_has_changed($email, $customer_id) {
$db = Registry::get('base')->db;
$sql = "SELECT email FROM customers where id = ".$db->real_escape_string($customer_id);
$result = $db->query($sql);
// not safe but if there are no results this function returns crap anyway
$old_email = $result->fetch_object()->email;
if ($old_email == $email) {
return false;
}
return true;
}
public static function delete_customer($id) {
$db = Registry::get('base')->db;
$sql = "DELETE FROM customers
WHERE id=".$db->real_escape_string($id);
return $db->query($sql);
} // end delete_customer
public static function delete_customers($ids) {
$db = Registry::get('base')->db;
$sql = "DELETE FROM customers
WHERE id IN (".$db->real_escape_string($ids).")";
return $db->query($sql);
} // end delete_customers
public static function verify_customer_data($data, $address, $restrictive = true) {
$verification = 'success';
/*if ($data['group_id'] == '0') {
$verification = 'error';
$return['group_id'] = "Kundengruppe ist ein Pflichtfeld";
}
// firstname
$cleaned = trim($data['firstname']);
if (!isset($data['firstname']) || $cleaned == '') {
$verification = 'error';
$return['firstname'] = "Vorname ist ein Pflichtfeld";
}
// nachname
$cleaned = trim($data['surname']);
if (!isset($data['surname']) || $cleaned == '') {
$verification = 'error';
$return['surname'] = "Nachname ist ein Pflichtfeld";
}
// email
if (!isset($data['id'])) {
$cleaned = trim($data['email']);
if (!isset($data['email']) || $cleaned == '') {
//$verification = 'error';
//$return['email'] = "E-Mail ist ein Pflichtfeld";
} else {
if (CustomerHelper::email_exists($data['email'])) {
$verification = 'error';
$return['email'] = "E-Mail Adresse ist bereits vergeben";
}
}
} else {
if (CustomerHelper::email_has_changed($data['email'], $data['id'])) {
if (CustomerHelper::email_exists($data['email'])) {
$verification = 'error';
$return['email'] = "E-Mail Adresse ist bereits vergeben";
}
}
}
// password
if (!isset($data['id'])) {
$cleaned = trim($data['pass1']);
if (!isset($data['pass1']) || $cleaned == '') {
$verification = 'error';
$return['pass1'] = "Passwort ist ein Pflichtfeld";
}
$cleaned = trim($data['pass2']);
if (!isset($data['pass2']) || $cleaned == '') {
$verification = 'error';
$return['pass2'] = "Passwort ist ein Pflichtfeld";
}
}
// birthdate
/*if ($restrictive) {
$cleaned = trim($data['burth_date']);
if (!isset($data['burth_date']) || $cleaned == '') {
$verification = 'error';
$return['burth_date'] = "Geburtsdatum ist ein Pflichtfeld";
}
}*/
// address
/*if (!isset($data['id'])) {
$return['address'] = CustomerHelper::verify_customer_address($address);
if ($return['address']['status'] == 'error') {
$verification = 'error';
}
}*/
if ($verification == 'success') {
return array('status' => 'success');
}
return array('status' => 'error', 'data' => $return);
} // end verify_customer_data
public static function verify_customer_address($address) {
$verification = 'success';
// honorific
$cleaned = trim($address['honorific']);
if (!isset($address['honorific']) || $cleaned == '') {
$verification = 'error';
$return['honorific'] = "Adress Anrede ist ein Pflichtfeld";
}
// firstname
$cleaned = trim($address['firstname']);
if (!isset($address['firstname']) || $cleaned == '') {
$verification = 'error';
$return['firstname'] = "Adress Vorname ist ein Pflichtfeld";
}
// surname
$cleaned = trim($address['surname']);
if (!isset($address['surname']) || $cleaned == '') {
$verification = 'error';
$return['surname'] = "Adress Nachname ist ein Pflichtfeld";
}
// street
$cleaned = trim($address['street']);
if (!isset($address['street']) || $cleaned == '') {
$verification = 'error';
$return['street'] = "Stra&szlig; ist ein Pflichtfeld";
}
// house_number
$cleaned = trim($address['house_number']);
if (!isset($address['house_number']) || $cleaned == '') {
$verification = 'error';
$return['house_number'] = "Hausnummer ist ein Pflichtfeld";
}
// zip_code
$cleaned = trim($address['zip_code']);
if (!isset($address['zip_code']) || $cleaned == '') {
$verification = 'error';
$return['zip_code'] = "Postleitzahl ist ein Pflichtfeld";
}
// city
$cleaned = trim($address['city']);
if (!isset($address['city']) || $cleaned == '') {
$verification = 'error';
$return['city'] = "Ort ist ein Pflichtfeld";
}
// country
$cleaned = trim($address['country']);
if (!isset($address['country']) || $cleaned == '') {
$verification = 'error';
$return['country'] = "Land ist ein Pflichtfeld";
}
if ($verification == 'success') {
return array('status' => 'success');
}
return array('status' => 'error', 'data' => $return);
}
public static function getAddressByIds($customerId, $addressId) {
$db = Registry::get('base')->db;
$query = "
SELECT
company, honorific, firstname, surname, street, house_number,
zip_code, city, country
FROM
customer_addresses
WHERE
customer_id = '".$db->real_escape_string($customerId)."'
AND
id = '".$db->real_escape_string($addressId)."'
";
return $db->query($query)->fetch_object();
}
public static function getCustomerDataForOrder($customerId) {
$db = Registry::get('base')->db;
$query = "SELECT
CONCAT_WS(' ', firstname, surname) AS customer_name,
id AS customer_id,
number AS customer_number,
tax_id AS customer_vat_reg_num
FROM
customers
WHERE
id = '".$db->real_escape_string($customerId)."'";
return $db->query($query)->fetch_object();
}
public static function get_customer_group_id_by_customer_id($customer_id = false) {
$db = Registry::get('base')->db;
if ($customer_id) {
$sql = "SELECT group_id FROM customers WHERE id=".$db->real_escape_string($customer_id);
return $db->query($sql)->fetch_object()->group_id;
}
return false;
}
}
?>

117
core/database.class.php Normal file
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
core/deliverer.class.php Normal file
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;
}
}
?>

View File

@ -0,0 +1,220 @@
<?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 DelivererHelper {
//=========================================
//
// THIS CLASS IS STATIC ONLY
//
//=========================================
public static $get_deliverers_by_country_error_var = '';
private function __construct() {}
private function __clone() {}
//=========================================
//
// THE PUBLIC INTERFACE
//
//=========================================
// TODO: do this with a triple join
public static function get_deliverers_by_country_error() {
return DelivererHelper::$get_deliverers_by_country_error_var;
}
public static function get_deliverers_by_country($country_id) {
$db = Registry::get('base')->db;
$sql = "SELECT shipping_area_id FROM countries WHERE id = ".$db->real_escape_string($country_id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
$shipping_area_id = $result->fetch_object()->shipping_area_id;
$sql = "SELECT deliverer_id
FROM shipping_area_deliverers
WHERE shipping_area_id = ".$db->real_escape_string($shipping_area_id).
" AND active = 1";
$result = $db->query($sql);
if ($result->num_rows > 0) {
$deliverer_ids = '';
while ($obj = $result->fetch_object()) {
if ($deliverer_ids == '') {
$deliverer_ids = $obj->deliverer_id;
} else {
$deliverer_ids .= ', '.$obj->deliverer_id;
}
}
$sql = "SELECT *
FROM deliverers
WHERE id IN (".$db->real_escape_string($deliverer_ids).")
and active = 1";
$result = $db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$return[] = $obj;
}
return $return;
}
return false;
}
DelivererHelper::$get_deliverers_by_country_error_var = 'no shipping area defined for country';
return false;
}
DelivererHelper::$get_deliverers_by_country_error_var = 'country not defined';
return false;
}
public static function get_deliverers_with_prices_by_country($country_id) {
$db = Registry::get('base')->db;
$sql = "SELECT shipping_area_id
FROM countries
WHERE id = ".$db->real_escape_string($country_id);
$result = $db->query($sql);
if ($result->num_rows > 0) {
$shipping_area_id = $result->fetch_object()->shipping_area_id;
$sql = "SELECT
sad.price_add AS price,
d.*
FROM
shipping_area_deliverers sad
JOIN
deliverers d
ON
sad.deliverer_id = d.id
WHERE
sad.shipping_area_id = ".$db->real_escape_string($shipping_area_id).
" AND sad.active = 1";
$result = $db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$return[] = $obj;
}
return $return;
}
return false;
}
return false;
}
public static function getDeliveryDataByIdAndCountry($method_id, $country_id, $default_vat_value, $customer_group_id = false) {
$shippingObject = new stdClass();
$shippingObject->methodId = $method_id;
$db = Registry::get('base')->db;
// Area
$result = $db->query("
SELECT
shipping_area_id
FROM
countries
WHERE
id = '".$db->real_escape_string($country_id)."'
");
$obj = $result->fetch_object();
$area_id = $obj ? $obj->shipping_area_id : false;
if ($customer_group_id) {
$sql = "SELECT * FROM country_customergroup_shippingarea
WHERE country_id = ".$country_id." AND customer_group_id = $customer_group_id";
$result2 = $db->query($sql);
if ($result2->num_rows > 0) {
$area_id = $result2->fetch_object()->shipping_area_id;
}
}
$shippingObject->areaId = $area_id;
// Costs
$result = $db->query("
SELECT
price_add
FROM
shipping_area_deliverers
WHERE
shipping_area_id = '".$db->real_escape_string($area_id)."'
AND
deliverer_id = '".$db->real_escape_string($method_id)."'
");
$obj = $result->fetch_object();
$price = $obj ? $obj->price_add : 0;
$shippingObject->priceGross = $price;
$shippingObject->priceNet = round($price / (100 + $default_vat_value) * 100, 2);
$shippingObject->priceVat = $shippingObject->priceGross - $shippingObject->priceNet;
$shippingObject->vatRate = $default_vat_value;
return $shippingObject;
}
public static function get_deliverers_by_shipping_area_array() {
$db = Registry::get('base')->db;
$sql = "SELECT
d.name,
sad.*
FROM
deliverers d
JOIN
shipping_area_deliverers sad
ON
d.id = sad.deliverer_id
WHERE
d.active = 1";
$result = $db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
if ($obj->active == '1') {
$deliverers[$obj->shipping_area_id][$obj->deliverer_id] = array('name' => $obj->name, 'price' => $obj->price_add, 'cost_type' => $obj->deliverer_cost_type, 'bulk_goods_price_add' => $obj->bulk_goods_price_add, 'shipping_free_price' => $obj->shipping_free_price);
}
}
return $deliverers;
}
return false;
}
//=========================================
//
// THE PRIVATE INTERFACE
//
//=========================================
}
?>

139
core/domain.class.php Normal file
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;
}
}
?>

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
core/export.class.php Normal file
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
?>

View File

@ -0,0 +1,46 @@
<?php
// www.billiger.de export filter
$data_array[] = array(
'aid',
'brand',
'mpnr',
'ean',
'name',
'desc',
'shop_cat',
'price',
'link',
'image',
'dlv_time',
'dlv_cost'
);
foreach ($items as $article_obj) {
$data_array[] = array(
csv_string($article_obj->refnr), // Artikelnummer im Shop
csv_string($article_obj->hersteller), // Herstellername
csv_string($article_obj->hersteller_number), // Original Herstellerartikelnummer
csv_string($article_obj->barcode), // EAN / Barcodenummer
csv_string($article_obj->bez), // Produktname
csv_string($article_obj->besde), // Produktbeschreibung
csv_string($article_obj->article_group), // Produktgruppe im Shop (m<>glichst als Pfad ausgehend von der Wurzelkategorie)
csv_string(number_format($article_obj->preis, 2, ",", ".")), // PreisEuro
csv_string(MAIN_URL.'?index.php?wg=2&shopAction=showArticle&article_id='.$article_obj->id), // ProduktURL
MAIN_URL.'/web/images/article/big_'.$article_obj->bild1, // BildURL (gro<72>es Bild)
csv_string($article_obj->delivery_time), // Lieferzeit
'8,80' // Versandkosten
);
}
function csv_string ($string) {
$string = trim($string);
$string = strip_tags($string);
$string = str_replace(';',',',$string);
$string = str_replace("\r\n",' ',$string);
$string = str_replace("\n",' ',$string);
return $string;
}
?>

View File

@ -0,0 +1,107 @@
<?php
$data_array[] = array('Kundennummer', 'Artikelnummer', 'Hersteller', 'Herstellernummer', 'Produktbezeichnung', 'Kurzbeschreibung', 'MwSt', 'Preis', 'UVP', 'EAN-Code', 'Grundpreis', 'Lieferstatus', 'Bildpfad', 'Warengruppe');
$image_url = 'http://'.$_SERVER['HTTP_HOST'].'/web/'.SHOP_SYSTEM.'/images/article/';
$shippability_array = array(
'0' => 'nicht lieferbar',
'1' => 'lieferbar',
'2' => 'lieferbar ab (bis)',
'3' => 'lieferzeit unbekannt',
'4' => 'Bestellartikel (Lieferzeit 2-3 Tage)',
'5' => 'Bestellartikel (Lieferzeit 14 Tage)',
'6' => 'Bestellartikel'
);
foreach ($items as $article_obj) {
if (isset($article_obj->shop_bargain_price_1) && $article_obj->shop_bargain_price_1 > 0) {
$price = $article_obj->shop_bargain_price_1;
} else {
$price = $article_obj->shop_price_1;
}
if (isset($article_obj->sample_price) && $article_obj->sample_price != 0.0000 ) {
$price_per_unit = number_format($article_obj->sample_price, 2, ',', '').' € pro '.$article_obj->sample_unit;
} else {
$price_per_unit = '';
}
if ($article_obj->default_image_file_name == 'leer.gif' || $article_obj->default_image_file_name == '') {
$item_image = '';
} else {
$item_image = $image_url.$article_obj->default_image_file_name;
}
if (isset($article_obj->uvp) && $article_obj->uvp != 0.00) {
$uvp = number_format($article_obj->uvp, 2, ',', '');
} else {
$uvp = '';
}
$shippable = $shippability_array[$article_obj->shippable];
if ($article_obj->shippable == 2) {
if (isset($article_obj->available_from) && $article_obj->available_from != '0000-00-00') {
$shippable .= ' '.$article_obj->available_from;
if (isset($article_obj->available_till) && $article_obj->available_till != '0000-00-00') {
$shippable .= ' '.$article_obj->available_till;
}
}
}
$data_array[] = array(
// OLD 0 A Kundennummer
$this->customer_number,
// OLD 1 B Interne Nummer
$article_obj->number,
// OLD 2 C Artikel-Nummer / NEW Manufacturer name
csv_string($article_obj->manufacturer_name),
// OLD 3 D Artikel-Bezeichnung / NEW Manufacturer number
$article_obj->manufacturer_item_number,
// OLD 4 E Preis (inkl. Rabatte, exkl. Mehrwertsteuer) / NEW Artikel Name
csv_string($article_obj->name),
// OLD 5 F Artikelbeschreibung
csv_string($article_obj->short_description),
// OLD 6 G Mehrwertsteur-Satz-ID / NEW Mehrwertsteuer
$article_obj->tax_rate,
// OLD 7 H Groesse; Menge ... / NEW Preis (inkl. Rabatte, exkl. Mehrwertsteuer)
number_format($price, 2, ',', ''),
// OLD 8 I Gewicht; Menge ... / NEW UVP
$uvp,
// OLD 9 J EAN-Code
$article_obj->ean_code,
// OLD 10 K Reserviert
$price_per_unit,
// OLD 11 L Reserviert // New Lieferstatus
$shippable,
// OLD 12 M Bildname
$item_image,
// OLD 13 N Reserviert
csv_string($article_obj->structure_name),
// OLD 14 O Reserviert
'',
// OLD 15 P Reserviert
'',
// OLD 16 Q Reserviert
'',
// OLD 17 R Reserviert
'',
// OLD 18 S Reserviert
'',
// OLD 19 T Reserviert
'',
// OLD 20 U Reserviert
''
);
}
function csv_string ($string) {
$string = trim($string);
$string = strip_tags($string);
$string = str_replace(array('&auml;', '&uuml;', '&ouml;', '&Auml;', '&Uuml;', '&Ouml;', '&szlig;', '&euro;', '&amp;'), array('ä', 'ü', 'ö', 'Ä', 'Ü', 'Ö', 'ß', '€', '&'), $string);
$string = str_replace(array(';', "\r", "\n"), array(',', ' ', ' '), $string);
return $string;
}

View File

@ -0,0 +1,102 @@
<?php
$today = getdate();
$today = $today['mday'].'.'.$today['mon'].'.'.$today['year'];
$data_array[] = array('Fachhandelspreisliste (Preise ohne Gewähr)', 'vom '.$today, '| Intelectra GmbH', 'Sachsenring 48', '94315 Straubing', 'Tel. +49 (0)9421-62015', 'Fax +49 (0)9421-72677');
$data_array[] = array('Best.Nr.', 'Bezeichnung', 'Beschreibung', 'Preis 1 St. (ohne MwSt.)', 'Preis ab 3 St. (ohne MwSt.)', 'Preis ab 100 St. (ohne MwSt.)', 'UVP ohne MwSt.');
$sql = "SELECT item_id, price_1 FROM item_prices WHERE customergroup_id=1";
$res = $this->db->query($sql);
$item_uvp = array();
while ($o = $res->fetch_object()) {
$item_uvp[$o->item_id] = $o->price_1;
}
foreach ($items as $article_obj) {
$price = '';
$price2 = 0;
$price3 = 0;
if (isset($article_obj->bargain_price_1) && $article_obj->bargain_price_1 > 0 && $article_obj->bargain_price_type == 1) {
$price = $article_obj->bargain_price_1;
} else if (isset($article_obj->bargain_price_1) && $article_obj->bargain_price_1 > 0 && $article_obj->bargain_price_type == 2) {
$today = getdate();
$today = $today['year'].'-'.$today['mon'].'-'.$today['mday'];
$sql = "SELECT item_types.item_type_id
FROM item_types
LEFT JOIN item_type_definitions ON item_type_definitions.item_type_definition_id=item_types.item_type_definition_id
WHERE item_id =".$this->db->real_escape_string($article_obj->id).
" AND item_type_available_from <= '".$this->db->real_escape_string($today)."'
AND item_type_available_until >= '".$this->db->real_escape_string($today)."'
AND item_type_definitions.item_type_definition_type=1
AND item_type_definitions.item_type_definition_is_active=1";
$result = $this->db->query($sql);
$found = $result->fetch_array();
if ($found) {
$price = $article_obj->bargain_price_1;
} else {
}
$price = $article_obj->price_1;
} else {
$price = $article_obj->price_1;
}
if (isset($article_obj->bargain_price_2) && $article_obj->bargain_price_2 > 0 && $article_obj->bargain_price_type == 1) {
$price2 = $article_obj->bargain_price_2;
} else {
$price2 = $article_obj->price_2;
}
if (isset($article_obj->bargain_price_3) && $article_obj->bargain_price_3 > 0 && $article_obj->bargain_price_type == 1) {
$price3 = $article_obj->bargain_price_3;
} else {
$price3 = $article_obj->price_3;
}
$price = number_format($price,2,',','').' EUR';
$price_2 = '';
$price_3 = '';
$uvp = '';
if ($price2 && $article_obj->quantity_2 == 3) {
$price_2 = number_format($price2,2,',','').' EUR';
} else if ($price2 && $article_obj->quantity_2 == 100) {
$price_2 = number_format($price3,2,',','').' EUR';
}
if ($price3 && $article_obj->quantity_3 == 100) {
$price_3 = number_format($price3,2,',','').' EUR';
} else if ($price2 && $article_obj->quantity_3 == 3) {
$price_3 = number_format($price2,2,',','').' EUR';
}
if (isset($item_uvp[$article_obj->id])) {
$uvp = number_format($item_uvp[$article_obj->id],2,',','').' EUR';
}
if ($article_obj->shippable) {
$data_array[] = array(
// Item number
csv_string($article_obj->number),
// Item name
csv_string($article_obj->name),
// Short description
csv_string($article_obj->short_description),
// preis ein stueck
csv_string($price),
// staffelpreis ab 3 stueck
csv_string($price_2),
// staffelpreis ab 100 stueck
csv_string($price_3),
// uvp
$uvp
);
}
}
function csv_string ($string) {
$string = trim($string);
$string = strip_tags($string);
$string = str_replace(array('&auml;', '&uuml;', '&ouml;', '&Auml;', '&Uuml;', '&Ouml;', '&szlig;', '&euro;', '&amp;'), array('ä', 'ü', 'ö', 'Ä', 'Ü', 'Ö', 'ß', '€', '&'), $string);
$string = str_replace(array(';', "\r", "\n"), array(',', ' ', ' '), $string);
return $string;
}

View File

@ -0,0 +1,107 @@
<?php
$data_array = array();
$image_url = 'http://'.$_SERVER['HTTP_HOST'].'/web/'.SHOP_SYSTEM.'/images/article/';
$shippability_array = array(
'0' => 'nicht lieferbar',
'1' => 'lieferbar',
'2' => 'lieferbar ab (bis)',
'3' => 'lieferzeit unbekannt',
'4' => 'Bestellartikel (Lieferzeit 2-3 Tage)',
'5' => 'Bestellartikel (Lieferzeit 14 Tage)',
'6' => 'Bestellartikel'
);
foreach ($items as $article_obj) {
if (isset($article_obj->shop_bargain_price_1) && $article_obj->shop_bargain_price_1 > 0) {
$price = $article_obj->shop_bargain_price_1;
} else {
$price = $article_obj->shop_price_1;
}
if (isset($article_obj->sample_price) && $article_obj->sample_price != 0.0000 ) {
$price_per_unit = number_format($article_obj->sample_price, 2, ',', '').' € pro '.$article_obj->sample_unit;
} else {
$price_per_unit = '';
}
if ($article_obj->default_image_file_name == 'leer.gif' || $article_obj->default_image_file_name == '') {
$item_image = '';
} else {
$item_image = $image_url.$article_obj->default_image_file_name;
}
if (isset($article_obj->uvp) && $article_obj->uvp != 0.00) {
$uvp = number_format($article_obj->uvp, 2, ',', '');
} else {
$uvp = '';
}
$shippable = $shippability_array[$article_obj->shippable];
if ($article_obj->shippable == 2) {
if (isset($article_obj->available_from) && $article_obj->available_from != '0000-00-00') {
$shippable .= ' '.$article_obj->available_from;
if (isset($article_obj->available_till) && $article_obj->available_till != '0000-00-00') {
$shippable .= ' '.$article_obj->available_till;
}
}
}
$data_array[] = array(
// OLD 0 A Kundennummer
$this->customer_number,
// OLD 1 B Interne Nummer
$article_obj->number,
// OLD 2 C Artikel-Nummer / NEW Manufacturer name
csv_string($article_obj->manufacturer_name),
// OLD 3 D Artikel-Bezeichnung / NEW Manufacturer number
$article_obj->manufacturer_item_number,
// OLD 4 E Preis (inkl. Rabatte, exkl. Mehrwertsteuer) / NEW Artikel Name
csv_string($article_obj->name),
// OLD 5 F Artikelbeschreibung
csv_string($article_obj->short_description),
// OLD 6 G Mehrwertsteur-Satz-ID / NEW Mehrwertsteuer
$article_obj->tax_rate,
// OLD 7 H Groesse; Menge ... / NEW Preis (inkl. Rabatte, exkl. Mehrwertsteuer)
number_format($price, 2, ',', ''),
// OLD 8 I Gewicht; Menge ... / NEW UVP
$uvp,
// OLD 9 J EAN-Code
$article_obj->ean_code,
// OLD 10 K Reserviert
$price_per_unit,
// OLD 11 L Reserviert // New Lieferstatus
$shippable,
// OLD 12 M Bildname
$item_image,
// OLD 13 N Reserviert
csv_string($article_obj->structure_name),
// OLD 14 O Reserviert
'',
// OLD 15 P Reserviert
'',
// OLD 16 Q Reserviert
'',
// OLD 17 R Reserviert
'',
// OLD 18 S Reserviert
'',
// OLD 19 T Reserviert
'',
// OLD 20 U Reserviert
''
);
}
function csv_string ($string) {
$string = trim($string);
$string = strip_tags($string);
$string = str_replace(array('&auml;', '&uuml;', '&ouml;', '&Auml;', '&Uuml;', '&Ouml;', '&szlig;', '&euro;', '&amp;'), array('ä', 'ü', 'ö', 'Ä', 'Ü', 'Ö', 'ß', '€', '&'), $string);
$string = str_replace(array(';', "\r", "\n"), array(',', ' ', ' '), $string);
return $string;
}

View File

@ -0,0 +1,109 @@
<?php
$data_array = array();
$image_url = 'http://'.$_SERVER['HTTP_HOST'].'/web/'.SHOP_SYSTEM.'/images/article/';
$shippability_array = array(
'0' => 'nicht lieferbar',
'1' => 'lieferbar',
'2' => 'lieferbar ab (bis)',
'3' => 'lieferzeit unbekannt',
'4' => 'Bestellartikel (Lieferzeit 2-3 Tage)',
'5' => 'Bestellartikel (Lieferzeit 14 Tage)',
'6' => 'Bestellartikel'
);
foreach ($items as $article_obj) {
if (isset($article_obj->shop_bargain_price_1) && $article_obj->shop_bargain_price_1 > 0) {
$price = $article_obj->shop_bargain_price_1;
} else {
$price = $article_obj->shop_price_1;
}
if (isset($article_obj->sample_price) && $article_obj->sample_price != 0.0000 ) {
$price_per_unit = number_format($article_obj->sample_price, 2, ',', '').' € pro '.$article_obj->sample_unit;
} else {
$price_per_unit = '';
}
if ($article_obj->default_image_file_name == 'leer.gif' || $article_obj->default_image_file_name == '') {
$item_image = '';
} else {
$item_image = $image_url.$article_obj->default_image_file_name;
}
if (isset($article_obj->uvp) && $article_obj->uvp != 0.00) {
$uvp = number_format($article_obj->uvp, 2, ',', '');
} else {
$uvp = '';
}
$shippable = $shippability_array[$article_obj->shippable];
if ($article_obj->shippable == 2) {
if (isset($article_obj->available_from) && $article_obj->available_from != '0000-00-00') {
$shippable .= ' '.$article_obj->available_from;
if (isset($article_obj->available_till) && $article_obj->available_till != '0000-00-00') {
$shippable .= ' '.$article_obj->available_till;
}
}
}
$data_array[] = array(
// OLD 0 A Kundennummer
$this->customer_number,
// OLD 1 B Interne Nummer
$article_obj->number,
// OLD 2 C Artikel-Nummer / NEW Manufacturer name
csv_string($article_obj->manufacturer_name),
// OLD 3 D Artikel-Bezeichnung / NEW Manufacturer number
$article_obj->manufacturer_item_number,
// OLD 4 E Preis (inkl. Rabatte, exkl. Mehrwertsteuer) / NEW Artikel Name
csv_string($article_obj->name),
// OLD 5 F Artikelbeschreibung
csv_string($article_obj->short_description),
// OLD 6 G Mehrwertsteur-Satz-ID / NEW Mehrwertsteuer
$article_obj->tax_rate,
// OLD 7 H Groesse; Menge ... / NEW Preis (inkl. Rabatte, exkl. Mehrwertsteuer)
number_format($price, 2, ',', ''),
// OLD 8 I Gewicht; Menge ... / NEW UVP
$uvp,
// OLD 9 J EAN-Code
$article_obj->ean_code,
// OLD 10 K Reserviert
$price_per_unit,
// OLD 11 L Reserviert // New Lieferstatus
$shippable,
// OLD 12 M Bildname
$item_image,
// OLD 13 N Reserviert
csv_string($article_obj->structure_name),
// OLD 14 O Reserviert
'',
// OLD 15 P Reserviert
'',
// OLD 16 Q Reserviert
'',
// OLD 17 R Reserviert
'',
// OLD 18 S Reserviert
'',
// OLD 19 T Reserviert
'',
// OLD 20 U Reserviert
'',
// Artikelbeschreibung
csv_string($article_obj->detail_description)
);
}
function csv_string ($string) {
$string = trim($string);
$string = strip_tags($string);
$string = str_replace(array('&auml;', '&uuml;', '&ouml;', '&Auml;', '&Uuml;', '&Ouml;', '&szlig;', '&euro;', '&amp;'), array('ä', 'ü', 'ö', 'Ä', 'Ü', 'Ö', 'ß', '€', '&'), $string);
$string = str_replace(array('|', "\r", "\n"), array(',', ' ', ' '), $string);
return $string;
}

View File

@ -0,0 +1,90 @@
<?php
// www.google.de export filter
//titel /have
//beschreibung /have (description)
//link /have
//preis /have
//bild_url /have (image link)
//id /have
//waehrung nicht
//zustand /haben (condition)
//hersteller / have brand (they have it twice?)
//versand / have shipping
//gtin / dont have isn't set
//brand /have
//googel product /have
//product type /have
//available /have
//mpn dont have
$data_array[] = array(
'id',
'availability',
'condition',
'description',
'product_type',
'google_product_category',
'link',
'price',
'title',
'brand',
'image_link',
'manufacturer',
'gtin'
// 'c:keywords:string',
// 'shipping'
);
foreach ($items as $article_obj) {
if (is_array($images)) {
$images = implode(',', $images);
}
$article_obj->short_description = str_replace('|',' - ', $article_obj->short_description);
/*if ($article_obj->shop_bargain_price_1 > 0) {
$article_obj->shop_price_1 = $article_obj->shop_bargain_price_1;
}*/
if ($article_obj->shop_price_1 > 0) {
$data_array[] = array(
$article_obj->id,
'available for order',
'new',
csv_string($article_obj->short_description),
csv_string($article_obj->structure_data->path_name),
csv_string($article_obj->google_product_category),
csv_string('http://'.$_SERVER['SERVER_NAME'].'/'.$article_obj->short_uri.'.html'),
number_format($article_obj->shop_price_1, 2, ',', ''),
csv_string($article_obj->name),
csv_string($article_obj->manufacturer_text),
csv_string('http://'.$_SERVER['SERVER_NAME'].'/web/'.SHOP_SYSTEM.'/images/article/'.$article_obj->file_name),
'Intelectra',//csv_string($article_obj->manufacturer_text),
csv_string($article_obj->ean_code),
//csv_string($article_obj->seo_keywords),
//'DE:::0.00'
);
}
}
function csv_string ($string) {
$string = trim($string);
$string = strip_tags($string);
$string = str_replace('&auml;','ä',$string);
$string = str_replace('&Auml;','Ä',$string);
$string = str_replace('&ouml;','ö',$string);
$string = str_replace('&Ouml;','Ö',$string);
$string = str_replace('&uuml;','ü',$string);
$string = str_replace('&Uuml;','Ü',$string);
$string = str_replace('&szlig;','ß',$string);
$string = str_replace('|',',',$string);
//$string = str_replace(';',',',$string);
$string = str_replace("\r\n",' ',$string);
$string = str_replace("\n",' ',$string);
return $string;
}
?>

View File

@ -0,0 +1,69 @@
<?php
// www.idealo.de export filter
$data_array[] = array(
'Artikelnummer im Shop',
'EAN / Barcodenummer',
'Original Herstellerartikelnummer',
'Herstellername',
'Produktname',
'Produktgruppe im Shop',
'PreisEuro',
'Lieferzeit',
'ProduktURL',
'BildURL',
//'Versandkosten Vorkasse',
//'Versandkosten Nachnahme',
//'Versandkosten Kreditkarte (z.B. nur bis 1000 EUR)',
'Versandkosten Paypal',
//'Versandkosten Sofort<72>berweisung',
/*'Versandkosten Bankeinzug',
'Versandkosten Rechnung',
'Versandkosten Moneybookers',
'Versandkosten Click & Buy',
'Versandkosten Giropay',
'Versandkosten Abholung',
'Versandkosten Kommentar',*/
'Produktbeschreibung'
);
foreach ($items as $article_obj) {
$data_array[] = array(
csv_string($article_obj->number), // Artikelnummer im Shop
csv_string($article_obj->barcode), // EAN / Barcodenummer
csv_string($article_obj->hersteller_number), // Original Herstellerartikelnummer
csv_string($article_obj->manufacturer_text), // Herstellername
csv_string($article_obj->name), // Produktname
csv_string($article_obj->article_group), // Produktgruppe im Shop (m<>glichst als Pfad ausgehend von der Wurzelkategorie)
csv_string(number_format($article_obj->preis, 2, ",", "")), // PreisEuro
csv_string($article_obj->delivery_time), // Lieferzeit
csv_string(MAIN_URL.'?index.php?wg=2&shopAction=showArticle&article_id='.$article_obj->id), // ProduktURL
MAIN_URL.'/web/images/article/big_'.$article_obj->bild1, // BildURL (gro<72>es Bild)
//'', // Versandkosten Vorkasse
//'', // Versandkosten Nachnahme
//'', // Versandkosten Kreditkarte (z.B. nur bis 1000 EUR)
'3%', // Versandkosten Paypal
//'', // Versandkosten Sofor<6F>berweisung
/*'', // Versandkosten Bankeinzug
'', // Versandkosten Rechnung
'', // Versandkosten Moneybookers
'', // Versandkosten Click & Buy
'', // Versandkosten Giropay
'', // Versandkosten Abholung
'', // Versandkosten Kommentar*/
csv_string($article_obj->besde) // Produktbeschreibung
);
}
function csv_string ($string) {
$string = trim($string);
$string = strip_tags($string);
$string = str_replace(';',',',$string);
$string = str_replace("\r\n",' ',$string);
$string = str_replace("\n",' ',$string);
return $string;
}
?>

View File

@ -0,0 +1,56 @@
<?php
/**
* Sitemap XML Export Filter
*/
if (!defined('ROOT_DIR')) {
die('You cannot access this file directly!');
}
class ExportFilter extends Export {
public function get_export_csv() {
header('Content-Type: application/xml; charset=UTF-8');
$output = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
// Startseite
$output .= $this->addUrl('https://intelectra.de/');
// Artikel aus der Datenbank holen
$sql = "SELECT id, last_update FROM item WHERE active = 1";
$result = $this->db->query($sql);
while($row = $result->fetch_object()) {
$url = 'https://intelectra.de/index.php?website_modul=website_item&id=' . $row->id;
$output .= $this->addUrl($url, $row->last_update);
}
// Kategorien
$sql = "SELECT id, last_update FROM itemgroup WHERE active = 1";
$result = $this->db->query($sql);
while($row = $result->fetch_object()) {
$url = 'https://intelectra.de/index.php?website_modul=website_itemgroup&id=' . $row->id;
$output .= $this->addUrl($url, $row->last_update);
}
$output .= '</urlset>';
// Update export statistics
$this->update_export_statistics(substr_count($output, '<url>'));
return $output;
}
private function addUrl($loc, $lastmod = '') {
$output = " <url>\n";
$output .= " <loc>" . htmlspecialchars($loc) . "</loc>\n";
if($lastmod) {
$output .= " <lastmod>" . date('Y-m-d', strtotime($lastmod)) . "</lastmod>\n";
}
$output .= " </url>\n";
return $output;
}
}

View File

@ -0,0 +1,51 @@
<?php
/**
* Sitemap XML Export Filter
*/
class SitemapXmlExport extends Export {
public function get_export_csv() {
header('Content-Type: application/xml; charset=UTF-8');
$output = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
// Startseite
$output .= $this->addUrl('https://intelectra.de/');
// Artikel aus der Datenbank holen
$sql = "SELECT id, last_update FROM item WHERE active = 1";
$result = $this->db->query($sql);
while($row = $result->fetch_object()) {
$url = 'https://intelectra.de/index.php?website_modul=website_item&id=' . $row->id;
$output .= $this->addUrl($url, $row->last_update);
}
// Kategorien
$sql = "SELECT id, last_update FROM itemgroup WHERE active = 1";
$result = $this->db->query($sql);
while($row = $result->fetch_object()) {
$url = 'https://intelectra.de/index.php?website_modul=website_itemgroup&id=' . $row->id;
$output .= $this->addUrl($url, $row->last_update);
}
$output .= '</urlset>';
// Update export statistics
$this->update_export_statistics(substr_count($output, '<url>'));
return $output;
}
private function addUrl($loc, $lastmod = '') {
$output = " <url>\n";
$output .= " <loc>" . htmlspecialchars($loc) . "</loc>\n";
if($lastmod) {
$output .= " <lastmod>" . date('Y-m-d', strtotime($lastmod)) . "</lastmod>\n";
}
$output .= " </url>\n";
return $output;
}
}

View File

@ -0,0 +1,68 @@
<?php
// www.yatego.de export filter
$data_array[] = array(
'Artikelnummer im Shop',
'EAN / Barcodenummer',
'Original Herstellerartikelnummer',
'Herstellername',
'Produktname',
'Produktgruppe im Shop',
'PreisEuro',
'Lieferzeit',
'ProduktURL',
'BildURL',
//'Versandkosten Vorkasse',
//'Versandkosten Nachnahme',
//'Versandkosten Kreditkarte (z.B. nur bis 1000 EUR)',
'Versandkosten Paypal',
//'Versandkosten Sofort<72>berweisung',
/*'Versandkosten Bankeinzug',
'Versandkosten Rechnung',
'Versandkosten Moneybookers',
'Versandkosten Click & Buy',
'Versandkosten Giropay',
'Versandkosten Abholung',
'Versandkosten Kommentar',*/
'Produktbeschreibung'
);
foreach ($items as $article_obj) {
$data_array[] = array(
csv_string($article_obj->refnr), // Artikelnummer im Shop
csv_string($article_obj->barcode), // EAN / Barcodenummer
csv_string($article_obj->hersteller_number), // Original Herstellerartikelnummer
csv_string($article_obj->hersteller), // Herstellername
csv_string($article_obj->bez), // Produktname
csv_string($article_obj->article_group), // Produktgruppe im Shop (m<>glichst als Pfad ausgehend von der Wurzelkategorie)
csv_string(number_format($article_obj->preis, 2, ",", "")), // PreisEuro
csv_string($article_obj->delivery_time), // Lieferzeit
csv_string(MAIN_URL.'?index.php?wg=2&shopAction=showArticle&article_id='.$article_obj->id), // ProduktURL
MAIN_URL.'/web/images/article/big_'.$article_obj->bild1, // BildURL (gro<72>es Bild)
//'', // Versandkosten Vorkasse
//'', // Versandkosten Nachnahme
//'', // Versandkosten Kreditkarte (z.B. nur bis 1000 EUR)
'3%', // Versandkosten Paypal
//'', // Versandkosten Sofor<6F>berweisung
/*'', // Versandkosten Bankeinzug
'', // Versandkosten Rechnung
'', // Versandkosten Moneybookers
'', // Versandkosten Click & Buy
'', // Versandkosten Giropay
'', // Versandkosten Abholung
'', // Versandkosten Kommentar*/
csv_string($article_obj->besde) // Produktbeschreibung
);
}
function csv_string ($string) {
$string = trim($string);
$string = strip_tags($string);
$string = str_replace(';',',',$string);
$string = str_replace("\r\n",' ',$string);
$string = str_replace("\n",' ',$string);
return $string;
}
?>

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
}
?>

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
core/honorific.class.php Normal file
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
core/i18n.class.php Normal file
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;
}
}
?>

152
core/import.class.php Normal file
View File

@ -0,0 +1,152 @@
<?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, $temp_file = null) {
// get import modul data
$this->id = $id;
$data = $this->get_data();
$import_modul = $data->import_filter;
// Verwende relativen Pfad statt ROOT_DIR
$import_dir = './tmp/import/';
// Prüfe ob tmp/import Ordner existiert
if (!is_dir($import_dir)) {
// Versuche auch tmp/ zu erstellen falls nicht vorhanden
if (!is_dir('./tmp/')) {
if (!mkdir('./tmp/', 0777, true)) {
error_log("Konnte tmp-Verzeichnis nicht erstellen: ./tmp/");
return false;
}
}
if (!mkdir($import_dir, 0777, true)) {
error_log("Konnte Import-Verzeichnis nicht erstellen: " . $import_dir);
return false;
}
}
// Bestimme Quell- und Ziel-Datei
if ($temp_file && file_exists($temp_file)) {
// Neuer Weg: temp_file direkt übergeben
$source_file = $temp_file;
$target_file = $import_dir . basename($_FILES['Filedata']['name']);
} else {
// Legacy-Weg: Aus $_FILES array
$source_file = $_FILES['Filedata']['tmp_name'];
$target_file = $import_dir . basename($_FILES['Filedata']['name']);
}
// save file
if (move_uploaded_file($source_file, $target_file)) {
$log_object = Logger::get_instance();
if ($log_object) {
$log_object->info('import', "Datei gespeichert: " . $target_file);
}
// Legacy: load import modul (wird nicht mehr verwendet mit Python)
if (file_exists('./core/import_filter/' . $import_modul)) {
include_once './core/import_filter/' . $import_modul;
}
return true;
} else {
error_log("move_uploaded_file fehlgeschlagen: $source_file -> $target_file");
error_log("Current dir: " . getcwd());
error_log("File exists: " . (file_exists($source_file) ? 'yes' : 'no'));
error_log("Target dir writable: " . (is_writable(dirname($target_file)) ? 'yes' : 'no'));
return false;
}
}
} // end Export
?>

View File

@ -0,0 +1,50 @@
<?php
// get items
$sql = "SELECT id, number FROM items";
$result = $this->db->query($sql);
$items = array();
while ($obj = $result->fetch_object()) {
$items[$obj->number] = $obj->id;
}
$row = 0;
if (($handle = fopen(ROOT_DIR.'tmp/import/'.basename($_FILES['Filedata']['name']), "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$row++;
if ($row != 1) {
if (strlen($data[0]) == 5) {
$data[0] = '0'.$data[0];
} else if (strlen($data[0]) == 4) {
$data[0] = '00'.$data[0];
} else if (strlen($data[0]) == 3) {
$data[0] = '000'.$data[0];
} else if (strlen($data[0]) == 2) {
$data[0] = '0000'.$data[0];
}
if (isset($items[$data[0]])) {
$item_id = $items[$data[0]];
// endkunde
$sql1 = "UPDATE item_prices SET price_1='".str_replace(',','.',$data[4])."' WHERE customergroup_id=1 AND item_id=".$item_id;
$this->db->query($sql1);
if ($this->db->error) {
$log_object->info('Error in /core/import_class', $this->db->error.', sql:'.$sql1);
}
// haendler
$sql2 = "UPDATE item_prices SET price_1='".str_replace(',','.',$data[1])."', quantity_2=3, price_2='".str_replace(',','.',$data[2])."', quantity_3=100, price_3='".str_replace(',','.',$data[3])."' WHERE customergroup_id=101 AND item_id=".$item_id;
$this->db->query($sql2);
if ($this->db->error) {
$log_object->info('Error in /core/import_class', $this->db->error.', sql:'.$sql2);
}
} else {
$log_object->info('Import prices','Item with number '.$data[0].' not found!');
}
}
}
fclose($handle);
}
?>

View File

@ -0,0 +1,118 @@
<?php
// get items intelectra
$sql = "SELECT attribute_7, number FROM items";
$result = $this->db->query($sql);
$item_numbers = array();
while ($obj = $result->fetch_object()) {
$item_numbers[$obj->number] = 1;
$item_numbers[$obj->attribute_7] = 1;
}
$row = 0;
if (($handle = fopen(ROOT_DIR.'tmp/import/'.basename($_FILES['Filedata']['name']), "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$row++;
if ($row > 1) {
if (strlen($data[0]) == 5) {
$data[0] = '0'.$data[0];
} else if (strlen($data[0]) == 4) {
$data[0] = '00'.$data[0];
} else if (strlen($data[0]) == 3) {
$data[0] = '000'.$data[0];
} else if (strlen($data[0]) == 2) {
$data[0] = '0000'.$data[0];
}
if (!isset($item_numbers[$data[0]])) {
$short_uri = $data[2].'-'.$data[0];
$short_uri = str_replace(array('ä', 'Ä', 'ö', 'Ö', 'ü', 'Ü', 'ß'), array('ae', 'Ae', 'oe', 'Oe', 'ue', 'Ue', 'ss'), $short_uri);
$short_uri = preg_replace("@[^0-9aA-zZ\-]@si", "-", $short_uri);
$short_uri = preg_replace("@(-{2,})@si", "-", $short_uri);
$new_uri = '';
$old_uri = $short_uri;
$i = 0;
while ($new_uri == '') {
$sql = "SELECT id FROM items WHERE short_uri = '$short_uri'";
$result = $this->db->query($sql);
if ($result->num_rows == 0) {
$new_uri = $short_uri;
} else {
$i++;
$short_uri = $old_uri.'_'.$i;
}
}
$item_id = 0;
// add item
$sql = "
INSERT INTO items
SET
number='".$this->db->real_escape_string(utf8_encode($data[0]))."',
attribute_7='".$this->db->real_escape_string(utf8_encode($data[1]))."',
attribute_10='".$this->db->real_escape_string('Stück')."',
shippable=1,
shippable_inventory=1,
active=1,
manufacturer_id=1,
schema_id=3,
price_type=1,
base_price=0.0,
bargain_price_type=0,
seo_keywords='',
tax_id=1,
min_quantity=1,
buy_quantity=1,
structure_id=10682,
shipping_cost_type=0,
short_uri=\"".$this->db->real_escape_string($short_uri)."\",
google_product_category='Heim & Garten',
short_description=\"".$this->db->real_escape_string(utf8_encode($data[2]))."\",
detail_description=\"".$this->db->real_escape_string(utf8_encode($data[2]))."\",
name=\"".$this->db->real_escape_string(utf8_encode($data[2]))."\"
";
$this->db->query($sql);
$item_id = $this->db->insert_id;
if ($this->db->error) {
$log_object->info('Error in /core/import_class', $this->db->error.', sql:'.$sql);
}
if ($item_id) {
// add item to group (10682 and 9928)
$sql3 = "INSERT INTO item_structure_assign SET structure_id=10682, item_id=".$item_id;
$this->db->query($sql3);
$sql3 = "INSERT INTO item_structure_assign SET structure_id=9928, item_id=".$item_id;
$this->db->query($sql3);
if ($this->db->error) {
$log_object->info('Error in /core/import_class', $this->db->error.', sql:'.$sql3);
}
// add price endkunde
$sql1 = "INSERT INTO item_prices SET price_1='".str_replace(',','.',$data[4])."', quantity_2=0, price_2='0', quantity_3=0, price_3='0', customergroup_id=1, item_id=".$item_id;
$this->db->query($sql1);
if ($this->db->error) {
$log_object->info('Error in /core/import_class', $this->db->error.', sql:'.$sql1);
}
// add price haendler
$sql2 = "INSERT INTO item_prices SET price_1='".str_replace(',','.',$data[3]);
$sql2 .= "', quantity_2=0, price_2='0";
$sql2 .= "', customergroup_id=101, item_id=".$item_id;
$this->db->query($sql2);
if ($this->db->error) {
$log_object->info('Error in /core/import_class', $this->db->error.', sql:'.$sql2);
}
}
} else {
$log_object->info('Can not import new article with existing number!','Item with number '.$data[0].' already exists!');
}
}
}
fclose($handle);
}
?>

View File

@ -0,0 +1,32 @@
<?php
$log_object = Logger::get_instance();
$row = 0;
if (($handle = fopen(ROOT_DIR.'tmp/import/'.basename($_FILES['Filedata']['name']), "r")) !== FALSE) {
$navids = array();
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$row++;
if ($row != 1) {
// löschen mit navisionid und orginal-nr
if (strlen($data[7]) == 0) {
$sql = "DELETE FROM import_geraetezuordnung where bestellcode='".$data[2]."' AND navisionid=".$data[0];
} else if (strlen($data[7]) == 1) { // datensatz hinzufügen
$sql = "INSERT INTO import_geraetezuordnung (navisionid, einkaufsmoeglichkeitencached, bezeichnungoriginal, nr, zusatz) VALUES "
."('".$data[0]."', '".utf8_encode($data[5])."', '".utf8_encode($data[4])."', '".utf8_encode($data[2])."', '".utf8_encode($data[6])."')";
//$sql = "REPLACE INTO passendwie (navisionid, vertreiber, bestellcode) VALUES ('".$data[0]."', '".utf8_encode($data[2])."', '".$data[3]."')";
} else if (strlen($data[7]) == 2) { // alle löschen mit navisionid
$sql = "DELETE FROM import_geraetezuordnung where navisionid=".$data[0];
}
$this->db->query($sql);
if ($this->db->error) {
$log_object->info('Error in /core/imports/kinseher_geraetezuordnung.inc.php', $this->db->error.', sql:'.$sql);
}
}
}
fclose($handle);
}
?>

View File

@ -0,0 +1,70 @@
<?php
// get items intelectra
$sql = "SELECT id, number FROM items";
// get items kinseher
$sql = "SELECT id, attribute_7
FROM items";
$result = $this->db->query($sql);
$items = array();
while ($obj = $result->fetch_object()) {
$items[$obj->attribute_7] = $obj->id;
}
$row = 0;
if (($handle = fopen(ROOT_DIR.'tmp/import/'.basename($_FILES['Filedata']['name']), "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$row++;
if ($row != 1) {
if (strlen($data[0]) == 5) {
$data[0] = '0'.$data[0];
} else if (strlen($data[0]) == 4) {
$data[0] = '00'.$data[0];
} else if (strlen($data[0]) == 3) {
$data[0] = '000'.$data[0];
} else if (strlen($data[0]) == 2) {
$data[0] = '0000'.$data[0];
}
if (isset($items[$data[0]])) {
$item_id = $items[$data[0]];
//$log_object->info('Import prices','Item with number '.$data[0].' updated!');
// endkunde
$sql1 = "REPLACE INTO item_prices SET price_1='".str_replace(',','.',$data[4])."', quantity_2=0, price_2='0', quantity_3=0, price_3='0', customergroup_id=1, item_id=".$item_id;
$this->db->query($sql1);
if ($this->db->error) {
$log_object->info('Error in /core/import_class', $this->db->error.', sql:'.$sql1);
}
// haendler
$sql2 = "REPLACE INTO item_prices SET price_1='".str_replace(',','.',$data[1]);
if ($data[2] == '0') {
$sql2 .= "', quantity_2=0, price_2='0";
} else {
$sql2 .= "', quantity_2=3, price_2='".str_replace(',','.',$data[2]);
}
if ($data[3] == '0') {
$sql2 .= "', quantity_3=0, price_3='0";
} else {
$sql2 .= "', quantity_3=100, price_3='".str_replace(',','.',$data[3]);
}
$sql2 .= "', customergroup_id=101, item_id=".$item_id;
$this->db->query($sql2);
if ($this->db->error) {
$log_object->info('Error in /core/import_class', $this->db->error.', sql:'.$sql2);
}
} else {
$log_object->info('Import prices','Item with number '.$data[0].' not found!');
}
}
}
fclose($handle);
}
?>

View File

@ -0,0 +1,73 @@
<?php
$log_object = Logger::get_instance();
$row = 0;
if (($handle = fopen(ROOT_DIR.'tmp/import/'.basename($_FILES['Filedata']['name']), "r")) !== FALSE) {
$navids = array();
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$row++;
if ($row != 1) {
// löschen mit navisionid und orginal-nr
if (strlen($data[4]) == 0) {
$sql = "DELETE FROM passendwie where bestellcode='".$data[3]."' AND navisionid=".$data[0];
} else if (strlen($data[4]) == 1) { // datensatz hinzufügen
$sql = "INSERT INTO passendwie (navisionid, vertreiber, bestellcode) VALUES ('".$data[0]."', '".utf8_encode($data[2])."', '".$data[3]."')";
//$sql = "REPLACE INTO passendwie (navisionid, vertreiber, bestellcode) VALUES ('".$data[0]."', '".utf8_encode($data[2])."', '".$data[3]."')";
} else if (strlen($data[4]) == 2) { // alle löschen mit navisionid
$sql = "DELETE FROM passendwie where navisionid=".$data[0];
}
$this->db->query($sql);
if ($this->db->error) {
$log_object->info('Error in /core/imports/inseher_passendwie.inc.php', $this->db->error.', sql:'.$sql);
}
$navids[$data[0]] = 1;
}
}
fclose($handle);
}
// update items
if ($navids) {
foreach ($navids as $navid => $value) {
// delete old data in item
$sql = "UPDATE items set attribute_1='' WHERE attribute_7='".$navid."'";
$this->db->query($sql);
if ($this->db->error) {
$log_object->info('Error in /core/imports/inseher_passendwie.inc.php', $this->db->error.', sql:'.$sql);
}
// get data for item
$sql = "SELECT * FROM passendwie WHERE navisionid='".$navid."'";
$result = $this->db->query($sql);
if ($this->db->error) {
$log_object->info('Error in /core/imports/inseher_passendwie.inc.php', $this->db->error.', sql:'.$sql);
}
$data = array();
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
// write data to tiem
foreach ($data as $object) {
$content ='<p>';
$content .= '<b>'.$object->vertreiber.'</b>';
if ($object->bestellcode) {
$content .= '<br>'.$object->bestellcode;
}
$content .='</p>';
$sql = "
UPDATE items
SET
attribute_1=CONCAT_WS('', attribute_1, '".$this->db->real_escape_string($content)."')
WHERE attribute_7='".$navid."'
";
$this->db->query($sql);
if ($this->db->error) {
$log_object->info('Error in /core/imports/inseher_passendwie.inc.php', $this->db->error.', sql:'.$sql);
}
}
}
}
?>

View File

@ -0,0 +1,451 @@
<?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_id_by_date($date) {
$sql = "SELECT id FROM incomming_goods WHERE date = '" . $this->db->real_escape_string($date) . "' LIMIT 1";
$result = $this->db->query($sql);
if ($result && $result->num_rows > 0) {
$obj = $result->fetch_object();
return $obj->id;
}
return false;
}
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, $object_id = false) {
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;
}
}
}
?>

82
core/index.php Normal file
View File

@ -0,0 +1,82 @@
<?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
*/
//echo "<h3>Wartungsarbeiten bis ca. 13 Uhr!</h3>";exit();
if (isset($_GET['debug']) && $_GET['debug'] == true) {
ini_set('display_errors', 1);
error_reporting(E_ALL);
} else {
ini_set('display_errors', 1);
error_reporting(E_ALL);
}
ini_set("memory_limit","1024M");
set_time_limit(60000);
// including libs
include_once './core/base.class.php';
include_once './core/registry.class.php';
include_once './core/uri.class.php';
//echo microtime_float() - $start_time;
// base object
$base_object = new base();
Registry::set('base', $base_object);
if (isset($_GET['admin_modul'])) {
// go to admin website
include './modules/admin_init.php';
} else if (isset($_GET['soap_modul'])) {
// soap
include './modules/soap_init.php';
} else if (isset($_GET['website_modul'])) {
include './modules/website_init.php';
} else if (isset($_GET['lightningrod'])) {
include './service/lightningrod_init.php';
} else if (isset($_GET['exportpdf'])) {
include './scripts/exportpdf.php';
} else {
// go to shop website
// get structure
if (isset($_GET['structure_suri'])) {
$structure = URI::fetch_structure($_GET['structure_suri']);
/*if (!$structure) {
header('Location: /error_404/');
} else {
$_GET['menu_id'] = $structure;
}*/
$_GET['menu_id'] = $structure;
}
// get parent structures 2-8
$_GET['parent_ids'] = isset($_GET['menu_id']) ? array($_GET['menu_id']) : array();
for ($i=1;$i<9;$i++) {
if (isset($_GET['structure_suri'.$i])) {
$_GET['parent_ids'][] = URI::fetch_structure($_GET['structure_suri'.$i]);
}
}
// get item
if (isset($_GET['item_suri'])) {
$item = URI::fetch_item($_GET['item_suri']);
if (!$item) {
header('Location: /error_404/');
} else {
$_GET['item_id'] = $item;
}
}
include './modules/website_init.php';
}
?>

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
}
?>

252
core/item-db.class.php Normal file
View File

@ -0,0 +1,252 @@
<?php
/**
* ItemDatabase - Saubere DB-Abfragen für Items
* Komplett neu geschrieben nach Auto-Refactoring-Chaos
*/
class ItemDatabase {
private $db;
private $base_object;
public function __construct($base_object) {
$this->base_object = $base_object;
$this->db = $base_object->db;
}
/**
* Holt Basis-Item-Daten
*/
public function getItemData($item_id) {
$sql = "SELECT * FROM items WHERE id = " . intval($item_id);
$result = $this->db->query($sql);
return $result ? $result->fetch_object() : false;
}
/**
* Holt Herstellerinformationen
*/
public function getManufacturerInfo($vendor_id) {
if (!$vendor_id) return [];
$sql = "SELECT * FROM herstellerinformationen WHERE id = ?";
$stmt = $this->db->prepare($sql);
if ($stmt) {
$vendor_id_int = intval($vendor_id);
$stmt->bind_param("i", $vendor_id_int);
$stmt->execute();
$result = $stmt->get_result();
return $result->fetch_assoc() ?: [];
}
return [];
}
/**
* Holt Admin User Daten
*/
public function getAdminUser($user_id) {
if (!$user_id) return null;
$sql = "SELECT * FROM customers WHERE id = " . intval($user_id);
$result = $this->db->query($sql);
return $result ? $result->fetch_object() : null;
}
/**
* Holt Sicherheitshinweise (REAKTIVIERT + FALLBACK)
* Übertragen aus item.class.php Zeile 885-936
* PRIORITÄT 1: attribute_5 (manuell)
* PRIORITÄT 2: attribute_7 (Navision-Automatik)
*/
public function getSecurityWarnings($navision_id, $manual_warning_ids = null) {
$warnings = [];
$documents = [];
// PRIORITÄT 1: Manuelle Warning-IDs aus attribute_5 (für alte Artikel)
if (!empty($manual_warning_ids) && preg_match('/^[\d,\s]+$/', $manual_warning_ids)) {
// SPECIAL CASE: warning_id 199 = Allgemeine Sicherheitsdokumente
if (trim($manual_warning_ids) == '199') {
// Lade das PDF aus sicherheitshinweis.bild für warning_id 199
$sql = "SELECT bild, name FROM sicherheitshinweis WHERE warning_id = 199";
$result = $this->db->query($sql);
if ($result && $row = $result->fetch_assoc()) {
if (!empty($row['bild'])) {
$documents[] = [
'file_name' => $row['bild'] . '.pdf',
'label' => $row['name'] ?? 'Allgemeine Sicherheitshinweise'
];
}
}
return [
'warnings' => [],
'documents' => $documents,
'source' => 'manual_attribute_5_document_199'
];
}
// Normale Warning-IDs (1-90): Nur Symbole, keine Dokumente
$warnings = $this->loadWarnings($manual_warning_ids);
return [
'warnings' => $warnings,
'documents' => [],
'source' => 'manual_attribute_5'
];
}
// PRIORITÄT 2: Automatische Navision-Logik aus attribute_7
if (!empty($navision_id)) {
$sql = "SELECT * FROM sicherheitshinweis_item WHERE navision_id = ?";
$stmt = $this->db->prepare($sql);
if ($stmt) {
$stmt->bind_param("s", $navision_id);
$stmt->execute();
$result = $stmt->get_result();
$warningDocsList = $result->fetch_assoc();
if ($warningDocsList) {
// Sicherheitswarnungen laden
$warningIdsList = $warningDocsList['warning_ids'] ?? null;
$warnings = $this->loadWarnings($warningIdsList);
// Dokumente laden
$documentColumns = [
'Bedienungsanleitung' => 'Allg. Sicherheitshinweise',
'EU_Datenblatt' => 'EU-Datenblatt',
'Energielabel' => 'Energielabel',
'Produktdatenblatt' => 'Produktdatenblatt',
'Sicherheitsdatenblatt' => 'Sicherheitsdatenblatt',
'Zertifikat' => 'Zertifikat',
'null_feld' => 'Allg. Sicherheitshinweise'
];
foreach ($documentColumns as $column => $label) {
if (!empty($warningDocsList[$column])) {
$pdfs = explode(',', $warningDocsList[$column]);
$pdfs = array_map('trim', $pdfs);
$pdfs = array_map(fn($pdf) => trim($pdf, '"'), $pdfs);
foreach ($pdfs as $pdf) {
if (!empty($pdf)) {
$documents[] = [
'file_name' => $pdf,
'label' => $label
];
}
}
}
}
}
}
}
return [
'warnings' => $warnings,
'documents' => $documents,
'source' => !empty($navision_id) ? 'navision_attribute_7' : 'empty'
];
}
/**
* Lädt Sicherheitswarnungen basierend auf IDs
* Übertragen aus item.class.php loadWarnings()
*/
private function loadWarnings($warningIdsList) {
$articleWarnings = [];
if ($warningIdsList) {
$ids = explode(',', $warningIdsList);
$ids = array_map('trim', $ids);
$ids = array_filter($ids, 'is_numeric');
if (!empty($ids)) {
$placeholders = implode(',', array_fill(0, count($ids), '?'));
$sqlWarn = "
SELECT warning_id, name, beschreibung, bild, bildnr, bilddateiname
FROM sicherheitshinweis
WHERE warning_id IN ($placeholders)
ORDER BY warning_id
";
$stmtWarn = $this->db->prepare($sqlWarn);
if ($stmtWarn) {
$types = str_repeat('i', count($ids));
$stmtWarn->bind_param($types, ...$ids);
$stmtWarn->execute();
$resultWarn = $stmtWarn->get_result();
$articleWarnings = $resultWarn->fetch_all(MYSQLI_ASSOC);
// Bild-Dateinamen generieren
foreach ($articleWarnings as &$warning) {
$warning['image_filename'] = $this->generateImageFileName($warning);
}
}
}
}
return $articleWarnings;
}
/**
* Generiert Bild-Dateinamen für Sicherheitshinweise
* Übertragen aus item.class.php generateImageFileName()
*/
private function generateImageFileName($warning) {
// Verwende "bilddateiname", wenn vorhanden
if (!empty($warning['bilddateiname'])) {
return $warning['bilddateiname'];
}
// Verwende "bildnr", wenn vorhanden
if (!empty($warning['bildnr'])) {
return $warning['bildnr'] . ".gif";
}
// Generiere basierend auf der Bildnummer
if (!empty($warning['bild'])) {
$baseName = "ISO_7010_";
$suffix = ".svg";
// Extrahiere die letzten 3 Ziffern der Bildnummer
$imageFileId = substr($warning['bild'], -4);
return $baseName . $imageFileId . $suffix;
}
// Kein Bild verfügbar
return null;
}
/**
* Performance-Debug - DIREKT AUF SEITE ausgeben
*/
public function debugItemPerformance($item_id) {
echo "<div style='background:yellow;padding:10px;margin:10px;border:2px solid red;'>";
echo "<h2>🔍 PERFORMANCE DEBUG für Item $item_id</h2>";
$this->benchmarkQuery("SELECT * FROM items WHERE id = $item_id", "1. Base Item Data");
$this->benchmarkQuery("SELECT * FROM item_files WHERE item_id = $item_id", "2. Files");
$this->benchmarkQuery("SELECT * FROM customers WHERE id = 1", "3. Test Admin User");
echo "<strong>✅ PERFORMANCE DEBUG ABGESCHLOSSEN</strong>";
echo "</div>";
}
/**
* Benchmark eine einzelne Abfrage - DIREKT AUF SEITE
*/
public function benchmarkQuery($sql, $description = '') {
$start = microtime(true);
$result = $this->db->query($sql);
$end = microtime(true);
$time = round(($end - $start) * 1000, 2);
echo "<p><strong>$description:</strong> {$time}ms<br>";
echo "<code>$sql</code></p>";
return $result;
}
}

5884
core/item.class.php Normal file

File diff suppressed because it is too large Load Diff

5341
core/item.class.php.backup Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,304 @@
<?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) {
// 🚀 FIX: Lightweight item data query - verhindert 504 Timeouts!
// Statt vollständigem Item->get_data() nur benötigte Felder laden
$sql = "SELECT id, number, name, tax_id FROM items WHERE id = " .
$this->db->real_escape_string($data['item_id']) . " LIMIT 1";
$result = $this->db->query($sql);
if (!$result || $result->num_rows === 0) {
$this->error = 'Item not found with ID: ' . $data['item_id'];
return false;
}
$item = $result->fetch_object();
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_id)."',
'".$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);
// 🚀 FIX: Lightweight inventory update - keine full Item-Instanz nötig
$count = $this->get_item_inventory_count($item->id);
$sql = "UPDATE items SET inventory = " . intval($count) .
" WHERE id = " . $this->db->real_escape_string($item->id);
$this->db->query($sql);
return 1;
}
public function remove($data) {
// 🚀 FIX: Lightweight - kein vollständiges Item-Objekt nötig!
$item_id = intval($data['item_id']);
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);
}
// 🚀 FIX: Lightweight inventory update - keine full Item-Instanz nötig
$count = $this->get_item_inventory_count($item_id);
$sql = "UPDATE items SET inventory = " . intval($count) .
" WHERE id = " . $this->db->real_escape_string($item_id);
$this->db->query($sql);
return 1;
}
public function get_item_inventory_count($item_id) {
$count = 0;
// Ensure item_id is valid
if (!$item_id || !is_numeric($item_id)) {
return 0;
}
$sql = "SELECT amount, inventory_object_type_id
FROM item_inventory
WHERE item_id = ".intval($item_id);
$result = $this->db->query($sql);
if ($result && $result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
// Ensure amount is numeric
$amount = is_numeric($obj->amount) ? floatval($obj->amount) : 0;
if ($obj->inventory_object_type_id == 2) {
// wareneingang
$count += $amount;
} else {
// warenausgang
$count -= $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;
}
}
}

View File

@ -0,0 +1,21 @@
<?php
$item_fields = array(
'number' => 1,
'name' => 1,
'short_description' => 0,
'detail_description' => 0,
'manufacturer_id' => 0,
'manufacturer_item_number' => 1,
'vendor_id' => 1,
'vendor_item_number' => 1,
'ean_code' => 1,
'active' => 1
);
?>

260
core/itemhelper.class.php Normal file
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
core/itemschema.class.php Normal file
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
core/itemtype.class.php Normal file
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
}

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
*/
include_once './core/base/edit.class.php';
class ItemTypeDefinition_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('item_type_definitions');
} // end get_data
public function delete_data($id = false) {
if ($id) {
$this->set_id($id);
}
return $this->delete_one('item_type_definitions');
} // end delete
public function create($data) {
return $this->create_one('item_type_definitions', $data);
} // end create
public function update($data, $id = false) {
if ($id) {
$this->set_id($id);
}
return $this->update_one('item_type_definitions', $data);
} // end update
}// end ItemTypeDefinition_Edit
/* EOF */

120
core/language.class.php Normal file
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;
}
}
?>

147
core/layout.class.php Normal file
View File

@ -0,0 +1,147 @@
<?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 layout extends Smarty {
public $currentComGroupPath;
public $allMetaTags;
public $metaTagStyle;
public $shopProducers;
public $theme_style = '';
public $theme_dir = '';
public $maincontent = '';
public $metaTagObject;
public $base_object;
function start($base_object) {
$this->base_object = $base_object;
// get domain and theme configuration
include_once './core/domain.class.php';
$domain_object = new Domain($this->base_object);
$domain = $domain_object->get_domain_config($_SERVER['SERVER_NAME']);
if (!$domain) {
echo "Keine Konfiguration gefunden!";
exit();
}
// get default domain config user language
include_once './core/language.class.php';
$language_object = new Language($base_object);
if (!isset($_SESSION['user_lang'])) {
$language = $language_object->load($domain->standard_language_id);
$_SESSION['user_lang'] = $language['iso_639_1'];
}
$this->assign('i18n_config', isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '');
$this->assign('user_lang', $_SESSION['user_lang']);
include_once './core/shop_theme.class.php';
$theme_object = new Shop_theme($this->base_object);
$theme = $theme_object->get_by_id($domain->standard_theme_id);
$this->assign('domain_config', $domain);
$this->assign('theme_config', $theme);
$this->assign('SERVER_NAME', $_SERVER['SERVER_NAME']);
// get text for templates
include_once './core/text_translation.class.php';
$text_class = new Text_translation($this->base_object);
$text = $text_class->get_text($_SESSION['user_lang']);
$this->assign('template_text', $text);
// set content charset
header('content-type: text/html; charset=utf-8');
$this->__construct();
$this->compile_id = SHOP_SYSTEM.'_'.$base_object->config->shopConfiguration['THEME'];
$this->compile_dir = ROOT_DIR.'/tmp/smarty_compile';
$this->cache_dir = ROOT_DIR.'/tmp/smarty_cache';
$tpl_paths = array();
$tpl_paths[] = ROOT_DIR.'/web/'.SHOP_SYSTEM.'/themes/'.$base_object->config->shopConfiguration['THEME'].'/templates';
if ($theme->parent_theme) {
$tpl_paths[] = ROOT_DIR.'/themes/'.$theme->parent_theme.'/templates';
}
$this->template_dir = $tpl_paths;
// if ($theme->parent_theme) {
// $this->template_dir = ROOT_DIR.'/themes/'.$theme->parent_theme.'/templates';
// } else {
// $this->template_dir = ROOT_DIR.'/web/'.SHOP_SYSTEM.'/themes/'.$base_object->config->shopConfiguration['THEME'].'/templates';
// }
//$smarty->caching = true;
$this->debugging = false;
$this->theme_dir = STANDARD_DIR.'web/'.SHOP_SYSTEM.'/themes/'.$base_object->config->shopConfiguration['THEME'];
// important variables
$this->assign('PARENT_THEME_DIR', STANDARD_DIR.'themes/'.$theme->parent_theme);
$this->assign('FULL_PARENT_THEME_DIR', ROOT_DIR.STANDARD_DIR.'themes/'.$theme->parent_theme);
$this->assign('THEME_DIR', $this->theme_dir);
$this->assign('SHOP_DIR', STANDARD_DIR.'web/'.SHOP_SYSTEM.'/');
$this->assign('SUB_DIR', STANDARD_DIR);
$this->assign('currentURI', $_SERVER['REQUEST_URI']);
$this->assign('system_configuration', $base_object->config->shopConfiguration);
$currentSURI = preg_replace("@[\?|\&].*@", "", $_SERVER['REQUEST_URI']);
$currentSURI = preg_replace("@Seite-[0-9]+/@si", "", $currentSURI);
$this->assign('currentSURI', $currentSURI);
$this->assign('servername', $_SERVER['SERVER_NAME']);
if ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) {
$this->assign('serverProtocol', 'https');
} else {
$this->assign('serverProtocol', 'http');
}
return;
}
function _fetch ($template) {
$content = '';
if (isset($this->base_object->config->shopConfiguration['customized_templates'][$template])) {
// Save current tpl path
$formerTplDir = $this->template_dir;
// Change tpl path
$this->template_dir = str_replace(array('//', '\\'), array('/', '/'), ROOT_DIR.'/web/'.SHOP_SYSTEM.'/themes/'.$this->base_object->config->shopConfiguration['THEME'].'/templates');
$content = $this->fetch($template);
// Restore tpl path
$this->template_dir = $formerTplDir;
} else {
$content = $this->fetch($template);
}
return $content;
}
public function show_site() {
$this->assign('maincontent', $this->maincontent);
$this->assign('items_in_memory', isset($_COOKIE['article_memorize']));
echo $this->_fetch('main.tpl');
}
public static function i18n_format_date($format, $date) {
$date = mktime(0,0,0,substr($date,5,2),substr($date,8,2),substr($date,0,4));
return date($format, $date);
}
public static function i18n_format_price($price) {
return $price.' EUR';
}
}
?>

87
core/logger.class.php Normal file
View File

@ -0,0 +1,87 @@
<?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 Logger {
private $log_file_name = 'log.csv';
private $log_file_path = 'tmp/';
private $log_file_handler;
private $full_path;
private static $instance = false;
protected function __construct() {
$this->full_path = './'.$this->log_file_path.$this->log_file_name;
$this->log_file_handler = fopen($this->full_path, 'a') or die;
}
function __destruct() {
fclose($this->log_file_handler);
}
private function __clone() {}
public static function get_instance() {
if (self::$instance) {
return self::$instance;
} else {
self::$instance = new Logger();
return self::$instance;
}
}
public function info($file, $message) {
$info = 'info; '.SHOP_SYSTEM.'; '.date("y-m-d; H:i:s",time()).'; '.$file.': '.$message."\n";
fwrite($this->log_file_handler, $info);
}
public function warning($file, $message) {
$warning = 'warning; '.SHOP_SYSTEM.'; '.date("y-m-d; H:i:s",time()).'; '.$file.': '.$message."\n";
fwrite($this->log_file_handler, $warning);
}
public function error($file, $message) {
$error = 'error; '.SHOP_SYSTEM.'; '.date("y-m-d; H:i:s",time()).'; '.$file.': '.$message."\n";
fwrite($this->log_file_handler, $error);
}
public function dump_var($file, $var) {
$dump_var = 'dump; '.SHOP_SYSTEM.'; '.date("y-m-d; H:i:s",time()).'; '.$file.': '.$var."\n";
fwrite($this->log_file_handler, $dump_var);
}
public function dump_array($file, $array) {
$dump_array = 'dump; '.SHOP_SYSTEM.'; '.date("y-m-d; H:i:s",time()).'; '.$file.': '.implode(",", $array)."\n";
fwrite($this->log_file_handler, $dump_array);
}
public function print_log_file() {
return $this->full_path;
}
public function get_last_log() {
$text = '';
$lines = file ($this->full_path);
$start = 0;
if (count($lines) < 10) {
$stop = count($lines)-1;
} else {
$start = count($lines) - 11;
$stop = count($lines)-1;
}
for ($i = $start;$i <= $stop; $i++) {
$text .= $lines[$i].'<br>';
}
return $text;
}
}

121
core/mail.class.php Normal file
View File

@ -0,0 +1,121 @@
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require_once 'phpmailer/Exception.php';
require_once 'phpmailer/PHPMailer.php';
require_once 'phpmailer/SMTP.php';
class mail_tools {
function __construct($base_object)
{
$this->base_object = $base_object;
}
function send_mail($subject, $message, $recipient = false, $logo = false, $recipients_from_db = false, $reply_to = false, $from_mail = false, $from_name = false, $attachments = false)
{
$mail = new PHPMailer(true);
date_default_timezone_set("Europe/Berlin");
$subject = utf8_decode($subject);
$from_name = ($from_name) ? mb_encode_mimeheader(utf8_decode($from_name), "UTF-8", "Q") : false;
$recipients['to'] = ($recipient) ? $recipient : $global_mail_settings['mail_to']['global'];
$email = $this->base_object->config->shopConfiguration['system_email'];
$from_mail = $this->base_object->config->shopConfiguration['system_email'];
$host = $this->base_object->config->shopConfiguration['system_email_host'];
$user = $this->base_object->config->shopConfiguration['system_email_user'];
$pass = $this->base_object->config->shopConfiguration['system_email_password'];
$from_name = $this->base_object->config->shopConfiguration['system_email_name'];
$reply_to = $this->base_object->config->shopConfiguration['system_email_reply'];
// read css file
$file_name = (isset($this->base_object->layout) && $this->base_object->layout) ? $this->base_object->layout->template_dir.'/../media/css/mail.css' : '';
$css = '';
if (file_exists($file_name)) {
$handle = fopen($file_name, "r");
while (!feof($handle)) {
$css .= fgets($handle,2);
};
fclose($handle);
}
try {
//Server settings
/*$mail->SMTPDebug = SMTP::DEBUG_SERVER; // OUTPUT DEBUG
$mail->SMTPDebug = 3;*/
$mail->isSMTP();
$mail->Host = $host;
$mail->SMTPAuth = true;
$mail->Username = $user;
$mail->Password = $pass;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->SMTPOptions = array('ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => false
));
$mail->Port = 587;
//Recipients
$mail->setFrom($from_mail, $from_name);
$mail->addAddress($recipients['to']);
if ($reply_to)
$mail->addReplyTo($reply_to, $from_name);
if (isset($recipients['cc']) && $recipients['cc'])
$mail->addCC($recipients['cc']);
if (isset($recipients['bcc']) && $recipients['bcc'])
$mail->addBCC($recipients['bcc']);
//Attachments
if ($attachments != false)
foreach ($attachments as $att)
$mail->addStringAttachment($att->content, $att->file_name);
//Content
$mail->isHTML(true);
$mail->Subject = $subject;
$inline_message = $inline_message ?? '';
$inline_logo = $inline_logo ?? '';
$body = '<html><head><style type="text/css">'.$css.'</style></head><body>'.utf8_decode($message).'<br /><br />'.utf8_decode($inline_message).'<br />'.$inline_logo.'</body></html>';
$mail->Body = $body;
//$mail->AltBody = ;
$mail->send();
return true;
}
catch(Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
return false;
}
} // end send_mail
public function checkmail($email)
{
$mail_addr = explode(';', $email);
$ready_mail = $mail_addr[0];
$mail_parts = explode('@', $ready_mail);
$domain = $mail_parts[1];
if (!$domain) {
return false;
}
if (function_exists('checkdnsrr')) {
if (checkdnsrr($domain, "MX")) {
if (function_exists('getmxrr')) {
if (!getmxrr($domain, $mxhosts)) {
return false;
}
}
} else {
return false;
}
}
return $ready_mail;
} // end checkmail
}
?>

View File

@ -0,0 +1,140 @@
<?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 mail_tools {
function __construct($base_object) {
$this->base_object = $base_object;
}
function send_mail($subject, $message, $recipient = false, $logo = false, $recipients_from_db = false, $reply_to = false, $from_mail = false, $from_name = false, $attachments = false) {
date_default_timezone_set("Europe/Berlin");
$subject = utf8_decode($subject);
$from_name = ($from_name) ? mb_encode_mimeheader(utf8_decode($from_name), "UTF-8", "Q") : false;
$recipients['to'] = ($recipient) ? $recipient : $global_mail_settings['mail_to']['global'];
include_once 'Mail.php';
include_once 'Mail/mime.php';
$email = $this->base_object->config->shopConfiguration['system_email'];
$from_mail = $this->base_object->config->shopConfiguration['system_email'];
$host = $this->base_object->config->shopConfiguration['system_email_host'];
$user = $this->base_object->config->shopConfiguration['system_email_user'];
$pass = $this->base_object->config->shopConfiguration['system_email_password'];
$from_name = $this->base_object->config->shopConfiguration['system_email_name'];
$reply = '';
$crlf = "\n";
$hdrs = array(
'From' => (($from_name) ? $from_name : $user).' <'.(($from_mail) ? $from_mail : $reply).'>',
'Sender' => $name.' <'.$email.'>',
'Reply-To'=> (($reply_to) ? $reply_to : $reply),
'Subject' => $subject,
'To' => $recipients['to'],
'Cc' => $recipients['cc'],
'Bcc' => $recipients['bcc']
);
$mime = new Mail_mime($crlf);
$inline_message = '';
/*if ($logo) {
if ($logo == 'intern') {
$mime->addHTMLimage(ROOT_DIR.'web/'.SHOP_SYSTEM.'/images/static/logo4mail2.jpg', 'image/jpeg');
$inline_logo = '<img src="'.ROOT_DIR.'web/'.SHOP_SYSTEM.'images/static/logo4mail2.jpg">';
$inline_message .= '<b>ELISA</b> - <b>E</b>asyway-Shop <b>L</b>ive <b>I</b>nformation <b>S</b>ervices and <b>A</b>nnouncements';
} else if ($logo == 'extern') {
$inline_message .= $global_mail_settings['inline_text'];
$mime->addHTMLimage(ROOT_DIR.'web/'.SHOP_SYSTEM.'/themes/'.THEME.'/images/logo4mail.jpg', 'image/jpeg');
$inline_logo = '<img src="'.ROOT_DIR.'web/'.SHOP_SYSTEM.'/themes/'.THEME.'/images/logo4mail.jpg">';
}
} else {*/
$inline_logo = '';
//}
// read css file
$file_name = $this->base_object->layout->template_dir.'/../media/css/mail.css';
if (file_exists($file_name)) {
$handle = fopen($file_name, "r");
$css = '';
while (!feof($handle)) {
$css .= fgets($handle,2);
};
fclose($handle);
}
$mime->setHTMLBody('<html><head><style type="text/css">'.$css.'</style></head><body>'.utf8_decode($message).'<br /><br />'.utf8_decode($inline_message).'<br />'.$inline_logo.'</body></html>');
// attachments
if ($attachments) {
foreach ($attachments as $attachment) {
if (is_object($attachment)) {
$mime->addAttachment(
$attachment->content,
'application/octet-stream',
$attachment->file_name,
false,
'base64',
'attachment'
);
} else {
$mime->addAttachment($attachment);
}
}
}
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mailx =& Mail::factory('smtp', array('host' => $host, 'auth' => true,'socket_options' => array('ssl' => array('verify_peer_name' => false, 'allow_self_signed' => true)), 'username' => $user, 'password' => $pass));
$sent = $mailx->send(implode(',', $recipients), $hdrs, $body);
if (PEAR::isError($sent)) {
$log_object = Logger::get_instance();
$log_object->info("Error in /core/mail.class.php->send_mail()", "Cant't send email. Sendstate: ".$sent);
return false;
} else {
$log_object = Logger::get_instance();
$log_object->info("Error in /core/mail.class.php->send_mail()", "erfolgreich gesendet");
return true;
}
return true;
} // end send_mail
public function checkmail($email) {
$mail_addr = explode(';', $email);
$ready_mail = $mail_addr[0];
$mail_parts = explode('@', $ready_mail);
$domain = $mail_parts[1];
if (!$domain) {
return false;
}
if (function_exists('checkdnsrr')) {
if (checkdnsrr($domain, "MX")) {
if (function_exists('getmxrr')) {
if (!getmxrr($domain, $mxhosts)) {
return false;
}
}
} else {
return false;
}
}
return $ready_mail;
} // end checkmail
}

View File

@ -0,0 +1,4 @@
<?php
echo date_default_timezone_get()."<br>";
phpinfo();
?>

529
core/main.class.php Normal file
View File

@ -0,0 +1,529 @@
<?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 Main {
protected $db;
public function __construct($base_object) {
$this->db = $base_object->db;
}
public function get_list_items($setting) {
// init rewrite functions
$rewrite_indexes = array();
$format_indexes = array();
$count_fields = count($this->list_table_config['list_fields']);
for ($i=0;$i<$count_fields;$i++) {
if (isset($this->list_table_config['list_fields'][$i]['rewrite_function'])) {
$this->list_table_config['list_fields'][$i]['rewrite_function'] = $this->{$this->list_table_config['list_fields'][$i]['rewrite_function']}();
$rewrite_indexes[] = $i;
}
if ($setting['data_format'] == 1 && isset($this->list_table_config['list_fields'][$i]['format'])) {
$format_indexes[] = $i;
}
}
$data = array();
$filter_sql = '';
// search
if (isset($setting['search_string']) && $setting['search_string'] != '') {
$count_search_fields = count($this->list_table_config['search_fields']);
for ($i=0;$i<$count_search_fields;$i++) {
if ($i == 0) {
$filter_sql .= $this->list_table_config['search_fields'][$i]." like '%".$setting['search_string']."%'";
} else {
$filter_sql .= " || ".$this->list_table_config['search_fields'][$i]." like '%".$setting['search_string']."%'";
}
}
if ($filter_sql) {
$filter_sql = '('.$filter_sql.')';
}
}
// list filter
$list_filter = '';
if (isset($this->list_table_config['list_filter']) && $this->list_table_config['list_filter']) {
foreach ($this->list_table_config['list_filter'] as $filter_item) {
if (isset($setting['list_filter'][$filter_item['db_field']])) {
if (isset($filter_item['relational_operator'])) {
if ($list_filter) {
$list_filter .= " AND ".$filter_item['db_field']." ".$filter_item['relational_operator']." '".$setting['list_filter'][$filter_item['db_field']]."'";
} else {
$list_filter .= $filter_item['db_field']." ".$filter_item['relational_operator']." '".$setting['list_filter'][$filter_item['db_field']]."'";
}
} else {
if ($list_filter) {
$list_filter .= " AND ".$filter_item['db_field']." ".$setting['list_filter'][$filter_item['db_field']];
} else {
$list_filter .= $filter_item['db_field']." ".$setting['list_filter'][$filter_item['db_field']];
}
}
}
}
if ($list_filter) {
$list_filter = '('.$list_filter.')';
}
}
if (isset($this->list_table_config['permanent_filter']) && $this->list_table_config['permanent_filter']) {
foreach ($this->list_table_config['permanent_filter'] as $filter_item) {
if ($list_filter) {
$list_filter .= " AND ";
}
if (isset($filter_item['accept_null']) && $filter_item['accept_null'] == 1) {
$list_filter .= '('.$filter_item['db_field']." ".$filter_item['relational_operator']." '".$filter_item['value']."' OR ".$filter_item['db_field']." IS NULL)";
} else {
$list_filter .= $filter_item['db_field']." ".$filter_item['relational_operator']." '".$filter_item['value']."'";
}
}
}
if ($list_filter) {
if ($filter_sql) {
$filter_sql .= ' AND ('.$list_filter.')';
} else {
$filter_sql = ' ('.$list_filter.') ';
}
}
// group by
$group_by = '';
if (isset($this->list_table_config['list_group_by']) && $this->list_table_config['list_group_by']) {
$group_by = ' GROUP BY '.$this->list_table_config['db_table'].'.'.$this->list_table_config['list_group_by'];
}
$select_fields = ' '.$this->list_table_config['db_table'].'.'.$this->list_table_config['db_id_field'].' as object_id';
$count_fields = count($this->list_table_config['list_fields']);
// ref tables
$ref_tables = array();
for ($i=0;$i<$count_fields;$i++) {
if (isset($this->list_table_config['list_fields'][$i]['ref_db_table'])) {
if (isset($this->list_table_config['list_fields'][$i]['function']) && $this->list_table_config['list_fields'][$i]['function'] == 'count') {
$select_fields .= ', count('.$this->list_table_config['list_fields'][$i]['ref_db_table'].'.'.$this->list_table_config['list_fields'][$i]['db_field'].')';
} else {
$select_fields .= ', '.$this->list_table_config['list_fields'][$i]['ref_db_table'].'.'.$this->list_table_config['list_fields'][$i]['db_field'];
}
$ref_tables[$this->list_table_config['list_fields'][$i]['ref_db_table']] = $this->list_table_config['db_table'].'.'.$this->list_table_config['list_fields'][$i]['ref_db1_field'].'='.$this->list_table_config['list_fields'][$i]['ref_db_table'].'.'.$this->list_table_config['list_fields'][$i]['ref_db2_field'];
} else {
if (isset($this->list_table_config['list_fields'][$i]['function']) && $this->list_table_config['list_fields'][$i]['function'] == 'count') {
$select_fields .= ', count('.$this->list_table_config['db_table'].'.'.$this->list_table_config['list_fields'][$i]['db_field'].')';
} else {
$select_fields .= ', '.$this->list_table_config['db_table'].'.'.$this->list_table_config['list_fields'][$i]['db_field'];
}
}
}
$ref_tables_string = '';
foreach ($ref_tables as $key => $value) {
$ref_tables_string .= ' LEFT JOIN '.$key.' ON '.$value;
}
/* old code:
$ref_tables_string = '';
$multitable = '';
foreach ($ref_tables as $key => $value) {
$ref_tables_string .= ', '.$key;
if ($multitable) {
$multitable .= ' AND '.$value;
} else {
$multitable .= $value;
}
}
if ($multitable) {
if ($filter_sql) {
$filter_sql = $filter_sql.' AND ('.$multitable.')';
} else {
$filter_sql = $multitable;
}
}
*/
if ($filter_sql) {
$filter_sql = ' WHERE '.$filter_sql;
}
// get count items
$sql = "SELECT COUNT(distinct(".$this->list_table_config['db_table'].'.'.$this->list_table_config['db_id_field'].")) FROM ".$this->list_table_config['db_table'].$ref_tables_string.$filter_sql;
$result = $this->db->query($sql);
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/main_class.php->get_list_items()', $this->db->error.', sql:'.$sql);
$count = 0;
} else {
$count = $result->fetch_array();
}
$data['count_list_items'] = $count[0];
$data['count_pages'] = (int)ceil($data['count_list_items'] / $setting['max_list_items']);
if ($data['count_pages'] < 1) {
$data['count_pages'] = 1;
}
if ($data['count_pages'] < $setting['actual_page']) {
$setting['actual_page'] = $data['count_pages'];
}
if ($setting['actual_page'] < 1) {
$setting['actual_page'] = 1;
}
$sql = "SELECT ".$select_fields." FROM ".$this->list_table_config['db_table'].$ref_tables_string.$filter_sql.$group_by;
// set order
if (isset($setting['sort_item']) && $setting['sort_item'] && isset($setting['sort_direction'])) {
if ($setting['sort_direction'] == 'up') {
$sql .= " ORDER BY ".$setting['sort_item']." ASC ";
} else {
$sql .= " ORDER BY ".$setting['sort_item']." DESC ";
}
} else if (isset($this->list_table_config['default_sort_item'])) {
if (isset($this->list_table_config['default_sort_direction']) && $this->list_table_config['default_sort_direction'] == 'up') {
$sql .= " ORDER BY ".$this->list_table_config['default_sort_item']." ASC ";
}
else {
$sql .= " ORDER BY ".$this->list_table_config['default_sort_item']." DESC ";
}
}
// set limit
if (isset($setting['max_list_items']) && isset($setting['actual_page'])) {
if ($setting['actual_page'] == 1) {
$sql .= " LIMIT 0, ".$this->db->real_escape_string($setting["max_list_items"]);
} else {
$start = (($setting['actual_page'] - 1) * $setting['max_list_items']);
$sql .= " LIMIT ".$start.', '.$this->db->real_escape_string($setting['max_list_items']);
}
}
$data['actual_page'] = $setting['actual_page'];
$data['sort_item'] = $setting['sort_item'];
$data['sort_direction'] = $setting['sort_direction'];
$result = $this->db->query($sql);
//echo $sql;exit();
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/main_class.php->get_list_items()', $this->db->error.', sql:'.$sql);
}
$data['list_items'] = array();
if ($result) {
while ($row = $result->fetch_assoc()) {
// rewrite result
if ($rewrite_indexes) {
foreach ($rewrite_indexes as $index) {
$db_field = $this->list_table_config['list_fields'][$index]['db_field'];
$field_value = isset($row[$db_field]) ? $row[$db_field] : '';
// Handle NULL/empty values - use '0' key for empty structure_id
if ($field_value === '' || $field_value === null) {
$field_value = '0';
}
if (isset($this->list_table_config['list_fields'][$index]['rewrite_function'][$field_value])) {
$row[$db_field] = $this->list_table_config['list_fields'][$index]['rewrite_function'][$field_value];
}
}
}
// string formating
if ($format_indexes) {
foreach ($format_indexes as $index) {
if (isset($this->list_table_config['list_fields'][$index]['db_field_rename'])) {
$this->list_table_config['list_fields'][$index]['db_field'] = $this->list_table_config['list_fields'][$index]['db_field_rename'];
}
$row[$this->list_table_config['list_fields'][$index]['db_field']] = $this->{$this->list_table_config['list_fields'][$index]['format']}($row[$this->list_table_config['list_fields'][$index]['db_field']]);
}
}
$data['list_items'][] = $row;
}
}
return $data;
}
public function load($object_id) {
$sql = "
SELECT *
FROM ".$this->list_table_config['db_table']."
WHERE ".$this->list_table_config['db_id_field']."='".$this->db->real_escape_string($object_id)."'";
$result = $this->db->query($sql);
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/main_class.php->load()', $this->db->error.', sql:'.$sql);
return false;
}
$data = $result->fetch_array();
return $data;
}
public function save($data, $object_id = false) {
if ($data) {
if ($object_id) {
// get old data
$old_data = $this->load($object_id);
// update in database
$sql = "UPDATE ".$this->list_table_config['db_table']."
SET ";
// check data
$object_data = array();
$events = array();
foreach ($this->list_table_config['edit_fields'] as $edit_field) {
// quote values
$correct = 0;
if (isset($edit_field['auto_value'])) {
$edit_field['auto_value']['func_param']['object_id'] = $object_id;
$edit_field['auto_value']['func_param']['db_field'] = $edit_field['db_field'];
$edit_field['auto_value']['func_param']['data'] = $data;
$data[$edit_field['db_field']] = $this->{$edit_field['auto_value']['function']}($edit_field['auto_value']['func_param']);
}
if (isset($data[$edit_field['db_field']]) && !isset($edit_field['function'])) {
if ($edit_field['type'] == 'text') {
$sql .= $edit_field['db_field'].'="'.$this->db->real_escape_string($data[$edit_field['db_field']]).'", ';
$correct = 1;
} else if ($edit_field['type'] == 'multitext') {
$sql .= $edit_field['db_field'].'="'.$this->db->real_escape_string($data[$edit_field['db_field']]).'", ';
$correct = 1;
} else if ($edit_field['type'] == 'formatedtext') {
$sql .= $edit_field['db_field'].'="'.$this->db->real_escape_string($data[$edit_field['db_field']]).'", ';
$correct = 1;
} else if ($edit_field['type'] == 'int' && $data[$edit_field['db_field']] != '') {
$sql .= $edit_field['db_field'].'='.$this->db->real_escape_string($data[$edit_field['db_field']]).', ';
$correct = 1;
} else if ($edit_field['type'] == 'float' && $data[$edit_field['db_field']] != '') {
$sql .= $edit_field['db_field'].'='.$this->db->real_escape_string($data[$edit_field['db_field']]).', ';
$correct = 1;
}
}
// change actions
if (isset($edit_field['change_function']) && $correct == 1 && $old_data[$edit_field['db_field']] != $data[$edit_field['db_field']]) {
$events[] = array(
'action' => 'change',
'object_id' => $object_id,
'function' => $edit_field['change_function'],
'db_field' => $edit_field['db_field'],
'old_value' => $old_data[$edit_field['db_field']],
'new_value' => $data[$edit_field['db_field']]
);
}
}
$sql = substr($sql, 0, -2);
$sql .= ' WHERE '.$this->list_table_config['db_id_field']."='".$this->db->real_escape_string($object_id)."'";
$this->db->query($sql);
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/main_class.php->save() (update)', $this->db->error.', sql:'.$sql);
return false;
}
// event actions
if ($events) {
$this->event_actions($events);
}
// already saved
return true;
} else {
// create in database
$sql = "INSERT INTO ".$this->list_table_config['db_table']."
SET ";
// check data
$object_data = array();
foreach ($this->list_table_config['edit_fields'] as $edit_field) {
if (isset($edit_field['auto_value'])) {
$edit_field['auto_value']['func_param']['db_field'] = $edit_field['db_field'];
$edit_field['auto_value']['func_param']['data'] = $data;
$data[$edit_field['db_field']] = $this->{$edit_field['auto_value']['function']}($edit_field['auto_value']['func_param']);
}
if (isset($data[$edit_field['db_field']]) && !isset($edit_field['function'])) {
if ($edit_field['type'] == 'text') {
$sql .= $edit_field['db_field'].'="'.$this->db->real_escape_string($data[$edit_field['db_field']]).'", ';
} else if ($edit_field['type'] == 'multitext') {
$sql .= $edit_field['db_field'].'="'.$this->db->real_escape_string($data[$edit_field['db_field']]).'", ';
} else if ($edit_field['type'] == 'formatedtext') {
$sql .= $edit_field['db_field'].'="'.$this->db->real_escape_string($data[$edit_field['db_field']]).'", ';
$correct = 1;
} else if ($edit_field['type'] == 'int') {
$sql .= $edit_field['db_field'].'='.$this->db->real_escape_string($data[$edit_field['db_field']]).', ';
} else if ($edit_field['type'] == 'create_time') {
$sql .= $edit_field['db_field']."=CURRENT_TIMESTAMP, ";
} else if ($edit_field['type'] == 'float') {
$sql .= $edit_field['db_field'].'='.$this->db->real_escape_string($data[$edit_field['db_field']]).', ';
}
}
}
$sql = substr($sql, 0, -2);
$this->db->query($sql);
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/main_class.php->save() (insert)', $this->db->error.', sql:'.$sql);
return false;
}
if ($this->list_table_config['db_id_field'] == 'id') {
$object_id = $this->db->insert_id;
} else if (!is_int($data[$this->list_table_config['db_id_field']])) {
$object_id = $data[$this->list_table_config['db_id_field']];
} else {
$object_id = $this->db->insert_id;
}
// event actions
if (isset($this->list_table_config['new_function'])) {
$event = array(
'action' => 'new',
'object_id' => $object_id,
'function' => $this->list_table_config['new_function']
);
$this->event_actions($event);
}
return $object_id;
}
} else {
// no data to save
$log_object = Logger::get_instance();
$log_object->info('Error in /core/main_class.php->save()', 'No data to save!');
return false;
}
}
public function remove($object_id) {
$sql = "DELETE FROM ".$this->list_table_config['db_table']."
WHERE ".$this->list_table_config['db_id_field']."='".$this->db->real_escape_string($object_id)."'";
$this->db->query($sql);
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/main_class.php->remove()', $this->db->error.', sql:'.$sql);
return 0;
}
return 1;
/*delete customer_addresses->customer_id
delete customer_files->customer_id
delete tickets->customer_id and tickt_messages->ticket_id and ticket_messages_attachments->ticket_message_id
delete customer*/
}
public function init_edit_fields($object_id) {
// rewrite indexes
$rewrite_indexes = array();
$count_fields = count($this->list_table_config['edit_fields']);
for ($i=0;$i<$count_fields;$i++) {
if (isset($this->list_table_config['edit_fields'][$i]['values'])) {
$this->list_table_config['edit_fields'][$i]['values'] = $this->{$this->list_table_config['edit_fields'][$i]['values']}();
$rewrite_indexes[] = $i;
}
}
// init languages
if ($this->list_table_config['edit_toolbar']['language']) {
$this->list_table_config['edit_toolbar']['language'] = array('de' => 'Deutsch', 'en' => 'English');
}
return;
}
public function get_all_selectable() {
$sql = "SELECT ".$this->list_table_config['db_id_field']." AS id, ".$this->list_table_config['db_selectable_field']." AS value FROM ".$this->list_table_config['db_table'];
$result = $this->db->query($sql);
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/main_class.php->get_select_array()', $this->db->error.', sql:'.$sql);
}
$data = array(0 => '-');
if ($result) {
while ($row = $result->fetch_object()) {
$data[$row->id] = $row->value;
}
}
return $data;
}
public function get_all_objects() {
$sql = "SELECT * FROM ".$this->list_table_config['db_table'];
$result = $this->db->query($sql);
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/main_class.php->get_select_array()', $this->db->error.', sql:'.$sql);
}
$data = array();
if ($result) {
while ($row = $result->fetch_object()) {
$data[] = $row;
}
}
return $data;
}
function get_filter() {
$data = array();
if (isset($this->list_table_config['list_filter']) && $this->list_table_config['list_filter']) {
foreach ($this->list_table_config['list_filter'] as $filter_item) {
$filter_item['values'] = $this->{$filter_item['values']}();
$data[] = $filter_item;
}
}
return $data;
}
function get_actions() {
$data = array();
if (isset($this->list_table_config['list_actions']) && $this->list_table_config['list_actions']) {
foreach ($this->list_table_config['list_actions'] as $filter_item) {
$filter_item['values'] = $this->{$filter_item['values']}();
$data[] = $filter_item;
}
}
return $data;
}
private function event_actions($events) {
foreach ($events as $event) {
$this->{$event['function']}($event);
}
return 1;
}
public function short_uri($param) {
$short_uri = ($param['data'][$param['db_field']]) ? $param['data'][$param['db_field']] : $param['data'][$param['default']];
$short_uri = str_replace(array('ä', 'Ä', 'ö', 'Ö', 'ü', 'Ü', 'ß'), array('ae', 'Ae', 'oe', 'Oe', 'ue', 'Ue', 'ss'), $short_uri);
$short_uri = preg_replace("@[^0-9aA-zZ\-]@si", "-", $short_uri);
$short_uri = preg_replace("@(-{2,})@si", "-", $short_uri);
$new_uri = '';
$old_uri = $short_uri;
if (isset($param['object_id'])) {
$sql = "SELECT ".$this->list_table_config['db_id_field']." FROM ".$this->list_table_config['db_table']." WHERE ".$param['db_field']." = '".$short_uri."' AND id != ".$param['object_id'];
} else {
$sql = "SELECT ".$this->list_table_config['db_id_field']." FROM ".$this->list_table_config['db_table']." WHERE ".$param['db_field']." = '".$short_uri."'";
}
$result = $this->db->query($sql);
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/main_class.php->short_uri()', $this->db->error.', sql:'.$sql);
return false;
}
if ($result->num_rows > 0) {
if ($param['object_id']) {
$short_uri .= $param['object_id'];
} else {
$short_uri .= rand(10000, 99999);
}
}
return $short_uri;
}
}

466
core/manufacturer.class.php Normal file
View File

@ -0,0 +1,466 @@
<?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';
include_once './libs/phImaginator/phImaginator.class.php';
include_once './core/config.class.php';
class Manufacturer extends Main {
protected $base_object;
protected $db;
public $list_table_config = array (
'title' => 'Hersteller',
'db_table' => 'manufacturers',
'list_fields' => array(
array(
'db_field' => 'name',
'name' => 'Herstellername',
'sortable' => 1
),
array(
'db_field' => 'email',
'name' => 'E-Mail',
'sortable' => 1
),
array(
'db_field' => 'website',
'name' => 'Webseite',
'sortable' => 1
),
array(
'db_field' => 'phone',
'name' => 'Telefon',
'sortable' => 1
),
array(
'db_field' => 'active',
'name' => 'Status',
'rewrite_function' => 'state_text',
'sortable' => 1
)
),
'default_sort_item' => 'name',
'default_sort_direction' => 'up',
'search_fields' => array('name', 'email', 'website'),
'db_id_field' => 'id',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=Manufacturer&object_id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_object_edit&object=Manufacturer',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
),
'edit_title' => 'Hersteller',
'edit_fields' => array (
array(
'name' => 'Stammdaten',
'type' => 'form_title'
),
array(
'db_field' => 'active',
'name' => 'Status',
'values' => 'state_text',
'type' => 'int'
),
array(
'db_field' => 'name',
'name' => 'Name',
'type' => 'text'
),
array(
'db_field' => 'description',
'name' => 'Beschreibung',
'type' => 'multitext'
),
array(
'db_field' => 'short_uri',
'name' => 'Kurz URL',
'type' => 'text',
'auto_value' => array(
'function' => 'short_uri',
'func_param' => array('default' => 'name')
)
),
array(
'name' => 'Kontakt',
'type' => 'form_title'
),
array(
'db_field' => 'phone',
'name' => 'Telefon',
'type' => 'text'
),
array(
'db_field' => 'email',
'name' => 'E-Mail',
'type' => 'text'
),
array(
'db_field' => 'website',
'name' => 'Webseite',
'type' => 'text'
),
array(
'name' => 'Herstellerlogo',
'type' => 'form_title'
),
array(
'db_field' => 'logo',
'name' => 'Logo',
'type' => 'image',
'file_directory' => '',
'max_image_size' => array('height' => '70', 'width' => '70')
)
),
'edit_mandatory_fields' => array('name'),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_edit&object=Manufacturer',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'delete' => 1
)
);
public $id; // so i don't break old code
private $config;
private $path;
private $url;
private $error;
private static $logo_size = array('height' => '70', 'width' => '70');
public function __construct($base_object) {
global $config_object;
$this->base_object = $base_object;
$this->config = $base_object->config;
$this->db = $base_object->db;
$this->path = ROOT_DIR.'web/'.SHOP_SYSTEM.'/images/manufacturers/';
$this->url = './web/'.SHOP_SYSTEM.'/images/manufacturers/';
$this->list_table_config['edit_fields'][10]['file_directory'] = $this->url;
$this->id = false;
$this->error = '';
} // 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_error() {
return $this->error;
}
public function get_all() {
$sql = "SELECT * FROM manufacturers ORDER BY name";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
} // end get_all
public function get_all_names() {
$sql = "SELECT id, name FROM manufacturers ORDER BY name";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[$obj->id] = $obj->name;
}
return $data;
} // end get_all
public function get_all_active() {
$sql = "SELECT * FROM manufacturers WHERE active=1 ORDER BY name";
$result = $this->db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
} // end get_all_active
public function get_by_id($id) {
$sql = "SELECT * FROM manufacturers WHERE id = $id";
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
return false;
} // end get_by_id
public function get_where_name_like($name) {
$sql = "SELECT id FROM manufacturers 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_active() {
$sql = "SELECT id, name FROM manufacturers WHERE active = 1 ORDER BY name";
$data = array();
$result = $this->db->query($sql);
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
} // end get_active
public function get_data($id = false) {
$sql = "SELECT * FROM manufacturers";
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 get_name_by_id($id) {
$sql = "SELECT name FROM manufacturers where id=$id";
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object()->name;
}
return false;
} // end get_name_by_id
public function set_logo($id, $name) {
$sql = "UPDATE manufacturers SET logo='$name' WHERE id=$id";
return $this->db->query($sql);
}
public function delete_logo($id) {
// get filename
$sql = "SELECT logo FROM manufacturers where id=$id";
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
$file_name = $result->fetch_object()->logo;
unlink($this->path.$file_name);
// update db
$this->set_logo($id,'');
return 1;
}
return 0;
}
public function save_logo($id) {
$file_info = getimagesize($_FILES['Filedata']['tmp_name']);
$image_type = array('', 'gif', 'jpg', 'png');
$file_name = 'manufacturer_logo_'.$id.'.'.$image_type[$file_info[2]];
if (move_uploaded_file($_FILES['Filedata']['tmp_name'], $this->path.$file_name)) {
$imaginator = new phImaginator();
$imaginator->add($this->path.$file_name);
$imaginator->Resize_fitBoth($this->config->shopConfiguration['manufacturer_image_size'], $this->config->shopConfiguration['manufacturer_image_size']);
$imaginator->save();
$this->set_logo($id, $file_name);
//return
return $this->url.$file_name;
} else {
return false;
}
}
public function get_image_url() {
return $this->url;
}
public static function get_name_id_pair() {
$db = Registry::get('base')->db;
$sql = "SELECT id, name
FROM manufacturers";
$result = $db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$return[$obj->id] = $obj->name;
}
return $return;
}
return false;
}
public static function get_name_by_id_static($id) {
$db = Registry::get('base')->db;
$sql = "SELECT name FROM manufacturers where id=$id";
$result = $db->query($sql)->fetch_array();
return $result['name'];
}
public static function get_names_by_structure_id($id) {
$db = Registry::get('base')->db;
$manufacturers = Manufacturer::get_name_id_pair();
$sql = "SELECT DISTINCT manufacturer_id
FROM items
WHERE
manufacturer_id != 0
AND (
structure_id = $id
OR structure_id_2 = $id
OR structure_id_3 = $id
OR structure_id_4 = $id
OR structure_id_5 = $id
)
";
$result = $db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$return[$obj->manufacturer_id] = $manufacturers[$obj->manufacturer_id];
}
asort($return);
return $return;
}
return false;
}
public static function get_manufacturers_by_structure_id($id) {
$db = Registry::get('base')->db;
$sql = "
SELECT DISTINCT items.manufacturer_id, manufacturers.*
FROM items
LEFT JOIN manufacturers ON items.manufacturer_id=manufacturers.id
WHERE structure_id = $id
OR structure_id_2 = $id
OR structure_id_3 = $id
";
$result = $db->query($sql);
$data = array();
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
}
return $data;
}
public static function get_all_active_static() {
$db = Registry::get('base')->db;
$sql = "SELECT name, short_uri, logo
FROM manufacturers
WHERE active = 1 ORDER BY name";
$result = $db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$return[] = $obj;
}
return $return;
}
return false;
}
public function get_by_suri($suri) {
$sql = "SELECT *
FROM manufacturers
WHERE short_uri LIKE '%".$suri."'";
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
return false;
} // end get_by_id
public function set_active($id, $active) {
$sql = "UPDATE manufacturers
SET active=".$this->db->real_escape_string($active).
" WHERE id=".$this->db->real_escape_string($id);
$result = $this->db->query($sql);
return $result;
}
} // end Manufacturer
?>

View File

@ -0,0 +1,145 @@
<?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 ManufacturerHelper {
//=========================================
//
// THIS CLASS IS STATIC ONLY
//
//=========================================
private function __construct() {}
private function __clone() {}
//=========================================
//
// THE PUBLIC INTERFACE
//
//=========================================
public static function get_best_selling_manufacturers($structure_id, $num = 3) {
$manufacturers = ManufacturerHelper::get_best_selling_manufacturers_object($structure_id, $num, false);
$manufacturer_object = new Manufacturer(Registry::get('base'));
foreach ($manufacturers as $manufacturer) {
$obj = $manufacturer_object->get_data($manufacturer->id);
$obj->items_in_shop = $manufacturer->items_in_shop;
$return_data[] = $obj;
}
return $return_data;
}
public static function get_best_selling_manufacturers_object($structure_id, $num, $with_logo = true) {
$db = Registry::get('base')->db;
$sql = "SELECT
i.manufacturer_id AS id,
COUNT(oi.id) AS num
FROM
order_item oi
RIGHT JOIN
items i
ON
i.id = oi.item_id
RIGHT JOIN
manufacturers m
ON
i.manufacturer_id = m.id
WHERE
oi.item_id is not null
AND
m.active=1";
if ($with_logo) {
$sql .= " AND m.logo != ''";
}
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 i.manufacturer_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()) {
$obj->items_in_shop = ItemHelper::get_number_of_items_by_manufacturer($obj->id, true);
$return_data[] = $obj;
}
return $return_data;
}
return false;
}
public static function set_manufacturers_active_by_ids($ids, $active) {
$db = Registry::get('base')->db;
$sql = "UPDATE manufacturers
SET active=".$db->real_escape_string($active).
" WHERE id IN (".$db->real_escape_string($ids).")";
return $db->query($sql);
}
public static function delete_manufacturers_by_ids($ids) {
$db = Registry::get('base')->db;
$sql = "DELETE FROM manufacturers
WHERE id IN (".$db->real_escape_string($ids).")";
return $db->query($sql);
}
public static function get_manufacturer_array() {
$db = Registry::get('base')->db;
$sql = "SELECT
id,
name
FROM
manufacturers";
$result = $db->query($sql);
$return_data[0] = '';
if ($result) {
while ($obj = $result->fetch_object()) {
$return_data[$obj->id] = $obj->name;
}
return $return_data;
}
return false;
}
}

81
core/memory.class.php Normal file
View File

@ -0,0 +1,81 @@
<?php
class Memory {
public function __construct() {
}
public function add($article_id) {
setcookie("article_memorize[".$article_id."]",$article_id,time()+(3600*24*100), "/");
return;
} // end add
public function delete($article_id) {
setcookie("article_memorize[".$article_id."]",$article_id,time()-3600, "/");
return;
} // end delete
public function clear() {
unset($_COOKIE['article_memorize']);
return;
} // end clear
public function get_all() {
if (isset($_COOKIE['article_memorize'])) {
return $_COOKIE['article_memorize'];
}
return;
} // end get_all
public function count() {
$i = 0;
if (isset($_COOKIE['article_memorize'])) {
$i = count($_COOKIE['article_memorize']);
}
return $i;
} // end count
/*
public function add($article_id) {
$_SESSION['easyshop']['article_memorize'][$article_id] = $article_id;
return;
} // end add
public function delete($article_id) {
unset($_SESSION['easyshop']['article_memorize'][$article_id]);
return;
} // end delete
public function clear() {
unset($_SESSION['easyshop']['article_memorize']);
return;
} // end clear
public function get_all() {
if (isset($_SESSION['easyshop']['article_memorize'])) {
return $_SESSION['easyshop']['article_memorize'];
}
return;
} // end get_all
public function count() {
$i = 0;
if (isset($_SESSION['easyshop']['article_memorize'])) {
$i = count($_SESSION['easyshop']['article_memorize']);
}
return $i;
}*/ // end count
}

234
core/metatag.class.php Normal file
View File

@ -0,0 +1,234 @@
<?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';
include_once './core/manufacturer.class.php';
class Metatag {
private $_db;
private $layoutObject;
private $baseObject;
private $metaTags;
private $metaVars = array(
'Hersteller' => '',
'VonHersteller' => '',
'Shopname' => '',
'Unterwarengruppen' => null,
'Warengruppe' => null,
'Bezeichnung' => null,
'ArtikelAttribut6' => '',
'Struktur1' => '',
'Struktur2' => '',
'Struktur3' => '',
'Struktur4' => '',
'Struktur5' => '',
'Struktur6' => ''
);
private $collectedManufacturers;
public function __construct($layoutObject = false, $baseObject = false) {
$this->_db = Registry::get('base')->db;
$this->layoutObject = $layoutObject;
$this->baseObject = $baseObject;
}
public function get_all() {
$sql = "SELECT * FROM metatags";
$result = $this->_db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$return[] = $obj;
}
return $return;
}
return false;
}
public function get_by_group($groupName = 'DEFAULT') {
$sql = "SELECT * FROM metatags WHERE groupName = '".$this->_db->real_escape_string($groupName)."'";
$result = $this->_db->query($sql);
if ($result->num_rows > 0) {
while ($obj = $result->fetch_object()) {
$this->layoutObject->allMetaTags[$obj->name] = $obj->content;
}
return true;
}
return false;
}
public function get_by_id($id) {
$sql = "SELECT * FROM metatags WHERE id=$id AND active=1";
$result = $this->_db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object();
}
return false;
}
public function save($data) {
$data = Database::clean($data);
if (isset($data['id'])) {
$id = $data['id'];
unset($data['id']);
$sql = Database::update('metatags', $data, 'WHERE id='.$id);
} else {
$sql = Database::insert('metatags', $data);
}
$result = $this->_db->query($sql);
if ($result) {
return $this->_db->insert_id;
}
return false;
}
public function delete($id) {
$sql = "DELETE FROM metatags WHERE id=$id";
$result = $this->_db->query($sql);
if ($result) {
return true;
}
return false;
}
public function get_content_by_name($name) {
$sql = "SELECT content FROM metatags WHERE name='$name'";
$result = $this->_db->query($sql);
if ($result->num_rows > 0) {
return $result->fetch_object()->content;
}
return false;
}
public function assign() {
if (is_array($this->layoutObject->allMetaTags)) {
if (!isset($this->metaVars['Hersteller']) || !$this->metaVars['Hersteller']) {
$manufacturer = new Manufacturer($this->baseObject);
$allManufacturer = $manufacturer->get_all_active();
$allManus = array();
foreach ($allManufacturer as $manuData) {
$allManus[] = $manuData->name;
}
$this->metaVars['Hersteller'] = implode(', ', $allManus);
}
$all_metatags = array();
$shopname = $this->baseObject->config->shopConfiguration['full_shop_name'];
$domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
$domain = str_replace('.com', '', $domain);
$domain = str_replace('.de', '', $domain);
if ($domain == 'mc-shower' ||
$domain == 'mc-trolley' ||
$domain == 'mc-heat' ||
$domain == 'dusche-led' ||
$domain == 'golf-trolley-caddy' ||
$domain == 'led-handbrause' ||
$domain == 'vgr-vertrieb'
) {
$shopname = $domain;
}
foreach ($this->layoutObject->allMetaTags as $metaTag => $content) {
$content = str_ireplace('[Shopname]', $shopname, $content);
$content = str_ireplace('[Hersteller]', $this->metaVars['Hersteller'], $content);
$content = str_ireplace('[VonHersteller]', $this->metaVars['VonHersteller'], $content);
$content = str_ireplace('[ArtikelAttribut6]', $this->metaVars['ArtikelAttribut6'], $content);
$content = str_ireplace('[Struktur1]', $this->metaVars['Struktur1'], $content);
$content = str_ireplace('[Struktur2]', $this->metaVars['Struktur2'], $content);
$content = str_ireplace('[Struktur3]', $this->metaVars['Struktur3'], $content);
$content = str_ireplace('[Struktur4]', $this->metaVars['Struktur4'], $content);
$content = str_ireplace('[Struktur5]', $this->metaVars['Struktur5'], $content);
$content = str_ireplace('[Struktur6]', $this->metaVars['Struktur6'], $content);
if (isset($this->metaVars['Warengruppe'])) {
$content = str_ireplace('[Warengruppe]', $this->metaVars['Warengruppe'], $content);
}
if (isset($this->metaVars['Unterwarengruppen'])) {
$content = str_ireplace('[Unterwarengruppen]', $this->metaVars['Unterwarengruppen'], $content);
}
if (isset($this->metaVars['Bezeichnung'])) {
$content = str_ireplace('[Bezeichnung]', $this->metaVars['Bezeichnung'], $content);
}
$all_metatags[$metaTag] = $content;
}
$this->layoutObject->assign('metatags', $all_metatags);
}
}
public function overwriteVar($var, $val) {
$this->metaVars[$var] = $val;
}
public function overwriteMeta($metaTag, $val) {
$this->layoutObject->allMetaTags[$metaTag] = $val;
}
public function overwriteMetas($metaTagsArray) {
foreach ($metaTagsArray as $metaTag => $val) {
if ($val) {
$this->layoutObject->allMetaTags[$metaTag] = $val;
}
}
}
public function get_all_metatags_by_group($groupName = 'DEFAULT') {
$sql = "SELECT * FROM metatags WHERE groupName = '".$this->_db->real_escape_string($groupName)."'";
$result = $this->_db->query($sql);
$data = array();
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
}
public function save_metatags($group, $data) {
foreach ($data as $key => $value) {
$sql = "UPDATE metatags
SET content='".$this->_db->real_escape_string($value)."'
WHERE groupName = '".$this->_db->real_escape_string($group)."'
AND name = '".$this->_db->real_escape_string($key)."'";
$result = $this->_db->query($sql);
if ($this->db->error) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/metatag.class.php->save_metatags()', $this->db->error.', sql:'.$sql);
}
}
return;
}
}
?>

35
core/money.class.php Normal file
View File

@ -0,0 +1,35 @@
<?php
class Money {
protected function __construct() {}
private function __clone() {}
public static function show_money($number) {
// $temp = number_format($number, 2, '.');
//
// return $temp;
return $number;
}
public static function get_price_with_taxes($price, $taxrate) {
$temp = Money::get_gross_price($price, $taxrate);
return $temp;
}
// get price without taxes from price with taxes and tax rate
public static function get_net_price($gross_price, $taxrate) {
$temp = number_format((float)$gross_price / ((float)(100 + $taxrate) / 100), 2, '.', '');
return $temp;
}
// get price with taxes from price without taxes and tax rate
public static function get_gross_price($net_price, $taxrate) {
$temp = number_format($net_price * (((float)(100 + $taxrate)) / 100.0 ), 2, '.', '');
return $temp;
}
}

192
core/news.class.php Normal file
View File

@ -0,0 +1,192 @@
<?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 News extends Main {
public $list_table_config = array (
'title' => 'Aktuelles',
'db_table' => 'news',
'list_fields' => array(
array(
'db_field' => 'title',
'name' => 'Title',
'sortable' => 1
),
array(
'db_field' => 'created',
'name' => 'Erstellt am',
'sortable' => 1
),
array(
'db_field' => 'active',
'name' => 'Status',
'rewrite_function' => 'state_text',
'sortable' => 1
)
),
'default_sort_item' => 'id',
'default_sort_direction' => 'down',
'search_fields' => array('title', 'text'),
'db_id_field' => 'id',
'db_selectable_field' => 'email',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=News&object_id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_object_edit&object=News',
'copy' => 0,
'select_all' => 1,
'edit' => 0,
'actions' => 0,
'filter' => 0,
'search' => 1
),
'edit_title' => 'Aktuelles bearbeiten',
'edit_fields' => array (
array(
'name' => 'Stammdaten',
'type' => 'form_title'
),
array(
'db_field' => 'title',
'name' => 'Titel',
'multi_lang' => 1,
'type' => 'text'
),
array(
'db_field' => 'sub_title',
'name' => 'Untertitel',
'multi_lang' => 1,
'type' => 'text'
),
array(
'db_field' => 'text',
'name' => 'Text',
'multi_lang' => 1,
'type' => 'formatedtext'
),
array(
'db_field' => 'link',
'name' => 'Link',
'type' => 'text'
),
array(
'db_field' => 'link_type',
'name' => 'Link-Typ',
'values' => 'link_type_values',
'type' => 'int'
),
array(
'db_field' => 'image',
'name' => 'Bild',
'type' => 'image',
'file_directory' => '',
'max_image_size' => array('height' => '70', 'width' => '70')
),
array(
'db_field' => 'created',
'name' => 'Erstellt am',
'type' => 'create_time'
),
array(
'db_field' => 'active',
'name' => 'Status',
'values' => 'state_text',
'type' => 'int'
)
),
'edit_mandatory_fields' => array('title', 'text'),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_list&object=News',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'language' => 1,
'delete' => 1
),
);
public function __construct($base_object) {
$this->base_object = $base_object;
$this->config = $base_object->config;
$this->db = $base_object->db;
$this->list_table_config['edit_fields'][6]['file_directory'] = './web/'.SHOP_SYSTEM.'/images/news/';
}
public function state_text() {
return array (
'1' => 'aktiv',
'0' => 'inaktiv'
);
}
public function link_type_values() {
return array (
'0' => 'Im aktuellen Fenster öffnen',
'1' => 'Neues Fenster öffnen'
);
}
public function get_list() {
$data = array();
$sql = "SELECT *
FROM news
WHERE active = 1
ORDER BY id DESC LIMIT 20";
$result = $this->db->query($sql);
while ($obj = $result->fetch_object()) {
$data[] = $obj;
}
return $data;
}
public function set_logo($id, $name) {
$sql = "UPDATE news SET image='$name' WHERE id=$id";
return $this->db->query($sql);
}
public function delete_logo($id) {
// get filename
$sql = "SELECT image FROM news where id=$id";
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
$file_name = $result->fetch_object()->logo;
unlink(ROOT_DIR.'web/'.SHOP_SYSTEM.'/images/news/'.$file_name);
// update db
$this->set_logo($id,'');
return 1;
}
return 0;
}
public function save_logo($id) {
$file_info = getimagesize($_FILES['Filedata']['tmp_name']);
$image_type = array('', 'gif', 'jpg', 'png');
$file_name = 'news_image_'.$id.'.'.$image_type[$file_info[2]];
if (move_uploaded_file($_FILES['Filedata']['tmp_name'], ROOT_DIR.'web/'.SHOP_SYSTEM.'/images/news/'.$file_name)) {
$imaginator = new phImaginator();
$imaginator->add(ROOT_DIR.'web/'.SHOP_SYSTEM.'/images/news/'.$file_name);
$imaginator->Resize_fitBoth($this->config->shopConfiguration['news_image_size'], $this->config->shopConfiguration['news_image_size']);
$imaginator->save();
$this->set_logo($id, $file_name);
//return
return './web/'.SHOP_SYSTEM.'/images/news/'.$file_name;
} else {
return false;
}
}
}
?>

204
core/newsletter.class.php Normal file
View File

@ -0,0 +1,204 @@
<?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 Newsletter extends Main {
protected $base_object;
public $list_table_config = array (
'title' => 'Newsletter',
'db_table' => 'newsletter',
'list_fields' => array(
array(
'db_field' => 'subject',
'name' => 'Betreff',
'sortable' => 1
),
array(
'db_field' => 'create_time',
'name' => 'Erstelldatum',
'sortable' => 1
),
array(
'db_field' => 'send_time',
'name' => 'Versand-Datum',
'sortable' => 1
),
array(
'db_field' => 'create_user_id',
'name' => 'Mitarbeiter',
'sortable' => 1
)
),
'search_fields' => array('subject'),
'db_id_field' => 'id',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=Newsletter&object_id=',
'toolbar' => array(
'delete' => 'index.php?admin_modul=admin_newsletter_editor&object_id=',
'new' => 'index.php?admin_modul=admin_object_edit&object=Newsletter',
'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' => 'mail_from',
'name' => 'Absender',
'type' => 'text',
'values' => 'mail_sender_values',
),
array(
'name' => 'Vorlage',
'values' => 'email_template_values',
'id' => 'email_template_selection',
'type' => 'tmp_function'
),
array(
'db_field' => 'subject',
'name' => 'Betreff',
'type' => 'text'
),
array(
'db_field' => 'message',
'name' => 'Nachricht',
'type' => 'formatedtext'
),
/*array(
'name' => 'Artikel hinzubuchen',
'type' => 'form_title'
),
array(
'name' => 'Artikelsuche',
'type' => 'livesearch',
'oject' => 'Item'
),*/
array(
'name' => 'Empfängerauswahl',
'type' => 'form_title'
),
array(
/*'name' => 'Kundengruppe,Land,PLZ,Einzelsuche,letzter einkauf vor 1 bis 5 Monaten, Umsatz in Euro von bis in den letzten 2 monaten',*/
'name' => 'Kundengruppe',
'values' => 'customer_group_values',
'id' => 'customer_group',
'type' => 'text',
'function' => 'newsletter_send',
'function_name' => 'Senden'
),
array(
'name' => 'Empfänger',
'type' => 'form_title'
),
),
'edit_js_file' => 'admin_newsletter_edit.js',
'edit_mandatory_fields' => array('email'),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_list&object=Newsletter',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'send' => 0,
'send_test' => 1,
'delete' => 1
)
);
protected $object_fields = array(
'name' => 'text',
'recipient' => 'integer',
'event_type' => 'integer',
'title' => 'text',
'active' => 'integer',
'customer_group_id' => 'integer',
'message' => 'text'
);
function __construct($base_object) {
$this->base_object = $base_object;
$this->db = $base_object->db;
}
function email_template_values() {
include_once './core/email_template.class.php';
$email_template_object = New Email_template($this->base_object);
return $email_template_object->get_all_selectable();
}
function mail_sender_values() {
return array(
$this->base_object->config->shopConfiguration['system_email'] => $this->base_object->config->shopConfiguration['system_email']
);
}
function customer_group_values() {
include_once './core/customer_group.class.php';
$customer_group_object = New Customer_group($this->base_object);
return $customer_group_object->get_all_selectable();
}
public function test_email($id, $email) {
// get newsletter data
$data = $this->load($id);
// send newsletter
include_once './core/mail.class.php';
$mailer = new mail_tools($this->base_object);
$result = $mailer->send_mail($data['subject'], $data['message'], $email, 'extern', false, false, false, false, false);
if (!$result) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/newsletter.php->email_test()', $result);
}
return 1;
}
public function send_email($id, $customer_group) {
// get newsletter data
$data = $this->load($id);
// get recipients
$recipients = $this->base_object->customer->get_all_newsletter_subscriber($customer_group);
// send newsletter
include_once './core/mail.class.php';
$mailer = new mail_tools($this->base_object);
foreach ($recipients as $subscriber) {
$email = $subscriber->email;
$result = $mailer->send_mail($data['subject'], $data['message'], $email, 'extern', false, false, false, false, false);
if (!$result) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/newsletter.php->send_email()', $result);
}
}
// set timestamp for sendet newsletter
$sql = "UPDATE newsletter SET send_time=CURRENT_TIMESTAMP WHERE id=".$this->db->real_escape_string($id);
$log_object = Logger::get_instance();
$result = $this->db->query($sql);
if (!$result) {
$log_object = Logger::get_instance();
$log_object->info('Error in /core/newsletter.php->send_email()', $this->db->error.', sql:'.$sql);
}
return 1;
}
}

View File

@ -0,0 +1,127 @@
<?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';
include_once './libs/phImaginator/phImaginator.class.php';
include_once './core/config.class.php';
class Newsletter_subscriber extends Main {
public $list_table_config = array (
'title' => 'Newsletter Abonnenten',
'db_table' => 'newsletter_subscriber',
'list_fields' => array(
array(
'db_field' => 'salutation',
'name' => 'Anrede',
'rewrite_function' => 'salutation_values',
'sortable' => 1
),
array(
'db_field' => 'firstname',
'name' => 'Vorname',
'sortable' => 1
),
array(
'db_field' => 'surname',
'name' => 'Nachname',
'sortable' => 1
),
array(
'db_field' => 'email',
'name' => 'E-Mail',
'sortable' => 1
),
array(
'db_field' => 'state',
'name' => 'Status',
'rewrite_function' => 'state_text',
'sortable' => 1
)
),
'search_fields' => array('firstname', 'surname', 'email'),
'db_id_field' => 'email',
'db_selectable_field' => 'email',
'edit_link' => 'index.php?admin_modul=admin_object_edit&object=Newsletter_subscriber&object_id=',
'toolbar' => array(
'delete' => '1',
'new' => 'index.php?admin_modul=admin_object_edit&object=Newsletter_subscriber',
'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' => 'salutation',
'name' => 'Anrede',
'values' => 'salutation_values',
'type' => 'int'
),
array(
'db_field' => 'firstname',
'name' => 'Vorname',
'type' => 'text'
),
array(
'db_field' => 'surname',
'name' => 'Nachname',
'type' => 'text'
),
array(
'db_field' => 'email',
'name' => 'E-Mail',
'type' => 'text'
),
array(
'db_field' => 'state',
'name' => 'Status',
'values' => 'state_text',
'type' => 'int'
)
),
'edit_mandatory_fields' => array('firstname', 'surename', 'email'),
'edit_toolbar' => array(
'close' => 'index.php?admin_modul=admin_object_list&object=Newsletter_subscriber',
'copy' => 0,
'undo' => 0,
'redo' => 0,
'save' => 1,
'delete' => 1
),
);
public function state_text() {
return array (
'0' => 'nicht aktiviert',
'1' => 'aktiv',
'2' => 'inaktiv',
'3' => 'gesperrt'
);
}
public function salutation_values() {
return array (
'0' => 'Herr',
'1' => 'Frau'
);
}
}
?>

288
core/old/country.class.php Normal file
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
?>

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;
}
}
?>

1653
core/old/customer.class.php Normal file

File diff suppressed because it is too large Load Diff

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
core/old/database.class.php Normal file
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
?>

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
core/old/domain.class.php Normal file
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;
}
}
?>

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
core/old/export.class.php Normal file
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
?>

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
}
?>

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;
}
}
?>

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
core/old/i18n.class.php Normal file
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
core/old/import.class.php Normal file
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
?>

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;
}
}
}
?>

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
}
?>

Some files were not shown because too many files have changed in this diff Show More